Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update copyright headers, and add execution
Browse files Browse the repository at this point in the history
payload signature tests, update toSignedBlindedBeaconBlock for eip-7732
Tomi-3-0 committed Jan 5, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 25c31c2 commit 3e016d2
Showing 41 changed files with 195 additions and 93 deletions.
2 changes: 1 addition & 1 deletion beacon_chain/beacon_chain_db_immutable.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2021-2024 Status Research & Development GmbH
# Copyright (c) 2021-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/beacon_node_light_client.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2022-2024 Status Research & Development GmbH
# Copyright (c) 2022-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/consensus_object_pools/blob_quarantine.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/consensus_object_pools/block_dag.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/consensus_object_pools/blockchain_dag.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/consensus_object_pools/blockchain_list.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/el/el_manager.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/el/engine_api_conversions.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2024 Status Research & Development GmbH
# Copyright (c) 2024-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
4 changes: 2 additions & 2 deletions beacon_chain/gossip_processing/block_processor.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -302,7 +302,7 @@ proc newExecutionPayload*(
blck.body.execution_payload
else:
debug "Block body does not support execution payload"
nil
default(electra.ExecutionPayload)

if not elManager.hasProperlyConfiguredConnection:
if elManager.hasConnection:
2 changes: 1 addition & 1 deletion beacon_chain/gossip_processing/gossip_validation.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2019-2024 Status Research & Development GmbH
# Copyright (c) 2019-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
3 changes: 2 additions & 1 deletion beacon_chain/nimbus_light_client.nim
Original file line number Diff line number Diff line change
@@ -111,7 +111,8 @@ programMain:
signedBlock: ForkedSignedBeaconBlock
): Future[void] {.async: (raises: [CancelledError]).} =
withBlck(signedBlock):
when consensusFork >= ConsensusFork.Bellatrix:
when consensusFork >= ConsensusFork.Bellatrix and
consensusFork < ConsensusFork.Fulu:
if forkyBlck.message.is_execution_block:
template payload(): auto = forkyBlck.message.body.execution_payload
if elManager != nil and not payload.block_hash.isZero:
2 changes: 1 addition & 1 deletion beacon_chain/spec/beacon_time.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/spec/beaconstate.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/spec/datatypes/constants.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2022-2024 Status Research & Development GmbH
# Copyright (c) 2022-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
20 changes: 7 additions & 13 deletions beacon_chain/spec/datatypes/fulu.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2024 Status Research & Development GmbH
# Copyright (c) 2024-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -20,7 +20,6 @@ import
ssz_serialization/[merkleization, proofs],
ssz_serialization/types as sszTypes,
kzg4844/[kzg, kzg_abi],
std/typetraits,
chronicles,
../digest,
"."/[base, phase0, electra],
@@ -36,11 +35,6 @@ from ./capella import
ExecutionBranch, HistoricalSummary, SignedBLSToExecutionChangeList,
Withdrawal, EXECUTION_PAYLOAD_GINDEX
from ./deneb import Blobs, BlobsBundle, KzgCommitments, KzgProofs
from ./electra import
PendingDeposit, PendingPartialWithdrawal,
PendingConsolidation, ExecutionPayload, Attestation, TrustedAttestation,
ElectraCommitteeValidatorsBits,AttesterSlashing, AttestationCommitteeBits,
FINALIZED_ROOT_GINDEX_ELECTRA, ExecutionRequests

export json_serialization, base, kzg4844

@@ -130,16 +124,16 @@ const
PTC_SIZE* = 512

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/_features/eip7732/beacon-chain.md#max-operations-per-block
MAX_PAYLOAD_ATTESTATIONS = 4
MAX_PAYLOAD_ATTESTATIONS* = 4
type

PTCStatus* = distinct uint64

# https://github.com/ethereum/consensus-specs/blob/dev/specs/_features/eip7732/beacon-chain.md#payloadattestationdata
PayloadAttestationData* = object
beaconBlockRoot*: Eth2Digest
beacon_block_root*: Eth2Digest
slot*: Slot
payload_Status*: uint8
payload_status*: uint8

# https://github.com/ethereum/consensus-specs/blob/dev/specs/_features/eip7732/beacon-chain.md#payloadattestation
PayloadAttestation* = object
@@ -155,7 +149,7 @@ type

