-
Notifications
You must be signed in to change notification settings - Fork 1k
Builder deposits optimisation #9311
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
base: unstable
Are you sure you want to change the base?
Changes from 19 commits
eda918d
ed15ac6
369eecd
112b093
0aa7d7a
5e46d38
18bcc24
826a521
49410fa
e2e8406
9738905
fd43fdc
44dcf5d
bc1a156
50cd378
16f615e
33bccd0
f89c099
de89987
70b8594
ecbb7e7
656e70a
31b6f3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,7 +120,9 @@ use slasher::Slasher; | |
| use slot_clock::SlotClock; | ||
| use ssz::Encode; | ||
| use state_processing::{ | ||
| BlockSignatureStrategy, ConsensusContext, SigVerifiedOp, VerifyBlockRoot, VerifyOperation, | ||
| BlockSignatureStrategy, ConsensusContext, GloasVerificationContext, SigVerifiedOp, | ||
| VerifyBlockRoot, VerifyOperation, | ||
| builder_deposits_cache::OnboardBuildersCache, | ||
| common::get_attesting_indices_from_state, | ||
| epoch_cache::initialize_epoch_cache, | ||
| per_block_processing, | ||
|
|
@@ -510,6 +512,9 @@ pub struct BeaconChain<T: BeaconChainTypes> { | |
| pub pending_payload_cache: Arc<PendingPayloadCache<T>>, | ||
| /// The KZG trusted setup used by this chain. | ||
| pub kzg: Arc<Kzg>, | ||
| /// Pre-validates builder deposit signatures. | ||
| /// Only required when gloas is enabled. | ||
| pub builder_onboarding_cache: Option<Arc<OnboardBuildersCache>>, | ||
| /// RNG instance used by the chain. Currently used for shuffling column sidecars in block publishing. | ||
| pub rng: Arc<Mutex<Box<dyn RngCore + Send>>>, | ||
| } | ||
|
|
@@ -1513,7 +1518,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |
| while state.slot() < slot { | ||
| // Note: supplying some `state_root` when it is known would be a cheap and easy | ||
| // optimization. | ||
| match per_slot_processing(&mut state, skip_state_root, &self.spec) { | ||
| match per_slot_processing( | ||
| &mut state, | ||
| skip_state_root, | ||
| GloasVerificationContext::from_cache( | ||
| self.builder_onboarding_cache.as_deref(), | ||
| ), | ||
| &self.spec, | ||
| ) { | ||
| Ok(_) => (), | ||
| Err(e) => { | ||
| warn!( | ||
|
|
@@ -2116,6 +2128,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |
| &mut state, | ||
| Some(advanced_state_root), | ||
| request_epoch.start_slot(T::EthSpec::slots_per_epoch()), | ||
| self.builder_onboarding_cache.as_deref(), | ||
| &self.spec, | ||
| ) | ||
| .map_err(Error::StateAdvanceError)?; | ||
|
|
@@ -4536,6 +4549,20 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |
| current_slot, | ||
| ); | ||
|
|
||
| if let Some(builder_onboarding_cache) = &self.builder_onboarding_cache { | ||
| let cache = builder_onboarding_cache.clone(); | ||
| let spec = self.spec.clone(); | ||
| let executor = self.task_executor.clone(); | ||
| // Using rayon pool here since `add_new_pending_deposits` uses rayon threads to | ||
| // perform the signature verification in batches. | ||
| // // We have until the fork transition for the cache to be used, so we use the low priority pool. | ||
| executor.spawn_blocking_with_rayon( | ||
| move || cache.add_new_pending_deposits::<T::EthSpec>(&state, &spec), | ||
|
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. Is this pretty much a no-op after the fork?
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. yeah it is. Hadn't considered it. can potentially only do this for pre-gloas states and then delete it post gloas |
||
| RayonPoolType::LowPriority, | ||
| "pre_verify_deposits", | ||
| ); | ||
| } | ||
|
|
||
| Ok(block_root) | ||
| } | ||
|
|
||
|
|
@@ -5170,6 +5197,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |
| &mut advanced_state, | ||
| Some(unadvanced_state_root), | ||
| proposal_slot, | ||
| self.builder_onboarding_cache.as_deref(), | ||
| &self.spec, | ||
| )?; | ||
|
|
||
|
|
@@ -5188,6 +5216,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |
| apply_parent_execution_payload( | ||
| &mut advanced_state, | ||
| &envelope.message.execution_requests, | ||
| self.builder_onboarding_cache.as_deref(), | ||
| &self.spec, | ||
| ) | ||
| .map_err(Error::PrepareProposerFailed)?; | ||
|
|
@@ -6191,6 +6220,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |
| signature_strategy, | ||
| VerifyBlockRoot::True, | ||
| &mut ctxt, | ||
| self.builder_onboarding_cache.as_deref(), | ||
| &self.spec, | ||
| )?; | ||
| drop(process_timer); | ||
|
|
@@ -6977,6 +7007,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |
| proposal_epoch, | ||
| accessor, | ||
| state_provider, | ||
| self.builder_onboarding_cache.as_deref(), | ||
| &self.spec, | ||
| ) | ||
| } | ||
|
|
@@ -7134,7 +7165,13 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |
| if state.current_epoch() + 1 < shuffling_epoch { | ||
| // Advance the state into the required slot, using the "partial" method since the | ||
| // state roots are not relevant for the shuffling. | ||
| partial_state_advance(&mut state, Some(state_root), target_slot, &self.spec)?; | ||
| partial_state_advance( | ||
| &mut state, | ||
| Some(state_root), | ||
| target_slot, | ||
| self.builder_onboarding_cache.as_deref(), | ||
| &self.spec, | ||
| )?; | ||
| } | ||
| metrics::stop_timer(state_skip_timer); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.