Repository navigation
Fix envelope proposal #8006
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
Fix envelope proposal #8006
Changes from 9 commits
def248e
107f2d1
e9bc87e
5e2f412
95a3e0e
5efc500
852e624
027402d
d94dd24
3a0071b
d751417
7ff9dd8
2dd0470
b7cf4a0
3771b68
5ebaebf
3ce23e8
9ac70cd
03ca849
2aa4eff
5286be3
0c53515
15b0756
8b655cc
6915bd4
8afbd94
04ef033
53fc4c6
ca70736
ee124a7
a6f8dae
c325245
7bb8f31
3f2b678
897f918
0129f3a
645d7df
7684d29
efc5cb1
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 | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -611,12 +611,33 @@ proc proposeBlockAux( | |||||||||||||||||||||||||||||||||||
| beacon_blocks_proposed.inc() | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| when consensusFork >= ConsensusFork.Gloas: | ||||||||||||||||||||||||||||||||||||
| let envelope = makeExecutionPayloadEnvelope( | ||||||||||||||||||||||||||||||||||||
| var envelope = makeExecutionPayloadEnvelope( | ||||||||||||||||||||||||||||||||||||
| eps = engineBid[].eps, | ||||||||||||||||||||||||||||||||||||
| execution_requests = engineBid[].execution_requests, | ||||||||||||||||||||||||||||||||||||
| beacon_block_root = blockRoot, | ||||||||||||||||||||||||||||||||||||
| slot = slot, | ||||||||||||||||||||||||||||||||||||
| state_root = signedBlock.message.state_root) | ||||||||||||||||||||||||||||||||||||
| state_root = ZERO_HASH) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| template rollbackState() = | ||||||||||||||||||||||||||||||||||||
| assign(node.dag.clearanceState, node.dag.headState) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| process_execution_payload( | ||||||||||||||||||||||||||||||||||||
| node.dag.cfg, | ||||||||||||||||||||||||||||||||||||
| node.dag.clearanceState.forky(consensusFork), | ||||||||||||||||||||||||||||||||||||
| gloas.SignedExecutionPayloadEnvelope(message: envelope), | ||||||||||||||||||||||||||||||||||||
| func(_: deneb.ExecutionPayload): bool = true, | ||||||||||||||||||||||||||||||||||||
| cache[], | ||||||||||||||||||||||||||||||||||||
| verify = false, | ||||||||||||||||||||||||||||||||||||
| ).isOkOr: | ||||||||||||||||||||||||||||||||||||
| rollbackState() | ||||||||||||||||||||||||||||||||||||
| debug "Proposed envelope failed to verify with transition", msg = error | ||||||||||||||||||||||||||||||||||||
| return head | ||||||||||||||||||||||||||||||||||||
|
tersec marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| envelope.state_root = hash_tree_root( | ||||||||||||||||||||||||||||||||||||
| node.dag.clearanceState.forky(consensusFork).data) | ||||||||||||||||||||||||||||||||||||
|
Contributor
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.
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
Contributor
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. The main reason is with nimbus-eth2/beacon_chain/spec/state_transition_block.nim Lines 1259 to 1262 in 82bb3f4
And follows the spec, |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Rollback clearance state as we have got the transitioned state root. | ||||||||||||||||||||||||||||||||||||
| rollbackState() | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| let signatureRes = await validator.getExecutionPayloadEnvelopeSignature( | ||||||||||||||||||||||||||||||||||||
| node.dag.forkAtEpoch(slot.epoch), | ||||||||||||||||||||||||||||||||||||
|
|
@@ -628,14 +649,18 @@ proc proposeBlockAux( | |||||||||||||||||||||||||||||||||||
| if signatureRes.isErr: | ||||||||||||||||||||||||||||||||||||
| error "Failed to sign sign execution payload envelope", | ||||||||||||||||||||||||||||||||||||
| slot, validator = shortLog(validator), err = signatureRes.error | ||||||||||||||||||||||||||||||||||||
| return head | ||||||||||||||||||||||||||||||||||||
|
tersec marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||
| let signedEnvelope = gloas.SignedExecutionPayloadEnvelope( | ||||||||||||||||||||||||||||||||||||
| message: envelope, | ||||||||||||||||||||||||||||||||||||
| signature: signatureRes.get() | ||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| discard await node.router.routeExecutionPayloadEnvelope( | ||||||||||||||||||||||||||||||||||||
| signedEnvelope, checkValidator = false) | ||||||||||||||||||||||||||||||||||||
| let res = await node.router.routeExecutionPayloadEnvelope( | ||||||||||||||||||||||||||||||||||||
|
Contributor
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. why is this a separate method? can it not be a part of
Contributor
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. 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. |
||||||||||||||||||||||||||||||||||||
| signedBlock, signedEnvelope, sidecarsOpt, checkValidator = false) | ||||||||||||||||||||||||||||||||||||
| if res.isErr(): | ||||||||||||||||||||||||||||||||||||
| error "Failed to propose envelope", reason = res.error(), slot = slot | ||||||||||||||||||||||||||||||||||||
| return head | ||||||||||||||||||||||||||||||||||||
|
tersec marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| notice "Payload Envelope proposed", | ||||||||||||||||||||||||||||||||||||
| blockRoot = shortLog(blockRoot), | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 withblock_processorcentralizes things: it means that bothbeacon_validatorsand therpc/rest_foo.nimcan callrouteFoo()and get the same checks, the same codepaths. As is, to the extent thisprocess_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:
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good shout. Will address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of message router, I move the logic to
makeExecutionPayloadEnvelopewhich I think it would also help on testing.