Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accomodate blobs in fulu #6809

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions beacon_chain/gossip_processing/gossip_validation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ template checkedReject(

func getMaxBlobsPerBlock(cfg: RuntimeConfig, wallTime: BeaconTime): uint64 =
if min(wallTime, wallTime - MAXIMUM_GOSSIP_CLOCK_DISPARITY).slotOrZero.epoch >=
cfg.FULU_FORK_EPOCH:
cfg.MAX_BLOBS_PER_BLOCK_FULU
elif min(wallTime, wallTime - MAXIMUM_GOSSIP_CLOCK_DISPARITY).slotOrZero.epoch >=
cfg.ELECTRA_FORK_EPOCH:
cfg.MAX_BLOBS_PER_BLOCK_ELECTRA
else:
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/networking/eth2_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ proc getLowSubnets(node: Eth2Node, epoch: Epoch):
else:
default(SyncnetBits),
if epoch >= node.cfg.FULU_FORK_EPOCH:
findLowSubnets(getDataColumnSidecarTopic, uint64, (DATA_COLUMN_SIDECAR_SUBNET_COUNT).int)
findLowSubnets(getDataColumnSidecarTopic, uint64, (fulu.DATA_COLUMN_SIDECAR_SUBNET_COUNT).int)
else:
default(CgcBits)
)
Expand Down
10 changes: 10 additions & 0 deletions beacon_chain/spec/datatypes/constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/p2p-interface.md#configuration
BLOB_SIDECAR_SUBNET_COUNT*: uint64 = 6

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/fulu/p2p-interface.md#configuration
DATA_COLUMN_SIDECAR_SUBNET_COUNT*: uint64 = 128

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#configuration
MAX_REQUEST_BLOCKS* = 1024'u64
RESP_TIMEOUT* = 10'u64
Expand All @@ -90,6 +93,13 @@ const
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/electra/beacon-chain.md#execution-1
MAX_BLOBS_PER_BLOCK_ELECTRA* = 9'u64

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/fulu/beacon-chain.md#execution
MAX_BLOBS_PER_BLOCK_FULU* = 12'u64

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/electra/p2p-interface.md#configuration
MAX_REQUEST_BLOB_SIDECARS_ELECTRA* =
MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/fulu/p2p-interface.md#configuration
MAX_REQUEST_BLOB_SIDECARS_FULU* =
MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_FULU
37 changes: 35 additions & 2 deletions beacon_chain/spec/presets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ type
MAX_BLOBS_PER_BLOCK_ELECTRA*: uint64
MAX_REQUEST_BLOB_SIDECARS_ELECTRA*: uint64

# Fulu
DATA_COLUMN_SIDECAR_SUBNET_COUNT*: uint64
MAX_BLOBS_PER_BLOCK_FULU*: uint64
MAX_REQUEST_BLOB_SIDECARS_FULU*: uint64


PresetFile* = object
values*: Table[string, string]
missingValues*: seq[string]
Expand Down Expand Up @@ -295,7 +301,15 @@ when const_preset == "mainnet":
# `uint64(9)`
MAX_BLOBS_PER_BLOCK_ELECTRA: 9,
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,

# Fulu
# `128`
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128,
# `uint64(12)`
MAX_BLOBS_PER_BLOCK_FULU: 12,
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_FULU
MAX_REQUEST_BLOB_SIDECARS_FULU: 1536
)

elif const_preset == "gnosis":
Expand Down Expand Up @@ -455,7 +469,15 @@ elif const_preset == "gnosis":
# `uint64(9)`
MAX_BLOBS_PER_BLOCK_ELECTRA: 9,
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,

# Fulu
# `128`
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128,
# `uint64(12)`
MAX_BLOBS_PER_BLOCK_FULU: 12,
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_FULU
MAX_REQUEST_BLOB_SIDECARS_FULU: 1536
)

elif const_preset == "minimal":
Expand Down Expand Up @@ -613,6 +635,14 @@ elif const_preset == "minimal":
MAX_BLOBS_PER_BLOCK_ELECTRA: 9,
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,

# Fulu
# `128`
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128,
# `uint64(12)`
MAX_BLOBS_PER_BLOCK_FULU: 12,
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_FULU
MAX_REQUEST_BLOB_SIDECARS_FULU: 1536
)

else:
Expand Down Expand Up @@ -826,6 +856,9 @@ proc readRuntimeConfig*(
checkCompatibility BLOB_SIDECAR_SUBNET_COUNT
checkCompatibility MAX_BLOBS_PER_BLOCK_ELECTRA
checkCompatibility MAX_REQUEST_BLOB_SIDECARS_ELECTRA
checkCompatibility DATA_COLUMN_SIDECAR_SUBNET_COUNT
checkCompatibility MAX_BLOBS_PER_BLOCK_FULU
checkCompatibility MAX_REQUEST_BLOB_SIDECARS_FULU

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/phase0/fork-choice.md#configuration
# Isn't being used as a preset in the usual way: at any time, there's one correct value
Expand Down
8 changes: 4 additions & 4 deletions beacon_chain/spec/state_transition_block.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ proc process_execution_payload*(
if not (payload.timestamp == compute_timestamp_at_slot(state, state.slot)):
return err("process_execution_payload: invalid timestamp")

# [New in Deneb] Verify commitments are under limit
# [New in Electra] Verify commitments are under limit
if not (lenu64(body.blob_kzg_commitments) <= cfg.MAX_BLOBS_PER_BLOCK_ELECTRA):
return err("process_execution_payload: too many KZG commitments")

Expand Down Expand Up @@ -1065,7 +1065,7 @@ type SomeFuluBeaconBlockBody =
fulu.BeaconBlockBody | fulu.SigVerifiedBeaconBlockBody |
fulu.TrustedBeaconBlockBody

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#modified-process_execution_payload
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/fulu/beacon-chain.md#modified-process_execution_payload
proc process_execution_payload*(
cfg: RuntimeConfig, state: var fulu.BeaconState,
body: SomeFuluBeaconBlockBody,
Expand All @@ -1086,8 +1086,8 @@ proc process_execution_payload*(
if not (payload.timestamp == compute_timestamp_at_slot(state, state.slot)):
return err("process_execution_payload: invalid timestamp")

# [New in Deneb] Verify commitments are under limit
if not (lenu64(body.blob_kzg_commitments) <= cfg.MAX_BLOBS_PER_BLOCK_ELECTRA):
# [New in Fulu] Verify commitments are under limit
if not (lenu64(body.blob_kzg_commitments) <= cfg.MAX_BLOBS_PER_BLOCK_FULU):
return err("process_execution_payload: too many KZG commitments")

# Verify the execution payload is valid
Expand Down
Loading