From 5878d3411737ef2f8ad7c6a5b35950bb170663c6 Mon Sep 17 00:00:00 2001 From: tersec Date: Wed, 5 Jan 2022 14:24:15 +0000 Subject: [PATCH] rename forkDigests.merge to forkDigests.bellatrix (#3245) --- .../consensus_object_pools/blockchain_dag.nim | 2 +- beacon_chain/networking/eth2_network.nim | 4 ++-- beacon_chain/nimbus_beacon_node.nim | 12 ++++++------ beacon_chain/spec/forks.nim | 19 +++++++++++-------- beacon_chain/sync/sync_protocol.nim | 4 ++-- 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/beacon_chain/consensus_object_pools/blockchain_dag.nim b/beacon_chain/consensus_object_pools/blockchain_dag.nim index 7a0656760..fd91d141e 100644 --- a/beacon_chain/consensus_object_pools/blockchain_dag.nim +++ b/beacon_chain/consensus_object_pools/blockchain_dag.nim @@ -628,7 +628,7 @@ template forkAtEpoch*(dag: ChainDAGRef, epoch: Epoch): Fork = proc forkDigestAtEpoch*(dag: ChainDAGRef, epoch: Epoch): ForkDigest = case dag.cfg.stateForkAtEpoch(epoch) - of BeaconStateFork.Bellatrix: dag.forkDigests.merge + of BeaconStateFork.Bellatrix: dag.forkDigests.bellatrix of BeaconStateFork.Altair: dag.forkDigests.altair of BeaconStateFork.Phase0: dag.forkDigests.phase0 diff --git a/beacon_chain/networking/eth2_network.nim b/beacon_chain/networking/eth2_network.nim index 1f4c406b9..f1681b095 100644 --- a/beacon_chain/networking/eth2_network.nim +++ b/beacon_chain/networking/eth2_network.nim @@ -2164,7 +2164,7 @@ proc updateForkId*(node: Eth2Node, epoch: Epoch, genesisValidatorsRoot: Eth2Dige func forkDigestAtEpoch(node: Eth2Node, epoch: Epoch): ForkDigest = case node.cfg.stateForkAtEpoch(epoch) - of BeaconStateFork.Bellatrix: node.forkDigests.merge + of BeaconStateFork.Bellatrix: node.forkDigests.bellatrix of BeaconStateFork.Altair: node.forkDigests.altair of BeaconStateFork.Phase0: node.forkDigests.phase0 @@ -2213,7 +2213,7 @@ proc broadcastBeaconBlock*(node: Eth2Node, blck: altair.SignedBeaconBlock) = node.broadcast(topic, blck) proc broadcastBeaconBlock*(node: Eth2Node, blck: merge.SignedBeaconBlock) = - let topic = getBeaconBlocksTopic(node.forkDigests.merge) + let topic = getBeaconBlocksTopic(node.forkDigests.bellatrix) node.broadcast(topic, blck) proc broadcastBeaconBlock*(node: Eth2Node, forked: ForkedSignedBeaconBlock) = diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 4c9ee4ac6..e194df210 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -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). @@ -575,7 +575,7 @@ proc updateAttestationSubnetHandlers(node: BeaconNode, slot: Slot) = let forkDigests: array[BeaconStateFork, auto] = [ node.dag.forkDigests.phase0, node.dag.forkDigests.altair, - node.dag.forkDigests.merge + node.dag.forkDigests.bellatrix ] for gossipFork in node.gossipState: @@ -780,7 +780,7 @@ proc updateGossipStatus(node: BeaconNode, slot: Slot) {.async.} = let forkDigests: array[BeaconStateFork, auto] = [ node.dag.forkDigests.phase0, node.dag.forkDigests.altair, - node.dag.forkDigests.merge + node.dag.forkDigests.bellatrix ] const removeMessageHandlers: array[BeaconStateFork, auto] = [ @@ -1064,7 +1064,7 @@ proc installMessageValidators(node: BeaconNode) = # Validators introduced in phase0 are also used in altair and merge, but with # different fork digest installPhase0Validators(node.dag.forkDigests.altair) - installPhase0Validators(node.dag.forkDigests.merge) + installPhase0Validators(node.dag.forkDigests.bellatrix) node.network.addValidator( getBeaconBlocksTopic(node.dag.forkDigests.altair), @@ -1073,7 +1073,7 @@ proc installMessageValidators(node: BeaconNode) = MsgSource.gossip, signedBlock))) node.network.addValidator( - getBeaconBlocksTopic(node.dag.forkDigests.merge), + getBeaconBlocksTopic(node.dag.forkDigests.bellatrix), proc (signedBlock: merge.SignedBeaconBlock): ValidationResult = toValidationResult(node.processor[].blockValidator( MsgSource.gossip, signedBlock))) @@ -1097,7 +1097,7 @@ proc installMessageValidators(node: BeaconNode) = await node.processor.contributionValidator(MsgSource.gossip, msg))) installSyncCommitteeeValidators(node.dag.forkDigests.altair) - installSyncCommitteeeValidators(node.dag.forkDigests.merge) + installSyncCommitteeeValidators(node.dag.forkDigests.bellatrix) proc stop(node: BeaconNode) = bnStatus = BeaconNodeStatus.Stopping diff --git a/beacon_chain/spec/forks.nim b/beacon_chain/spec/forks.nim index 35e22b773..a06efc494 100644 --- a/beacon_chain/spec/forks.nim +++ b/beacon_chain/spec/forks.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2021 Status Research & Development GmbH +# Copyright (c) 2021-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 @@ {.push raises: [Defect].} import - stew/[assign2], + stew/assign2, chronicles, ../extras, "."/[eth2_merkleization, eth2_ssz_serialization, presets], @@ -73,8 +73,8 @@ type ForkedBeaconBlock* = object case kind*: BeaconBlockFork - of BeaconBlockFork.Phase0: phase0Data*: phase0.BeaconBlock - of BeaconBlockFork.Altair: altairData*: altair.BeaconBlock + of BeaconBlockFork.Phase0: phase0Data*: phase0.BeaconBlock + of BeaconBlockFork.Altair: altairData*: altair.BeaconBlock of BeaconBlockFork.Bellatrix: mergeData*: merge.BeaconBlock ForkedTrustedBeaconBlock* = object @@ -117,9 +117,10 @@ type ForkyEpochInfo* = phase0.EpochInfo | altair.EpochInfo ForkDigests* = object - phase0*: ForkDigest - altair*: ForkDigest - merge*: ForkDigest + phase0*: ForkDigest + altair*: ForkDigest + bellatrix*: ForkDigest + sharding*: ForkDigest template toFork*[T: phase0.BeaconState | phase0.HashedBeaconState]( t: type T): BeaconStateFork = @@ -501,6 +502,8 @@ func init*(T: type ForkDigests, compute_fork_digest(cfg.GENESIS_FORK_VERSION, genesisValidatorsRoot), altair: compute_fork_digest(cfg.ALTAIR_FORK_VERSION, genesisValidatorsRoot), - merge: + bellatrix: compute_fork_digest(cfg.MERGE_FORK_VERSION, genesisValidatorsRoot), + sharding: + compute_fork_digest(cfg.SHARDING_FORK_VERSION, genesisValidatorsRoot), ) diff --git a/beacon_chain/sync/sync_protocol.nim b/beacon_chain/sync/sync_protocol.nim index 73a165436..73ce39299 100644 --- a/beacon_chain/sync/sync_protocol.nim +++ b/beacon_chain/sync/sync_protocol.nim @@ -79,7 +79,7 @@ proc readChunkPayload*(conn: Connection, peer: Peer, return ok ForkedSignedBeaconBlock.init(res.get) else: return err(res.error) - elif contextBytes == peer.network.forkDigests.merge: + elif contextBytes == peer.network.forkDigests.bellatrix: let res = await readChunkPayload(conn, peer, merge.SignedBeaconBlock) if res.isOk: return ok ForkedSignedBeaconBlock.init(res.get) @@ -104,7 +104,7 @@ proc sendResponseChunk*(response: UntypedResponse, of BeaconBlockFork.Bellatrix: response.stream.writeChunk(some ResponseCode.Success, SSZ.encode(val.mergeData), - response.peer.network.forkDigests.merge.bytes) + response.peer.network.forkDigests.bellatrix.bytes) func shortLog*(s: StatusMsg): auto = (