# https://github.com/ethereum/consensus-specs/blob/dev/specs/_features/eip7732/beacon-chain.md#indexedpayloadattestation
IndexedPayloadAttestation* = object
attestingIndices*: List[ValidatorIndex, Limit PTC_SIZE]
attesting_indices*: List[ValidatorIndex, Limit PTC_SIZE]
data*: PayloadAttestationData
signature*: ValidatorSig

@@ -630,9 +624,9 @@ func initHashedBeaconState*(s: BeaconState): HashedBeaconState =

func shortLog*(v: PayloadAttestationData): auto =
(
beaconBlockRoot: shortLog(v.beaconBlockRoot),
beacon_block_root: shortLog(v.beacon_block_root),
slot: shortLog(v.slot),
payload_Status: $v.payload_Status
payload_status: $v.payload_status
)

func shortLog*(v: SomeBeaconBlock): auto =
2 changes: 1 addition & 1 deletion beacon_chain/spec/eip7594_helpers.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/spec/eip7732_helpers.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2024 Status Research & Development GmbH
# Copyright (c) 2024-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/spec/forks_light_client.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2023-2024 Status Research & Development GmbH
# Copyright (c) 2023-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/spec/helpers.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/spec/helpers_el.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2024 Status Research & Development GmbH
# Copyright (c) 2024-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
13 changes: 7 additions & 6 deletions beacon_chain/spec/mev/fulu_mev.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2024 Status Research & Development GmbH
# Copyright (c) 2024-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -40,10 +40,10 @@ type
deposits*: List[Deposit, Limit MAX_DEPOSITS]
voluntary_exits*: List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS]
sync_aggregate*: SyncAggregate
signed_execution_payload_header*: SignedExecutionPayloadHeader
bls_to_execution_changes*:
List[SignedBLSToExecutionChange,
Limit MAX_BLS_TO_EXECUTION_CHANGES]
List[SignedBLSToExecutionChange, Limit MAX_BLS_TO_EXECUTION_CHANGES]
signed_execution_payload_header*: SignedExecutionPayloadHeader
payload_attestations*: List[PayloadAttestation, Limit MAX_PAYLOAD_ATTESTATIONS]
# blob_kzg_commitments*: KzgCommitments # [New in Deneb]
# execution_requests*: ExecutionRequests # [New in Electra]

@@ -124,6 +124,7 @@ func toSignedBlindedBeaconBlock*(blck: fulu.SignedBeaconBlock):
deposits: blck.message.body.deposits,
voluntary_exits: blck.message.body.voluntary_exits,
sync_aggregate: blck.message.body.sync_aggregate,
bls_to_execution_changes: blck.message.body.bls_to_execution_changes,
signed_execution_payload_header: SignedExecutionPayloadHeader(
message: ExecutionPayloadHeader(
parent_block_hash: blck.message.body.signed_execution_payload_header.message.parent_block_hash,
@@ -135,6 +136,6 @@ func toSignedBlindedBeaconBlock*(blck: fulu.SignedBeaconBlock):
blob_kzg_commitments_root: blck.message.body.signed_execution_payload_header.message.blob_kzg_commitments_root,
block_hash: blck.message.body.signed_execution_payload_header.message.block_hash
),
signature: blck.signature),
bls_to_execution_changes: blck.message.body.bls_to_execution_changes)),
signature: blck.message.body.signed_execution_payload_header.signature),
payload_attestations: blck.message.body.payload_attestations)),
signature: blck.signature)
2 changes: 1 addition & 1 deletion beacon_chain/spec/network.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/spec/signatures.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/spec/state_transition.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/spec/state_transition_block.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/sync/request_manager.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/sync/sync_manager.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/validators/beacon_validators.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/validators/message_router.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion beacon_chain/validators/message_router_mev.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2022-2024 Status Research & Development GmbH
# Copyright (c) 2022-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion ncli/ncli_testnet.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
22 changes: 18 additions & 4 deletions research/mev_mock.nim
Original file line number Diff line number Diff line change
@@ -50,13 +50,27 @@ proc getParentBlock(restClient: RestClientRef):
return Opt.none ParentHeaderInfo

withBlck(resp):
when consensusFork >= ConsensusFork.Capella:
return Opt.some ParentHeaderInfo(
block_number: forkyBlck.message.body.execution_payload.block_number,
timestamp: forkyBlck.message.body.execution_payload.timestamp)
when consensusFork >= ConsensusFork.Capella and
consensusFork < ConsensusFork.Fulu:
return Opt.some ParentHeaderInfo(
block_number: forkyBlck.message.body.execution_payload.block_number,
timestamp: forkyBlck.message.body.execution_payload.timestamp)
else:
discard

