complete switch to beacon_chain/specs/datatypes/bellatrix (#3295)

This commit is contained in:
tersec 2022-01-18 13:36:52 +00:00 committed by GitHub
parent 47f1f7ff1a
commit 9c0c9c98ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 67 additions and 63 deletions

View File

@ -15,7 +15,7 @@ import
../spec/[
eth2_merkleization, forks, helpers, signatures, signatures_batch,
state_transition],
../spec/datatypes/[phase0, altair, merge],
../spec/datatypes/[phase0, altair],
"."/[blockchain_dag]
export results, signatures_batch

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 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).
@ -10,7 +10,7 @@
import
chronicles,
../spec/datatypes/[phase0, altair, merge],
../spec/datatypes/[phase0, altair],
../spec/[helpers]
export chronicles, phase0, altair, merge, helpers

View File

@ -13,7 +13,7 @@ import
metrics, snappy, chronicles,
../spec/[beaconstate, eth2_merkleization, eth2_ssz_serialization, helpers,
state_transition, validator],
../spec/datatypes/[phase0, altair, merge],
../spec/datatypes/[phase0, altair],
".."/beacon_chain_db,
"."/[block_pools_types, block_quarantine]

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2020-2021 Status Research & Development GmbH
# Copyright (c) 2020-2022 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
chronicles,
# Internal
../spec/helpers,
../spec/datatypes/[phase0, altair, merge],
../spec/datatypes/[phase0, altair],
./blockchain_dag
export phase0, altair, merge, deques, sets, blockchain_dag

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 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).
@ -11,7 +11,7 @@ import
std/math,
stew/results,
chronicles, chronos, metrics,
../spec/datatypes/[phase0, altair, merge],
../spec/datatypes/[phase0, altair],
../spec/[forks, signatures_batch],
../consensus_object_pools/[
attestation_pool, block_clearance, blockchain_dag, block_quarantine,

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 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).
@ -12,7 +12,7 @@ import
stew/results, bearssl,
chronicles, chronos, metrics, taskpools,
../spec/[helpers, forks],
../spec/datatypes/[altair, merge, phase0],
../spec/datatypes/[altair, phase0],
../consensus_object_pools/[
block_clearance, block_quarantine, blockchain_dag, exit_pool, attestation_pool,
sync_committee_msg_pool],

View File

@ -35,7 +35,7 @@ import
slashing_protection, keystore_management],
./sync/[sync_protocol],
./rpc/[rest_api, rpc_api, state_ttl_cache],
./spec/datatypes/[altair, merge, phase0],
./spec/datatypes/[altair, bellatrix, phase0],
./spec/eth2_apis/rpc_beacon_client,
./spec/[
beaconstate, forks, helpers, network, weak_subjectivity, signatures,
@ -1085,7 +1085,7 @@ proc installMessageValidators(node: BeaconNode) =
node.network.addValidator(
getBeaconBlocksTopic(node.dag.forkDigests.bellatrix),
proc (signedBlock: merge.SignedBeaconBlock): ValidationResult =
proc (signedBlock: bellatrix.SignedBeaconBlock): ValidationResult =
toValidationResult(node.processor[].blockValidator(
MsgSource.gossip, signedBlock)))

View File

@ -1,5 +1,5 @@
# nimbus_sign_node
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 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).
@ -9,7 +9,7 @@ import serialization, json_serialization,
json_serialization/std/[options, net],
chronos, presto, presto/secureserver, chronicles, confutils,
stew/[base10, results, byteutils, io2]
import "."/spec/datatypes/[base, altair, phase0, merge],
import "."/spec/datatypes/[base, altair, phase0],
"."/spec/[crypto, digest, network, signatures, forks],
"."/spec/eth2_apis/[rest_types, eth2_rest_serialization],
"."/rpc/rest_constants,

View File

@ -1,2 +0,0 @@
import ./bellatrix
export bellatrix

View File

@ -1,4 +1,4 @@
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 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).
@ -9,7 +9,7 @@
import
chronos, presto/client, chronicles,
".."/".."/validators/slashing_protection_common,
".."/datatypes/[phase0, altair, merge],
".."/datatypes/[phase0, altair],
".."/[helpers, forks, keystore, eth2_ssz_serialization],
"."/[rest_types, rest_keymanager_types, eth2_rest_serialization]

View File

