use EF consensus spec v1.5.0-alpha.6 test vectors (#6568)

* use EF consensus spec v1.5.0-alpha.6 test vectors

* LC changes are good as is, no need for the debug comment

* Fix indentation

* Use `execution_requests` for requests root

* fill in spec reference URLs for ExecutionPayload(Header)

* copy `execution_requests` when blidning blocks for Electra and add test

* fix `test_engine_api_conversions`

---------

Co-authored-by: Etan Kissling <etan@nimbus.team>
This commit is contained in:
tersec 2024-09-20 19:32:16 +00:00 committed by GitHub
parent 9df3d075de
commit 193a982d24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 2828 additions and 2698 deletions

View File

@ -2914,6 +2914,7 @@ OK: 24/24 Fail: 0/24 Skip: 0/24
+ [Valid] EF - Electra - Operations - Withdrawal Request - activation_epoch_less_than_shar OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - basic_withdrawal_request OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - basic_withdrawal_request_with_c OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - basic_withdrawal_request_with_f OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - incorrect_source_address OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - incorrect_withdrawal_credential OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - insufficient_effective_balance OK
@ -2926,7 +2927,7 @@ OK: 24/24 Fail: 0/24 Skip: 0/24
+ [Valid] EF - Electra - Operations - Withdrawal Request - partial_withdrawal_on_exit_init OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - pending_withdrawals_consume_all OK
```
OK: 14/14 Fail: 0/14 Skip: 0/14
OK: 15/15 Fail: 0/15 Skip: 0/15
## EF - Electra - Operations - Withdrawals [Preset: mainnet]
```diff
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_a_lot_fully_withdrawable_too_f OK
@ -3063,6 +3064,7 @@ OK: 34/34 Fail: 0/34 Skip: 0/34
+ Testing Eth1Data OK
+ Testing ExecutionPayload OK
+ Testing ExecutionPayloadHeader OK
+ Testing ExecutionRequests OK
+ Testing Fork OK
+ Testing ForkData OK
+ Testing HistoricalBatch OK
@ -3096,7 +3098,7 @@ OK: 34/34 Fail: 0/34 Skip: 0/34
+ Testing Withdrawal OK
+ Testing WithdrawalRequest OK
```
OK: 54/54 Fail: 0/54 Skip: 0/54
OK: 55/55 Fail: 0/55 Skip: 0/55
## EF - Electra - Sanity - Blocks [Preset: mainnet]
```diff
+ [Invalid] EF - Electra - Sanity - Blocks - deposit_transition__invalid_eth1_deposits_overl OK
@ -3761,4 +3763,4 @@ OK: 69/88 Fail: 0/88 Skip: 19/88
OK: 3/3 Fail: 0/3 Skip: 0/3
---TOTAL---
OK: 3035/3055 Fail: 0/3055 Skip: 20/3055
OK: 3037/3057 Fail: 0/3057 Skip: 20/3057

View File

@ -3060,6 +3060,7 @@ OK: 20/20 Fail: 0/20 Skip: 0/20
+ [Valid] EF - Electra - Operations - Withdrawal Request - basic_withdrawal_request OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - basic_withdrawal_request_with_c OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - basic_withdrawal_request_with_f OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - basic_withdrawal_request_with_f OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - incorrect_source_address OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - incorrect_withdrawal_credential OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - insufficient_effective_balance OK
@ -3078,7 +3079,7 @@ OK: 20/20 Fail: 0/20 Skip: 0/20
+ [Valid] EF - Electra - Operations - Withdrawal Request - partial_withdrawal_request_with OK
+ [Valid] EF - Electra - Operations - Withdrawal Request - pending_withdrawals_consume_all OK
```
OK: 24/24 Fail: 0/24 Skip: 0/24
OK: 25/25 Fail: 0/25 Skip: 0/25
## EF - Electra - Operations - Withdrawals [Preset: minimal]
```diff
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_a_lot_fully_withdrawable_too_f OK
@ -3216,6 +3217,7 @@ OK: 34/34 Fail: 0/34 Skip: 0/34
+ Testing Eth1Data OK
+ Testing ExecutionPayload OK
+ Testing ExecutionPayloadHeader OK
+ Testing ExecutionRequests OK
+ Testing Fork OK
+ Testing ForkData OK
+ Testing HistoricalBatch OK
@ -3249,7 +3251,7 @@ OK: 34/34 Fail: 0/34 Skip: 0/34
+ Testing Withdrawal OK
+ Testing WithdrawalRequest OK
```
OK: 54/54 Fail: 0/54 Skip: 0/54
OK: 55/55 Fail: 0/55 Skip: 0/55
## EF - Electra - Sanity - Blocks [Preset: minimal]
```diff
+ [Invalid] EF - Electra - Sanity - Blocks - deposit_transition__invalid_eth1_deposits_overl OK
@ -4098,4 +4100,4 @@ OK: 185/207 Fail: 0/207 Skip: 22/207
OK: 3/3 Fail: 0/3 Skip: 0/3
---TOTAL---
OK: 3341/3364 Fail: 0/3364 Skip: 23/3364
OK: 3343/3366 Fail: 0/3366 Skip: 23/3366

View File

@ -943,7 +943,7 @@ proc sendNewPayload*(
let
startTime = Moment.now()
deadline = sleepAsync(NEWPAYLOAD_TIMEOUT)
payload = blck.body.execution_payload.asEngineExecutionPayload
payload = blck.body.asEngineExecutionPayload
var
responseProcessor = ELConsensusViolationDetector.init()

View File

@ -197,18 +197,7 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV4):
withdrawals: List[capella.Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD].init(
mapIt(rpcExecutionPayload.withdrawals, it.asConsensusWithdrawal)),
blob_gas_used: rpcExecutionPayload.blobGasUsed.uint64,
excess_blob_gas: rpcExecutionPayload.excessBlobGas.uint64,
deposit_requests:
List[electra.DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD].init(
mapIt(rpcExecutionPayload.depositRequests, it.getDepositRequest)),
withdrawal_requests: List[electra.WithdrawalRequest,
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD].init(
mapIt(rpcExecutionPayload.withdrawalRequests,
it.getWithdrawalRequest)),
consolidation_requests: List[electra.ConsolidationRequest,
Limit MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD].init(
mapIt(rpcExecutionPayload.consolidationRequests,
it.getConsolidationRequest)))
excess_blob_gas: rpcExecutionPayload.excessBlobGas.uint64)
func asConsensusType*(payload: engine_api.GetPayloadV4Response):
electra.ExecutionPayloadForSigning =
@ -229,8 +218,10 @@ func asConsensusType*(payload: engine_api.GetPayloadV4Response):
blobs: Blobs.init(
payload.blobsBundle.blobs.mapIt(it.bytes))))
func asEngineExecutionPayload*(executionPayload: bellatrix.ExecutionPayload):
func asEngineExecutionPayload*(blockBody: bellatrix.BeaconBlockBody):
ExecutionPayloadV1 =
template executionPayload(): untyped = blockBody.execution_payload
template getTypedTransaction(tt: bellatrix.Transaction): TypedTransaction =
TypedTransaction(tt.distinctBase)
@ -258,8 +249,10 @@ template toEngineWithdrawal*(w: capella.Withdrawal): WithdrawalV1 =
address: Address(w.address.data),
amount: Quantity(w.amount))
func asEngineExecutionPayload*(executionPayload: capella.ExecutionPayload):
func asEngineExecutionPayload*(blockBody: capella.BeaconBlockBody):
ExecutionPayloadV2 =
template executionPayload(): untyped = blockBody.execution_payload
template getTypedTransaction(tt: bellatrix.Transaction): TypedTransaction =
TypedTransaction(tt.distinctBase)
engine_api.ExecutionPayloadV2(
@ -280,8 +273,10 @@ func asEngineExecutionPayload*(executionPayload: capella.ExecutionPayload):
transactions: mapIt(executionPayload.transactions, it.getTypedTransaction),
withdrawals: mapIt(executionPayload.withdrawals, it.toEngineWithdrawal))
func asEngineExecutionPayload*(executionPayload: deneb.ExecutionPayload):
func asEngineExecutionPayload*(blockBody: deneb.BeaconBlockBody):
ExecutionPayloadV3 =
template executionPayload(): untyped = blockBody.execution_payload
template getTypedTransaction(tt: bellatrix.Transaction): TypedTransaction =
TypedTransaction(tt.distinctBase)
@ -305,8 +300,10 @@ func asEngineExecutionPayload*(executionPayload: deneb.ExecutionPayload):
blobGasUsed: Quantity(executionPayload.blob_gas_used),
excessBlobGas: Quantity(executionPayload.excess_blob_gas))
func asEngineExecutionPayload*(executionPayload: electra.ExecutionPayload):
func asEngineExecutionPayload*(blockBody: electra.BeaconBlockBody):
ExecutionPayloadV4 =
template executionPayload(): untyped = blockBody.execution_payload
template getTypedTransaction(tt: bellatrix.Transaction): TypedTransaction =
TypedTransaction(tt.distinctBase)
@ -352,9 +349,9 @@ func asEngineExecutionPayload*(executionPayload: electra.ExecutionPayload):
withdrawals: mapIt(executionPayload.withdrawals, it.asEngineWithdrawal),
blobGasUsed: Quantity(executionPayload.blob_gas_used),
excessBlobGas: Quantity(executionPayload.excess_blob_gas),
depositRequests: mapIt(
executionPayload.deposit_requests, it.getDepositRequest),
depositRequests:
mapIt(blockBody.execution_requests.deposits, it.getDepositRequest),
withdrawalRequests: mapIt(
executionPayload.withdrawal_requests, it.getWithdrawalRequest),
blockBody.execution_requests.withdrawals, it.getWithdrawalRequest),
consolidationRequests: mapIt(
executionPayload.consolidation_requests, it.getConsolidationRequest))
blockBody.execution_requests.consolidations, it.getConsolidationRequest))

