Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
def248e
feat: export
ahshum Feb 21, 2026
107f2d1
fix: disable gloas columns at block time
ahshum Feb 21, 2026
e9bc87e
fix: envelope proposal per spec
ahshum Feb 21, 2026
5e2f412
fix: process envelope with sidecars
ahshum Feb 21, 2026
95a3e0e
merge unstable
ahshum Feb 24, 2026
5efc500
merge unstable
ahshum Feb 24, 2026
852e624
merge unstable
ahshum Feb 27, 2026
027402d
fix: expose due to revert
ahshum Feb 27, 2026
d94dd24
merge unstable
ahshum Feb 27, 2026
3a0071b
refactor: move envelope creation to shared path
ahshum Mar 3, 2026
d751417
merge unstable
ahshum Mar 3, 2026
7ff9dd8
fix: stack limit
ahshum Mar 3, 2026
2dd0470
merge unstable
ahshum Mar 4, 2026
b7cf4a0
fix: drop pre-Electra proposal
ahshum Mar 4, 2026
3771b68
merge unstable
ahshum Mar 16, 2026
5ebaebf
fix: log instead of err on broadcast failing
ahshum Mar 16, 2026
3ce23e8
merge unstable
ahshum Apr 9, 2026
9ac70cd
fix: heze fork
ahshum Apr 9, 2026
03ca849
merge unstable
ahshum Apr 9, 2026
2aa4eff
chore: add spec url
ahshum Apr 9, 2026
5286be3
merge unstable
ahshum Apr 15, 2026
0c53515
merge unstable
ahshum Apr 16, 2026
15b0756
fix: return head and heze comments
ahshum Apr 16, 2026
8b655cc
fix: unused vars and heze comments
ahshum Apr 16, 2026
6915bd4
merge unstable
ahshum Apr 16, 2026
8afbd94
fix: heze block
ahshum Apr 16, 2026
04ef033
merge unstable
ahshum Apr 23, 2026
53fc4c6
feat: update envelope proposal
ahshum Apr 24, 2026
ca70736
feat: validate envelope with gossip
ahshum Apr 24, 2026
ee124a7
merge unstable
ahshum Apr 24, 2026
a6f8dae
merge unstable
ahshum Apr 24, 2026
c325245
merge unstable
ahshum Apr 27, 2026
7bb8f31
merge unstable
ahshum Apr 29, 2026
3f2b678
merge unstable
ahshum May 1, 2026
897f918
chore: update spec
ahshum May 1, 2026
0129f3a
fix: use func
ahshum May 1, 2026
645d7df
chore: clean up
ahshum May 1, 2026
7684d29
fix: clean up
ahshum May 1, 2026
efc5cb1
refactor: callers for pre-Gloas and Gloas
ahshum May 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion beacon_chain/gossip_processing/block_processor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ proc storeBackfillPayload(
self.storeSidecars(sidecarsOpt)
ok()

proc addPayload(
proc addPayload*(
self: ref BlockProcessor,
signedBlock: gloas.SignedBeaconBlock,
signedEnvelope: gloas.SignedExecutionPayloadEnvelope,
Expand Down
33 changes: 29 additions & 4 deletions beacon_chain/validators/beacon_validators.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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(

Copy link
Copy Markdown
Contributor

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 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.,

proc routeSignedBeaconBlock*(
router: ref MessageRouter,
blck: ForkySignedBeaconBlock,
someSidecarsOpt: SomeSidecarsToRoute,
checkValidator: bool
): Future[RouteBlockResult] {.async: (raises: [CancelledError]).} =
# 1. Validate
? router.validateRouteBlock(blck, checkValidator)
# 2. Publish block
await router.publishRouteBlock(blck)
# 3. Publish sidecars
when someSidecarsOpt is NoSidecarsAtFork:
const finalSidecars = noSidecars
else:
let finalSidecars = await publishSidecars(router, blck, someSidecarsOpt)
# 4. Add block to DAG
return await router.addRoutedBlock(blck, finalSidecars)

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().

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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 makeExecutionPayloadEnvelope which I think it would also help on testing.

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
Comment thread
tersec marked this conversation as resolved.
Resolved

envelope.state_root = hash_tree_root(
node.dag.clearanceState.forky(consensusFork).data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clearanceState is a ForkedHashedBeaconState, which means one shouldn't have to recompute the hash; it's cached:

ForkedHashedBeaconState* = object
case kind*: ConsensusFork
of ConsensusFork.Phase0: phase0Data*: phase0.HashedBeaconState
of ConsensusFork.Altair: altairData*: altair.HashedBeaconState
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.HashedBeaconState
of ConsensusFork.Capella: capellaData*: capella.HashedBeaconState
of ConsensusFork.Deneb: denebData*: deneb.HashedBeaconState
of ConsensusFork.Electra: electraData*: electra.HashedBeaconState
of ConsensusFork.Fulu: fuluData*: fulu.HashedBeaconState
of ConsensusFork.Gloas: gloasData*: gloas.HashedBeaconState

and
HashedBeaconState* = object
data*: BeaconState
root*: Eth2Digest # hash_tree_root(data)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason is with verify = false, state.root wouldn't be updated due to

if verify:
state.root = hash_tree_root(state.data)
if envelope.state_root != state.root:
return err("process_execution_payload: state root mismatch")

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.


# Rollback clearance state as we have got the transitioned state root.
rollbackState()

let signatureRes = await validator.getExecutionPayloadEnvelopeSignature(
node.dag.forkAtEpoch(slot.epoch),
Expand All @@ -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
Comment thread
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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 routeSignedBeaconBlock? i'm just trying to understand

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signedBlock, signedEnvelope, sidecarsOpt, checkValidator = false)
if res.isErr():
error "Failed to propose envelope", reason = res.error(), slot = slot
return head
Comment thread
tersec marked this conversation as resolved.
Resolved

notice "Payload Envelope proposed",
blockRoot = shortLog(blockRoot),
Expand Down
43 changes: 22 additions & 21 deletions beacon_chain/validators/message_router.nim
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,14 @@ proc routeSignedBeaconBlock*(
await router.publishRouteBlock(blck)

# 3. Publish sidecars
when someSidecarsOpt is NoSidecarsAtFork:
const consensusFork = typeof(blck).kind
when consensusFork >= ConsensusFork.Gloas:
# Disable column processing at block time.
Comment thread
arnetheduck marked this conversation as resolved.
Resolved
const finalSidecars = noSidecars
else:
elif consensusFork in ConsensusFork.Deneb .. ConsensusFork.Fulu:
Comment thread
tersec marked this conversation as resolved.
Resolved
let finalSidecars = await publishSidecars(router, blck, someSidecarsOpt)
else:
const finalSidecars = noSidecars

# 4. Add block to DAG
return await router.addRoutedBlock(blck, finalSidecars)
Expand Down Expand Up @@ -704,28 +708,25 @@ proc routePayloadAttestationMessage*(

proc routeExecutionPayloadEnvelope*(
router: ref MessageRouter,
signedBlock: gloas.SignedBeaconBlock,
signedEnvelope: gloas.SignedExecutionPayloadEnvelope,
sidecarsOpt: Opt[seq[gloas.DataColumnSidecar]],
checkValidator: bool
Comment thread
tersec marked this conversation as resolved.
Resolved
): Future[SendResult] {.async: (raises: [CancelledError]).} =
block:
let res = router[].processor[].processExecutionPayloadEnvelope(
MsgSource.api, signedEnvelope)
): Future[Result[void, string]] {.async: (raises: [CancelledError]).} =
# Publish envelope
(await router[].network.broadcastExecutionPayloadEnvelope(
signedEnvelope)).isOkOr:
return err("Proposed envelope failed to broadcast")

if not res.isGoodForSending:
warn "Execution payload envelope failed validation",
envelope = shortLog(signedEnvelope.message),
error = res.error()
return err(res.error()[1])
info "Execution payload envelope sent",
envelope = shortLog(signedEnvelope.message)

let res =
await router[].network.broadcastExecutionPayloadEnvelope(signedEnvelope)
# Publish sidecars
let finalSidecars = await publishSidecars(router, signedBlock, sidecarsOpt)

if res.isOk():
info "Execution payload envelope sent",
envelope = shortLog(signedEnvelope.message)
else:
notice "Execution payload envelope not sent",
envelope = shortLog(signedEnvelope.message),
error = res.error()
# Add envelope and sidecars to DAG
(await router[].blockProcessor.addPayload(
signedBlock, signedEnvelope, finalSidecars)).isOkOr:
return err("Proposed envelope failed to add to the chain")

return ok()
ok()
Loading