@ -1,4 +1,4 @@
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 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).
@ -8,7 +8,7 @@
import
chronos, presto/client,
".."/[helpers, forks], ".."/datatypes/[phase0, altair, merge],
".."/[helpers, forks], ".."/datatypes/[phase0, altair],
"."/[rest_types, eth2_rest_serialization]
export chronos, client, rest_types, eth2_rest_serialization

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 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).
@ -11,7 +11,7 @@ import
std/[os, strformat],
chronicles,
./spec/[beaconstate, eth2_ssz_serialization, eth2_merkleization, forks],
./spec/datatypes/[phase0, altair, merge]
./spec/datatypes/[phase0, altair]
export
beaconstate, eth2_ssz_serialization, eth2_merkleization, forks

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 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).
@ -10,7 +10,7 @@
import std/[options, heapqueue, tables, strutils, sequtils, algorithm]
import stew/results, chronos, chronicles
import
../spec/datatypes/[phase0, altair, merge],
../spec/datatypes/[phase0, altair],
../spec/eth2_apis/rpc_types,
../spec/[helpers, forks],
../networking/[peer_pool, eth2_network],

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 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).
@ -10,7 +10,7 @@
import std/[options, heapqueue, tables, strutils, sequtils, math, algorithm]
import stew/results, chronos, chronicles
import
../spec/datatypes/[base, phase0, altair, merge],
../spec/datatypes/[base, phase0, altair],
../spec/eth2_apis/rpc_types,
../spec/[helpers, forks],
../networking/[peer_pool, eth2_network],

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 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).
@ -21,7 +21,7 @@ import
web3/ethtypes,
# Local modules
../spec/datatypes/[phase0, altair, merge],
../spec/datatypes/[phase0, altair, bellatrix],
../spec/[
eth2_merkleization, forks, helpers, network, signatures, state_transition,
validator],
@ -416,12 +416,12 @@ proc getBlockProposalEth1Data*(node: BeaconNode,
state, finalizedEpochRef.eth1_data,
finalizedEpochRef.eth1_deposit_index)
proc forkchoice_updated(state: merge.BeaconState,
proc forkchoice_updated(state: bellatrix.BeaconState,
head_block_hash: Eth2Digest,
finalized_block_hash: Eth2Digest,
fee_recipient: ethtypes.Address,
execution_engine: Web3DataProviderRef):
Future[Option[merge.PayloadId]] {.async.} =
Future[Option[bellatrix.PayloadId]] {.async.} =
let
timestamp = compute_timestamp_at_slot(state, state.slot)
random = get_randao_mix(state, get_current_epoch(state))
@ -430,9 +430,9 @@ proc forkchoice_updated(state: merge.BeaconState,
head_block_hash, finalized_block_hash, timestamp, random.data,
fee_recipient)).payloadId
return if payloadId.isSome:
some(merge.PayloadId(payloadId.get))
some(bellatrix.PayloadId(payloadId.get))
else:
none(merge.PayloadId)
none(bellatrix.PayloadId)
proc makeBeaconBlockForHeadAndSlot*(node: BeaconNode,
randao_reveal: ValidatorSig,
@ -476,7 +476,7 @@ proc makeBeaconBlockForHeadAndSlot*(node: BeaconNode,
SyncAggregate.init()
else:
node.sync_committee_msg_pool[].produceSyncAggregate(head.root),
default(merge.ExecutionPayload),
default(bellatrix.ExecutionPayload),
noRollback, # Temporary state - no need for rollback
cache)
if res.isErr():
@ -562,8 +562,8 @@ proc proposeBlock(node: BeaconNode,
elif blck is altair.BeaconBlock:
altair.SignedBeaconBlock(
message: blck, signature: signature, root: blockRoot)
elif blck is merge.BeaconBlock:
merge.SignedBeaconBlock(
elif blck is bellatrix.BeaconBlock:
bellatrix.SignedBeaconBlock(
message: blck, signature: signature, root: blockRoot)
else:
static: doAssert "Unkown block type"
@ -1265,7 +1265,7 @@ proc sendBeaconBlock*(node: BeaconNode, forked: ForkedSignedBeaconBlock
# Start with a quick gossip validation check such that broadcasting the
# block doesn't get the node into trouble
let res = withBlck(forked):
when blck isnot merge.SignedBeaconBlock:
when blck isnot bellatrix.SignedBeaconBlock:
validateBeaconBlock(
node.dag, node.quarantine, blck, node.beaconClock.now(),
{})

View File

@ -4,7 +4,7 @@ import
stew/byteutils,
../research/simutils,
../beacon_chain/spec/eth2_apis/eth2_rest_serialization,
../beacon_chain/spec/datatypes/[phase0, altair, merge],
../beacon_chain/spec/datatypes/[phase0, altair, bellatrix],
../beacon_chain/spec/[
eth2_ssz_serialization, forks, helpers, state_transition],
../beacon_chain/networking/network_metadata
@ -176,20 +176,20 @@ proc doSSZ(conf: NcliConf) =
of "attestation": printit(Attestation)
of "phase0_signed_block": printit(phase0.SignedBeaconBlock)
of "altair_signed_block": printit(altair.SignedBeaconBlock)
of "merge_signed_block": printit(merge.SignedBeaconBlock)
of "merge_signed_block": printit(bellatrix.SignedBeaconBlock)
of "phase0_block": printit(phase0.BeaconBlock)
of "altair_block": printit(altair.BeaconBlock)
of "merge_block": printit(merge.BeaconBlock)
of "merge_block": printit(bellatrix.BeaconBlock)
of "phase0_block_body": printit(phase0.BeaconBlockBody)
of "altair_block_body": printit(altair.BeaconBlockBody)
of "merge_block_body": printit(merge.BeaconBlockBody)
of "merge_block_body": printit(bellatrix.BeaconBlockBody)
of "block_header": printit(BeaconBlockHeader)
of "deposit": printit(Deposit)
of "deposit_data": printit(DepositData)
of "eth1_data": printit(Eth1Data)
of "phase0_state": printit(phase0.BeaconState)
of "altiar_state": printit(altair.BeaconState)
of "merge_state": printit(merge.BeaconState)
of "merge_state": printit(bellatrix.BeaconState)
of "proposer_slashing": printit(ProposerSlashing)
of "voluntary_exit": printit(VoluntaryExit)

View File

@ -4,7 +4,7 @@ import
datatypes/base,
datatypes/phase0,
datatypes/altair,
datatypes/merge,
datatypes/bellatrix,
beaconstate,
state_transition_epoch,
state_transition_block,
@ -175,7 +175,7 @@ proc collectEpochRewardsAndPenalties*(
proc collectEpochRewardsAndPenalties*(
rewardsAndPenalties: var seq[RewardsAndPenalties],
state: altair.BeaconState | merge.BeaconState,
state: altair.BeaconState | bellatrix.BeaconState,
cache: var StateCache, cfg: RuntimeConfig) =
if get_current_epoch(state) == GENESIS_EPOCH:
return

View File

@ -4,7 +4,7 @@ import
../beacon_chain/networking/network_metadata,
../beacon_chain/[beacon_chain_db],
../beacon_chain/consensus_object_pools/[blockchain_dag],
../beacon_chain/spec/datatypes/[phase0, altair, merge],
../beacon_chain/spec/datatypes/[phase0, altair, bellatrix],
../beacon_chain/spec/[
beaconstate, helpers, state_transition, state_transition_epoch, validator,
ssz_codec],
@ -209,7 +209,7 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
blocks: (
seq[phase0.TrustedSignedBeaconBlock],
seq[altair.TrustedSignedBeaconBlock],
seq[merge.TrustedSignedBeaconBlock])
seq[bellatrix.TrustedSignedBeaconBlock])
echo &"Loaded {dag.blocks.len} blocks, head slot {dag.head.slot}, selected {blockRefs.len} blocks"
doAssert blockRefs.len() > 0, "Must select at least one block"
@ -233,7 +233,7 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
loadedState = (
(ref phase0.HashedBeaconState)(),
(ref altair.HashedBeaconState)(),
(ref merge.HashedBeaconState)())
(ref bellatrix.HashedBeaconState)())
withTimer(timers[tLoadState]):
doAssert dag.updateStateData(
@ -307,7 +307,7 @@ proc cmdDumpState(conf: DbConf) =
let
phase0State = (ref phase0.HashedBeaconState)()
altairState = (ref altair.HashedBeaconState)()
mergeState = (ref merge.HashedBeaconState)()
mergeState = (ref bellatrix.HashedBeaconState)()
for stateRoot in conf.stateRoot:
if shouldShutDown: quit QuitSuccess

View File

@ -22,7 +22,7 @@ import
../tests/testblockutil,
../beacon_chain/spec/[
beaconstate, forks, helpers, signatures, state_transition],
../beacon_chain/spec/datatypes/[phase0, altair, merge],
../beacon_chain/spec/datatypes/[phase0, altair, bellatrix],
../beacon_chain/[beacon_chain_db, beacon_clock],
../beacon_chain/eth1/eth1_monitor,
../beacon_chain/validators/validator_pool,
@ -250,7 +250,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
sync_aggregate =
when T is phase0.SignedBeaconBlock:
SyncAggregate.init()
elif T is altair.SignedBeaconBlock or T is merge.SignedBeaconBlock:
elif T is altair.SignedBeaconBlock or T is bellatrix.SignedBeaconBlock:
syncCommitteePool[].produceSyncAggregate(dag.head.root)
else:
static: doAssert false
@ -259,7 +259,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
addr stateData.data.phase0Data
elif T is altair.SignedBeaconBlock:
addr stateData.data.altairData
elif T is merge.SignedBeaconBlock:
elif T is bellatrix.SignedBeaconBlock:
addr stateData.data.mergeData
else:
static: doAssert false
@ -349,9 +349,9 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
dag.withUpdatedState(tmpState[], dag.head.atSlot(slot)) do:
let
newBlock = getNewBlock[merge.SignedBeaconBlock](stateData, slot, cache)
newBlock = getNewBlock[bellatrix.SignedBeaconBlock](stateData, slot, cache)
added = dag.addHeadBlock(verifier, newBlock) do (
blckRef: BlockRef, signedBlock: merge.TrustedSignedBeaconBlock,
blckRef: BlockRef, signedBlock: bellatrix.TrustedSignedBeaconBlock,
epochRef: EpochRef):
# Callback add to fork choice if valid
attPool.addForkChoice(

View File

@ -2,7 +2,7 @@ import
unittest2,
stew/byteutils,
../beacon_chain/spec/[forks, helpers],
../beacon_chain/spec/datatypes/[phase0, altair, merge]
../beacon_chain/spec/datatypes/[phase0, altair, bellatrix]
{.used.}
@ -47,7 +47,7 @@ suite "Forked SSZ readers":
expect(SszError):
testHashedBeaconState(altair.BeaconState, 0.Slot)
expect(SszError):
testHashedBeaconState(merge.BeaconState, 0.Slot)
testHashedBeaconState(bellatrix.BeaconState, 0.Slot)
test "load altair state":
testHashedBeaconState(altair.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
@ -55,10 +55,10 @@ suite "Forked SSZ readers":
expect(SszError):
testHashedBeaconState(phase0.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
expect(SszError):
testHashedBeaconState(merge.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
testHashedBeaconState(bellatrix.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
test "load merge state":
testHashedBeaconState(merge.BeaconState, cfg.MERGE_FORK_EPOCH.start_slot)
testHashedBeaconState(bellatrix.BeaconState, cfg.MERGE_FORK_EPOCH.start_slot)
expect(SszError):
testHashedBeaconState(phase0.BeaconState, cfg.MERGE_FORK_EPOCH.start_slot)
@ -76,22 +76,28 @@ suite "Forked SSZ readers":
expect(SszError):
testTrustedSignedBeaconBlock(altair.TrustedSignedBeaconBlock, 0.Slot)
expect(SszError):
testTrustedSignedBeaconBlock(merge.TrustedSignedBeaconBlock, 0.Slot)
testTrustedSignedBeaconBlock(bellatrix.TrustedSignedBeaconBlock, 0.Slot)
test "load altair block":
testTrustedSignedBeaconBlock(altair.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
testTrustedSignedBeaconBlock(
altair.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
expect(SszError):
testTrustedSignedBeaconBlock(phase0.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
testTrustedSignedBeaconBlock(
phase0.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
expect(SszError):
testTrustedSignedBeaconBlock(merge.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
testTrustedSignedBeaconBlock(
bellatrix.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
test "load merge block":
testTrustedSignedBeaconBlock(merge.TrustedSignedBeaconBlock, cfg.MERGE_FORK_EPOCH.start_slot)
testTrustedSignedBeaconBlock(
bellatrix.TrustedSignedBeaconBlock, cfg.MERGE_FORK_EPOCH.start_slot)
expect(SszError):
testTrustedSignedBeaconBlock(phase0.TrustedSignedBeaconBlock, cfg.MERGE_FORK_EPOCH.start_slot)
testTrustedSignedBeaconBlock(
phase0.TrustedSignedBeaconBlock, cfg.MERGE_FORK_EPOCH.start_slot)
expect(SszError):
testTrustedSignedBeaconBlock(altair.TrustedSignedBeaconBlock, cfg.MERGE_FORK_EPOCH.start_slot)
testTrustedSignedBeaconBlock(
altair.TrustedSignedBeaconBlock, cfg.MERGE_FORK_EPOCH.start_slot)
test "should raise on unknown data":
let