View File

@ -2038,10 +2038,7 @@ func upgrade_to_electra*(
transactions_root: pre.latest_execution_payload_header.transactions_root,
withdrawals_root: pre.latest_execution_payload_header.withdrawals_root,
blob_gas_used: 0,
excess_blob_gas: 0,
deposit_requests_root: ZERO_HASH, # [New in Electra:EIP6110]
withdrawal_requests_root: ZERO_HASH, # [New in Electra:EIP7002],
consolidation_requests_root: ZERO_HASH # [New in Electra:EIP7251]
excess_blob_gas: 0
)
var max_exit_epoch = FAR_FUTURE_EPOCH

View File

@ -74,7 +74,7 @@ export
tables, results, endians2, json_serialization, sszTypes, beacon_time, crypto,
digest, presets
const SPEC_VERSION* = "1.5.0-alpha.5"
const SPEC_VERSION* = "1.5.0-alpha.6"
## Spec version we're aiming to be compatible with, right now
const

View File

@ -58,9 +58,6 @@ const
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/capella/beacon-chain.md#domain-types
DOMAIN_BLS_TO_EXECUTION_CHANGE* = DomainType([byte 0x0a, 0x00, 0x00, 0x00])
# https://github.com/ethereum/consensus-specs/blob/82133085a1295e93394ebdf71df8f2f6e0962588/specs/electra/beacon-chain.md#domains
DOMAIN_CONSOLIDATION* = DomainType([byte 0x0b, 0x00, 0x00, 0x00])
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/fork-choice.md#configuration
PROPOSER_SCORE_BOOST*: uint64 = 40
REORG_HEAD_WEIGHT_THRESHOLD*: uint64 = 20