# TODO {what is expected of eip-7732 blocks}
# withBlck(resp):
# when consensusFork >= ConsensusFork.Fulu:
# return Opt.some ParentHeaderInfo(
# block_: forkyBlck.message.body.signed_execution_payload_header.message,
# timestamp: forkyBlck.message.signed_execution_payload_header.message)
# elif consensusFork >= ConsensusFork.Capella:
# return Opt.some ParentHeaderInfo(
# block_number: forkyBlck.message.body.execution_payload.block_number,
# timestamp: forkyBlck.message.body.execution_payload.timestamp)
# else:
# discard

proc getWithdrawals(restClient: RestClientRef):
Future[Opt[seq[Withdrawal]]] {.async.} =
let resp: RestResponse[rest_types.GetNextWithdrawalsResponse] =
43 changes: 22 additions & 21 deletions research/wss_sim.nim
Original file line number Diff line number Diff line change
@@ -119,27 +119,28 @@ cli do(validatorsDir: string, secretsDir: string,
# The EL may otherwise refuse to produce new heads
elManager.start(syncChain = false)
withBlck(blck[]):
when consensusFork >= ConsensusFork.Bellatrix:
if forkyBlck.message.is_execution_block:
template payload(): auto = forkyBlck.message.body.execution_payload
if not payload.block_hash.isZero:
notice "Syncing EL", elUrl, jwtSecret
while true:
waitFor noCancel sleepAsync(chronos.seconds(2))
(waitFor noCancel elManager
.newExecutionPayload(forkyBlck.message)).isOkOr:
continue

let (status, _) = waitFor noCancel elManager.forkchoiceUpdated(
headBlockHash = payload.block_hash,
safeBlockHash = payload.block_hash,
finalizedBlockHash = ZERO_HASH,
payloadAttributes = Opt.none(consensusFork.PayloadAttributes))
if status != PayloadExecutionStatus.valid:
continue

notice "EL synced", elUrl, jwtSecret
break
when consensusFork >= ConsensusFork.Bellatrix and
consensusFork < ConsensusFork.Fulu:
if forkyBlck.message.is_execution_block:
template payload(): auto = forkyBlck.message.body.execution_payload
if not payload.block_hash.isZero:
notice "Syncing EL", elUrl, jwtSecret
while true:
waitFor noCancel sleepAsync(chronos.seconds(2))
(waitFor noCancel elManager
.newExecutionPayload(forkyBlck.message)).isOkOr:
continue

let (status, _) = waitFor noCancel elManager.forkchoiceUpdated(
headBlockHash = payload.block_hash,
safeBlockHash = payload.block_hash,
finalizedBlockHash = ZERO_HASH,
payloadAttributes = Opt.none(consensusFork.PayloadAttributes))
if status != PayloadExecutionStatus.valid:
continue

notice "EL synced", elUrl, jwtSecret
break

var
clock = BeaconClock.init(getStateField(state[], genesis_time)).valueOr:
2 changes: 1 addition & 1 deletion tests/all_tests.nim
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

{.push raises: [].}

# All tests except scenarios, which as compiled separately for mainnet and minimal
# All tests except scenarios, which is compiled separately for mainnet and minimal

import
./testutil
Binary file added tests/consensus_spec/all_tests
Binary file not shown.
105 changes: 104 additions & 1 deletion tests/test_message_signatures.nim
Original file line number Diff line number Diff line change
@@ -272,4 +272,107 @@ suite "Message signatures":
fork0, genesis_validators_root0, slot, subcommittee_index,
load(pubkey0).get, get_sync_committee_selection_proof(
fork0, genesis_validators_root1, slot,
subcommittee_index, privkey0).toValidatorSig)
subcommittee_index, privkey0).toValidatorSig)

test "execution payload header signatures":
let
msg = default(fulu.SignedExecutionPayloadHeader)
state = default(fulu.BeaconState)

check:
# Matching public/private keys and genesis validator roots
verify_execution_payload_header_signature(
fork0, genesis_validators_root0, msg, state,
load(pubkey0).get, get_execution_payload_header_signature(
fork0, genesis_validators_root0, msg,
state, privkey0).toValidatorSig)

