-
Notifications
You must be signed in to change notification settings - Fork 992
Clone state ahead of block production #4925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,19 +227,51 @@ async fn state_advance_timer<T: BeaconChainTypes>( | |
|
|
||
| // Prepare proposers so that the node can send payload attributes in the case where | ||
| // it decides to abandon a proposer boost re-org. | ||
| if let Err(e) = beacon_chain.prepare_beacon_proposer(current_slot).await { | ||
| warn!( | ||
| log, | ||
| "Unable to prepare proposer with lookahead"; | ||
| "error" => ?e, | ||
| "slot" => next_slot, | ||
| ); | ||
| } | ||
| let proposer_head = beacon_chain | ||
| .prepare_beacon_proposer(current_slot) | ||
| .await | ||
| .unwrap_or_else(|e| { | ||
| warn!( | ||
| log, | ||
| "Unable to prepare proposer with lookahead"; | ||
| "error" => ?e, | ||
| "slot" => next_slot, | ||
| ); | ||
| None | ||
| }); | ||
|
|
||
| // Use a blocking task to avoid blocking the core executor whilst waiting for locks | ||
| // in `ForkChoiceSignalTx`. | ||
| beacon_chain.task_executor.clone().spawn_blocking( | ||
| move || { | ||
| // If we're proposing, clone the head state preemptively so that it isn't on the hot | ||
| // path of proposing. We can delete this once we have tree-states. | ||
| if let Some(proposer_head) = proposer_head { | ||
| if let Some(proposer_state) = beacon_chain | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it would be beneficial to drop the The downside would be that there are some times where we clear the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. I've added that in 6d5d558. It will still hold 2 states in memory if the beacon node has two proposals two slots in a row on the same head block, but I think this is reasonably obscure enough to be tolerated until we get tree-states. I'll try to deploy that change on Holesky in a few hours so I can confirm it didn't regress on the perf front. |
||
| .snapshot_cache | ||
| .try_read_for(BLOCK_PROCESSING_CACHE_LOCK_TIMEOUT) | ||
| .and_then(|snapshot_cache| { | ||
| snapshot_cache.get_state_for_block_production(proposer_head) | ||
| }) | ||
| { | ||
| *beacon_chain.block_production_state.lock() = | ||
| Some((proposer_head, proposer_state)); | ||
| debug!( | ||
| log, | ||
| "Cloned state ready for block production"; | ||
| "head_block_root" => ?proposer_head, | ||
| "slot" => next_slot | ||
| ); | ||
| } | ||
| } else { | ||
| warn!( | ||
| log, | ||
| "Block production state missing from snapshot cache"; | ||
| "head_block_root" => ?proposer_head, | ||
| "slot" => next_slot | ||
| ); | ||
| } | ||
|
|
||
| // Signal block proposal for the next slot (if it happens to be waiting). | ||
| if let Some(tx) = &beacon_chain.fork_choice_signal_tx { | ||
| if let Err(e) = tx.notify_fork_choice_complete(next_slot) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.