View File

@ -89,7 +89,7 @@ type
attestation_1*: TrustedIndexedAttestation # Modified in Electra:EIP7549]
attestation_2*: TrustedIndexedAttestation # Modified in Electra:EIP7549]
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#executionpayload
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/deneb/beacon-chain.md#executionpayload
ExecutionPayload* = object
# Execution block header fields
parent_hash*: Eth2Digest
@ -114,21 +114,13 @@ type
withdrawals*: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]
blob_gas_used*: uint64
excess_blob_gas*: uint64
deposit_requests*: List[DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD]
## [New in Electra:EIP6110]
withdrawal_requests*:
List[WithdrawalRequest, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD]
## [New in Electra:EIP7002:EIP7251]
consolidation_requests*:
List[ConsolidationRequest, Limit MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD]
## [New in Electra:EIP7251]
ExecutionPayloadForSigning* = object
executionPayload*: ExecutionPayload
blockValue*: Wei
blobsBundle*: BlobsBundle
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#executionpayloadheader
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/deneb/beacon-chain.md#executionpayloadheader
ExecutionPayloadHeader* = object
# Execution block header fields
parent_hash*: Eth2Digest
@ -151,9 +143,6 @@ type
withdrawals_root*: Eth2Digest
blob_gas_used*: uint64
excess_blob_gas*: uint64
deposit_requests_root*: Eth2Digest # [New in Electra:EIP6110]
withdrawal_requests_root*: Eth2Digest # [New in Electra:EIP7002:EIP7251]
consolidation_requests_root*: Eth2Digest # [New in Electra:EIP7251]
ExecutePayload* = proc(
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].}
@ -304,6 +293,18 @@ type
## (used to compute safety threshold)
current_max_active_participants*: uint64
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#executionrequests
ExecutionRequests* = object
deposits*:
List[DepositRequest,
Limit MAX_DEPOSIT_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP6110]
withdrawals*:
List[WithdrawalRequest,
Limit MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP7002:EIP7251]
consolidations*:
List[ConsolidationRequest,
Limit MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP7251]
# https://github.com/ethereum/consensus-specs/blob/82133085a1295e93394ebdf71df8f2f6e0962588/specs/electra/beacon-chain.md#beaconstate
BeaconState* = object
# Versioning
@ -456,7 +457,7 @@ type
state_root*: Eth2Digest
body*: TrustedBeaconBlockBody
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#beaconblockbody
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#beaconblockbody
BeaconBlockBody* = object
randao_reveal*: ValidatorSig
eth1_data*: Eth1Data
@ -481,6 +482,7 @@ type
execution_payload*: electra.ExecutionPayload # [Modified in Electra:EIP6110:EIP7002]
bls_to_execution_changes*: SignedBLSToExecutionChangeList
blob_kzg_commitments*: KzgCommitments
execution_requests*: ExecutionRequests # [New in Electra]
SigVerifiedBeaconBlockBody* = object
## A BeaconBlock body with signatures verified
@ -520,6 +522,7 @@ type
execution_payload*: ExecutionPayload # [Modified in Electra:EIP6110:EIP7002]
bls_to_execution_changes*: SignedBLSToExecutionChangeList
blob_kzg_commitments*: KzgCommitments
execution_requests*: ExecutionRequests # [New in Electra]
TrustedBeaconBlockBody* = object
## A full verified block
@ -547,6 +550,7 @@ type
execution_payload*: ExecutionPayload # [Modified in Electra:EIP6110:EIP7002]
bls_to_execution_changes*: SignedBLSToExecutionChangeList
blob_kzg_commitments*: KzgCommitments
execution_requests*: ExecutionRequests # [New in Electra]
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#signedbeaconblock
SignedBeaconBlock* = object
@ -731,18 +735,11 @@ func get_lc_execution_root*(
ZERO_HASH
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/light-client/sync-protocol.md#modified-is_valid_light_client_header
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/light-client/sync-protocol.md#modified-is_valid_light_client_header
func is_valid_light_client_header*(
header: LightClientHeader, cfg: RuntimeConfig): bool =
let epoch = header.beacon.slot.epoch
# [New in Electra:EIP6110:EIP7002:EIP7251]
if epoch < cfg.ELECTRA_FORK_EPOCH:
if not header.execution.deposit_requests_root.isZero or
not header.execution.withdrawal_requests_root.isZero or
not header.execution.consolidation_requests_root.isZero:
return false
if epoch < cfg.DENEB_FORK_EPOCH:
if header.execution.blob_gas_used != 0 or
header.execution.excess_blob_gas != 0:
@ -750,7 +747,7 @@ func is_valid_light_client_header*(
if epoch < cfg.CAPELLA_FORK_EPOCH:
return
header.execution == static(default(ExecutionPayloadHeader)) and
header.execution == static(default(electra.ExecutionPayloadHeader)) and
header.execution_branch == static(default(ExecutionBranch))
is_valid_merkle_branch(
@ -776,7 +773,7 @@ func normalize_merkle_branch*[N](
res[0 ..< depth] = branch[num_extra ..< branch.len]
res
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/light-client/fork.md#upgrading-light-client-data
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/light-client/fork.md#upgrading-light-client-data
func upgrade_lc_header_to_electra*(
pre: deneb.LightClientHeader): LightClientHeader =
LightClientHeader(
@ -798,10 +795,7 @@ func upgrade_lc_header_to_electra*(
transactions_root: pre.execution.transactions_root,
withdrawals_root: pre.execution.withdrawals_root,
blob_gas_used: pre.execution.blob_gas_used,
excess_blob_gas: pre.execution.excess_blob_gas,
deposit_requests_root: ZERO_HASH, # [New in Electra:EIP6110]
withdrawal_requests_root: ZERO_HASH, # [New in Electra:EIP7002:EIP7251]
consolidation_requests_root: ZERO_HASH), # [New in Electra:EIP7251]
excess_blob_gas: pre.execution.excess_blob_gas),
execution_branch: pre.execution_branch)
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/light-client/fork.md#upgrading-light-client-data

View File

@ -68,6 +68,7 @@ RestJson.useDefaultSerializationFor(
EmptyBody,
Eth1Data,
EventBeaconBlockObject,
ExecutionRequests,
Fork,
GetBlockAttestationsResponse,
GetBlockHeaderResponse,

View File

@ -1229,11 +1229,7 @@ func toElectraLightClientHeader(
transactions_root: hash_tree_root(payload.transactions),
withdrawals_root: hash_tree_root(payload.withdrawals),
blob_gas_used: payload.blob_gas_used,
excess_blob_gas: payload.excess_blob_gas,
deposit_requests_root: hash_tree_root(payload.deposit_requests),
withdrawal_requests_root: hash_tree_root(payload.withdrawal_requests),
consolidation_requests_root:
hash_tree_root(payload.consolidation_requests)),
excess_blob_gas: payload.excess_blob_gas),
execution_branch: blck.message.body.build_proof(
capella.EXECUTION_PAYLOAD_GINDEX).get)

View File

@ -501,11 +501,11 @@ func toExecutionConsolidationRequest*(
targetPubkey: request.target_pubkey.blob)
# https://eips.ethereum.org/EIPS/eip-7685
proc computeRequestsTrieRoot*(
payload: electra.ExecutionPayload): ExecutionHash256 =
if payload.deposit_requests.len == 0 and
payload.withdrawal_requests.len == 0 and
payload.consolidation_requests.len == 0:
proc computeRequestsTrieRoot(
requests: electra.ExecutionRequests): ExecutionHash256 =
if requests.deposits.len == 0 and
requests.withdrawals.len == 0 and
requests.consolidations.len == 0:
return EMPTY_ROOT_HASH
var
@ -517,7 +517,7 @@ proc computeRequestsTrieRoot*(
doAssert WITHDRAWAL_REQUEST_TYPE < CONSOLIDATION_REQUEST_TYPE
# EIP-6110
for request in payload.deposit_requests:
for request in requests.deposits:
try:
tr.put(rlp.encode(i.uint), rlp.encode(
toExecutionDepositRequest(request)))
@ -526,7 +526,7 @@ proc computeRequestsTrieRoot*(
inc i
# EIP-7002
for request in payload.withdrawal_requests:
for request in requests.withdrawals:
try:
tr.put(rlp.encode(i.uint), rlp.encode(
toExecutionWithdrawalRequest(request)))
@ -535,7 +535,7 @@ proc computeRequestsTrieRoot*(
inc i
# EIP-7251
for request in payload.consolidation_requests:
for request in requests.consolidations:
try:
tr.put(rlp.encode(i.uint), rlp.encode(
toExecutionConsolidationRequest(request)))
@ -576,7 +576,7 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader =
Opt.none(ExecutionHash256)
requestsRoot =
when typeof(payload).kind >= ConsensusFork.Electra:
Opt.some payload.computeRequestsTrieRoot()
Opt.some blck.body.execution_requests.computeRequestsTrieRoot()
else:
Opt.none(ExecutionHash256)

View File

@ -44,6 +44,7 @@ type
List[SignedBLSToExecutionChange,
Limit MAX_BLS_TO_EXECUTION_CHANGES]
blob_kzg_commitments*: KzgCommitments # [New in Deneb]
execution_requests*: ExecutionRequests # [New in Electra]
# https://github.com/ethereum/builder-specs/blob/v0.4.0/specs/bellatrix/builder.md#blindedbeaconblock
BlindedBeaconBlock* = object
@ -142,13 +143,8 @@ func toSignedBlindedBeaconBlock*(blck: electra.SignedBeaconBlock):
withdrawals_root:
hash_tree_root(blck.message.body.execution_payload.withdrawals),
blob_gas_used: blck.message.body.execution_payload.blob_gas_used,
excess_blob_gas: blck.message.body.execution_payload.excess_blob_gas,
deposit_requests_root: hash_tree_root(
blck.message.body.execution_payload.deposit_requests),
withdrawal_requests_root: hash_tree_root(
blck.message.body.execution_payload.withdrawal_requests),
consolidation_requests_root: hash_tree_root(
blck.message.body.execution_payload.consolidation_requests)),
excess_blob_gas: blck.message.body.execution_payload.excess_blob_gas),
bls_to_execution_changes: blck.message.body.bls_to_execution_changes,
blob_kzg_commitments: blck.message.body.blob_kzg_commitments)),
blob_kzg_commitments: blck.message.body.blob_kzg_commitments,
execution_requests: blck.message.body.execution_requests)),
signature: blck.signature)

View File

@ -686,9 +686,9 @@ proc process_operations(
default(ExitQueueInfo) # not used
bsv_use =
when typeof(body).kind >= ConsensusFork.Electra:
body.deposits.len + body.execution_payload.deposit_requests.len +
body.execution_payload.withdrawal_requests.len +
body.execution_payload.consolidation_requests.len > 0
body.deposits.len + body.execution_requests.deposits.len +
body.execution_requests.withdrawals.len +
body.execution_requests.consolidations.len > 0
else:
body.deposits.len > 0
bsv =
@ -720,12 +720,12 @@ proc process_operations(
? process_bls_to_execution_change(cfg, state, op)
when typeof(body).kind >= ConsensusFork.Electra:
for op in body.execution_payload.deposit_requests:
for op in body.execution_requests.deposits:
? process_deposit_request(cfg, state, bsv[], op, {})
for op in body.execution_payload.withdrawal_requests:
for op in body.execution_requests.withdrawals:
# [New in Electra:EIP7002:7251]
process_withdrawal_request(cfg, state, bsv[], op, cache)
for op in body.execution_payload.consolidation_requests:
for op in body.execution_requests.consolidations:
# [New in Electra:EIP7251]
process_consolidation_request(cfg, state, bsv[], op, cache)
@ -1001,13 +1001,7 @@ proc process_execution_payload*(
transactions_root: hash_tree_root(payload.transactions),
withdrawals_root: hash_tree_root(payload.withdrawals),
blob_gas_used: payload.blob_gas_used,
excess_blob_gas: payload.excess_blob_gas,
deposit_requests_root:
hash_tree_root(payload.deposit_requests), # [New in Electra:EIP6110]
withdrawal_requests_root:
hash_tree_root(payload.withdrawal_requests), # [New in Electra:EIP7002:EIP7251]
consolidation_requests_root:
hash_tree_root(payload.consolidation_requests)) # [New in Electra:EIP7251]
excess_blob_gas: payload.excess_blob_gas)
ok()

View File

@ -1019,6 +1019,7 @@ func get_adjusted_total_slashing_balance*(
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#slashings
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/altair/beacon-chain.md#slashings
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/bellatrix/beacon-chain.md#slashings
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#modified-process_slashings
func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
validator.slashed and
epoch + EPOCHS_PER_SLASHINGS_VECTOR div 2 == validator.withdrawable_epoch
@ -1026,18 +1027,32 @@ func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/phase0/beacon-chain.md#slashings
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/altair/beacon-chain.md#slashings
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/bellatrix/beacon-chain.md#slashings
func get_slashing_penalty*(validator: Validator,
adjusted_total_slashing_balance,
total_balance: Gwei): Gwei =
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#modified-process_slashings
func get_slashing_penalty*(
consensusFork: static ConsensusFork, validator: Validator,
adjusted_total_slashing_balance, total_balance: Gwei): Gwei =
# Factored out from penalty numerator to avoid uint64 overflow
const increment = EFFECTIVE_BALANCE_INCREMENT.Gwei
when consensusFork <= ConsensusFork.Deneb:
let penalty_numerator = validator.effective_balance div increment *
adjusted_total_slashing_balance
penalty_numerator div total_balance * increment
elif consensusFork == ConsensusFork.Electra:
let
effective_balance_increments = validator.effective_balance div increment
penalty_per_effective_balance_increment =
adjusted_total_slashing_balance div (total_balance div increment)
# [Modified in Electra:EIP7251]
penalty_per_effective_balance_increment * effective_balance_increments
else:
static: doAssert false
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#slashings
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/altair/beacon-chain.md#slashings
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/bellatrix/beacon-chain.md#slashings
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#modified-process_slashings
func get_slashing(
state: ForkyBeaconState, total_balance: Gwei, vidx: ValidatorIndex): Gwei =
# For efficiency reasons, it doesn't make sense to have process_slashings use
@ -1050,7 +1065,8 @@ func get_slashing(
let validator = unsafeAddr state.validators.item(vidx)
if slashing_penalty_applies(validator[], epoch):
get_slashing_penalty(
validator[], adjusted_total_slashing_balance, total_balance)
typeof(state).kind, validator[], adjusted_total_slashing_balance,
total_balance)
else:
0.Gwei
@ -1064,7 +1080,8 @@ func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) =
let validator = unsafeAddr state.validators.item(vidx)
if slashing_penalty_applies(validator[], epoch):
let penalty = get_slashing_penalty(
validator[], adjusted_total_slashing_balance, total_balance)
typeof(state).kind, validator[], adjusted_total_slashing_balance,
total_balance)
decrease_balance(state, vidx, penalty)
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#eth1-data-votes-updates

