Skip to content

Commit dd39631

Browse files
authored
use EF consensus spec v1.6.0-alpha.0 test vectors (#7173)
1 parent 4945c9f commit dd39631

13 files changed

+553
-320
lines changed

AllTests-mainnet.md

Lines changed: 289 additions & 287 deletions
Large diffs are not rendered by default.

ConsensusSpecPreset-mainnet.md

Lines changed: 96 additions & 3 deletions
Large diffs are not rendered by default.

ConsensusSpecPreset-minimal.md

Lines changed: 108 additions & 3 deletions
Large diffs are not rendered by default.

beacon_chain/rpc/rest_config_api.nim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
300300
Base10.toString(VALIDATOR_CUSTODY_REQUIREMENT.uint64),
301301
BALANCE_PER_ADDITIONAL_CUSTODY_GROUP:
302302
Base10.toString(BALANCE_PER_ADDITIONAL_CUSTODY_GROUP),
303-
# MAX_BLOBS_PER_BLOCK_FULU:
304-
# Base10.toString(cfg.MAX_BLOBS_PER_BLOCK_FULU),
305303
# MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS:
306304
# Base10.toString(cfg.MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS),
307305

beacon_chain/spec/datatypes/base.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export
7474
tables, results, endians2, json_serialization, sszTypes, beacon_time, crypto,
7575
digest, presets
7676

77-
const SPEC_VERSION* = "1.5.0-beta.5"
77+
const SPEC_VERSION* = "1.6.0-alpha.0"
7878
## Spec version we're aiming to be compatible with, right now
7979

8080
const

beacon_chain/spec/presets.nim

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const
3838
type
3939
Version* = distinct array[4, byte]
4040
Eth1Address* = web3types.Address
41+
BPOForkInfo* = object
42+
EPOCH*: Epoch
43+
MAX_BLOBS_PER_BLOCK*: uint64
4144

4245
RuntimeConfig* = object
4346
## https://github.com/ethereum/consensus-specs/tree/v1.5.0-beta.2/configs
@@ -134,8 +137,8 @@ type
134137
# TODO CUSTODY_REQUIREMENT*: uint64
135138
# TODO VALIDATOR_CUSTODY_REQUIREMENT*: uint64
136139
# TODO BALANCE_PER_ADDITIONAL_CUSTODY_GROUP*: uint64
137-
# TODO MAX_BLOBS_PER_BLOCK_FULU*: uint64
138140
# TODO MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS*: uint64
141+
BLOB_SCHEDULE*: seq[BPOForkInfo]
139142

140143
PresetFile* = object
141144
values*: Table[string, string]
@@ -315,6 +318,11 @@ when const_preset == "mainnet":
315318
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,
316319

317320
# Fulu
321+
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.0/specs/fulu/das-core.md#get_max_blobs_per_block
322+
# provides sorting rules.
323+
BLOB_SCHEDULE: @[
324+
BPOForkInfo(EPOCH: 364032.Epoch, MAX_BLOBS_PER_BLOCK: 9),
325+
BPOForkInfo(EPOCH: 269568.Epoch, MAX_BLOBS_PER_BLOCK: 6)],
318326
# TODO NUMBER_OF_COLUMNS: 128,
319327
# TODO NUMBER_OF_CUSTODY_GROUPS: 128,
320328
# TODO DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128,
@@ -323,7 +331,6 @@ when const_preset == "mainnet":
323331
# TODO CUSTODY_REQUIREMENT: 4,
324332
# TODO VALIDATOR_CUSTODY_REQUIREMENT: 8,
325333
# TODO BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: 32000000000,
326-
# TODO MAX_BLOBS_PER_BLOCK_FULU: 12,
327334
# TODO MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: 4096
328335
)
329336

@@ -491,7 +498,6 @@ elif const_preset == "gnosis":
491498
# TODO CUSTODY_REQUIREMENT: 4,
492499
# TODO VALIDATOR_CUSTODY_REQUIREMENT: 8,
493500
# TODO BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: 32000000000,
494-
# TODO MAX_BLOBS_PER_BLOCK_FULU: 12,
495501
# TODO MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: 4096
496502
)
497503

@@ -647,9 +653,14 @@ elif const_preset == "minimal":
647653
# `uint64(9)`
648654
MAX_BLOBS_PER_BLOCK_ELECTRA: 9,
649655
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
650-
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152
656+
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,
651657

652658
# Fulu
659+
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.0/specs/fulu/das-core.md#get_max_blobs_per_block
660+
# provides sorting rules.
661+
BLOB_SCHEDULE: @[
662+
BPOForkInfo(EPOCH: FAR_FUTURE_EPOCH, MAX_BLOBS_PER_BLOCK: 6),
663+
BPOForkInfo(EPOCH: FAR_FUTURE_EPOCH, MAX_BLOBS_PER_BLOCK: 9)],
653664
# TODO NUMBER_OF_COLUMNS: 128,
654665
# TODO NUMBER_OF_CUSTODY_GROUPS: 128,
655666
# TODO DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128,
@@ -658,7 +669,6 @@ elif const_preset == "minimal":
658669
# TODO CUSTODY_REQUIREMENT: 4,
659670
# TODO VALIDATOR_CUSTODY_REQUIREMENT: 8,
660671
# TODO BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: 32000000000,
661-
# TODO MAX_BLOBS_PER_BLOCK_FULU: 12,
662672
# TODO MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: 4096
663673
)
664674

