5 more modules of eip4844.foo to deneb.foo renames (#4698)

This commit is contained in:
tersec 2023-03-06 18:45:52 +00:00 committed by GitHub
parent 8541674498
commit 63b1b0840f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 42 deletions

View File

@ -22,8 +22,7 @@ import
./batch_validation
from ../spec/datatypes/capella import SignedBeaconBlock
from ../spec/datatypes/eip4844 import
SignedBeaconBlock, BLS_MODULUS
from ../spec/datatypes/deneb import SignedBeaconBlock, BLS_MODULUS
from libp2p/protocols/pubsub/pubsub import ValidationResult
@ -182,7 +181,7 @@ template validateBeaconBlockBellatrix(
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/bellatrix/p2p-interface.md#beacon_block
template validateBeaconBlockBellatrix(
signed_beacon_block: bellatrix.SignedBeaconBlock |
capella.SignedBeaconBlock | eip4844.SignedBeaconBlock,
capella.SignedBeaconBlock | deneb.SignedBeaconBlock,
parent: BlockRef): untyped =
# If the execution is enabled for the block -- i.e.
# is_execution_enabled(state, block.body) then validate the following:

View File

@ -464,11 +464,11 @@ template partialBeaconBlock*(
sync_aggregate: SyncAggregate,
execution_payload: deneb.ExecutionPayloadForSigning):
deneb.BeaconBlock =
eip4844.BeaconBlock(
deneb.BeaconBlock(
slot: state.data.slot,
proposer_index: proposer_index.uint64,
parent_root: state.latest_block_root,
body: eip4844.BeaconBlockBody(
body: deneb.BeaconBlockBody(
randao_reveal: randao_reveal,
eth1_data: eth1data,
graffiti: graffiti,

View File

@ -245,7 +245,7 @@ proc makeSimulationBlock(
proc makeSimulationBlock(
cfg: RuntimeConfig,
state: var eip4844.HashedBeaconState,
state: var deneb.HashedBeaconState,
proposer_index: ValidatorIndex,
randao_reveal: ValidatorSig,
eth1_data: Eth1Data,
@ -254,14 +254,14 @@ proc makeSimulationBlock(
deposits: seq[Deposit],
exits: BeaconBlockValidatorChanges,
sync_aggregate: SyncAggregate,
execution_payload: eip4844.ExecutionPayloadForSigning,
execution_payload: deneb.ExecutionPayloadForSigning,
bls_to_execution_changes: SignedBLSToExecutionChangeList,
rollback: RollbackHashedProc[eip4844.HashedBeaconState],
rollback: RollbackHashedProc[deneb.HashedBeaconState],
cache: var StateCache,
# TODO:
# `verificationFlags` is needed only in tests and can be
# removed if we don't use invalid signatures there
verificationFlags: UpdateFlags = {}): Result[eip4844.BeaconBlock, cstring] =
verificationFlags: UpdateFlags = {}): Result[deneb.BeaconBlock, cstring] =
## Create a block for the given state. The latest block applied to it will
## be used for the parent_root value, and the slot will be take from
## state.slot meaning process_slots must be called up to the slot for which
@ -482,7 +482,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
when T is phase0.SignedBeaconBlock:
SyncAggregate.init()
elif T is altair.SignedBeaconBlock or T is bellatrix.SignedBeaconBlock or
T is capella.SignedBeaconBlock or T is eip4844.SignedBeaconBlock:
T is capella.SignedBeaconBlock or T is deneb.SignedBeaconBlock:
syncCommitteePool[].produceSyncAggregate(dag.head.root)
else:
static: doAssert false
@ -495,7 +495,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
addr state.bellatrixData
elif T is capella.SignedBeaconBlock:
addr state.capellaData
elif T is eip4844.SignedBeaconBlock:
elif T is deneb.SignedBeaconBlock:
addr state.denebData
else:
static: doAssert false
@ -513,8 +513,8 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
eth1ProposalData.deposits,
BeaconBlockValidatorChanges(),
sync_aggregate,
when T is eip4844.SignedBeaconBlock:
default(eip4844.ExecutionPayloadForSigning)
when T is deneb.SignedBeaconBlock:
default(deneb.ExecutionPayloadForSigning)
elif T is capella.SignedBeaconBlock:
default(capella.ExecutionPayloadForSigning)
else:
@ -639,9 +639,9 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
dag.withUpdatedState(tmpState[], dag.getBlockIdAtSlot(slot).expect("block")) do:
let
newBlock = getNewBlock[eip4844.SignedBeaconBlock](updatedState, slot, cache)
newBlock = getNewBlock[deneb.SignedBeaconBlock](updatedState, slot, cache)
added = dag.addHeadBlock(verifier, newBlock) do (
blckRef: BlockRef, signedBlock: eip4844.TrustedSignedBeaconBlock,
blckRef: BlockRef, signedBlock: deneb.TrustedSignedBeaconBlock,
epochRef: EpochRef, unrealized: FinalityCheckpoints):
# Callback add to fork choice if valid
attPool.addForkChoice(

View File

@ -55,12 +55,12 @@ proc getCapellaStateRef(db: BeaconChainDB, root: Eth2Digest):
if db.getState(root, res[], noRollback):
return res
from ../beacon_chain/spec/datatypes/eip4844 import TrustedSignedBeaconBlock
from ../beacon_chain/spec/datatypes/deneb import TrustedSignedBeaconBlock
proc getEIP4844StateRef(db: BeaconChainDB, root: Eth2Digest):
eip4844.NilableBeaconStateRef =
deneb.NilableBeaconStateRef =
# load beaconstate the way the block pool does it - into an existing instance
let res = (eip4844.BeaconStateRef)()
let res = (deneb.BeaconStateRef)()
if db.getState(root, res[], noRollback):
return res
@ -92,9 +92,9 @@ func withDigest(blck: capella.TrustedBeaconBlock):
root: hash_tree_root(blck)
)
func withDigest(blck: eip4844.TrustedBeaconBlock):
eip4844.TrustedSignedBeaconBlock =
eip4844.TrustedSignedBeaconBlock(
func withDigest(blck: deneb.TrustedBeaconBlock):
deneb.TrustedSignedBeaconBlock =
deneb.TrustedSignedBeaconBlock(
message: blck,
root: hash_tree_root(blck)
)
@ -149,7 +149,7 @@ suite "Beacon chain DB" & preset():
not db.containsBlock(root, altair.TrustedSignedBeaconBlock)
not db.containsBlock(root, bellatrix.TrustedSignedBeaconBlock)
not db.containsBlock(root, capella.TrustedSignedBeaconBlock)
not db.containsBlock(root, eip4844.TrustedSignedBeaconBlock)
not db.containsBlock(root, deneb.TrustedSignedBeaconBlock)
db.getBlock(root, phase0.TrustedSignedBeaconBlock).get() == signedBlock
db.getBlockSSZ(root, tmp, phase0.TrustedSignedBeaconBlock)
db.getBlockSZ(root, tmp2, phase0.TrustedSignedBeaconBlock)
@ -164,7 +164,7 @@ suite "Beacon chain DB" & preset():
not db.containsBlock(root, altair.TrustedSignedBeaconBlock)
not db.containsBlock(root, bellatrix.TrustedSignedBeaconBlock)
not db.containsBlock(root, capella.TrustedSignedBeaconBlock)
not db.containsBlock(root, eip4844.TrustedSignedBeaconBlock)
not db.containsBlock(root, deneb.TrustedSignedBeaconBlock)
db.getBlock(root, phase0.TrustedSignedBeaconBlock).isErr()
not db.getBlockSSZ(root, tmp, phase0.TrustedSignedBeaconBlock)
not db.getBlockSZ(root, tmp2, phase0.TrustedSignedBeaconBlock)
@ -196,7 +196,7 @@ suite "Beacon chain DB" & preset():
db.containsBlock(root, altair.TrustedSignedBeaconBlock)
not db.containsBlock(root, bellatrix.TrustedSignedBeaconBlock)
not db.containsBlock(root, capella.TrustedSignedBeaconBlock)
not db.containsBlock(root, eip4844.TrustedSignedBeaconBlock)
not db.containsBlock(root, deneb.TrustedSignedBeaconBlock)
db.getBlock(root, altair.TrustedSignedBeaconBlock).get() == signedBlock
db.getBlockSSZ(root, tmp, altair.TrustedSignedBeaconBlock)
db.getBlockSZ(root, tmp2, altair.TrustedSignedBeaconBlock)
@ -211,7 +211,7 @@ suite "Beacon chain DB" & preset():
not db.containsBlock(root, altair.TrustedSignedBeaconBlock)
not db.containsBlock(root, bellatrix.TrustedSignedBeaconBlock)
not db.containsBlock(root, capella.TrustedSignedBeaconBlock)
not db.containsBlock(root, eip4844.TrustedSignedBeaconBlock)
not db.containsBlock(root, deneb.TrustedSignedBeaconBlock)
db.getBlock(root, altair.TrustedSignedBeaconBlock).isErr()
not db.getBlockSSZ(root, tmp, altair.TrustedSignedBeaconBlock)
not db.getBlockSZ(root, tmp2, altair.TrustedSignedBeaconBlock)
@ -243,7 +243,7 @@ suite "Beacon chain DB" & preset():
not db.containsBlock(root, altair.TrustedSignedBeaconBlock)
db.containsBlock(root, bellatrix.TrustedSignedBeaconBlock)
not db.containsBlock(root, capella.TrustedSignedBeaconBlock)
not db.containsBlock(root, eip4844.TrustedSignedBeaconBlock)
not db.containsBlock(root, deneb.TrustedSignedBeaconBlock)
db.getBlock(root, bellatrix.TrustedSignedBeaconBlock).get() == signedBlock
db.getBlockSSZ(root, tmp, bellatrix.TrustedSignedBeaconBlock)
db.getBlockSZ(root, tmp2, bellatrix.TrustedSignedBeaconBlock)
@ -258,7 +258,7 @@ suite "Beacon chain DB" & preset():
not db.containsBlock(root, altair.TrustedSignedBeaconBlock)
not db.containsBlock(root, bellatrix.TrustedSignedBeaconBlock)
not db.containsBlock(root, capella.TrustedSignedBeaconBlock)
not db.containsBlock(root, eip4844.TrustedSignedBeaconBlock)
not db.containsBlock(root, deneb.TrustedSignedBeaconBlock)
db.getBlock(root, bellatrix.TrustedSignedBeaconBlock).isErr()
not db.getBlockSSZ(root, tmp, bellatrix.TrustedSignedBeaconBlock)
not db.getBlockSZ(root, tmp2, bellatrix.TrustedSignedBeaconBlock)
@ -289,7 +289,7 @@ suite "Beacon chain DB" & preset():
not db.containsBlock(root, phase0.TrustedSignedBeaconBlock)
not db.containsBlock(root, altair.TrustedSignedBeaconBlock)
not db.containsBlock(root, bellatrix.TrustedSignedBeaconBlock)
not db.containsBlock(root, eip4844.TrustedSignedBeaconBlock)
not db.containsBlock(root, deneb.TrustedSignedBeaconBlock)
db.containsBlock(root, capella.TrustedSignedBeaconBlock)
db.getBlock(root, capella.TrustedSignedBeaconBlock).get() == signedBlock
db.getBlockSSZ(root, tmp, capella.TrustedSignedBeaconBlock)
@ -305,7 +305,7 @@ suite "Beacon chain DB" & preset():
not db.containsBlock(root, altair.TrustedSignedBeaconBlock)
not db.containsBlock(root, bellatrix.TrustedSignedBeaconBlock)
not db.containsBlock(root, capella.TrustedSignedBeaconBlock)
not db.containsBlock(root, eip4844.TrustedSignedBeaconBlock)
not db.containsBlock(root, deneb.TrustedSignedBeaconBlock)
db.getBlock(root, capella.TrustedSignedBeaconBlock).isErr()
not db.getBlockSSZ(root, tmp, capella.TrustedSignedBeaconBlock)
not db.getBlockSZ(root, tmp2, capella.TrustedSignedBeaconBlock)
@ -325,7 +325,7 @@ suite "Beacon chain DB" & preset():
let db = BeaconChainDB.new("", inMemory = true)
let
signedBlock = withDigest((eip4844.TrustedBeaconBlock)())
signedBlock = withDigest((deneb.TrustedBeaconBlock)())
root = hash_tree_root(signedBlock.message)
db.putBlock(signedBlock)
@ -337,10 +337,10 @@ suite "Beacon chain DB" & preset():
not db.containsBlock(root, altair.TrustedSignedBeaconBlock)
not db.containsBlock(root, bellatrix.TrustedSignedBeaconBlock)
not db.containsBlock(root, capella.TrustedSignedBeaconBlock)
db.containsBlock(root, eip4844.TrustedSignedBeaconBlock)
db.getBlock(root, eip4844.TrustedSignedBeaconBlock).get() == signedBlock
db.getBlockSSZ(root, tmp, eip4844.TrustedSignedBeaconBlock)
db.getBlockSZ(root, tmp2, eip4844.TrustedSignedBeaconBlock)
db.containsBlock(root, deneb.TrustedSignedBeaconBlock)
db.getBlock(root, deneb.TrustedSignedBeaconBlock).get() == signedBlock
db.getBlockSSZ(root, tmp, deneb.TrustedSignedBeaconBlock)
db.getBlockSZ(root, tmp2, deneb.TrustedSignedBeaconBlock)
tmp == SSZ.encode(signedBlock)
tmp2 == encodeFramed(tmp)
uncompressedLenFramed(tmp2).isSome
@ -352,10 +352,10 @@ suite "Beacon chain DB" & preset():
not db.containsBlock(root, altair.TrustedSignedBeaconBlock)
not db.containsBlock(root, bellatrix.TrustedSignedBeaconBlock)
not db.containsBlock(root, capella.TrustedSignedBeaconBlock)
not db.containsBlock(root, eip4844.TrustedSignedBeaconBlock)
db.getBlock(root, eip4844.TrustedSignedBeaconBlock).isErr()
not db.getBlockSSZ(root, tmp, eip4844.TrustedSignedBeaconBlock)
not db.getBlockSZ(root, tmp2, eip4844.TrustedSignedBeaconBlock)
not db.containsBlock(root, deneb.TrustedSignedBeaconBlock)
db.getBlock(root, deneb.TrustedSignedBeaconBlock).isErr()
not db.getBlockSSZ(root, tmp, deneb.TrustedSignedBeaconBlock)
not db.getBlockSZ(root, tmp2, deneb.TrustedSignedBeaconBlock)
db.putStateRoot(root, signedBlock.message.slot, root)
var root2 = root
@ -540,7 +540,7 @@ suite "Beacon chain DB" & preset():
test "sanity check EIP4844 states, reusing buffers" & preset():
let db = makeTestDB(SLOTS_PER_EPOCH)
let stateBuffer = (eip4844.BeaconStateRef)()
let stateBuffer = (deneb.BeaconStateRef)()
for state in testStatesEIP4844:
let root = state[].denebData.root
@ -666,7 +666,7 @@ suite "Beacon chain DB" & preset():
dag = init(ChainDAGRef, defaultRuntimeConfig, db, validatorMonitor, {})
state = (ref ForkedHashedBeaconState)(
kind: ConsensusFork.Deneb,
denebData: eip4844.HashedBeaconState(data: eip4844.BeaconState(
denebData: deneb.HashedBeaconState(data: deneb.BeaconState(
slot: 10.Slot)))
root = Eth2Digest()

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2022 Status Research & Development GmbH
# Copyright (c) 2018-2023 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@ -14,7 +14,7 @@ import
eth/keys, taskpools,
../beacon_chain/[conf, beacon_clock],
../beacon_chain/spec/[beaconstate, forks, helpers, state_transition],
../beacon_chain/spec/datatypes/eip4844,
../beacon_chain/spec/datatypes/deneb,
../beacon_chain/gossip_processing/block_processor,
../beacon_chain/consensus_object_pools/[
attestation_pool, blockchain_dag, block_quarantine, block_clearance,