Currently pruneblockchain(0) will call StateFlushToDisk. This might not be required/wanted, as the internal code appears to be using 0 to indicate "legacy" pruning.
rpc: Don't FlushStateToDisk when pruneblockchain(0) #9524
pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:Mf1701-qaPruning changing 1 files +4 −0-
MarcoFalke commented at 11:02 AM on January 12, 2017: member
- MarcoFalke added the label RPC/REST/ZMQ on Jan 12, 2017
- MarcoFalke added the label Tests on Jan 12, 2017
-
laanwj commented at 11:06 AM on January 12, 2017: member
Currently pruneblockchain(0) will call StateFlushToDisk. This might not be required/wanted.
If it doesn't cause an error or corruption, I'd prefer not to add a special case for it. There is no reason for calling it with 0 so if there is a slight performance overhead when that's done, that's too bad.
-
MarcoFalke commented at 11:12 AM on January 12, 2017: member
The thing is that it clashes with the default value of FlushStateToDisk(nManualPruneHeight=0), which is used to indicate "legacy" pruning. It might cause unwanted bugs if someone refactors the code in the future.
- MarcoFalke force-pushed on Jan 12, 2017
-
laanwj commented at 11:22 AM on January 12, 2017: member
Okay, true. On one hand this is adding belt and suspenders it's just that I prefer the underlying code to be robust to cases like this instead of catching potential errors on the RPC interface. But yes you have a point too, I don't know...
- MarcoFalke force-pushed on Jan 12, 2017
- MarcoFalke force-pushed on Jan 27, 2017
- MarcoFalke renamed this:
qa/rpc: Fix pruneblockchain edge cases
rpc: Don't FlushStatToDisk when pruneblockchain(0)
on Jan 27, 2017 - MarcoFalke renamed this:
rpc: Don't FlushStatToDisk when pruneblockchain(0)
rpc: Don't FlushStateToDisk when pruneblockchain(0)
on Jan 28, 2017 -
rpc: Don't FlushStateToDisk when pruneblockchain(0) 88883ae13d
- MarcoFalke force-pushed on Jan 28, 2017
- MarcoFalke removed the label Tests on Jan 28, 2017
-
laanwj commented at 8:18 AM on February 17, 2017: member
The thing is that it clashes with the default value of FlushStateToDisk(nManualPruneHeight=0), which is used to indicate "legacy" pruning. It might cause unwanted bugs if someone refactors the code in the future.
It seems that in that case there will also be automatic problems. On IRC yesterday there was a discussion about this, and there are more paths through which it will get into
FlushStateToDiskwithnManualPruneHeight=0when manual pruning is enabled. This change would cover only one of them.I wrongly assumed that
fCheckForPruningwould always be false when pruning manual. But it can be set, in which caseFlushStateToDiskwill be called from block processing.For 0.15 or later it would be nice to refactor the pruning code.
fCheckForPruningwould be better as an argument of the appropriate functions instead of a global flag (to have a better grasp on when it's set and not set), and the pruning modeOFF|MANUAL|AUTOwould be better represented as an enum. -
laanwj commented at 8:32 AM on April 19, 2017: member
Ok, I still stand by what I said above, the code in question should be refactored as there are various paths where this could theoretically go wrong, catching this at the RPC call site will only solve one entry point, and for the right might hide eventual problems further.
E.g. let's say we added a test that calls pruneblockchain(0) and verifies that it does nothing would no longer test anything useful.
- laanwj closed this on Apr 19, 2017
- MarcoFalke deleted the branch on Apr 23, 2017
- MarcoFalke locked this on Sep 8, 2021