Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2b61c86
feat: disable execution payload validation for beacon block on gloas
ahshum Oct 17, 2025
d49413a
chore: include gloas spec for beacon_block
ahshum Oct 17, 2025
411deae
feat: full block pool
ahshum Oct 17, 2025
48075c3
fix: case
ahshum Oct 17, 2025
46ad77e
feat: check block by root
ahshum Oct 17, 2025
8bdb4f8
feat: add validation for execution payload
ahshum Oct 17, 2025
1286ae7
feat: init full block pool
ahshum Oct 17, 2025
4c02aa0
feat: create execution payload gossip processor
ahshum Oct 17, 2025
4a81e7b
refactor: move toBlockId under gloas
ahshum Oct 17, 2025
6463ef4
test: add full block pool
ahshum Oct 17, 2025
f9295bd
fix: simplify checks
ahshum Oct 17, 2025
85cd2b6
chore: copyright year
ahshum Oct 20, 2025
dafc65a
fix: validation
ahshum Oct 20, 2025
16a1c56
test: update case name
ahshum Oct 20, 2025
a4e16b6
feat: log bid for fallback investigation
ahshum Oct 20, 2025
a2af12a
fix: specify beacon block type
ahshum Oct 20, 2025
d3f1aa2
chore: todo
ahshum Oct 20, 2025
8fce3e3
refactor: remove processing status
ahshum Oct 20, 2025
7950b9b
chore: free unused var
ahshum Oct 20, 2025
9abc8db
chore: import ordering
ahshum Oct 20, 2025
8b78858
Merge branch 'unstable' into sam/g
ahshum Oct 20, 2025
2f4d295
Merge branch 'unstable' into sam/g
ahshum Oct 20, 2025
4922fb1
fix: beacon time from cfg
ahshum Oct 20, 2025
59fab8f
refactor: check seen block from existing data
ahshum Oct 20, 2025
832e990
Merge branch 'unstable' into sam/g
ahshum Oct 21, 2025
7f13385
fix: beacon time from time params
ahshum Oct 21, 2025
b96fda8
fix: time params
ahshum Oct 21, 2025
b0fa3a5
Merge branch 'unstable' into sam/g
ahshum Oct 22, 2025
3dbd874
fix: time params
ahshum Oct 22, 2025
07bf838
fix: use table
ahshum Oct 22, 2025
a40ff27
refactor: remove unused function
ahshum Oct 22, 2025
1c440d7
refactor: rename processor
ahshum Oct 22, 2025
c0da29d
refactor: remove unused block execution enabled impl
ahshum Oct 22, 2025
b6058b6
revert: gloas beacon_block validation
ahshum Oct 22, 2025
cf8fb6e
revert: undo full block pool
ahshum Oct 22, 2025
5d5b8c5
refactor: execution payload gossip validation
ahshum Oct 22, 2025
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
74 changes: 73 additions & 1 deletion beacon_chain/gossip_processing/gossip_validation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import
helpers, network, signatures, peerdas_helpers],
../consensus_object_pools/[
attestation_pool, blockchain_dag, blob_quarantine, block_quarantine,
spec_cache, light_client_pool, sync_committee_msg_pool,
light_client_pool, spec_cache, sync_committee_msg_pool,
validator_change_pool],
".."/[beacon_clock],
./batch_validation
Expand Down Expand Up @@ -973,6 +973,78 @@ proc validateBeaconBlock*(

ok()

# https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/gloas/p2p-interface.md#execution_payload
proc validateExecutionPayload*(
dag: ChainDAGRef, quarantine: ref Quarantine,
signed_execution_payload_envelope: SignedExecutionPayloadEnvelope):
Result[void, ValidationError] =
template envelope: untyped = signed_execution_payload_envelope.message

# [IGNORE] The envelope's block root envelope.block_root has been seen (via
# gossip or non-gossip sources) (a client MAY queue payload for processing
# once the block is retrieved).
let blockSeen =
block:
var seen =
envelope.beacon_block_root in quarantine.unviable or
envelope.beacon_block_root in quarantine.missing or
dag.getBlockRef(envelope.beacon_block_root).isSome()
if not seen:
for k, _ in quarantine.orphans:
if k[0] == envelope.beacon_block_root:
seen = true
break
seen
if not blockSeen:
return errIgnore("ExecutionPayload: block not found")

# [IGNORE] The node has not seen another valid SignedExecutionPayloadEnvelope
# for this block root from this builder.
debugGloasComment("")

# [REJECT] block passes validation.
let blck =
block:
let forkedBlock = dag.getForkedBlock(signed_execution_payload_envelope.toBlockId()).valueOr:
return errReject("ExecutionPayload: invalid block")
withBlck(forkedBlock):
when consensusFork >= ConsensusFork.Gloas:
forkyBlck.asSigned().message
else:
return errReject("ExecutionPayload: invalid fork")

# [REJECT] block.slot equals envelope.slot.
if blck.slot != envelope.slot:
return errReject("ExecutionPayload: slot mismatch")

# TODO: check if it needs fallback to `state.latest_execution_payload_bid`
template bid: untyped = blck.body.signed_execution_payload_bid.message
debug "Validating execution payload", bid = shortLog(bid)

# [REJECT] envelope.builder_index == bid.builder_index
if envelope.builder_index != bid.builder_index:
return errReject("ExecutionPayload: builder index mismatch")

# [REJECT] payload.block_hash == bid.block_hash
if envelope.payload.block_hash != bid.block_hash:
return errReject("ExecutionPayload: block hash mismatch")

# [REJECT] signed_execution_payload_envelope.signature is valid with respect
# to the builder's public key.
withState(dag.headState):
when consensusFork >= ConsensusFork.Gloas:
if not verify_execution_payload_envelope_signature(
dag.forkAtEpoch(envelope.slot.epoch),
getStateField(dag.headState, genesis_validators_root),
signed_execution_payload_envelope, forkyState.data,
dag.validatorKey(envelope.builder_index).get(),
signed_execution_payload_envelope.signature):
return dag.checkedReject("ExecutionPayload: invalid builder signature")
else:
return dag.checkedReject("ExecutionPayload: invalid fork")

ok()

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof
proc validateAttestation*(
Expand Down
7 changes: 5 additions & 2 deletions beacon_chain/spec/datatypes/gloas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import
json_serialization,
ssz_serialization/[merkleization, proofs],
ssz_serialization/types as sszTypes,
../digest,
../[block_id, digest],
kzg4844/[kzg, kzg_abi]

from ./altair import
Expand Down Expand Up @@ -115,7 +115,7 @@ type

# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.6/specs/gloas/beacon-chain.md#payloadattestationmessage
PayloadAttestationMessage* = object
validatorIndex*: uint64
validator_index*: uint64
data*: PayloadAttestationData
signature*: ValidatorSig

Expand Down Expand Up @@ -626,3 +626,6 @@ template asTrusted*(
x: SignedBeaconBlock |
SigVerifiedSignedBeaconBlock): TrustedSignedBeaconBlock =
isomorphicCast[TrustedSignedBeaconBlock](x)

func toBlockId*(v: SignedExecutionPayloadEnvelope): BlockId =
BlockId(root: v.message.beacon_block_root, slot: v.message.slot)
Loading