rename Beacon{Block,State}Fork.Merge to Bellatrix; update copyright years (#3240)

This commit is contained in:
tersec 2022-01-04 09:45:38 +00:00 committed by GitHub
parent d20387e910
commit b81c06edab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 178 additions and 177 deletions

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).
@ -135,7 +135,7 @@ func init*(
case state.data.kind:
of BeaconStateFork.Phase0: false
of BeaconStateFork.Altair: false
of BeaconStateFork.Merge:
of BeaconStateFork.Bellatrix:
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/beacon-chain.md#is_merge_transition_complete
state.data.mergeData.data.latest_execution_payload_header !=
ExecutionPayloadHeader()
@ -281,9 +281,9 @@ func contains*(dag: ChainDAGRef, root: Eth2Digest): bool =
proc containsBlock(
cfg: RuntimeConfig, db: BeaconChainDB, slot: Slot, root: Eth2Digest): bool =
case cfg.blockForkAtEpoch(slot.epoch)
of BeaconBlockFork.Phase0: db.containsBlockPhase0(root)
of BeaconBlockFork.Altair: db.containsBlockAltair(root)
of BeaconBlockFork.Merge: db.containsBlockMerge(root)
of BeaconBlockFork.Phase0: db.containsBlockPhase0(root)
of BeaconBlockFork.Altair: db.containsBlockAltair(root)
of BeaconBlockFork.Bellatrix: db.containsBlockMerge(root)
func isStateCheckpoint(bs: BlockSlot): bool =
## State checkpoints are the points in time for which we store full state
@ -315,7 +315,7 @@ proc getStateData(
state.data = (ref ForkedHashedBeaconState)(kind: expectedFork)[]
case expectedFork
of BeaconStateFork.Merge:
of BeaconStateFork.Bellatrix:
if not db.getState(root.get(), state.data.mergeData.data, rollback):
return false
of BeaconStateFork.Altair:
@ -468,7 +468,7 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
stateFork = tmpState.data.altairData.data.fork,
configFork = altairFork(cfg)
quit 1
of BeaconStateFork.Merge:
of BeaconStateFork.Bellatrix:
if tmpState.data.mergeData.data.fork != mergeFork(cfg):
error "State from database does not match network, check --network parameter",
genesisRef, tailRef, headRef, tailRoot, headRoot,
@ -628,9 +628,9 @@ template forkAtEpoch*(dag: ChainDAGRef, epoch: Epoch): Fork =
proc forkDigestAtEpoch*(dag: ChainDAGRef, epoch: Epoch): ForkDigest =
case dag.cfg.stateForkAtEpoch(epoch)
of BeaconStateFork.Merge: dag.forkDigests.merge
of BeaconStateFork.Altair: dag.forkDigests.altair
of BeaconStateFork.Phase0: dag.forkDigests.phase0
of BeaconStateFork.Bellatrix: dag.forkDigests.merge
of BeaconStateFork.Altair: dag.forkDigests.altair
of BeaconStateFork.Phase0: dag.forkDigests.phase0
proc getState(dag: ChainDAGRef, state: var StateData, bs: BlockSlot): bool =
## Load a state from the database given a block and a slot - this will first
@ -760,7 +760,7 @@ proc getForkedBlock*(dag: ChainDAGRef, id: BlockId): Opt[ForkedTrustedSignedBeac
let data = dag.db.getAltairBlock(id.root)
if data.isOk():
return ok ForkedTrustedSignedBeaconBlock.init(data.get)
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
let data = dag.db.getMergeBlock(id.root)
if data.isOk():
return ok ForkedTrustedSignedBeaconBlock.init(data.get)

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2019-2021 Status Research & Development GmbH
# Copyright (c) 2019-2022 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
@ -176,13 +176,13 @@ template checkedReject(error: ValidationError): untyped =
raiseAssert $error[1]
err(error)
template validateBeaconBlockMerge(
template validateBeaconBlockBellatrix(
signed_beacon_block: phase0.SignedBeaconBlock |
altair.SignedBeaconBlock): untyped =
discard
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/p2p-interface.md#beacon_block
template validateBeaconBlockMerge(
template validateBeaconBlockBellatrix(
signed_beacon_block: merge.SignedBeaconBlock): untyped =
# If the execution is enabled for the block -- i.e.
# is_execution_enabled(state, block.body) then validate the following:
@ -204,7 +204,7 @@ template validateBeaconBlockMerge(
false
of BeaconBlockFork.Altair:
false
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/beacon-chain.md#process_execution_payload
# shows how this gets folded into the state each block; checking this
# is equivalent, without ever requiring state replay or any similarly
@ -350,7 +350,7 @@ proc validateBeaconBlock*(
signed_beacon_block.signature):
return errReject("Invalid proposer signature")
validateBeaconBlockMerge(signed_beacon_block)
validateBeaconBlockBellatrix(signed_beacon_block)
ok()

View File

@ -2157,9 +2157,9 @@ proc updateForkId*(node: Eth2Node, epoch: Epoch, genesisValidatorsRoot: Eth2Dige
func forkDigestAtEpoch(node: Eth2Node, epoch: Epoch): ForkDigest =
case node.cfg.stateForkAtEpoch(epoch)
of BeaconStateFork.Merge: node.forkDigests.merge
of BeaconStateFork.Altair: node.forkDigests.altair
of BeaconStateFork.Phase0: node.forkDigests.phase0
of BeaconStateFork.Bellatrix: node.forkDigests.merge
of BeaconStateFork.Altair: node.forkDigests.altair
of BeaconStateFork.Phase0: node.forkDigests.phase0
proc getWallEpoch(node: Eth2Node): Epoch =
node.getBeaconTime().slotOrZero.epoch

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).
@ -825,7 +825,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
RestApiResponse.jsonResponse(bdata.data.phase0Data)
else:
RestApiResponse.jsonError(Http500, InvalidAcceptError)
of BeaconBlockFork.Altair, BeaconBlockFork.Merge:
of BeaconBlockFork.Altair, BeaconBlockFork.Bellatrix:
RestApiResponse.jsonError(Http404, BlockNotFoundError)
# https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockV2
@ -855,7 +855,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
RestApiResponse.sszResponse(bdata.data.phase0Data)
of BeaconBlockFork.Altair:
RestApiResponse.sszResponse(bdata.data.altairData)
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
RestApiResponse.sszResponse(bdata.data.mergeData)
of "application/json":
RestApiResponse.jsonResponsePlain(bdata.data.asSigned())

View File

@ -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).
@ -48,7 +48,7 @@ proc installDebugApiHandlers*(router: var RestRouter, node: BeaconNode) =
RestApiResponse.jsonResponse(stateData.data.phase0Data.data)
else:
RestApiResponse.jsonError(Http500, InvalidAcceptError)
of BeaconStateFork.Altair, BeaconStateFork.Merge:
of BeaconStateFork.Altair, BeaconStateFork.Bellatrix:
RestApiResponse.jsonError(Http404, StateNotFoundError)
return RestApiResponse.jsonError(Http404, StateNotFoundError)

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).
@ -700,7 +700,7 @@ proc readValue*(reader: var JsonReader[RestJson],
of "altair":
version = some(BeaconBlockFork.Altair)
of "merge":
version = some(BeaconBlockFork.Merge)
version = some(BeaconBlockFork.Bellatrix)
else:
reader.raiseUnexpectedValue("Incorrect version field value")
of "data":
@ -737,7 +737,7 @@ proc readValue*(reader: var JsonReader[RestJson],
if res.isNone():
reader.raiseUnexpectedValue("Incorrect altair block format")
value = ForkedBeaconBlock.init(res.get())
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
let res =
try:
some(RestJson.decode(string(data.get()), merge.BeaconBlock,
@ -758,7 +758,7 @@ proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedBeaconBlock) {.
of BeaconBlockFork.Altair:
writer.writeField("version", "altair")
writer.writeField("data", value.altairData)
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
writer.writeField("version", "merge")
when false:
# TODO SerializationError
@ -786,7 +786,7 @@ proc readValue*(reader: var JsonReader[RestJson],
of "altair":
version = some(BeaconBlockFork.Altair)
of "merge":
version = some(BeaconBlockFork.Merge)
version = some(BeaconBlockFork.Bellatrix)
else:
reader.raiseUnexpectedValue("Incorrect version field value")
of "data":
@ -823,7 +823,7 @@ proc readValue*(reader: var JsonReader[RestJson],
if res.isNone():
reader.raiseUnexpectedValue("Incorrect altair block format")
value = ForkedSignedBeaconBlock.init(res.get())
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
let res =
try:
some(RestJson.decode(string(data.get()), merge.SignedBeaconBlock,
@ -845,7 +845,7 @@ proc writeValue*(writer: var JsonWriter[RestJson],
of BeaconBlockFork.Altair:
writer.writeField("version", "altair")
writer.writeField("data", value.altairData)
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
writer.writeField("version", "merge")
when false:
# TODO SerializationError
@ -871,7 +871,7 @@ proc readValue*(reader: var JsonReader[RestJson],
version = case vres
of "phase0": some(BeaconStateFork.Phase0)
of "altair": some(BeaconStateFork.Altair)
of "merge": some(BeaconStateFork.Merge)
of "merge": some(BeaconStateFork.Bellatrix)
else: reader.raiseUnexpectedValue("Incorrect version field value")
of "data":
if data.isSome():
@ -915,7 +915,7 @@ proc readValue*(reader: var JsonReader[RestJson],
reader.raiseUnexpectedValue("Incorrect altair beacon state format")
toValue(altairData)
of BeaconStateFork.Merge:
of BeaconStateFork.Bellatrix:
try:
tmp[].mergeData.data = RestJson.decode(
string(data.get()), merge.BeaconState, requireAllFields = true)
@ -933,7 +933,7 @@ proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedHashedBeaconStat
of BeaconStateFork.Altair:
writer.writeField("version", "altair")
writer.writeField("data", value.altairData.data)
of BeaconStateFork.Merge:
of BeaconStateFork.Bellatrix:
writer.writeField("version", "merge")
when false:
# TODO SerializationError

View File

@ -38,7 +38,7 @@ type
BeaconStateFork* {.pure.} = enum
Phase0,
Altair,
Merge
Bellatrix
ForkyBeaconState* =
phase0.BeaconState |
@ -52,14 +52,14 @@ type
ForkedHashedBeaconState* = object
case kind*: BeaconStateFork
of BeaconStateFork.Phase0: phase0Data*: phase0.HashedBeaconState
of BeaconStateFork.Altair: altairData*: altair.HashedBeaconState
of BeaconStateFork.Merge: mergeData*: merge.HashedBeaconState
of BeaconStateFork.Phase0: phase0Data*: phase0.HashedBeaconState
of BeaconStateFork.Altair: altairData*: altair.HashedBeaconState
of BeaconStateFork.Bellatrix: mergeData*: merge.HashedBeaconState
BeaconBlockFork* {.pure.} = enum
Phase0
Altair
Merge
Bellatrix
ForkyBeaconBlock* =
phase0.BeaconBlock |
@ -73,15 +73,15 @@ type
ForkedBeaconBlock* = object
case kind*: BeaconBlockFork
of BeaconBlockFork.Phase0: phase0Data*: phase0.BeaconBlock
of BeaconBlockFork.Altair: altairData*: altair.BeaconBlock
of BeaconBlockFork.Merge: mergeData*: merge.BeaconBlock
of BeaconBlockFork.Phase0: phase0Data*: phase0.BeaconBlock
of BeaconBlockFork.Altair: altairData*: altair.BeaconBlock
of BeaconBlockFork.Bellatrix: mergeData*: merge.BeaconBlock
ForkedTrustedBeaconBlock* = object
case kind*: BeaconBlockFork
of BeaconBlockFork.Phase0: phase0Data*: phase0.TrustedBeaconBlock
of BeaconBlockFork.Altair: altairData*: altair.TrustedBeaconBlock
of BeaconBlockFork.Merge: mergeData*: merge.TrustedBeaconBlock
of BeaconBlockFork.Phase0: phase0Data*: phase0.TrustedBeaconBlock
of BeaconBlockFork.Altair: altairData*: altair.TrustedBeaconBlock
of BeaconBlockFork.Bellatrix: mergeData*: merge.TrustedBeaconBlock
ForkySignedBeaconBlock* =
phase0.SignedBeaconBlock |
@ -90,9 +90,9 @@ type
ForkedSignedBeaconBlock* = object
case kind*: BeaconBlockFork
of BeaconBlockFork.Phase0: phase0Data*: phase0.SignedBeaconBlock
of BeaconBlockFork.Altair: altairData*: altair.SignedBeaconBlock
of BeaconBlockFork.Merge: mergeData*: merge.SignedBeaconBlock
of BeaconBlockFork.Phase0: phase0Data*: phase0.SignedBeaconBlock
of BeaconBlockFork.Altair: altairData*: altair.SignedBeaconBlock
of BeaconBlockFork.Bellatrix: mergeData*: merge.SignedBeaconBlock
ForkyTrustedSignedBeaconBlock* =
phase0.TrustedSignedBeaconBlock |
@ -101,9 +101,9 @@ type
ForkedTrustedSignedBeaconBlock* = object
case kind*: BeaconBlockFork
of BeaconBlockFork.Phase0: phase0Data*: phase0.TrustedSignedBeaconBlock
of BeaconBlockFork.Altair: altairData*: altair.TrustedSignedBeaconBlock
of BeaconBlockFork.Merge: mergeData*: merge.TrustedSignedBeaconBlock
of BeaconBlockFork.Phase0: phase0Data*: phase0.TrustedSignedBeaconBlock
of BeaconBlockFork.Altair: altairData*: altair.TrustedSignedBeaconBlock
of BeaconBlockFork.Bellatrix: mergeData*: merge.TrustedSignedBeaconBlock
EpochInfoFork* {.pure.} = enum
Phase0
@ -129,35 +129,35 @@ template toFork*[T: altair.BeaconState | altair.HashedBeaconState](
BeaconStateFork.Altair
template toFork*[T: merge.BeaconState | merge.HashedBeaconState](
t: type T): BeaconStateFork =
BeaconStateFork.Merge
BeaconStateFork.Bellatrix
template init*(T: type ForkedHashedBeaconState, data: phase0.HashedBeaconState): T =
T(kind: BeaconStateFork.Phase0, phase0Data: data)
template init*(T: type ForkedHashedBeaconState, data: altair.HashedBeaconState): T =
T(kind: BeaconStateFork.Altair, altairData: data)
template init*(T: type ForkedHashedBeaconState, data: merge.HashedBeaconState): T =
T(kind: BeaconStateFork.Merge, mergeData: data)
T(kind: BeaconStateFork.Bellatrix, mergeData: data)
template init*(T: type ForkedBeaconBlock, blck: phase0.BeaconBlock): T =
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
template init*(T: type ForkedBeaconBlock, blck: altair.BeaconBlock): T =
T(kind: BeaconBlockFork.Altair, altairData: blck)
template init*(T: type ForkedBeaconBlock, blck: merge.BeaconBlock): T =
T(kind: BeaconBlockFork.Merge, mergeData: blck)
T(kind: BeaconBlockFork.Bellatrix, mergeData: blck)
template init*(T: type ForkedTrustedBeaconBlock, blck: phase0.TrustedBeaconBlock): T =
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
template init*(T: type ForkedTrustedBeaconBlock, blck: altair.TrustedBeaconBlock): T =
T(kind: BeaconBlockFork.Altair, altairData: blck)
template init*(T: type ForkedTrustedBeaconBlock, blck: merge.TrustedBeaconBlock): T =
T(kind: BeaconBlockFork.Merge, mergeData: blck)
T(kind: BeaconBlockFork.Bellatrix, mergeData: blck)
template init*(T: type ForkedSignedBeaconBlock, blck: phase0.SignedBeaconBlock): T =
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
template init*(T: type ForkedSignedBeaconBlock, blck: altair.SignedBeaconBlock): T =
T(kind: BeaconBlockFork.Altair, altairData: blck)
template init*(T: type ForkedSignedBeaconBlock, blck: merge.SignedBeaconBlock): T =
T(kind: BeaconBlockFork.Merge, mergeData: blck)
T(kind: BeaconBlockFork.Bellatrix, mergeData: blck)
template init*(T: type ForkedSignedBeaconBlock, forked: ForkedBeaconBlock,
blockRoot: Eth2Digest, signature: ValidatorSig): T =
@ -172,8 +172,8 @@ template init*(T: type ForkedSignedBeaconBlock, forked: ForkedBeaconBlock,
altairData: altair.SignedBeaconBlock(message: forked.altairData,
root: blockRoot,
signature: signature))
of BeaconBlockFork.Merge:
T(kind: BeaconBlockFork.Merge,
of BeaconBlockFork.Bellatrix:
T(kind: BeaconBlockFork.Bellatrix,
mergeData: merge.SignedBeaconBlock(message: forked.mergeData,
root: blockRoot,
signature: signature))
@ -183,7 +183,7 @@ template init*(T: type ForkedTrustedSignedBeaconBlock, blck: phase0.TrustedSigne
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: altair.TrustedSignedBeaconBlock): T =
T(kind: BeaconBlockFork.Altair, altairData: blck)
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: merge.TrustedSignedBeaconBlock): T =
T(kind: BeaconBlockFork.Merge, mergeData: blck)
T(kind: BeaconBlockFork.Bellatrix, mergeData: blck)
template toFork*[T: phase0.TrustedSignedBeaconBlock](
t: type T): BeaconBlockFork =
@ -193,7 +193,7 @@ template toFork*[T: altair.TrustedSignedBeaconBlock](
BeaconBlockFork.Altair
template toFork*[T: merge.TrustedSignedBeaconBlock](
t: type T): BeaconBlockFork =
BeaconBlockFork.Merge
BeaconBlockFork.Bellatrix
template init*(T: type ForkedEpochInfo, info: phase0.EpochInfo): T =
T(kind: EpochInfoFork.Phase0, phase0Data: info)
@ -202,8 +202,8 @@ template init*(T: type ForkedEpochInfo, info: altair.EpochInfo): T =
template withState*(x: ForkedHashedBeaconState, body: untyped): untyped =
case x.kind
of BeaconStateFork.Merge:
const stateFork {.inject, used.} = BeaconStateFork.Merge
of BeaconStateFork.Bellatrix:
const stateFork {.inject, used.} = BeaconStateFork.Bellatrix
template state: untyped {.inject, used.} = x.mergeData
body
of BeaconStateFork.Altair:
@ -240,7 +240,7 @@ template withEpochInfo*(
func assign*(tgt: var ForkedHashedBeaconState, src: ForkedHashedBeaconState) =
if tgt.kind == src.kind:
case tgt.kind
of BeaconStateFork.Merge:
of BeaconStateFork.Bellatrix:
assign(tgt.mergeData, src.mergeData):
of BeaconStateFork.Altair:
assign(tgt.altairData, src.altairData):
@ -258,9 +258,9 @@ template getStateField*(x: ForkedHashedBeaconState, y: untyped): untyped =
# ```
# Without `unsafeAddr`, the `validators` list would be copied to a temporary variable.
(case x.kind
of BeaconStateFork.Merge: unsafeAddr x.mergeData.data.y
of BeaconStateFork.Altair: unsafeAddr x.altairData.data.y
of BeaconStateFork.Phase0: unsafeAddr x.phase0Data.data.y)[]
of BeaconStateFork.Bellatrix: unsafeAddr x.mergeData.data.y
of BeaconStateFork.Altair: unsafeAddr x.altairData.data.y
of BeaconStateFork.Phase0: unsafeAddr x.phase0Data.data.y)[]
func getStateRoot*(x: ForkedHashedBeaconState): Eth2Digest =
withState(x): state.root
@ -271,17 +271,17 @@ func setStateRoot*(x: var ForkedHashedBeaconState, root: Eth2Digest) =
func stateForkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): BeaconStateFork =
## Return the current fork for the given epoch.
static:
doAssert BeaconStateFork.Merge > BeaconStateFork.Altair
doAssert BeaconStateFork.Altair > BeaconStateFork.Phase0
doAssert BeaconStateFork.Bellatrix > BeaconStateFork.Altair
doAssert BeaconStateFork.Altair > BeaconStateFork.Phase0
doAssert GENESIS_EPOCH == 0
if epoch >= cfg.MERGE_FORK_EPOCH: BeaconStateFork.Merge
if epoch >= cfg.MERGE_FORK_EPOCH: BeaconStateFork.Bellatrix
elif epoch >= cfg.ALTAIR_FORK_EPOCH: BeaconStateFork.Altair
else: BeaconStateFork.Phase0
func blockForkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): BeaconBlockFork =
## Return the current fork for the given epoch.
if epoch >= cfg.MERGE_FORK_EPOCH: BeaconBlockFork.Merge
if epoch >= cfg.MERGE_FORK_EPOCH: BeaconBlockFork.Bellatrix
elif epoch >= cfg.ALTAIR_FORK_EPOCH: BeaconBlockFork.Altair
else: BeaconBlockFork.Phase0
@ -304,8 +304,8 @@ template withBlck*(
const stateFork {.inject, used.} = BeaconStateFork.Altair
template blck: untyped {.inject.} = x.altairData
body
of BeaconBlockFork.Merge:
const stateFork {.inject, used.} = BeaconStateFork.Merge
of BeaconBlockFork.Bellatrix:
const stateFork {.inject, used.} = BeaconStateFork.Bellatrix
template blck: untyped {.inject.} = x.mergeData
body
@ -318,9 +318,9 @@ func hash_tree_root*(x: ForkedBeaconBlock): Eth2Digest =
template getForkedBlockField*(x: ForkedSignedBeaconBlock | ForkedTrustedSignedBeaconBlock, y: untyped): untyped =
# unsafeAddr avoids a copy of the field in some cases
(case x.kind
of BeaconBlockFork.Phase0: unsafeAddr x.phase0Data.message.y
of BeaconBlockFork.Altair: unsafeAddr x.altairData.message.y
of BeaconBlockFork.Merge: unsafeAddr x.mergeData.message.y)[]
of BeaconBlockFork.Phase0: unsafeAddr x.phase0Data.message.y
of BeaconBlockFork.Altair: unsafeAddr x.altairData.message.y
of BeaconBlockFork.Bellatrix: unsafeAddr x.mergeData.message.y)[]
template signature*(x: ForkedSignedBeaconBlock): ValidatorSig =
withBlck(x): blck.signature
@ -350,8 +350,8 @@ template withStateAndBlck*(
ForkedTrustedSignedBeaconBlock,
body: untyped): untyped =
case s.kind
of BeaconStateFork.Merge:
const stateFork {.inject.} = BeaconStateFork.Merge
of BeaconStateFork.Bellatrix:
const stateFork {.inject.} = BeaconStateFork.Bellatrix
template state: untyped {.inject.} = s.mergeData
template blck: untyped {.inject.} = b.mergeData
body
@ -388,21 +388,21 @@ func mergeFork*(cfg: RuntimeConfig): Fork =
proc forkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Fork =
case cfg.stateForkAtEpoch(epoch)
of BeaconStateFork.Merge: cfg.mergeFork
of BeaconStateFork.Altair: cfg.altairFork
of BeaconStateFork.Phase0: cfg.genesisFork
of BeaconStateFork.Bellatrix: cfg.mergeFork
of BeaconStateFork.Altair: cfg.altairFork
of BeaconStateFork.Phase0: cfg.genesisFork
proc forkVersionAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Version =
case cfg.stateForkAtEpoch(epoch)
of BeaconStateFork.Merge: cfg.MERGE_FORK_VERSION
of BeaconStateFork.Altair: cfg.ALTAIR_FORK_VERSION
of BeaconStateFork.Phase0: cfg.GENESIS_FORK_VERSION
of BeaconStateFork.Bellatrix: cfg.MERGE_FORK_VERSION
of BeaconStateFork.Altair: cfg.ALTAIR_FORK_VERSION
of BeaconStateFork.Phase0: cfg.GENESIS_FORK_VERSION
proc nextForkEpochAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Epoch =
case cfg.stateForkAtEpoch(epoch)
of BeaconStateFork.Merge: FAR_FUTURE_EPOCH
of BeaconStateFork.Altair: cfg.MERGE_FORK_EPOCH
of BeaconStateFork.Phase0: cfg.ALTAIR_FORK_EPOCH
of BeaconStateFork.Bellatrix: FAR_FUTURE_EPOCH
of BeaconStateFork.Altair: cfg.MERGE_FORK_EPOCH
of BeaconStateFork.Phase0: cfg.ALTAIR_FORK_EPOCH
func getForkSchedule*(cfg: RuntimeConfig): array[3, Fork] =
## This procedure returns list of known and/or scheduled forks.
@ -466,9 +466,9 @@ func readSszForkedTrustedSignedBeaconBlock*(
func toBeaconBlockFork*(fork: BeaconStateFork): BeaconBlockFork =
case fork
of BeaconStateFork.Phase0: BeaconBlockFork.Phase0
of BeaconStateFork.Altair: BeaconBlockFork.Altair
of BeaconStateFork.Merge: BeaconBlockFork.Merge
of BeaconStateFork.Phase0: BeaconBlockFork.Phase0
of BeaconStateFork.Altair: BeaconBlockFork.Altair
of BeaconStateFork.Bellatrix: BeaconBlockFork.Bellatrix
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#compute_fork_data_root
func compute_fork_data_root*(current_version: Version,

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).
@ -135,7 +135,7 @@ func getTargetGossipState*(
# The order of these checks doesn't matter.
elif epoch >= MERGE_FORK_EPOCH:
{BeaconStateFork.Merge}
{BeaconStateFork.Bellatrix}
elif epoch + 1 < ALTAIR_FORK_EPOCH:
{BeaconStateFork.Phase0}
@ -144,8 +144,8 @@ func getTargetGossipState*(
# intermediate pure-Altair epochs.
#
# In the first case, should never enable Altair, and there's also never
# any Phase -> Altair or Altair -> Merge gossip transition epoch. Given
# contiguous Phase0 -> Altair and Altair -> Merge gossip transitions, a
# a Phase -> Altair, or Altair -> Bellatrix gossip transition epoch. In
# contiguous Phase0 -> Altair and Altair -> Bellatrix transitions, that
# pure Altair state gossip state never occurs, but it works without any
# special cases so long as one checks for transition-to-fork+1 before a
# pure fork gossip state.
@ -157,7 +157,7 @@ func getTargetGossipState*(
BeaconStateFork.Phase0
else:
BeaconStateFork.Altair,
BeaconStateFork.Merge}
BeaconStateFork.Bellatrix}
elif epoch >= ALTAIR_FORK_EPOCH:
{BeaconStateFork.Altair}

View File

@ -1,4 +1,4 @@
import
./mainnet/[altair_preset, merge_preset, phase0_preset]
./mainnet/[altair_preset, bellatrix_preset, phase0_preset]
export altair_preset, merge_preset, phase0_preset
export altair_preset, bellatrix_preset, phase0_preset

View File

@ -1,4 +1,4 @@
import
./minimal/[altair_preset, merge_preset, phase0_preset]
./minimal/[altair_preset, bellatrix_preset, phase0_preset]
export altair_preset, merge_preset, phase0_preset
export altair_preset, bellatrix_preset, phase0_preset

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).
@ -201,7 +201,7 @@ proc maybeUpgradeStateToAltair(
altairData: altair.HashedBeaconState(
root: hash_tree_root(newState[]), data: newState[]))[]
func maybeUpgradeStateToMerge(
func maybeUpgradeStateToBellatrix(
cfg: RuntimeConfig, state: var ForkedHashedBeaconState) =
# Both process_slots() and state_transition_block() call this, so only run it
# once by checking for existing fork.
@ -209,14 +209,14 @@ func maybeUpgradeStateToMerge(
state.kind == BeaconStateFork.Altair:
var newState = upgrade_to_merge(cfg, state.altairData.data)
state = (ref ForkedHashedBeaconState)(
kind: BeaconStateFork.Merge,
kind: BeaconStateFork.Bellatrix,
mergeData: merge.HashedBeaconState(
root: hash_tree_root(newState[]), data: newState[]))[]
proc maybeUpgradeState*(
cfg: RuntimeConfig, state: var ForkedHashedBeaconState) =
cfg.maybeUpgradeStateToAltair(state)
cfg.maybeUpgradeStateToMerge(state)
cfg.maybeUpgradeStateToBellatrix(state)
proc process_slots*(
cfg: RuntimeConfig, state: var ForkedHashedBeaconState, slot: Slot,
@ -614,6 +614,6 @@ proc makeBeaconBlock*(
ok(blck)
case state.kind
of BeaconStateFork.Phase0: makeBeaconBlock(phase0)
of BeaconStateFork.Altair: makeBeaconBlock(altair)
of BeaconStateFork.Merge: makeBeaconBlock(merge)
of BeaconStateFork.Phase0: makeBeaconBlock(phase0)
of BeaconStateFork.Altair: makeBeaconBlock(altair)
of BeaconStateFork.Bellatrix: makeBeaconBlock(merge)

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).
@ -101,7 +101,7 @@ proc sendResponseChunk*(response: UntypedResponse,
response.stream.writeChunk(some ResponseCode.Success,
SSZ.encode(val.altairData),
response.peer.network.forkDigests.altair.bytes)
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
response.stream.writeChunk(some ResponseCode.Success,
SSZ.encode(val.mergeData),
response.peer.network.forkDigests.merge.bytes)
@ -233,7 +233,7 @@ p2pProtocol BeaconSync(version = 1,
case blck.kind
of BeaconBlockFork.Phase0:
await response.write(blck.phase0Data.asSigned)
of BeaconBlockFork.Altair, BeaconBlockFork.Merge:
of BeaconBlockFork.Altair, BeaconBlockFork.Bellatrix:
# Skipping all subsequent blocks should be OK because the spec says:
# "Clients MAY limit the number of blocks in the response."
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#beaconblocksbyrange
@ -273,7 +273,7 @@ p2pProtocol BeaconSync(version = 1,
of BeaconBlockFork.Phase0:
await response.write(blk.phase0Data.asSigned)
inc found
of BeaconBlockFork.Altair, BeaconBlockFork.Merge:
of BeaconBlockFork.Altair, BeaconBlockFork.Bellatrix:
# Skipping this block should be fine because the spec says:
# "Clients MAY limit the number of blocks in the response."
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#beaconblocksbyroot

View File

@ -773,7 +773,7 @@ proc publishBlock*(vc: ValidatorClientRef,
publishBlock(it, data.phase0Data)
of BeaconBlockFork.Altair:
publishBlock(it, data.altairData)
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
raiseAssert "trying to publish merge block"
# TODO this doesn't build due to some nim-presto error
# publishBlock(it, data.mergeData)

View File

@ -76,9 +76,9 @@ type
template saveSSZFile(filename: string, value: ForkedHashedBeaconState) =
case value.kind:
of BeaconStateFork.Phase0: SSZ.saveFile(filename, value.phase0Data.data)
of BeaconStateFork.Altair: SSZ.saveFile(filename, value.altairData.data)
of BeaconStateFork.Merge: SSZ.saveFile(filename, value.mergeData.data)
of BeaconStateFork.Phase0: SSZ.saveFile(filename, value.phase0Data.data)
of BeaconStateFork.Altair: SSZ.saveFile(filename, value.altairData.data)
of BeaconStateFork.Bellatrix: SSZ.saveFile(filename, value.mergeData.data)
proc doTransition(conf: NcliConf) =
let

View File

@ -224,7 +224,7 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
blocks[0].add dag.db.getPhase0Block(blck.root).get()
of BeaconBlockFork.Altair:
blocks[1].add dag.db.getAltairBlock(blck.root).get()
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
blocks[2].add dag.db.getMergeBlock(blck.root).get()
let stateData = newClone(dag.headState)
@ -284,15 +284,15 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
of BeaconStateFork.Altair:
doAssert dbBenchmark.getState(
state.root, loadedState[1][].data, noRollback)
of BeaconStateFork.Merge:
of BeaconStateFork.Bellatrix:
doAssert dbBenchmark.getState(
state.root, loadedState[2][].data, noRollback)
if state.data.slot.epoch mod 16 == 0:
let loadedRoot = case stateFork
of BeaconStateFork.Phase0: hash_tree_root(loadedState[0][].data)
of BeaconStateFork.Altair: hash_tree_root(loadedState[1][].data)
of BeaconStateFork.Merge: hash_tree_root(loadedState[2][].data)
of BeaconStateFork.Phase0: hash_tree_root(loadedState[0][].data)
of BeaconStateFork.Altair: hash_tree_root(loadedState[1][].data)
of BeaconStateFork.Bellatrix: hash_tree_root(loadedState[2][].data)
doAssert hash_tree_root(state.data) == loadedRoot
processBlocks(blocks[0])

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2019-2021 Status Research & Development GmbH
# Copyright (c) 2019-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).
@ -337,7 +337,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
dag.pruneStateCachesDAG()
attPool.prune()
proc proposeMergeBlock(slot: Slot) =
proc proposeBellatrixBlock(slot: Slot) =
if rand(r, 1.0) > blockRatio:
return
@ -398,9 +398,9 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
if blockRatio > 0.0:
withTimer(timers[t]):
case dag.cfg.stateForkAtEpoch(slot.epoch)
of BeaconStateFork.Merge: proposeMergeBlock(slot)
of BeaconStateFork.Altair: proposeAltairBlock(slot)
of BeaconStateFork.Phase0: proposePhase0Block(slot)
of BeaconStateFork.Bellatrix: proposeBellatrixBlock(slot)
of BeaconStateFork.Altair: proposeAltairBlock(slot)
of BeaconStateFork.Phase0: proposePhase0Block(slot)
if attesterRatio > 0.0:
withTimer(timers[tAttest]):
handleAttestations(slot)

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).
@ -36,7 +36,8 @@ proc runTest(testName, testDir, unitTestName: string) =
var
preState = newClone(parseTest(testPath/"pre.ssz_snappy", SSZ, merge.BeaconState))
fhPreState = (ref ForkedHashedBeaconState)(mergeData: merge.HashedBeaconState(
data: preState[], root: hash_tree_root(preState[])), kind: BeaconStateFork.Merge)
data: preState[], root: hash_tree_root(preState[])),
kind: BeaconStateFork.Bellatrix)
cache = StateCache()
info = ForkedEpochInfo()

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).
@ -32,7 +32,7 @@ proc runTest(identifier: string) =
fhPreState = (ref ForkedHashedBeaconState)(
mergeData: merge.HashedBeaconState(
data: preState[], root: hash_tree_root(preState[])),
kind: BeaconStateFork.Merge)
kind: BeaconStateFork.Bellatrix)
cache = StateCache()
info = ForkedEpochInfo()
let postState = newClone(parseTest(testDir/"post.ssz_snappy", SSZ, merge.BeaconState))

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).
@ -129,7 +129,7 @@ proc loadOps(path: string, fork: BeaconBlockFork): seq[Operation] =
)
result.add Operation(kind: opOnBlock,
blk: ForkedSignedBeaconBlock.init(blk))
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
let blk = parseTest(
path/filename & ".ssz_snappy",
SSZ, merge.SignedBeaconBlock

View File

@ -85,9 +85,9 @@ proc mockBlock*(
doAssert process_slots(cfg, tmpState[], slot, cache, info, flags = {})
result.kind = case tmpState[].kind
of BeaconStateFork.Phase0: BeaconBlockFork.Phase0
of BeaconStateFork.Altair: BeaconBlockFork.Altair
of BeaconStateFork.Merge: BeaconBlockFork.Merge
of BeaconStateFork.Phase0: BeaconBlockFork.Phase0
of BeaconStateFork.Altair: BeaconBlockFork.Altair
of BeaconStateFork.Bellatrix: BeaconBlockFork.Bellatrix
withStateAndBlck(tmpState[], result):
blck.message.slot = slot
blck.message.proposer_index =
@ -104,7 +104,7 @@ proc mockBlock*(
when stateFork >= BeaconStateFork.Altair:
blck.message.body.sync_aggregate = SyncAggregate.init()
when stateFork >= BeaconStateFork.Merge:
when stateFork >= BeaconStateFork.Bellatrix:
blck.message.body.execution_payload =
build_empty_execution_payload(state.data)

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
@ -79,9 +79,9 @@ proc getTestStates(stateFork: BeaconStateFork): auto =
# Each of phase 0/altair/merge states gets used twice, so make them global to
# module
let
testStatesPhase0 = getTestStates(BeaconStateFork.Phase0)
testStatesAltair = getTestStates(BeaconStateFork.Altair)
testStatesMerge = getTestStates(BeaconStateFork.Merge)
testStatesPhase0 = getTestStates(BeaconStateFork.Phase0)
testStatesAltair = getTestStates(BeaconStateFork.Altair)
testStatesBellatrix = getTestStates(BeaconStateFork.Bellatrix)
suite "Beacon chain DB" & preset():
test "empty database" & preset():
@ -235,7 +235,7 @@ suite "Beacon chain DB" & preset():
test "sanity check Merge states" & preset():
var db = makeTestDB(SLOTS_PER_EPOCH)
for state in testStatesMerge:
for state in testStatesBellatrix:
let root = state[].mergeData.root
db.putState(root, state[].mergeData.data)
@ -294,7 +294,7 @@ suite "Beacon chain DB" & preset():
var db = makeTestDB(SLOTS_PER_EPOCH)
let stateBuffer = (merge.BeaconStateRef)()
for state in testStatesMerge:
for state in testStatesBellatrix:
let root = state[].mergeData.root
db.putState(root, state[].mergeData.data)
@ -365,7 +365,7 @@ suite "Beacon chain DB" & preset():
validatorMonitor = newClone(ValidatorMonitor.init())
dag = init(ChainDAGRef, defaultRuntimeConfig, db, validatorMonitor, {})
state = (ref ForkedHashedBeaconState)(
kind: BeaconStateFork.Merge,
kind: BeaconStateFork.Bellatrix,
mergeData: merge.HashedBeaconState(data: merge.BeaconState(
slot: 10.Slot)))
root = Eth2Digest()

View File

@ -11,7 +11,7 @@ template getTargetGossipState(a, b, c: int, isBehind: bool): auto =
suite "Gossip fork transition":
test "Gossip fork transition":
check:
getTargetGossipState(0, 0, 0, false) == {BeaconStateFork.Merge}
getTargetGossipState(0, 0, 0, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(0, 0, 2, false) == {BeaconStateFork.Altair}
getTargetGossipState(0, 1, 2, false) == {BeaconStateFork.Phase0, BeaconStateFork.Altair}
getTargetGossipState(0, 2, 3, false) == {BeaconStateFork.Phase0}
@ -20,45 +20,45 @@ suite "Gossip fork transition":
getTargetGossipState(0, 3, 5, false) == {BeaconStateFork.Phase0}
getTargetGossipState(0, 4, 4, false) == {BeaconStateFork.Phase0}
getTargetGossipState(0, 4, 5, false) == {BeaconStateFork.Phase0}
getTargetGossipState(1, 0, 1, false) == {BeaconStateFork.Merge}
getTargetGossipState(1, 0, 1, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(1, 0, 5, false) == {BeaconStateFork.Altair}
getTargetGossipState(1, 1, 4, false) == {BeaconStateFork.Altair}
getTargetGossipState(2, 0, 2, false) == {BeaconStateFork.Merge}
getTargetGossipState(2, 2, 3, false) == {BeaconStateFork.Altair, BeaconStateFork.Merge}
getTargetGossipState(2, 0, 2, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(2, 2, 3, false) == {BeaconStateFork.Altair, BeaconStateFork.Bellatrix}
getTargetGossipState(2, 2, 4, false) == {BeaconStateFork.Altair}
getTargetGossipState(2, 3, 4, false) == {BeaconStateFork.Phase0, BeaconStateFork.Altair}
getTargetGossipState(2, 3, 5, true) == {}
getTargetGossipState(2, 5, 5, false) == {BeaconStateFork.Phase0}
getTargetGossipState(3, 0, 2, false) == {BeaconStateFork.Merge}
getTargetGossipState(3, 0, 3, false) == {BeaconStateFork.Merge}
getTargetGossipState(3, 0, 2, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(3, 0, 3, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(3, 0, 5, false) == {BeaconStateFork.Altair}
getTargetGossipState(3, 1, 2, false) == {BeaconStateFork.Merge}
getTargetGossipState(3, 1, 1, false) == {BeaconStateFork.Merge}
getTargetGossipState(3, 1, 3, false) == {BeaconStateFork.Merge}
getTargetGossipState(3, 1, 2, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(3, 1, 1, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(3, 1, 3, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(3, 1, 5, true) == {}
getTargetGossipState(3, 1, 4, false) == {BeaconStateFork.Altair, BeaconStateFork.Merge}
getTargetGossipState(3, 2, 3, false) == {BeaconStateFork.Merge}
getTargetGossipState(3, 3, 4, false) == {BeaconStateFork.Altair, BeaconStateFork.Merge}
getTargetGossipState(3, 1, 4, false) == {BeaconStateFork.Altair, BeaconStateFork.Bellatrix}
getTargetGossipState(3, 2, 3, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(3, 3, 4, false) == {BeaconStateFork.Altair, BeaconStateFork.Bellatrix}
getTargetGossipState(3, 3, 4, true) == {}
getTargetGossipState(3, 4, 4, false) == {BeaconStateFork.Phase0, BeaconStateFork.Merge}
getTargetGossipState(4, 0, 0, false) == {BeaconStateFork.Merge}
getTargetGossipState(4, 0, 1, false) == {BeaconStateFork.Merge}
getTargetGossipState(4, 1, 1, false) == {BeaconStateFork.Merge}
getTargetGossipState(4, 1, 3, false) == {BeaconStateFork.Merge}
getTargetGossipState(4, 2, 4, false) == {BeaconStateFork.Merge}
getTargetGossipState(4, 3, 4, false) == {BeaconStateFork.Merge}
getTargetGossipState(4, 4, 4, false) == {BeaconStateFork.Merge}
getTargetGossipState(4, 5, 5, false) == {BeaconStateFork.Phase0, BeaconStateFork.Merge}
getTargetGossipState(5, 0, 0, false) == {BeaconStateFork.Merge}
getTargetGossipState(5, 0, 2, false) == {BeaconStateFork.Merge}
getTargetGossipState(5, 0, 4, false) == {BeaconStateFork.Merge}
getTargetGossipState(5, 0, 5, false) == {BeaconStateFork.Merge}
getTargetGossipState(3, 4, 4, false) == {BeaconStateFork.Phase0, BeaconStateFork.Bellatrix}
getTargetGossipState(4, 0, 0, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(4, 0, 1, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(4, 1, 1, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(4, 1, 3, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(4, 2, 4, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(4, 3, 4, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(4, 4, 4, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(4, 5, 5, false) == {BeaconStateFork.Phase0, BeaconStateFork.Bellatrix}
getTargetGossipState(5, 0, 0, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(5, 0, 2, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(5, 0, 4, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(5, 0, 5, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(5, 0, 5, true) == {}
getTargetGossipState(5, 1, 5, false) == {BeaconStateFork.Merge}
getTargetGossipState(5, 2, 2, false) == {BeaconStateFork.Merge}
getTargetGossipState(5, 1, 5, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(5, 2, 2, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(5, 2, 4, true) == {}
getTargetGossipState(5, 3, 4, false) == {BeaconStateFork.Merge}
getTargetGossipState(5, 3, 5, false) == {BeaconStateFork.Merge}
getTargetGossipState(5, 5, 5, false) == {BeaconStateFork.Merge}
getTargetGossipState(2, 0, 3, false) == {BeaconStateFork.Altair, BeaconStateFork.Merge}
getTargetGossipState(4, 1, 2, false) == {BeaconStateFork.Merge}
getTargetGossipState(5, 3, 4, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(5, 3, 5, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(5, 5, 5, false) == {BeaconStateFork.Bellatrix}
getTargetGossipState(2, 0, 3, false) == {BeaconStateFork.Altair, BeaconStateFork.Bellatrix}
getTargetGossipState(4, 1, 2, false) == {BeaconStateFork.Bellatrix}

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).
@ -205,7 +205,7 @@ suite "Gossip validation - Extra": # Not based on preset config
of BeaconBlockFork.Altair:
const nilCallback = OnAltairBlockAdded(nil)
dag.addHeadBlock(verifier, blck.altairData, nilCallback)
of BeaconBlockFork.Merge:
of BeaconBlockFork.Bellatrix:
const nilCallback = OnMergeBlockAdded(nil)
dag.addHeadBlock(verifier, blck.mergeData, nilCallback)
check: added.isOk()

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2021 Status Research & Development GmbH
# Copyright (c) 2021-2022 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
@ -64,10 +64,10 @@ proc getTestStates*(
info = ForkedEpochInfo()
cfg = defaultRuntimeConfig
if stateFork in [BeaconStateFork.Altair, BeaconStateFork.Merge]:
if stateFork in [BeaconStateFork.Altair, BeaconStateFork.Bellatrix]:
cfg.ALTAIR_FORK_EPOCH = 1.Epoch
if stateFork == BeaconStateFork.Merge:
if stateFork == BeaconStateFork.Bellatrix:
cfg.MERGE_FORK_EPOCH = 1.Epoch
for i, epoch in stateEpochs: