add consolidations block body packing plumbing and correct electra MEV block body htr override (#6335)
This commit is contained in:
parent
e3d4ad5d39
commit
598485ee1a
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
# Types specific to Deneb (i.e. known to have changed across hard forks) - see
|
# Types specific to Electra (i.e. known to have changed across hard forks) - see
|
||||||
# `base` for types and guidelines common across forks
|
# `base` for types and guidelines common across forks
|
||||||
|
|
||||||
# TODO Careful, not nil analysis is broken / incomplete and the semantics will
|
# TODO Careful, not nil analysis is broken / incomplete and the semantics will
|
||||||
|
|
|
@ -361,7 +361,8 @@ func partialBeaconBlock*(
|
||||||
deposits: seq[Deposit],
|
deposits: seq[Deposit],
|
||||||
validator_changes: BeaconBlockValidatorChanges,
|
validator_changes: BeaconBlockValidatorChanges,
|
||||||
sync_aggregate: SyncAggregate,
|
sync_aggregate: SyncAggregate,
|
||||||
execution_payload: ForkyExecutionPayloadForSigning
|
execution_payload: ForkyExecutionPayloadForSigning,
|
||||||
|
consolidations: openArray[SignedConsolidation]
|
||||||
): auto =
|
): auto =
|
||||||
const consensusFork = typeof(state).kind
|
const consensusFork = typeof(state).kind
|
||||||
|
|
||||||
|
@ -411,12 +412,14 @@ func partialBeaconBlock*(
|
||||||
deposits: seq[Deposit],
|
deposits: seq[Deposit],
|
||||||
validator_changes: BeaconBlockValidatorChanges,
|
validator_changes: BeaconBlockValidatorChanges,
|
||||||
sync_aggregate: SyncAggregate,
|
sync_aggregate: SyncAggregate,
|
||||||
execution_payload: ForkyExecutionPayloadForSigning
|
execution_payload: ForkyExecutionPayloadForSigning,
|
||||||
|
consolidations: seq[SignedConsolidation],
|
||||||
): auto =
|
): auto =
|
||||||
const consensusFork = typeof(state).kind
|
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
|
# 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,
|
slot: state.data.slot,
|
||||||
proposer_index: proposer_index.uint64,
|
proposer_index: proposer_index.uint64,
|
||||||
parent_root: state.latest_block_root,
|
parent_root: state.latest_block_root,
|
||||||
|
@ -429,28 +432,14 @@ func partialBeaconBlock*(
|
||||||
attestations:
|
attestations:
|
||||||
List[electra.Attestation, Limit MAX_ATTESTATIONS_ELECTRA](attestations),
|
List[electra.Attestation, Limit MAX_ATTESTATIONS_ELECTRA](attestations),
|
||||||
deposits: List[Deposit, Limit MAX_DEPOSITS](deposits),
|
deposits: List[Deposit, Limit MAX_DEPOSITS](deposits),
|
||||||
voluntary_exits: validator_changes.voluntary_exits))
|
voluntary_exits: validator_changes.voluntary_exits,
|
||||||
|
sync_aggregate: sync_aggregate,
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/validator.md#preparing-a-beaconblock
|
execution_payload: execution_payload.executionPayload,
|
||||||
when consensusFork >= ConsensusFork.Altair:
|
bls_to_execution_changes: validator_changes.bls_to_execution_changes,
|
||||||
res.body.sync_aggregate = sync_aggregate
|
blob_kzg_commitments: execution_payload.blobsBundle.commitments,
|
||||||
|
consolidations:
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/bellatrix/validator.md#block-proposal
|
List[SignedConsolidation, Limit MAX_CONSOLIDATIONS].init(
|
||||||
when consensusFork >= ConsensusFork.Bellatrix:
|
consolidations)))
|
||||||
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
|
|
||||||
|
|
||||||
proc makeBeaconBlockWithRewards*(
|
proc makeBeaconBlockWithRewards*(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
|
@ -464,6 +453,7 @@ proc makeBeaconBlockWithRewards*(
|
||||||
validator_changes: BeaconBlockValidatorChanges,
|
validator_changes: BeaconBlockValidatorChanges,
|
||||||
sync_aggregate: SyncAggregate,
|
sync_aggregate: SyncAggregate,
|
||||||
executionPayload: ForkyExecutionPayloadForSigning,
|
executionPayload: ForkyExecutionPayloadForSigning,
|
||||||
|
consolidations: seq[SignedConsolidation],
|
||||||
rollback: RollbackForkedHashedProc,
|
rollback: RollbackForkedHashedProc,
|
||||||
cache: var StateCache,
|
cache: var StateCache,
|
||||||
# TODO:
|
# TODO:
|
||||||
|
@ -490,7 +480,7 @@ proc makeBeaconBlockWithRewards*(
|
||||||
partialBeaconBlock(
|
partialBeaconBlock(
|
||||||
cfg, state.`kind Data`, proposer_index, randao_reveal, eth1_data,
|
cfg, state.`kind Data`, proposer_index, randao_reveal, eth1_data,
|
||||||
graffiti, attestations, deposits, validator_changes, sync_aggregate,
|
graffiti, attestations, deposits, validator_changes, sync_aggregate,
|
||||||
executionPayload))
|
executionPayload, consolidations))
|
||||||
|
|
||||||
let res = process_block(
|
let res = process_block(
|
||||||
cfg, state.`kind Data`.data, blck.`kind Data`.asSigVerified(),
|
cfg, state.`kind Data`.data, blck.`kind Data`.asSigVerified(),
|
||||||
|
@ -533,9 +523,8 @@ proc makeBeaconBlockWithRewards*(
|
||||||
forkyState.data.latest_execution_payload_header.transactions_root =
|
forkyState.data.latest_execution_payload_header.transactions_root =
|
||||||
transactions_root.get
|
transactions_root.get
|
||||||
|
|
||||||
debugComment "makeBeaconBlock doesn't support Electra (i.e. check for missing beaconblock body fields)"
|
|
||||||
when executionPayload is electra.ExecutionPayloadForSigning:
|
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(
|
forkyState.data.latest_block_header.body_root = hash_tree_root(
|
||||||
[hash_tree_root(randao_reveal),
|
[hash_tree_root(randao_reveal),
|
||||||
hash_tree_root(eth1_data),
|
hash_tree_root(eth1_data),
|
||||||
|
@ -550,7 +539,9 @@ proc makeBeaconBlockWithRewards*(
|
||||||
hash_tree_root(sync_aggregate),
|
hash_tree_root(sync_aggregate),
|
||||||
execution_payload_root.get,
|
execution_payload_root.get,
|
||||||
hash_tree_root(validator_changes.bls_to_execution_changes),
|
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:
|
else:
|
||||||
raiseAssert "Attempt to use non-Electra payload with post-Deneb state"
|
raiseAssert "Attempt to use non-Electra payload with post-Deneb state"
|
||||||
|
@ -593,6 +584,7 @@ proc makeBeaconBlock*(
|
||||||
validator_changes: BeaconBlockValidatorChanges,
|
validator_changes: BeaconBlockValidatorChanges,
|
||||||
sync_aggregate: SyncAggregate,
|
sync_aggregate: SyncAggregate,
|
||||||
executionPayload: ForkyExecutionPayloadForSigning,
|
executionPayload: ForkyExecutionPayloadForSigning,
|
||||||
|
consolidations: seq[SignedConsolidation],
|
||||||
rollback: RollbackForkedHashedProc, cache: var StateCache,
|
rollback: RollbackForkedHashedProc, cache: var StateCache,
|
||||||
verificationFlags: UpdateFlags,
|
verificationFlags: UpdateFlags,
|
||||||
transactions_root: Opt[Eth2Digest],
|
transactions_root: Opt[Eth2Digest],
|
||||||
|
@ -603,8 +595,8 @@ proc makeBeaconBlock*(
|
||||||
? makeBeaconBlockWithRewards(
|
? makeBeaconBlockWithRewards(
|
||||||
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
||||||
attestations, deposits, validator_changes, sync_aggregate,
|
attestations, deposits, validator_changes, sync_aggregate,
|
||||||
executionPayload, rollback, cache, verificationFlags, transactions_root,
|
executionPayload, consolidations, rollback, cache, verificationFlags,
|
||||||
execution_payload_root, kzg_commitments)
|
transactions_root, execution_payload_root, kzg_commitments)
|
||||||
ok(blockAndRewards.blck)
|
ok(blockAndRewards.blck)
|
||||||
|
|
||||||
proc makeBeaconBlock*(
|
proc makeBeaconBlock*(
|
||||||
|
@ -616,12 +608,13 @@ proc makeBeaconBlock*(
|
||||||
validator_changes: BeaconBlockValidatorChanges,
|
validator_changes: BeaconBlockValidatorChanges,
|
||||||
sync_aggregate: SyncAggregate,
|
sync_aggregate: SyncAggregate,
|
||||||
executionPayload: ForkyExecutionPayloadForSigning,
|
executionPayload: ForkyExecutionPayloadForSigning,
|
||||||
|
consolidations: seq[SignedConsolidation],
|
||||||
rollback: RollbackForkedHashedProc, cache: var StateCache):
|
rollback: RollbackForkedHashedProc, cache: var StateCache):
|
||||||
Result[ForkedBeaconBlock, cstring] =
|
Result[ForkedBeaconBlock, cstring] =
|
||||||
makeBeaconBlock(
|
makeBeaconBlock(
|
||||||
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
||||||
attestations, deposits, validator_changes, sync_aggregate,
|
attestations, deposits, validator_changes, sync_aggregate,
|
||||||
executionPayload, rollback, cache,
|
executionPayload, consolidations, rollback, cache,
|
||||||
verificationFlags = {}, transactions_root = Opt.none Eth2Digest,
|
verificationFlags = {}, transactions_root = Opt.none Eth2Digest,
|
||||||
execution_payload_root = Opt.none Eth2Digest,
|
execution_payload_root = Opt.none Eth2Digest,
|
||||||
kzg_commitments = Opt.none KzgCommitments)
|
kzg_commitments = Opt.none KzgCommitments)
|
||||||
|
@ -635,13 +628,14 @@ proc makeBeaconBlock*(
|
||||||
validator_changes: BeaconBlockValidatorChanges,
|
validator_changes: BeaconBlockValidatorChanges,
|
||||||
sync_aggregate: SyncAggregate,
|
sync_aggregate: SyncAggregate,
|
||||||
executionPayload: ForkyExecutionPayloadForSigning,
|
executionPayload: ForkyExecutionPayloadForSigning,
|
||||||
|
consolidations: seq[SignedConsolidation],
|
||||||
rollback: RollbackForkedHashedProc,
|
rollback: RollbackForkedHashedProc,
|
||||||
cache: var StateCache, verificationFlags: UpdateFlags):
|
cache: var StateCache, verificationFlags: UpdateFlags):
|
||||||
Result[ForkedBeaconBlock, cstring] =
|
Result[ForkedBeaconBlock, cstring] =
|
||||||
makeBeaconBlock(
|
makeBeaconBlock(
|
||||||
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
||||||
attestations, deposits, validator_changes, sync_aggregate,
|
attestations, deposits, validator_changes, sync_aggregate,
|
||||||
executionPayload, rollback, cache,
|
executionPayload, consolidations, rollback, cache,
|
||||||
verificationFlags = verificationFlags,
|
verificationFlags = verificationFlags,
|
||||||
transactions_root = Opt.none Eth2Digest,
|
transactions_root = Opt.none Eth2Digest,
|
||||||
execution_payload_root = Opt.none Eth2Digest,
|
execution_payload_root = Opt.none Eth2Digest,
|
||||||
|
|
|
@ -537,6 +537,7 @@ proc makeBeaconBlockForHeadAndSlot*(
|
||||||
slot, validator_index
|
slot, validator_index
|
||||||
return err("Unable to get execution payload")
|
return err("Unable to get execution payload")
|
||||||
|
|
||||||
|
debugComment "flesh out consolidations"
|
||||||
let res = makeBeaconBlockWithRewards(
|
let res = makeBeaconBlockWithRewards(
|
||||||
node.dag.cfg,
|
node.dag.cfg,
|
||||||
state[],
|
state[],
|
||||||
|
@ -549,6 +550,7 @@ proc makeBeaconBlockForHeadAndSlot*(
|
||||||
exits,
|
exits,
|
||||||
node.syncCommitteeMsgPool[].produceSyncAggregate(head.bid, slot),
|
node.syncCommitteeMsgPool[].produceSyncAggregate(head.bid, slot),
|
||||||
payload,
|
payload,
|
||||||
|
@[], # consolidations
|
||||||
noRollback, # Temporary state - no need for rollback
|
noRollback, # Temporary state - no need for rollback
|
||||||
cache,
|
cache,
|
||||||
verificationFlags = {},
|
verificationFlags = {},
|
||||||
|
|
|
@ -85,7 +85,7 @@ proc makeSimulationBlock(
|
||||||
|
|
||||||
var blck = partialBeaconBlock(
|
var blck = partialBeaconBlock(
|
||||||
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
||||||
attestations, deposits, exits, sync_aggregate, execution_payload)
|
attestations, deposits, exits, sync_aggregate, execution_payload, @[])
|
||||||
|
|
||||||
let res = process_block(
|
let res = process_block(
|
||||||
cfg, state.data, blck.asSigVerified(), verificationFlags, cache)
|
cfg, state.data, blck.asSigVerified(), verificationFlags, cache)
|
||||||
|
@ -128,7 +128,7 @@ proc makeSimulationBlock(
|
||||||
|
|
||||||
var blck = partialBeaconBlock(
|
var blck = partialBeaconBlock(
|
||||||
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
||||||
attestations, deposits, exits, sync_aggregate, execution_payload)
|
attestations, deposits, exits, sync_aggregate, execution_payload, @[])
|
||||||
|
|
||||||
let res = process_block(
|
let res = process_block(
|
||||||
cfg, state.data, blck.asSigVerified(), verificationFlags, cache)
|
cfg, state.data, blck.asSigVerified(), verificationFlags, cache)
|
||||||
|
|
|
@ -295,6 +295,7 @@ cli do(validatorsDir: string, secretsDir: string,
|
||||||
BeaconBlockValidatorChanges(),
|
BeaconBlockValidatorChanges(),
|
||||||
syncAggregate,
|
syncAggregate,
|
||||||
payload,
|
payload,
|
||||||
|
@[], # consolidations
|
||||||
noRollback,
|
noRollback,
|
||||||
cache).get()
|
cache).get()
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,8 @@ proc addTestBlock*(
|
||||||
cfg, state, getStateField(state, slot) + 1, cache, info, flags).expect(
|
cfg, state, getStateField(state, slot) + 1, cache, info, flags).expect(
|
||||||
"can advance 1")
|
"can advance 1")
|
||||||
|
|
||||||
|
debugComment "add consolidations support to addTestBlock"
|
||||||
|
|
||||||
let
|
let
|
||||||
proposer_index = get_beacon_proposer_index(
|
proposer_index = get_beacon_proposer_index(
|
||||||
state, cache, getStateField(state, slot)).expect("valid proposer index")
|
state, cache, getStateField(state, slot)).expect("valid proposer index")
|
||||||
|
@ -227,6 +229,7 @@ proc addTestBlock*(
|
||||||
BeaconBlockValidatorChanges(),
|
BeaconBlockValidatorChanges(),
|
||||||
sync_aggregate,
|
sync_aggregate,
|
||||||
execution_payload,
|
execution_payload,
|
||||||
|
@[],
|
||||||
noRollback,
|
noRollback,
|
||||||
cache,
|
cache,
|
||||||
verificationFlags = {skipBlsValidation})
|
verificationFlags = {skipBlsValidation})
|
||||||
|
|
Loading…
Reference in New Issue