@@ -887,11 +897,14 @@ proc readRuntimeConfig*(
887897

888898
for name, field in cfg.fieldPairs():
889899
if name in values:
890-
try:
891-
field = parse(typeof(field), values[name])
892-
values.del name
893-
except ValueError:
894-
raise (ref PresetFileError)(msg: "Unable to parse " & name)
900+
when field is seq[BPOForkInfo]:
901+
discard
902+
else:
903+
try:
904+
field = parse(typeof(field), values[name])
905+
values.del name
906+
except ValueError:
907+
raise (ref PresetFileError)(msg: "Unable to parse " & name)
895908

896909
if cfg.PRESET_BASE != const_preset:
897910
raise (ref PresetIncompatibleError)(

beacon_chain/spec/presets/minimal/electra_preset.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# beacon_chain
2-
# Copyright (c) 2024 Status Research & Development GmbH
2+
# Copyright (c) 2024-2025 Status Research & Development GmbH
33
# Licensed and distributed under either of
44
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
55
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -44,10 +44,10 @@ const
4444

4545
# Execution
4646
# ---------------------------------------------------------------
47-
# [customized]
48-
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD* = 4
49-
# [customized] 2**1 (= 2) withdrawal requests
50-
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD* = 2
47+
# 2**13 (= 8,192) deposit requests
48+
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD* = 8192
49+
# 2**4 (= 16) withdrawal requests
50+
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD* = 16
5151

5252
# Withdrawals processing
5353
# ---------------------------------------------------------------

beacon_chain/spec/state_transition_block.nim

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import
3232
kzg4844/kzg_abi, kzg4844/kzg
3333

3434
from std/algorithm import fill, sorted
35-
from std/sequtils import count, filterIt, mapIt
35+
from std/sequtils import count, foldl, filterIt, mapIt
3636
from ./datatypes/capella import
3737
BeaconState, MAX_WITHDRAWALS_PER_PAYLOAD, SignedBLSToExecutionChange,
3838
Withdrawal
@@ -687,6 +687,24 @@ type
687687
proposer_slashings*: Gwei
688688
attester_slashings*: Gwei
689689

690+
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.0/specs/fulu/das-core.md#get_max_blobs_per_block
691+
func get_max_blobs_per_block(cfg: RuntimeConfig, epoch: Epoch): Opt[uint64] =
692+
## Return the maximum number of blobs that can be included in a block for a
693+
## given epoch.
694+
if not len(cfg.BLOB_SCHEDULE) > 0:
695+
return Opt.none(uint64)
696+
697+
# Spec version of function sorts every time, which should happen only once at
698+
# loading.
699+
for entry in cfg.BLOB_SCHEDULE:
700+
if epoch >= entry.EPOCH:
701+
return Opt.some entry.MAX_BLOBS_PER_BLOCK
702+
703+
# This is effectively a constant per node instance.
704+
Opt.some foldl(
705+
cfg.BLOB_SCHEDULE, min(a, b.MAX_BLOBS_PER_BLOCK),
706+
cfg.BLOB_SCHEDULE[0].MAX_BLOBS_PER_BLOCK)
707+
690708
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/beacon-chain.md#operations
691709
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#modified-process_operations
692710
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/electra/beacon-chain.md#modified-process_operations
@@ -1064,7 +1082,7 @@ type SomeFuluBeaconBlockBody =
10641082
fulu.BeaconBlockBody | fulu.SigVerifiedBeaconBlockBody |
10651083
fulu.TrustedBeaconBlockBody
10661084

1067-
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#modified-process_execution_payload
1085+
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.0/specs/fulu/beacon-chain.md#modified-process_execution_payload
10681086
proc process_execution_payload*(
10691087
cfg: RuntimeConfig, state: var fulu.BeaconState,
10701088
body: SomeFuluBeaconBlockBody,
@@ -1085,8 +1103,11 @@ proc process_execution_payload*(
10851103
if not (payload.timestamp == compute_timestamp_at_slot(state, state.slot)):
10861104
return err("process_execution_payload: invalid timestamp")
10871105

1088-
# [New in Deneb] Verify commitments are under limit
1089-
if not (lenu64(body.blob_kzg_commitments) <= cfg.MAX_BLOBS_PER_BLOCK_ELECTRA):
1106+
# Verify commitments are under limit
1107+
let max_blobs_per_block =
1108+
cfg.get_max_blobs_per_block(get_current_epoch(state)).valueOr:
1109+
return err("process_execution_payload: missing blob schedule")
1110+
if not (lenu64(body.blob_kzg_commitments) <= max_blobs_per_block):
10901111
return err("process_execution_payload: too many KZG commitments")
10911112

10921113
# Verify the execution payload is valid

scripts/mainnet-non-overriden-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,4 @@ SAMPLES_PER_SLOT: 8
173173
CUSTODY_REQUIREMENT: 4
174174
VALIDATOR_CUSTODY_REQUIREMENT: 8
175175
BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: 32000000000
176-
MAX_BLOBS_PER_BLOCK_FULU: 12
177176
MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: 4096

scripts/minimal-non-overriden-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,4 @@ SAMPLES_PER_SLOT: 8
174174
CUSTODY_REQUIREMENT: 4
175175
VALIDATOR_CUSTODY_REQUIREMENT: 8
176176
BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: 32000000000
177-
MAX_BLOBS_PER_BLOCK_FULU: 12
178177
MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: 4096

0 commit comments

Comments
 (0)