View File

@ -201,8 +201,9 @@ func collectSlashings(
let validator = unsafeAddr state.validators[index]
if slashing_penalty_applies(validator[], epoch):
rewardsAndPenalties[index].slashing_outcome +=
validator[].get_slashing_penalty(
adjusted_total_slashing_balance, total_balance).int64
get_slashing_penalty(
typeof(state).kind, validator[], adjusted_total_slashing_balance,
total_balance).int64
proc collectEpochRewardsAndPenalties*(
rewardsAndPenalties: var seq[RewardsAndPenalties],

View File

@ -140,6 +140,7 @@ suite "EF - Electra - SSZ consensus objects " & preset():
checkSSZ(electra.ExecutionPayload, path, hash)
of "ExecutionPayloadHeader":
checkSSZ(electra.ExecutionPayloadHeader, path, hash)
of "ExecutionRequests": checkSSZ(ExecutionRequests, path, hash)
of "Fork": checkSSZ(Fork, path, hash)
of "ForkData": checkSSZ(ForkData, path, hash)
of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash)

File diff suppressed because it is too large Load Diff

View File

@ -119,6 +119,17 @@ template deneb_steps() =
check: b.message.body.blob_kzg_commitments.add(default(KzgCommitment))
do_check
template electra_steps() =
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:
@ -131,5 +142,5 @@ suite "Blinded block conversions":
when consensusFork >= ConsensusFork.Deneb:
deneb_steps
when consensusFork >= ConsensusFork.Electra:
debugComment "add electra_steps"
electra_steps
static: doAssert high(ConsensusFork) == ConsensusFork.Electra

@ -1 +1 @@
Subproject commit 4748d838797fd42bcb57c38f682adcb4522a152a
Subproject commit c55d6e94d7c5eefdf8312504d436b932b233ce1e