more eip4844 -> deneb changes (#4666)
This commit is contained in:
parent
3c542c3ae0
commit
982d79f9a2
|
@ -23,7 +23,7 @@ import
|
|||
"."/[beacon_chain_db_light_client, filepath]
|
||||
|
||||
from ./spec/datatypes/capella import BeaconState
|
||||
from ./spec/datatypes/eip4844 import TrustedSignedBeaconBlock, BlobsSidecar
|
||||
from ./spec/datatypes/deneb import TrustedSignedBeaconBlock, BlobsSidecar
|
||||
|
||||
export
|
||||
phase0, altair, eth2_ssz_serialization, eth2_merkleization, kvstore,
|
||||
|
@ -786,8 +786,7 @@ proc putBlock*(
|
|||
proc putBlock*(
|
||||
db: BeaconChainDB,
|
||||
value: bellatrix.TrustedSignedBeaconBlock |
|
||||
capella.TrustedSignedBeaconBlock |
|
||||
eip4844.TrustedSignedBeaconBlock) =
|
||||
capella.TrustedSignedBeaconBlock | deneb.TrustedSignedBeaconBlock) =
|
||||
db.withManyWrites:
|
||||
db.blocks[type(value).toFork].putSZSSZ(value.root.data, value)
|
||||
db.putBeaconBlockSummary(value.root, value.message.toBeaconBlockSummary())
|
||||
|
@ -827,7 +826,7 @@ template toBeaconStateNoImmutableValidators(state: capella.BeaconState):
|
|||
CapellaBeaconStateNoImmutableValidators =
|
||||
isomorphicCast[CapellaBeaconStateNoImmutableValidators](state)
|
||||
|
||||
template toBeaconStateNoImmutableValidators(state: eip4844.BeaconState):
|
||||
template toBeaconStateNoImmutableValidators(state: deneb.BeaconState):
|
||||
EIP4844BeaconStateNoImmutableValidators =
|
||||
isomorphicCast[EIP4844BeaconStateNoImmutableValidators](state)
|
||||
|
||||
|
@ -840,7 +839,7 @@ proc putState*(
|
|||
|
||||
proc putState*(
|
||||
db: BeaconChainDB, key: Eth2Digest,
|
||||
value: bellatrix.BeaconState | capella.BeaconState | eip4844.BeaconState) =
|
||||
value: bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState) =
|
||||
db.updateImmutableValidators(value.validators.asSeq())
|
||||
db.statesNoVal[type(value).toFork()].putSZSSZ(
|
||||
key.data, toBeaconStateNoImmutableValidators(value))
|
||||
|
@ -975,7 +974,7 @@ proc getBlock*(
|
|||
|
||||
proc getBlock*[
|
||||
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
||||
eip4844.TrustedSignedBeaconBlock](
|
||||
deneb.TrustedSignedBeaconBlock](
|
||||
db: BeaconChainDB, key: Eth2Digest,
|
||||
T: type X): Opt[T] =
|
||||
# We only store blocks that we trust in the database
|
||||
|
@ -1037,7 +1036,7 @@ proc getBlockSSZ*(
|
|||
|
||||
proc getBlockSSZ*[
|
||||
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
||||
eip4844.TrustedSignedBeaconBlock](
|
||||
deneb.TrustedSignedBeaconBlock](
|
||||
db: BeaconChainDB, key: Eth2Digest, data: var seq[byte], T: type X): bool =
|
||||
let dataPtr = addr data # Short-lived
|
||||
var success = true
|
||||
|
@ -1059,8 +1058,7 @@ proc getBlockSSZ*(
|
|||
of ConsensusFork.Capella:
|
||||
getBlockSSZ(db, key, data, capella.TrustedSignedBeaconBlock)
|
||||
of ConsensusFork.EIP4844:
|
||||
getBlockSSZ(db, key, data, eip4844.TrustedSignedBeaconBlock)
|
||||
|
||||
getBlockSSZ(db, key, data, deneb.TrustedSignedBeaconBlock)
|
||||
|
||||
proc getBlobsSidecarSZ*(db: BeaconChainDB, key: Eth2Digest, data: var seq[byte]):
|
||||
bool =
|
||||
|
@ -1094,7 +1092,7 @@ proc getBlockSZ*(
|
|||
|
||||
proc getBlockSZ*[
|
||||
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
||||
eip4844.TrustedSignedBeaconBlock](
|
||||
deneb.TrustedSignedBeaconBlock](
|
||||
db: BeaconChainDB, key: Eth2Digest, data: var seq[byte], T: type X): bool =
|
||||
let dataPtr = addr data # Short-lived
|
||||
func decode(data: openArray[byte]) =
|
||||
|
@ -1114,7 +1112,7 @@ proc getBlockSZ*(
|
|||
of ConsensusFork.Capella:
|
||||
getBlockSZ(db, key, data, capella.TrustedSignedBeaconBlock)
|
||||
of ConsensusFork.EIP4844:
|
||||
getBlockSZ(db, key, data, eip4844.TrustedSignedBeaconBlock)
|
||||
getBlockSZ(db, key, data, deneb.TrustedSignedBeaconBlock)
|
||||
|
||||
proc getStateOnlyMutableValidators(
|
||||
immutableValidators: openArray[ImmutableValidatorData2],
|
||||
|
@ -1195,7 +1193,7 @@ proc getStateOnlyMutableValidators(
|
|||
proc getStateOnlyMutableValidators(
|
||||
immutableValidators: openArray[ImmutableValidatorData2],
|
||||
store: KvStoreRef, key: openArray[byte],
|
||||
output: var (capella.BeaconState | eip4844.BeaconState),
|
||||
output: var (capella.BeaconState | deneb.BeaconState),
|
||||
rollback: RollbackProc): bool =
|
||||
## Load state into `output` - BeaconState is large so we want to avoid
|
||||
## re-allocating it if possible
|
||||
|
@ -1276,7 +1274,7 @@ proc getState*(
|
|||
proc getState*(
|
||||
db: BeaconChainDB, key: Eth2Digest,
|
||||
output: var (altair.BeaconState | bellatrix.BeaconState |
|
||||
capella.BeaconState | eip4844.BeaconState),
|
||||
capella.BeaconState | deneb.BeaconState),
|
||||
rollback: RollbackProc): bool =
|
||||
## Load state into `output` - BeaconState is large so we want to avoid
|
||||
## re-allocating it if possible
|
||||
|
@ -1355,7 +1353,7 @@ proc containsBlock*(
|
|||
|
||||
proc containsBlock*[
|
||||
X: altair.TrustedSignedBeaconBlock | bellatrix.TrustedSignedBeaconBlock |
|
||||
capella.TrustedSignedBeaconBlock | eip4844.TrustedSignedBeaconBlock](
|
||||
capella.TrustedSignedBeaconBlock | deneb.TrustedSignedBeaconBlock](
|
||||
db: BeaconChainDB, key: Eth2Digest, T: type X): bool =
|
||||
db.blocks[X.toFork].contains(key.data).expectDb()
|
||||
|
||||
|
@ -1509,7 +1507,7 @@ iterator getAncestorSummaries*(db: BeaconChainDB, root: Eth2Digest):
|
|||
res.summary = blck.get().message.toBeaconBlockSummary()
|
||||
elif (let blck = db.getBlock(res.root, capella.TrustedSignedBeaconBlock); blck.isSome()):
|
||||
res.summary = blck.get().message.toBeaconBlockSummary()
|
||||
elif (let blck = db.getBlock(res.root, eip4844.TrustedSignedBeaconBlock); blck.isSome()):
|
||||
elif (let blck = db.getBlock(res.root, deneb.TrustedSignedBeaconBlock); blck.isSome()):
|
||||
res.summary = blck.get().message.toBeaconBlockSummary()
|
||||
else:
|
||||
break
|
||||
|
|
|
@ -13,7 +13,7 @@ import
|
|||
|
||||
from ./spec/datatypes/capella import
|
||||
ExecutionPayloadHeader, HistoricalSummary, Withdrawal
|
||||
from ./spec/datatypes/eip4844 import ExecutionPayloadHeader
|
||||
from ./spec/datatypes/deneb import ExecutionPayloadHeader
|
||||
|
||||
type
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/phase0/beacon-chain.md#beaconstate
|
||||
|
@ -315,7 +315,7 @@ type
|
|||
next_sync_committee*: SyncCommittee
|
||||
|
||||
# Execution
|
||||
latest_execution_payload_header*: eip4844.ExecutionPayloadHeader
|
||||
latest_execution_payload_header*: deneb.ExecutionPayloadHeader
|
||||
|
||||
# Withdrawals
|
||||
next_withdrawal_index*: WithdrawalIndex
|
||||
|
|
|
@ -13,7 +13,7 @@ import
|
|||
../spec/forks
|
||||
|
||||
from ../spec/datatypes/capella import SomeBeaconBlock, TrustedBeaconBlock
|
||||
from ../spec/datatypes/eip4844 import SomeBeaconBlock, TrustedBeaconBlock
|
||||
from ../spec/datatypes/deneb import SomeBeaconBlock, TrustedBeaconBlock
|
||||
|
||||
export chronicles, forks
|
||||
|
||||
|
@ -69,7 +69,7 @@ func init*(
|
|||
T: type BlockRef, root: Eth2Digest,
|
||||
blck: bellatrix.SomeBeaconBlock | bellatrix.TrustedBeaconBlock |
|
||||
capella.SomeBeaconBlock | capella.TrustedBeaconBlock |
|
||||
eip4844.SomeBeaconBlock | eip4844.TrustedBeaconBlock): BlockRef =
|
||||
deneb.SomeBeaconBlock | deneb.TrustedBeaconBlock): BlockRef =
|
||||
BlockRef.init(
|
||||
root, Opt.some Eth2Digest(blck.body.execution_payload.block_hash),
|
||||
blck.slot)
|
||||
|
|
|
@ -20,7 +20,7 @@ import
|
|||
./block_dag, block_pools_types_light_client
|
||||
|
||||
from ../spec/datatypes/capella import TrustedSignedBeaconBlock
|
||||
from ../spec/datatypes/eip4844 import TrustedSignedBeaconBlock
|
||||
from ../spec/datatypes/deneb import TrustedSignedBeaconBlock
|
||||
|
||||
from "."/vanity_logs/vanity_logs import VanityLogs
|
||||
|
||||
|
@ -310,7 +310,7 @@ type
|
|||
|
||||
OnEIP4844BlockAdded* = proc(
|
||||
blckRef: BlockRef,
|
||||
blck: eip4844.TrustedSignedBeaconBlock,
|
||||
blck: deneb.TrustedSignedBeaconBlock,
|
||||
epochRef: EpochRef,
|
||||
unrealized: FinalityCheckpoints) {.gcsafe, raises: [Defect].}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import
|
|||
std/[tables],
|
||||
stew/bitops2,
|
||||
../spec/forks,
|
||||
../spec/datatypes/eip4844
|
||||
../spec/datatypes/deneb
|
||||
|
||||
export tables, forks
|
||||
|
||||
|
@ -40,7 +40,7 @@ type
|
|||
## Trivially invalid blocks may be dropped before reaching this stage.
|
||||
|
||||
orphans*: Table[(Eth2Digest, ValidatorSig),
|
||||
(ForkedSignedBeaconBlock, Opt[eip4844.BlobsSidecar])]
|
||||
(ForkedSignedBeaconBlock, Opt[deneb.BlobsSidecar])]
|
||||
## Blocks that we don't have a parent for - when we resolve the parent, we
|
||||
## can proceed to resolving the block as well - we index this by root and
|
||||
## signature such that a block with invalid signature won't cause a block
|
||||
|
@ -193,7 +193,7 @@ func clearAfterReorg*(quarantine: var Quarantine) =
|
|||
func addOrphan*(
|
||||
quarantine: var Quarantine, finalizedSlot: Slot,
|
||||
signedBlock: ForkedSignedBeaconBlock,
|
||||
blobs: Opt[eip4844.BlobsSidecar]): bool =
|
||||
blobs: Opt[deneb.BlobsSidecar]): bool =
|
||||
## Adds block to quarantine's `orphans` and `missing` lists.
|
||||
if not isViableOrphan(finalizedSlot, signedBlock):
|
||||
quarantine.addUnviable(signedBlock.root)
|
||||
|
@ -221,7 +221,7 @@ func addOrphan*(
|
|||
true
|
||||
|
||||
iterator pop*(quarantine: var Quarantine, root: Eth2Digest):
|
||||
(ForkedSignedBeaconBlock, Opt[eip4844.BlobsSidecar]) =
|
||||
(ForkedSignedBeaconBlock, Opt[deneb.BlobsSidecar]) =
|
||||
# Pop orphans whose parent is the block identified by `root`
|
||||
|
||||
var toRemove: seq[(Eth2Digest, ValidatorSig)]
|
||||
|
|
|
@ -17,7 +17,7 @@ import
|
|||
eth/async_utils, stew/[byteutils, objects, results, shims/hashes],
|
||||
# Local modules:
|
||||
../spec/[deposit_snapshots, eth2_merkleization, forks, helpers],
|
||||
../spec/datatypes/[base, phase0, bellatrix, eip4844],
|
||||
../spec/datatypes/[base, phase0, bellatrix, deneb],
|
||||
../networking/network_metadata,
|
||||
../consensus_object_pools/block_pools_types,
|
||||
".."/[beacon_chain_db, beacon_node_status, beacon_clock],
|
||||
|
@ -301,11 +301,11 @@ func asConsensusExecutionPayload*(rpcExecutionPayload: ExecutionPayloadV2):
|
|||
mapIt(rpcExecutionPayload.withdrawals, it.asConsensusWithdrawal)))
|
||||
|
||||
func asConsensusExecutionPayload*(rpcExecutionPayload: ExecutionPayloadV3):
|
||||
eip4844.ExecutionPayload =
|
||||
deneb.ExecutionPayload =
|
||||
template getTransaction(tt: TypedTransaction): bellatrix.Transaction =
|
||||
bellatrix.Transaction.init(tt.distinctBase)
|
||||
|
||||
eip4844.ExecutionPayload(
|
||||
deneb.ExecutionPayload(
|
||||
parent_hash: rpcExecutionPayload.parentHash.asEth2Digest,
|
||||
feeRecipient:
|
||||
ExecutionAddress(data: rpcExecutionPayload.feeRecipient.distinctBase),
|
||||
|
@ -371,7 +371,7 @@ func asEngineExecutionPayload*(executionPayload: capella.ExecutionPayload):
|
|||
transactions: mapIt(executionPayload.transactions, it.getTypedTransaction),
|
||||
withdrawals: mapIt(executionPayload.withdrawals, it.asEngineWithdrawal))
|
||||
|
||||
func asEngineExecutionPayload*(executionPayload: eip4844.ExecutionPayload):
|
||||
func asEngineExecutionPayload*(executionPayload: deneb.ExecutionPayload):
|
||||
ExecutionPayloadV3 =
|
||||
template getTypedTransaction(tt: bellatrix.Transaction): TypedTransaction =
|
||||
TypedTransaction(tt.distinctBase)
|
||||
|
|
|
@ -19,7 +19,7 @@ import ".."/[eth2_ssz_serialization, forks, keystore],
|
|||
import nimcrypto/utils as ncrutils
|
||||
|
||||
from ".."/datatypes/capella import SignedBeaconBlock
|
||||
from ".."/datatypes/eip4844 import BeaconState
|
||||
from ".."/datatypes/deneb import BeaconState
|
||||
|
||||
export
|
||||
eth2_ssz_serialization, results, peerid, common, serialization, chronicles,
|
||||
|
@ -1768,7 +1768,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
|||
try:
|
||||
tmp[].eip4844Data.data = RestJson.decode(
|
||||
string(data.get()),
|
||||
eip4844.BeaconState,
|
||||
deneb.BeaconState,
|
||||
requireAllFields = true,
|
||||
allowUnknownFields = true)
|
||||
except SerializationError:
|
||||
|
|
|
@ -17,7 +17,7 @@ import
|
|||
std/json,
|
||||
stew/base10, web3/ethtypes,
|
||||
".."/forks,
|
||||
".."/datatypes/[phase0, altair, bellatrix, eip4844],
|
||||
".."/datatypes/[phase0, altair, bellatrix, deneb],
|
||||
".."/mev/[bellatrix_mev, capella_mev]
|
||||
|
||||
from ".."/datatypes/capella import BeaconBlockBody
|
||||
|
@ -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.EIP4844: eip4844Body*: eip4844.BeaconBlockBody
|
||||
of ConsensusFork.EIP4844: eip4844Body*: deneb.BeaconBlockBody
|
||||
|
||||
RestSpec* = object
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/presets/mainnet/phase0.yaml
|
||||
|
|
|
@ -190,7 +190,7 @@ template kind*(
|
|||
|
||||
template LightClientHeader*(kind: static LightClientDataFork): auto =
|
||||
when kind == LightClientDataFork.EIP4844:
|
||||
typedesc[eip4844.LightClientHeader]
|
||||
typedesc[deneb.LightClientHeader]
|
||||
elif kind == LightClientDataFork.Capella:
|
||||
typedesc[capella.LightClientHeader]
|
||||
elif kind == LightClientDataFork.Altair:
|
||||
|
@ -210,7 +210,7 @@ template LightClientBootstrap*(kind: static LightClientDataFork): auto =
|
|||
|
||||
template LightClientUpdate*(kind: static LightClientDataFork): auto =
|
||||
when kind == LightClientDataFork.EIP4844:
|
||||
typedesc[eip4844.LightClientUpdate]
|
||||
typedesc[deneb.LightClientUpdate]
|
||||
elif kind == LightClientDataFork.Capella:
|
||||
typedesc[capella.LightClientUpdate]
|
||||
elif kind == LightClientDataFork.Altair:
|
||||
|
@ -240,7 +240,7 @@ template LightClientOptimisticUpdate*(kind: static LightClientDataFork): auto =
|
|||
|
||||
template LightClientStore*(kind: static LightClientDataFork): auto =
|
||||
when kind == LightClientDataFork.EIP4844:
|
||||
typedesc[eip4844.LightClientStore]
|
||||
typedesc[deneb.LightClientStore]
|
||||
elif kind == LightClientDataFork.Capella:
|
||||
typedesc[capella.LightClientStore]
|
||||
elif kind == LightClientDataFork.Altair:
|
||||
|
|
|
@ -726,7 +726,7 @@ proc registerAttestationInBlock*(
|
|||
update_if_lt(
|
||||
epochSummary.attestation_min_block_inclusion_distance, inclusion_lag)
|
||||
|
||||
from ../spec/datatypes/eip4844 import shortLog
|
||||
from ../spec/datatypes/deneb import shortLog
|
||||
|
||||
proc registerBeaconBlock*(
|
||||
self: var ValidatorMonitor,
|
||||
|
|
|
@ -19,7 +19,7 @@ import
|
|||
chronos/timer, eth/keys, taskpools,
|
||||
../tests/testblockutil,
|
||||
../beacon_chain/spec/[forks, state_transition],
|
||||
../beacon_chain/spec/datatypes/[phase0, altair, bellatrix, eip4844],
|
||||
../beacon_chain/spec/datatypes/[phase0, altair, bellatrix, deneb],
|
||||
../beacon_chain/[beacon_chain_db, beacon_clock],
|
||||
../beacon_chain/eth1/eth1_monitor,
|
||||
../beacon_chain/validators/validator_pool,
|
||||
|
@ -34,8 +34,6 @@ from std/random import Rand, initRand, rand
|
|||
from std/stats import RunningStat
|
||||
from std/strformat import `&`
|
||||
from ../beacon_chain/spec/datatypes/capella import SignedBeaconBlock
|
||||
from ../beacon_chain/spec/datatypes/eip4844 import
|
||||
HashedBeaconState, asSigVerified
|
||||
from ../beacon_chain/spec/beaconstate import
|
||||
get_beacon_committee, get_beacon_proposer_index,
|
||||
get_committee_count_per_slot, get_committee_indices
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import
|
||||
# Beacon chain internals
|
||||
../../beacon_chain/spec/[beaconstate, validator, helpers, state_transition_epoch],
|
||||
../../beacon_chain/spec/datatypes/[altair, eip4844],
|
||||
../../beacon_chain/spec/datatypes/[altair, deneb],
|
||||
# Test utilities
|
||||
../../testutil,
|
||||
../fixtures_utils, ../os_ops
|
||||
|
|
|
@ -12,7 +12,7 @@ import
|
|||
chronicles,
|
||||
# Beacon chain internals
|
||||
../../../beacon_chain/spec/[beaconstate, presets, state_transition_epoch],
|
||||
../../../beacon_chain/spec/datatypes/[altair, eip4844],
|
||||
../../../beacon_chain/spec/datatypes/[altair, deneb],
|
||||
# Test utilities
|
||||
../../testutil,
|
||||
../fixtures_utils, ../os_ops,
|
||||
|
|
Loading…
Reference in New Issue