misc local `EIP4844` > `Deneb` bumps (#4717)

* misc local `EIP4844` > `Deneb` bumps

* fix
This commit is contained in:
Etan Kissling 2023-03-11 01:28:19 +01:00 committed by GitHub
parent f91fe5646e
commit 969c6f73ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 57 additions and 59 deletions

View File

@ -167,7 +167,7 @@ OK: 10/12 Fail: 0/12 Skip: 2/12
+ Rewrite HTTPS Infura URLs OK
+ Roundtrip engine RPC V1 and bellatrix ExecutionPayload representations OK
+ Roundtrip engine RPC V2 and capella ExecutionPayload representations OK
+ Roundtrip engine RPC V3 and eip4844 ExecutionPayload representations OK
+ Roundtrip engine RPC V3 and deneb ExecutionPayload representations OK
```
OK: 5/5 Fail: 0/5 Skip: 0/5
## Eth2 specific discovery tests

View File

@ -1085,7 +1085,7 @@ proc updateGossipStatus(node: BeaconNode, slot: Slot) {.async.} =
removeAltairMessageHandlers,
removeAltairMessageHandlers, # bellatrix (altair handlers, different forkDigest)
removeCapellaMessageHandlers,
removeCapellaMessageHandlers # eip4844 (capella handlers, different forkDigest)
removeCapellaMessageHandlers # deneb (capella handlers, different forkDigest)
]
for gossipFork in oldGossipForks:
@ -1096,7 +1096,7 @@ proc updateGossipStatus(node: BeaconNode, slot: Slot) {.async.} =
addAltairMessageHandlers,
addAltairMessageHandlers, # bellatrix (altair handlers, different forkDigest)
addCapellaMessageHandlers,
addCapellaMessageHandlers # eip4844 (capella handlers, different forkDigest)
addCapellaMessageHandlers # deneb (capella handlers, different forkDigest)
]
for gossipFork in newGossipForks:

View File

@ -803,7 +803,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
withBlck(forked):
blck.root = hash_tree_root(blck.message)
# TODO: Fetch blobs from EE when blck is eip4844.SignedBeaconBlock
# TODO: Fetch blobs from EE when blck is deneb.SignedBeaconBlock
await node.router.routeSignedBeaconBlock(blck)
if res.isErr():

View File

@ -921,7 +921,7 @@ proc initialize_hashed_beacon_state_from_eth1*(
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/bellatrix/beacon-chain.md#testing
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/capella/beacon-chain.md#testing
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/eip4844/beacon-chain.md#testing
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/beacon-chain.md#testing
proc initialize_beacon_state_from_eth1*(
cfg: RuntimeConfig,
eth1_block_hash: Eth2Digest,

View File

@ -27,16 +27,16 @@ import
export json_serialization, base
const
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/polynomial-commitments.md#constants
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/polynomial-commitments.md#constants
BYTES_PER_FIELD_ELEMENT = 32
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/beacon-chain.md#blob
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/beacon-chain.md#blob
BLOB_TX_TYPE* = 0x05'u8
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/polynomial-commitments.md#constants
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/polynomial-commitments.md#constants
BLS_MODULUS* = "52435875175126190479447740508185965837690552500527637822603658699938581184513".u256
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.0/specs/eip4844/p2p-interface.md#configuration
MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS* = 4096'u64
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/p2p-interface.md#configuration
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS* = 4096'u64
type
# this block belongs elsewhere - will figure out after implementing c-kzg bindings
@ -366,7 +366,7 @@ type
state_root*: Eth2Digest
body*: TrustedBeaconBlockBody
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/beacon-chain.md#beaconblockbody
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/beacon-chain.md#beaconblockbody
BeaconBlockBody* = object
randao_reveal*: ValidatorSig
eth1_data*: Eth1Data
@ -385,9 +385,9 @@ type
sync_aggregate*: SyncAggregate
# Execution
execution_payload*: ExecutionPayload
execution_payload*: ExecutionPayload # [Modified in Deneb]
bls_to_execution_changes*: SignedBLSToExecutionChangeList
blob_kzg_commitments*: KZGCommitments # [New in EIP-4844]
blob_kzg_commitments*: KZGCommitments # [New in Deneb]
SigVerifiedBeaconBlockBody* = object
## A BeaconBlock body with signatures verified
@ -420,9 +420,9 @@ type
sync_aggregate*: TrustedSyncAggregate
# Execution
execution_payload*: ExecutionPayload
execution_payload*: ExecutionPayload # [Modified in Deneb]
bls_to_execution_changes*: SignedBLSToExecutionChangeList
blob_kzg_commitments*: List[KZGCommitment, Limit MAX_BLOBS_PER_BLOCK] # [New in EIP-4844]
blob_kzg_commitments*: List[KZGCommitment, Limit MAX_BLOBS_PER_BLOCK] # [New in Deneb]
TrustedBeaconBlockBody* = object
## A full verified block
@ -443,9 +443,9 @@ type
sync_aggregate*: TrustedSyncAggregate
# Execution
execution_payload*: ExecutionPayload
execution_payload*: ExecutionPayload # [Modified in Deneb]
bls_to_execution_changes*: SignedBLSToExecutionChangeList
blob_kzg_commitments*: List[KZGCommitment, Limit MAX_BLOBS_PER_BLOCK] # [New in EIP-4844]
blob_kzg_commitments*: List[KZGCommitment, Limit MAX_BLOBS_PER_BLOCK] # [New in Deneb]
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/phase0/beacon-chain.md#signedbeaconblock
SignedBeaconBlock* = object

View File

@ -1773,7 +1773,7 @@ proc readValue*(reader: var JsonReader[RestJson],
requireAllFields = true,
allowUnknownFields = true)
except SerializationError:
reader.raiseUnexpectedValue("Incorrect EIP4844 beacon state format")
reader.raiseUnexpectedValue("Incorrect deneb beacon state format")
toValue(denebData)
proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedHashedBeaconState)

View File

@ -311,7 +311,7 @@ type
of ConsensusFork.Altair: altairBody*: altair.BeaconBlockBody
of ConsensusFork.Bellatrix: bellatrixBody*: bellatrix.BeaconBlockBody
of ConsensusFork.Capella: capellaBody*: capella.BeaconBlockBody
of ConsensusFork.Deneb: eip4844Body*: deneb.BeaconBlockBody
of ConsensusFork.Deneb: denebBody*: deneb.BeaconBlockBody
RestSpec* = object
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/presets/mainnet/phase0.yaml

View File

@ -417,7 +417,7 @@ template init*(T: type ForkedMsgTrustedSignedBeaconBlock, blck: bellatrix.MsgTru
template init*(T: type ForkedMsgTrustedSignedBeaconBlock, blck: capella.MsgTrustedSignedBeaconBlock): T =
T(kind: ConsensusFork.Capella, capellaData: blck)
template init*(T: type ForkedMsgTrustedSignedBeaconBlock, blck: deneb.MsgTrustedSignedBeaconBlock): T =
T(kind: ConsensusFork.Deneb, eip4844Data: blck)
T(kind: ConsensusFork.Deneb, denebData: blck)
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: phase0.TrustedSignedBeaconBlock): T =
T(kind: ConsensusFork.Phase0, phase0Data: blck)

View File

@ -1,5 +1,5 @@
# Mainnet preset - EIP-4844
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/presets/mainnet/eip4844.yaml
# Mainnet preset - Deneb
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/presets/mainnet/deneb.yaml
const
# `uint64(4096)`
FIELD_ELEMENTS_PER_BLOB*: uint64 = 4096

View File

@ -1,5 +1,5 @@
# Mainnet preset - EIP-4844
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/presets/mainnet/eip4844.yaml
# Mainnet preset - Deneb
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/presets/mainnet/deneb.yaml
const
# `uint64(4096)`
FIELD_ELEMENTS_PER_BLOB*: uint64 = 4096

View File

@ -1,5 +1,5 @@
# Minimal preset - EIP-4844
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/presets/minimal/eip4844.yaml
# Minimal preset - Deneb
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/presets/minimal/deneb.yaml
const
# [customized]
FIELD_ELEMENTS_PER_BLOB*: uint64 = 4

View File

@ -165,7 +165,7 @@ func noRollback*(state: var capella.HashedBeaconState) =
from ./datatypes/deneb import HashedBeaconState
func noRollback*(state: var deneb.HashedBeaconState) =
trace "Skipping rollback of broken EIP4844 state"
trace "Skipping rollback of broken Deneb state"
func maybeUpgradeStateToAltair(
cfg: RuntimeConfig, state: var ForkedHashedBeaconState) =
@ -598,7 +598,7 @@ proc makeBeaconBlock*(
case state.kind
of ConsensusFork.Phase0, ConsensusFork.Altair,
ConsensusFork.Bellatrix, ConsensusFork.Capella:
raiseAssert "Attempt to use EIP4844 payload with non-EIP4844 state"
raiseAssert "Attempt to use Deneb payload with non-Deneb state"
of ConsensusFork.Deneb: makeBeaconBlock(deneb)
else:
{.error: "You need to add support for the next fork".}

View File

@ -595,7 +595,7 @@ proc process_execution_payload*(
ok()
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/beacon-chain.md#process_execution_payload
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/beacon-chain.md#process_execution_payload
proc process_execution_payload*(
state: var deneb.BeaconState, payload: deneb.ExecutionPayload,
notify_new_payload: deneb.ExecutePayload): Result[void, cstring] =
@ -631,11 +631,11 @@ proc process_execution_payload*(
gas_used: payload.gas_used,
timestamp: payload.timestamp,
base_fee_per_gas: payload.base_fee_per_gas,
excess_data_gas: payload.excess_data_gas, # [New in EIP-4844]
block_hash: payload.block_hash,
extra_data: payload.extra_data,
transactions_root: hash_tree_root(payload.transactions),
withdrawals_root: hash_tree_root(payload.withdrawals))
withdrawals_root: hash_tree_root(payload.withdrawals),
excess_data_gas: payload.excess_data_gas) # [New in Deneb]
ok()
@ -681,11 +681,11 @@ func process_withdrawals*(
ok()
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/beacon-chain.md#tx_peek_blob_versioned_hashes
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/beacon-chain.md#tx_peek_blob_versioned_hashes
func tx_peek_blob_versioned_hashes(opaque_tx: Transaction):
Result[seq[VersionedHash], cstring] =
## This function retrieves the hashes from the `SignedBlobTransaction` as
## defined in EIP-4844, using SSZ offsets. Offsets are little-endian `uint32`
## defined in Deneb, using SSZ offsets. Offsets are little-endian `uint32`
## values, as defined in the SSZ specification. See the full details of
## `blob_versioned_hashes` offset calculation.
if not (opaque_tx[0] == BLOB_TX_TYPE):
@ -710,10 +710,10 @@ func tx_peek_blob_versioned_hashes(opaque_tx: Transaction):
res.add versionedHash
ok res
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/beacon-chain.md#kzg_commitment_to_versioned_hash
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/beacon-chain.md#kzg_commitment_to_versioned_hash
func kzg_commitment_to_versioned_hash(
kzg_commitment: deneb.KZGCommitment): VersionedHash =
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/beacon-chain.md#blob
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/beacon-chain.md#blob
const VERSIONED_HASH_VERSION_KZG = 0x01'u8
var res: VersionedHash
@ -721,7 +721,7 @@ func kzg_commitment_to_versioned_hash(
res[1 .. 31] = eth2digest(kzg_commitment).data.toOpenArray(1, 31)
res
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/beacon-chain.md#verify_kzg_commitments_against_transactions
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/beacon-chain.md#verify_kzg_commitments_against_transactions
func verify_kzg_commitments_against_transactions*(
transactions: seq[Transaction],
kzg_commitments: seq[deneb.KZGCommitment]): bool =
@ -738,7 +738,7 @@ func verify_kzg_commitments_against_transactions*(
all_versioned_hashes == mapIt(kzg_commitments, it.kzg_commitment_to_versioned_hash)
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/beacon-chain.md#blob-kzg-commitments
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/beacon-chain.md#blob-kzg-commitments
func process_blob_kzg_commitments(
state: var deneb.BeaconState,
body: deneb.BeaconBlockBody | deneb.TrustedBeaconBlockBody |
@ -771,7 +771,7 @@ proc validate_blobs_sidecar*(slot: Slot, root: Eth2Digest,
ok()
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/fork-choice.md#is_data_available
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/fork-choice.md#is_data_available
func is_data_available(
slot: Slot, beacon_block_root: Eth2Digest,
blob_kzg_commitments: seq[deneb.KZGCommitment]): bool =
@ -894,11 +894,11 @@ proc process_block*(
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.2/specs/eip4844/beacon-chain.md#block-processing
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095
type SomeEIP4844Block =
type SomeDenebBlock =
deneb.BeaconBlock | deneb.SigVerifiedBeaconBlock | deneb.TrustedBeaconBlock
proc process_block*(
cfg: RuntimeConfig,
state: var deneb.BeaconState, blck: SomeEIP4844Block,
state: var deneb.BeaconState, blck: SomeDenebBlock,
flags: UpdateFlags, cache: var StateCache): Result[void, cstring]=
## When there's a new block, we need to verify that the block is sane and
## update the state accordingly - the state is left in an unknown state when
@ -922,7 +922,7 @@ proc process_block*(
? process_sync_aggregate(
state, blck.body.sync_aggregate, total_active_balance, cache)
? process_blob_kzg_commitments(state, blck.body) # [New in EIP-4844]
? process_blob_kzg_commitments(state, blck.body) # [New in Deneb]
# New in EIP-4844
if not is_data_available(

View File

@ -53,7 +53,7 @@ func shortLog*(x: seq[FetchRecord]): string =
"[" & x.mapIt(shortLog(it.root)).join(", ") & "]"
proc init*(T: type RequestManager, network: Eth2Node,
eip4844Epoch: Epoch,
denebEpoch: Epoch,
getBeaconTime: GetBeaconTimeFn,
blockVerifier: BlockVerifier): RequestManager =
RequestManager(

View File

@ -117,7 +117,7 @@ proc initQueue[A, B](man: SyncManager[A, B]) =
man.ident)
proc newSyncManager*[A, B](pool: PeerPool[A, B],
eip4844Epoch: Epoch,
denebEpoch: Epoch,
direction: SyncQueueKind,
getLocalHeadSlotCb: GetSlotCallback,
getLocalWallSlotCb: GetSlotCallback,
@ -140,7 +140,7 @@ proc newSyncManager*[A, B](pool: PeerPool[A, B],
var res = SyncManager[A, B](
pool: pool,
DENEB_FORK_EPOCH: eip4844Epoch,
DENEB_FORK_EPOCH: denebEpoch,
getLocalHeadSlot: getLocalHeadSlotCb,
getLocalWallSlot: getLocalWallSlotCb,
getSafeSlot: getSafeSlot,
@ -191,8 +191,8 @@ proc getBlocks*[A, B](man: SyncManager[A, B], peer: A,
proc shouldGetBlobs[A, B](man: SyncManager[A, B], e: Epoch): bool =
let wallEpoch = man.getLocalWallSlot().epoch
e >= man.DENEB_FORK_EPOCH and
(wallEpoch < MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS or
e >= wallEpoch - MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS)
(wallEpoch < MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS or
e >= wallEpoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS)
proc getBlobSidecars*[A, B](man: SyncManager[A, B], peer: A,
req: SyncRequest): Future[BlobSidecarsRes] {.async.} =

View File

@ -504,10 +504,10 @@ p2pProtocol BeaconSync(version = 1,
let
dag = peer.networkState.dag
epochBoundary =
if MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS >= dag.head.slot.epoch:
if MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS >= dag.head.slot.epoch:
GENESIS_EPOCH
else:
dag.head.slot.epoch - MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS
dag.head.slot.epoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS
if startSlot.epoch < epochBoundary:
raise newException(ResourceUnavailableError, BlobsOutOfRange)

View File

@ -633,7 +633,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
do:
raiseAssert "withUpdatedState failed"
proc proposeEIP4844Block(slot: Slot) =
proc proposeDenebBlock(slot: Slot) =
if rand(r, 1.0) > blockRatio:
return
@ -695,7 +695,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
if blockRatio > 0.0:
withTimer(timers[t]):
case dag.cfg.consensusForkAtEpoch(slot.epoch)
of ConsensusFork.Deneb: proposeEIP4844Block(slot)
of ConsensusFork.Deneb: proposeDenebBlock(slot)
of ConsensusFork.Capella: proposeCapellaBlock(slot)
of ConsensusFork.Bellatrix: proposeBellatrixBlock(slot)
of ConsensusFork.Altair: proposeAltairBlock(slot)

View File

@ -54,9 +54,9 @@ BELLATRIX_FORK_VERSION: 0x02000000
# Capella
CAPELLA_FORK_VERSION: 0x03000000
# (overriden in launch_local_testnet.sh) CAPELLA_FORK_EPOCH: 18446744073709551615
# EIP4844
EIP4844_FORK_VERSION: 0x04000000
# (overriden in launch_local_testnet.sh) EIP4844_FORK_EPOCH: 18446744073709551615
# Deneb
DENEB_FORK_VERSION: 0x04000000
# (overriden in launch_local_testnet.sh) DENEB_FORK_EPOCH: 18446744073709551615
@ -100,4 +100,3 @@ PROPOSER_SCORE_BOOST: 40
DEPOSIT_CHAIN_ID: 1
DEPOSIT_NETWORK_ID: 1
# (overriden in launch_local_testnet.sh) DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa

View File

@ -53,9 +53,9 @@ BELLATRIX_FORK_VERSION: 0x02000001
# Capella
CAPELLA_FORK_VERSION: 0x03000001
# (overriden in launch_local_testnet.sh) CAPELLA_FORK_EPOCH: 18446744073709551615
# EIP4844
EIP4844_FORK_VERSION: 0x04000001
# (overriden in launch_local_testnet.sh) EIP4844_FORK_EPOCH: 18446744073709551615
# Deneb
DENEB_FORK_VERSION: 0x04000001
# (overriden in launch_local_testnet.sh) DENEB_FORK_EPOCH: 18446744073709551615
# Time parameters
@ -99,4 +99,3 @@ DEPOSIT_CHAIN_ID: 5
DEPOSIT_NETWORK_ID: 5
# Configured on a per testnet basis
# (overriden in launch_local_testnet.sh) DEPOSIT_CONTRACT_ADDRESS: 0x1234567890123456789012345678901234567890

View File

@ -1023,7 +1023,7 @@ suite "Eth1 monitor":
executionPayload == asConsensusType(
asEngineExecutionPayload(executionPayload))
test "Roundtrip engine RPC V3 and eip4844 ExecutionPayload representations":
test "Roundtrip engine RPC V3 and deneb ExecutionPayload representations":
# Each Eth2Digest field is chosen randomly. Each uint64 field is random,
# with boosted probabilities for 0, 1, and high(uint64). There can be 0,
# 1, 2, or 3 transactions uniformly. Each transaction is 0, 8, 13, or 16