Upgrade in-memory and on-disk state representation with tree states#3206
Closed
michaelsproul wants to merge 84 commits intounstablefrom
Closed
Upgrade in-memory and on-disk state representation with tree states#3206michaelsproul wants to merge 84 commits intounstablefrom
michaelsproul wants to merge 84 commits intounstablefrom
Conversation
This was referenced Oct 19, 2022
bors bot
pushed a commit
that referenced
this pull request
Nov 11, 2022
## Issue Addressed Part of #3651. ## Proposed Changes Add a flag for enabling the light client server, which should be checked before gossip/RPC traffic is processed (e.g. #3693, #3711). The flag is available at runtime from `beacon_chain.config.enable_light_client_server`. Additionally, a new method `BeaconChain::with_mutable_state_for_block` is added which I envisage being used for computing light client updates. Unfortunately its performance will be quite poor on average because it will only run quickly with access to the tree hash cache. Each slot the tree hash cache is only available for a brief window of time between the head block being processed and the state advance at 9s in the slot. When the state advance happens the cache is moved and mutated to get ready for the next slot, which makes it no longer useful for merkle proofs related to the head block. Rather than spend more time trying to optimise this I think we should continue prototyping with this code, and I'll make sure `tree-states` is ready to ship before we enable the light client server in prod (cf. #3206). ## Additional Info I also fixed a bug in the implementation of `BeaconState::compute_merkle_proof` whereby the tree hash cache was moved with `.take()` but never put back with `.restore()`.
macladson
pushed a commit
to macladson/lighthouse
that referenced
this pull request
Jan 5, 2023
## Issue Addressed Part of sigp#3651. ## Proposed Changes Add a flag for enabling the light client server, which should be checked before gossip/RPC traffic is processed (e.g. sigp#3693, sigp#3711). The flag is available at runtime from `beacon_chain.config.enable_light_client_server`. Additionally, a new method `BeaconChain::with_mutable_state_for_block` is added which I envisage being used for computing light client updates. Unfortunately its performance will be quite poor on average because it will only run quickly with access to the tree hash cache. Each slot the tree hash cache is only available for a brief window of time between the head block being processed and the state advance at 9s in the slot. When the state advance happens the cache is moved and mutated to get ready for the next slot, which makes it no longer useful for merkle proofs related to the head block. Rather than spend more time trying to optimise this I think we should continue prototyping with this code, and I'll make sure `tree-states` is ready to ship before we enable the light client server in prod (cf. sigp#3206). ## Additional Info I also fixed a bug in the implementation of `BeaconState::compute_merkle_proof` whereby the tree hash cache was moved with `.take()` but never put back with `.restore()`.
ba7ad3e to
23db089
Compare
* Address some clippy lints * Box errors to fix error size lint * Add Default impl for Validator * Address more clippy lints * Re-implement `check_state_diff` * Fix misc test compile errors
* Use "rebasing" to minimise BeaconState mem usage * Update metastruct * Use upstream milhouse, update cargo lock * Rebase caches for extra memory savings
* Get tests passing * Get benchmarks compiling * Fix EF withdrawals test * Remove unused deps * Fix tree_hash panic in tests * Fix slasher compilation * Fix ssz_generic test * Get more tests passing * Fix EF tests for real * Fix local testnet scripts
Workaround for #4236
* Fix db-migration-period default * Fix version regex
* Relocate epoch cache to BeaconState * Optimize per block processing by pulling previous epoch & current epoch calculation up. * Revert `get_cow` change (no performance improvement) * Initialize `EpochCache` in epoch processing and load it from state when getting base rewards. * Initialize `EpochCache` at start of block processing if required. * Initialize `EpochCache` in `transition_blocks` if `exclude_cache_builds` is enabled * Fix epoch cache initialization logic * Remove FIXME comment. * Cache previous & current epochs in `consensus_context.rs`. * Move `get_base_rewards` from `ConsensusContext` to `BeaconState`. * Update Milhouse version
4 tasks
* Delete unused epoch processing code * Compare total deltas * Remove unnecessary apply_pending * cargo fmt * Remove newline
dapplion
reviewed
Feb 8, 2024
| "Updating historic state config"; | ||
| "previous_config" => ?disk_config.hierarchy_config, | ||
| "new_config" => ?db.config.hierarchy_config, | ||
| ); |
Collaborator
There was a problem hiding this comment.
@michaelsproul I recall you commenting changing the hierarchy_config is not possible without a re-sync. Should this comment state so?
Member
Author
There was a problem hiding this comment.
Well if you see this comment then it has already worked, so not sure if it's helpful at this stage.
You can change it by running prune-states and then restarting with the new config. I think it probably makes sense to just have that in the docs.
* Fix beta compiler lints * Fix fork choice tests * Fix op_pool tests --------- Co-authored-by: dapplion <35266934+dapplion@users.noreply.github.com>
* Fix CLI help text * Tree states release v5.0.111-exp
* Fix clippy * Fix beacon chain tests * Comment out dodgy iterator test * Fix imports for beta compiler
Member
Author
|
Closing now that v6.0.0 is out with tree-states proper. There are still a few changes from OG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an umbrella PR for fundamental changes to Lighthouse's state representation.
The plan is to merge smaller PRs into this one, and then merge it to
unstablewithout squashing.TODO List
There are few things that need fixing on this branch before it's ready for primetime:
get_state. The recursion is liable to overflow the stack, so we should switch to an iterative algorithm.jemallocFIXME(sproul)s in the codeIssues Addressed
Closes #2806
Closes #2805
Closes #2944
Closes #2371
Closes #3208
Closes #3505