|
|
|
@ -361,7 +361,8 @@ func partialBeaconBlock*(
|
|
|
|
|
deposits: seq[Deposit],
|
|
|
|
|
validator_changes: BeaconBlockValidatorChanges,
|
|
|
|
|
sync_aggregate: SyncAggregate,
|
|
|
|
|
execution_payload: ForkyExecutionPayloadForSigning
|
|
|
|
|
execution_payload: ForkyExecutionPayloadForSigning,
|
|
|
|
|
consolidations: openArray[SignedConsolidation]
|
|
|
|
|
): auto =
|
|
|
|
|
const consensusFork = typeof(state).kind
|
|
|
|
|
|
|
|
|
@ -411,12 +412,14 @@ func partialBeaconBlock*(
|
|
|
|
|
deposits: seq[Deposit],
|
|
|
|
|
validator_changes: BeaconBlockValidatorChanges,
|
|
|
|
|
sync_aggregate: SyncAggregate,
|
|
|
|
|
execution_payload: ForkyExecutionPayloadForSigning
|
|
|
|
|
execution_payload: ForkyExecutionPayloadForSigning,
|
|
|
|
|
consolidations: seq[SignedConsolidation],
|
|
|
|
|
): auto =
|
|
|
|
|
const consensusFork = typeof(state).kind
|
|
|
|
|
|
|
|
|
|
debugComment "re-enable attester slashing packing in electra"
|
|
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#preparing-for-a-beaconblock
|
|
|
|
|
var res = consensusFork.BeaconBlock(
|
|
|
|
|
consensusFork.BeaconBlock(
|
|
|
|
|
slot: state.data.slot,
|
|
|
|
|
proposer_index: proposer_index.uint64,
|
|
|
|
|
parent_root: state.latest_block_root,
|
|
|
|
@ -429,28 +432,14 @@ func partialBeaconBlock*(
|
|
|
|
|
attestations:
|
|
|
|
|
List[electra.Attestation, Limit MAX_ATTESTATIONS_ELECTRA](attestations),
|
|
|
|
|
deposits: List[Deposit, Limit MAX_DEPOSITS](deposits),
|
|
|
|
|
voluntary_exits: validator_changes.voluntary_exits))
|
|
|
|
|
|
|
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/validator.md#preparing-a-beaconblock
|
|
|
|
|
when consensusFork >= ConsensusFork.Altair:
|
|
|
|
|
res.body.sync_aggregate = sync_aggregate
|
|
|
|
|
|
|
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/bellatrix/validator.md#block-proposal
|
|
|
|
|
when consensusFork >= ConsensusFork.Bellatrix:
|
|
|
|
|
res.body.execution_payload = execution_payload.executionPayload
|
|
|
|
|
|
|
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/validator.md#block-proposal
|
|
|
|
|
when consensusFork >= ConsensusFork.Capella:
|
|
|
|
|
res.body.bls_to_execution_changes =
|
|
|
|
|
validator_changes.bls_to_execution_changes
|
|
|
|
|
|
|
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/validator.md#constructing-the-beaconblockbody
|
|
|
|
|
when consensusFork >= ConsensusFork.Deneb:
|
|
|
|
|
res.body.blob_kzg_commitments = execution_payload.blobsBundle.commitments
|
|
|
|
|
|
|
|
|
|
debugComment "either consolidate this within separate function or recombine, re when consensusFork >= foo and atts/attslashings; here to allow noninterference with pre-pectra"
|
|
|
|
|
|
|
|
|
|
res
|
|
|
|
|
voluntary_exits: validator_changes.voluntary_exits,
|
|
|
|
|
sync_aggregate: sync_aggregate,
|
|
|
|
|
execution_payload: execution_payload.executionPayload,
|
|
|
|
|
bls_to_execution_changes: validator_changes.bls_to_execution_changes,
|
|
|
|
|
blob_kzg_commitments: execution_payload.blobsBundle.commitments,
|
|
|
|
|
consolidations:
|
|
|
|
|
List[SignedConsolidation, Limit MAX_CONSOLIDATIONS].init(
|
|
|
|
|
consolidations)))
|
|
|
|
|
|
|
|
|
|
proc makeBeaconBlockWithRewards*(
|
|
|
|
|
cfg: RuntimeConfig,
|
|
|
|
@ -464,6 +453,7 @@ proc makeBeaconBlockWithRewards*(
|
|
|
|
|
validator_changes: BeaconBlockValidatorChanges,
|
|
|
|
|
sync_aggregate: SyncAggregate,
|
|
|
|
|
executionPayload: ForkyExecutionPayloadForSigning,
|
|
|
|
|
consolidations: seq[SignedConsolidation],
|
|
|
|
|
rollback: RollbackForkedHashedProc,
|
|
|
|
|
cache: var StateCache,
|
|
|
|
|
# TODO:
|
|
|
|
@ -490,7 +480,7 @@ proc makeBeaconBlockWithRewards*(
|
|
|
|
|
partialBeaconBlock(
|
|
|
|
|
cfg, state.`kind Data`, proposer_index, randao_reveal, eth1_data,
|
|
|
|
|
graffiti, attestations, deposits, validator_changes, sync_aggregate,
|
|
|
|
|
executionPayload))
|
|
|
|
|
executionPayload, consolidations))
|
|
|
|
|
|
|
|
|
|
let res = process_block(
|
|
|
|
|
cfg, state.`kind Data`.data, blck.`kind Data`.asSigVerified(),
|
|
|
|
@ -533,9 +523,8 @@ proc makeBeaconBlockWithRewards*(
|
|
|
|
|
forkyState.data.latest_execution_payload_header.transactions_root =
|
|
|
|
|
transactions_root.get
|
|
|
|
|
|
|
|
|
|
debugComment "makeBeaconBlock doesn't support Electra (i.e. check for missing beaconblock body fields)"
|
|
|
|
|
when executionPayload is electra.ExecutionPayloadForSigning:
|
|
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody
|
|
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/electra/beacon-chain.md#beaconblockbody
|
|
|
|
|
forkyState.data.latest_block_header.body_root = hash_tree_root(
|
|
|
|
|
[hash_tree_root(randao_reveal),
|
|
|
|
|
hash_tree_root(eth1_data),
|
|
|
|
@ -550,7 +539,9 @@ proc makeBeaconBlockWithRewards*(
|
|
|
|
|
hash_tree_root(sync_aggregate),
|
|
|
|
|
execution_payload_root.get,
|
|
|
|
|
hash_tree_root(validator_changes.bls_to_execution_changes),
|
|
|
|
|
hash_tree_root(kzg_commitments.get)
|
|
|
|
|
hash_tree_root(kzg_commitments.get),
|
|
|
|
|
hash_tree_root(List[SignedConsolidation, Limit MAX_CONSOLIDATIONS].init(
|
|
|
|
|
consolidations))
|
|
|
|
|
])
|
|
|
|
|
else:
|
|
|
|
|
raiseAssert "Attempt to use non-Electra payload with post-Deneb state"
|
|
|
|
@ -593,6 +584,7 @@ proc makeBeaconBlock*(
|
|
|
|
|
validator_changes: BeaconBlockValidatorChanges,
|
|
|
|
|
sync_aggregate: SyncAggregate,
|
|
|
|
|
executionPayload: ForkyExecutionPayloadForSigning,
|
|
|
|
|
consolidations: seq[SignedConsolidation],
|
|
|
|
|
rollback: RollbackForkedHashedProc, cache: var StateCache,
|
|
|
|
|
verificationFlags: UpdateFlags,
|
|
|
|
|
transactions_root: Opt[Eth2Digest],
|
|
|
|
@ -603,8 +595,8 @@ proc makeBeaconBlock*(
|
|
|
|
|
? makeBeaconBlockWithRewards(
|
|
|
|
|
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
|
|
|
|
attestations, deposits, validator_changes, sync_aggregate,
|
|
|
|
|
executionPayload, rollback, cache, verificationFlags, transactions_root,
|
|
|
|
|
execution_payload_root, kzg_commitments)
|
|
|
|
|
executionPayload, consolidations, rollback, cache, verificationFlags,
|
|
|
|
|
transactions_root, execution_payload_root, kzg_commitments)
|
|
|
|
|
ok(blockAndRewards.blck)
|
|
|
|
|
|
|
|
|
|
proc makeBeaconBlock*(
|
|
|
|
@ -616,12 +608,13 @@ proc makeBeaconBlock*(
|
|
|
|
|
validator_changes: BeaconBlockValidatorChanges,
|
|
|
|
|
sync_aggregate: SyncAggregate,
|
|
|
|
|
executionPayload: ForkyExecutionPayloadForSigning,
|
|
|
|
|
consolidations: seq[SignedConsolidation],
|
|
|
|
|
rollback: RollbackForkedHashedProc, cache: var StateCache):
|
|
|
|
|
Result[ForkedBeaconBlock, cstring] =
|
|
|
|
|
makeBeaconBlock(
|
|
|
|
|
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
|
|
|
|
attestations, deposits, validator_changes, sync_aggregate,
|
|
|
|
|
executionPayload, rollback, cache,
|
|
|
|
|
executionPayload, consolidations, rollback, cache,
|
|
|
|
|
verificationFlags = {}, transactions_root = Opt.none Eth2Digest,
|
|
|
|
|
execution_payload_root = Opt.none Eth2Digest,
|
|
|
|
|
kzg_commitments = Opt.none KzgCommitments)
|
|
|
|
@ -635,13 +628,14 @@ proc makeBeaconBlock*(
|
|
|
|
|
validator_changes: BeaconBlockValidatorChanges,
|
|
|
|
|
sync_aggregate: SyncAggregate,
|
|
|
|
|
executionPayload: ForkyExecutionPayloadForSigning,
|
|
|
|
|
consolidations: seq[SignedConsolidation],
|
|
|
|
|
rollback: RollbackForkedHashedProc,
|
|
|
|
|
cache: var StateCache, verificationFlags: UpdateFlags):
|
|
|
|
|
Result[ForkedBeaconBlock, cstring] =
|
|
|
|
|
makeBeaconBlock(
|
|
|
|
|
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
|
|
|
|
attestations, deposits, validator_changes, sync_aggregate,
|
|
|
|
|
executionPayload, rollback, cache,
|
|
|
|
|
executionPayload, consolidations, rollback, cache,
|
|
|
|
|
verificationFlags = verificationFlags,
|
|
|
|
|
transactions_root = Opt.none Eth2Digest,
|
|
|
|
|
execution_payload_root = Opt.none Eth2Digest,
|
|
|
|
|