@@ -159,50 +159,46 @@ fn load_snapshot<T: BeaconChainTypes>(
159159
160160 // TODO(EIP-7732): add metrics here
161161
162- let result = {
163- // Load the parent block's state from the database, returning an error if it is not found.
164- // It is an error because if we know the parent block we should also know the parent state.
165- // Retrieve any state that is advanced through to at most `block.slot()`: this is
166- // particularly important if `block` descends from the finalized/split block, but at a slot
167- // prior to the finalized slot (which is invalid and inaccessible in our DB schema).
168- let ( parent_state_root, state) = chain
169- . store
170- // TODO(EIP-7732): the state doesn't need to be advanced here because we're applying an envelope
171- // but this function does use a lot of caches that could be more efficient. Is there
172- // a better way to do this?
173- . get_advanced_hot_state (
174- beacon_block_root,
175- proto_beacon_block. slot ,
162+ // Load the parent block's state from the database, returning an error if it is not found.
163+ // It is an error because if we know the parent block we should also know the parent state.
164+ // Retrieve any state that is advanced through to at most `block.slot()`: this is
165+ // particularly important if `block` descends from the finalized/split block, but at a slot
166+ // prior to the finalized slot (which is invalid and inaccessible in our DB schema).
167+ let ( parent_state_root, state) = chain
168+ . store
169+ // TODO(EIP-7732): the state doesn't need to be advanced here because we're applying an envelope
170+ // but this function does use a lot of caches that could be more efficient. Is there
171+ // a better way to do this?
172+ . get_advanced_hot_state (
173+ beacon_block_root,
174+ proto_beacon_block. slot ,
175+ proto_beacon_block. state_root ,
176+ )
177+ . map_err ( |e| EnvelopeError :: BeaconChainError ( Arc :: new ( e. into ( ) ) ) ) ?
178+ . ok_or_else ( || {
179+ BeaconChainError :: DBInconsistent ( format ! (
180+ "Missing state for parent block {beacon_block_root:?}" ,
181+ ) )
182+ } ) ?;
183+
184+ if state. slot ( ) == proto_beacon_block. slot {
185+ // Sanity check.
186+ if parent_state_root != proto_beacon_block. state_root {
187+ return Err ( BeaconChainError :: DBInconsistent ( format ! (
188+ "Parent state at slot {} has the wrong state root: {:?} != {:?}" ,
189+ state. slot( ) ,
190+ parent_state_root,
176191 proto_beacon_block. state_root,
177- )
178- . map_err ( |e| EnvelopeError :: BeaconChainError ( Arc :: new ( e. into ( ) ) ) ) ?
179- . ok_or_else ( || {
180- BeaconChainError :: DBInconsistent ( format ! (
181- "Missing state for parent block {beacon_block_root:?}" ,
182- ) )
183- } ) ?;
184-
185- if state. slot ( ) == proto_beacon_block. slot {
186- // Sanity check.
187- if parent_state_root != proto_beacon_block. state_root {
188- return Err ( BeaconChainError :: DBInconsistent ( format ! (
189- "Parent state at slot {} has the wrong state root: {:?} != {:?}" ,
190- state. slot( ) ,
191- parent_state_root,
192- proto_beacon_block. state_root,
193- ) )
194- . into ( ) ) ;
195- }
192+ ) )
193+ . into ( ) ) ;
196194 }
195+ }
197196
198- Ok ( EnvelopeProcessingSnapshot {
199- pre_state : state,
200- state_root : parent_state_root,
201- beacon_block_root,
202- } )
203- } ;
204-
205- result
197+ Ok ( EnvelopeProcessingSnapshot {
198+ pre_state : state,
199+ state_root : parent_state_root,
200+ beacon_block_root,
201+ } )
206202}
207203
208204/// A wrapper around a `SignedExecutionPayloadEnvelope` that indicates it has been approved for re-gossiping on
@@ -320,7 +316,7 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
320316 builder_index : envelope. builder_index ( ) ,
321317 } ) ?;
322318 signed_envelope. verify_signature (
323- & builder_pubkey,
319+ builder_pubkey,
324320 & fork,
325321 chain. genesis_validators_root ,
326322 & chain. spec ,
0 commit comments