Fix envelope proposal - #8006
Conversation
|
|
||
| discard await node.router.routeExecutionPayloadEnvelope( | ||
| signedEnvelope, checkValidator = false) | ||
| let res = await node.router.routeExecutionPayloadEnvelope( |
There was a problem hiding this comment.
why is this a separate method? can it not be a part of routeSignedBeaconBlock? i'm just trying to understand
There was a problem hiding this comment.
This is one of the duties of builder (https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.2/specs/gloas/builder.md) now.
|
Updating to an looks likely to fix the jenkins/nimbus-eth2/linux/x86_64/nix CI failure. |
| return head | ||
|
|
||
| envelope.state_root = hash_tree_root( | ||
| node.dag.clearanceState.forky(consensusFork).data) |
There was a problem hiding this comment.
clearanceState is a ForkedHashedBeaconState, which means one shouldn't have to recompute the hash; it's cached:
nimbus-eth2/beacon_chain/spec/forks.nim
Lines 80 to 89 in 82bb3f4
and
nimbus-eth2/beacon_chain/spec/datatypes/gloas.nim
Lines 392 to 394 in 82bb3f4
There was a problem hiding this comment.
The main reason is with verify = false, state.root wouldn't be updated due to
nimbus-eth2/beacon_chain/spec/state_transition_block.nim
Lines 1259 to 1262 in 82bb3f4
And follows the spec, envelope.state_root is created by using process_execution_payload with verify=false so I believe I have to manually compute the state root after that.
| template rollbackState() = | ||
| assign(node.dag.clearanceState, node.dag.headState) | ||
|
|
||
| process_execution_payload( |
There was a problem hiding this comment.
This seems a bit odd to verify here, in general, because this whole handleProposal()/proposeBlock()/proposeBlockAux() callstack only triggers for BN-controlled validators, while as much as possible should be architected to support (even though, yes, Nimbus doesn't have the Beacon API support in place yet, it will have to by hoodi/sepolia testnet shipping) the VC/Beacon REST API approach as symmetrically/identically as possible, so they're guaranteed the same logic and have as much as feasible the same codepaths.
This is why routeFoo() combined with block_processor centralizes things: it means that both beacon_validators and the rpc/rest_foo.nim can call routeFoo() and get the same checks, the same codepaths. As is, to the extent this process_execution_payload() call is important, it's not reached at all here a REST version of Gloas block proposal.
I'd note that similarly the code above delegates to routeSignedBeaconBlock() to handle everything involved e.g.,
nimbus-eth2/beacon_chain/validators/message_router.nim
Lines 293 to 313 in 82bb3f4
and then all these callers (aside from the exported definition) run the same validation:
$ rg routeSignedBeaconBlock
beacon_chain/validators/message_router_mev.nim
133: (await node.router.routeSignedBeaconBlock(
136: return err("routeSignedBeaconBlock error") # Errors logged in router
beacon_chain/validators/message_router.nim
293:proc routeSignedBeaconBlock*(
beacon_chain/validators/beacon_validators.nim
593: node.router.routeSignedBeaconBlock(signedBlock, sidecarsOpt,
beacon_chain/rpc/rest_beacon_api.nim
1052: await node.router.routeSignedBeaconBlock(
1059: await node.router.routeSignedBeaconBlock(
1064: await node.router.routeSignedBeaconBlock(
1069: await node.router.routeSignedBeaconBlock(
1207: await node.router.routeSignedBeaconBlock(
with no code duplication and no possibility for different validation variations to drift apart, because they all live in that one routeSignedBeaconBlock.
So whatever validation needs to happen should ideally be part of routeExecutionPayloadEnvelope().
There was a problem hiding this comment.
Good shout. Will address this.
There was a problem hiding this comment.
Instead of message router, I move the logic to makeExecutionPayloadEnvelope which I think it would also help on testing.
# Conflicts: # beacon_chain/validators/message_router.nim
# Conflicts: # beacon_chain/validators/beacon_validators.nim # beacon_chain/validators/block_payloads.nim # beacon_chain/validators/message_router.nim
| if signatureRes.isErr: | ||
| error "Failed to sign sign execution payload envelope", | ||
| slot, validator = shortLog(validator), err = signatureRes.error | ||
| return newBlockRef.get() |
There was a problem hiding this comment.
| return newBlockRef.get() |
this looks redundant?
Fix as per
https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.2/specs/gloas/builder.md#constructing-the-signedexecutionpayloadenvelopehttps://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.5/specs/gloas/builder.md#constructing-the-signedexecutionpayloadenvelope