-
Notifications
You must be signed in to change notification settings - Fork 764
Add Blocks at a Configured Depth to Pruning Queue #1689
Add Blocks at a Configured Depth to Pruning Queue #1689
Conversation
Remove #[macro_use] for cpython, as it is no longer necessary. Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
df17664
to
9e4c206
Compare
validator/src/journal/chain.rs
Outdated
state.state_prune_manager.update_queue( | ||
&result | ||
.new_chain | ||
.iter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make more sense to have the function take care of this .iter.map.collect
stuff rather than make the caller do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The state pruning manager operates on state root hashes, not blocks
9e4c206
to
c6e533c
Compare
Oh, commit |
ee433d8
to
f6d005b
Compare
Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
- Add validation for integer CLI args (they must be positive, greater than zero) - Parse the args as u32 before sending them to the config object Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
b3f6357
to
271c6dc
Compare
Adds the CLI argument and configuration option for state_pruning_block_depth. Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
Pass the state_pruning_block_depth configuration option through to the ChainController via the FFI interface. Signed-off-by: Peter Schwarz <peterx.schwarz@intel.com>
The StatePruningManager is responsible fore managing a queue of state roots and their respective block heights. It keeps track of unique hashes and supplies an execute method which will delete any hash below a certain depth. If there are state roots that compute the same hash value, they will be removed so as not to cause lost state roots for newer blocks. Any hash unsuccessfully pruned will be put back on the queue until such time as it can be removed. Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
271c6dc
to
cd76cf8
Compare
Added some new commits to handle the issue where an identical leaf is produced, and then is pruned from a prior state root hash. This approach is the most direct - scanning the change logs. Future changes could make this more efficient by managing this with an in-memory reference count. |
When a block is committed to the block store, the added state root hashes and any uncommitted blocks' state root hashes are passed to the StatePruningManager. Also, if the block is of height greater than the state pruning depth, a block at that depth is added to the queue and the pruning operation is executed for that height. Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
Supply the global state database instance across the FFI boundary in order to create the a StatePruningManager Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
Provide the state database to the python chain controller, in order to pass it through to the FFI rust layer. Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
Update tests to include a state database instance Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
Add `next` to LmdbDatabaseReaderCursor, which previously only had `first` and `last`. Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
Remove duplicate keys from the change log during pruning, to avoid removing leaf or intermediate nodes that may be referenced in future tries. Signed-off-by: Peter Schwarz <pschwarz@bitwise.io>
cd76cf8
to
de0babb
Compare
This PR creates a pruning manager, which prunes state roots from a queue at predictable times. It is evaluated at chain commit time. 10 percent of the queue is pruned, which allows state roots to be returned to validity, if need be before they are finally pruned.
This PR does not solve the problem of abandoned forks, as they cannot be properly re-evaluated if a validator switches back to them. To properly cleanup state after a chain has been dropped, we will need the Block Tree Manager (See RFC 5). When uncommitted blocks expire from the Block Tree Manager, their state roots can be pruned.