# Mismatched public/private keys
not verify_execution_payload_header_signature(
fork0, genesis_validators_root0, msg, state,
load(pubkey0).get, get_execution_payload_header_signature(
fork0, genesis_validators_root0, msg,
state, privkey1).toValidatorSig)

# Mismatched forks
not verify_execution_payload_header_signature(
fork0, genesis_validators_root0, msg, state,
load(pubkey0).get, get_execution_payload_header_signature(
fork1, genesis_validators_root0, msg,
state, privkey0).toValidatorSig)

# Mismatched genesis validator roots
not verify_execution_payload_header_signature(
fork0, genesis_validators_root0, msg, state,
load(pubkey0).get, get_execution_payload_header_signature(
fork0, genesis_validators_root1, msg,
state, privkey0).toValidatorSig)

test "execution payload envelope signatures":
let
msg = default(fulu.SignedExecutionPayloadEnvelope)
state = default(fulu.BeaconState)

check:
# Matching public/private keys and genesis validator roots
verify_execution_payload_envelope_signature(
fork0, genesis_validators_root0, msg, state,
load(pubkey0).get, get_execution_payload_envelope_signature(
fork0, genesis_validators_root0, msg,
state, privkey0).toValidatorSig)

# Mismatched public/private keys
not verify_execution_payload_envelope_signature(
fork0, genesis_validators_root0, msg, state,
load(pubkey0).get, get_execution_payload_envelope_signature(
fork0, genesis_validators_root0, msg,
state, privkey1).toValidatorSig)

# Mismatched forks
not verify_execution_payload_envelope_signature(
fork0, genesis_validators_root0, msg, state,
load(pubkey0).get, get_execution_payload_envelope_signature(
fork1, genesis_validators_root0, msg,
state, privkey0).toValidatorSig)

# Mismatched genesis validator roots
not verify_execution_payload_envelope_signature(
fork0, genesis_validators_root0, msg, state,
load(pubkey0).get, get_execution_payload_envelope_signature(
fork0, genesis_validators_root1, msg,
state, privkey0).toValidatorSig)

test "execution payload attestation signatures":
let
slot = default(Slot)
attestation = default(fulu.PayloadAttestationMessage)
state = default(fulu.BeaconState)

check:
# Matching public/private keys and genesis validator roots
verify_payload_attestation_message_signature(
fork0, genesis_validators_root0, attestation, state,
load(pubkey0).get, get_payload_attestation_message_signature(
fork0, genesis_validators_root0, attestation,
state, privkey0).toValidatorSig)

# Mismatched public/private keys
not verify_payload_attestation_message_signature(
fork0, genesis_validators_root0, attestation, state,
load(pubkey0).get, get_payload_attestation_message_signature(
fork0, genesis_validators_root0, attestation,
state, privkey1).toValidatorSig)

# Mismatched forks
not verify_payload_attestation_message_signature(
fork0, genesis_validators_root0, attestation, state,
load(pubkey0).get, get_payload_attestation_message_signature(
fork1, genesis_validators_root0, attestation,
state, privkey0).toValidatorSig)

# Mismatched genesis validator roots
not verify_payload_attestation_message_signature(
fork0, genesis_validators_root0, attestation, state,
load(pubkey0).get, get_payload_attestation_message_signature(
fork0, genesis_validators_root1, attestation,
state, privkey0).toValidatorSig)
2 changes: 1 addition & 1 deletion tests/test_sync_manager.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2020-2024 Status Research & Development GmbH
# Copyright (c) 2020-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
14 changes: 1 addition & 13 deletions tests/test_toblindedblock.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2024 Status Research & Development GmbH
# Copyright (c) 2024-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -136,18 +136,6 @@ template electra_steps() =
default(ConsolidationRequest))
do_check

template fulu_steps() =
when consensusFork < ConsensusFork.Fulu:
check: b.message.body.execution_requests.deposits.add(
default(DepositRequest))
do_check
check: b.message.body.execution_requests.withdrawals.add(
default(WithdrawalRequest))
do_check
check: b.message.body.execution_requests.consolidations.add(
default(ConsolidationRequest))
do_check

suite "Blinded block conversions":
withAll(ConsensusFork):
when consensusFork >= ConsensusFork.Bellatrix:

0 comments on commit 3e016d2

Please sign in to comment.