rename mergeData to bellatrixData and mergeFork to bellatrixFork (#3315)
This commit is contained in:
parent
e07044754a
commit
351c2fd48a
|
@ -142,7 +142,7 @@ func init*(
|
||||||
of BeaconStateFork.Altair: false
|
of BeaconStateFork.Altair: false
|
||||||
of BeaconStateFork.Bellatrix:
|
of BeaconStateFork.Bellatrix:
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.7/specs/merge/beacon-chain.md#is_merge_transition_complete
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.7/specs/merge/beacon-chain.md#is_merge_transition_complete
|
||||||
state.data.mergeData.data.latest_execution_payload_header !=
|
state.data.bellatrixData.data.latest_execution_payload_header !=
|
||||||
ExecutionPayloadHeader()
|
ExecutionPayloadHeader()
|
||||||
)
|
)
|
||||||
epochStart = epoch.start_slot()
|
epochStart = epoch.start_slot()
|
||||||
|
@ -349,7 +349,7 @@ proc getStateData(
|
||||||
|
|
||||||
case expectedFork
|
case expectedFork
|
||||||
of BeaconStateFork.Bellatrix:
|
of BeaconStateFork.Bellatrix:
|
||||||
if not db.getState(root.get(), state.data.mergeData.data, rollback):
|
if not db.getState(root.get(), state.data.bellatrixData.data, rollback):
|
||||||
return false
|
return false
|
||||||
of BeaconStateFork.Altair:
|
of BeaconStateFork.Altair:
|
||||||
if not db.getState(root.get(), state.data.altairData.data, rollback):
|
if not db.getState(root.get(), state.data.altairData.data, rollback):
|
||||||
|
@ -516,11 +516,11 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
|
||||||
configFork = altairFork(cfg)
|
configFork = altairFork(cfg)
|
||||||
quit 1
|
quit 1
|
||||||
of BeaconStateFork.Bellatrix:
|
of BeaconStateFork.Bellatrix:
|
||||||
if tmpState.data.mergeData.data.fork != mergeFork(cfg):
|
if tmpState.data.bellatrixData.data.fork != bellatrixFork(cfg):
|
||||||
error "State from database does not match network, check --network parameter",
|
error "State from database does not match network, check --network parameter",
|
||||||
genesisRef, tailRef, headRef, tailRoot, headRoot,
|
genesisRef, tailRef, headRef, tailRoot, headRoot,
|
||||||
stateFork = tmpState.data.mergeData.data.fork,
|
stateFork = tmpState.data.bellatrixData.data.fork,
|
||||||
configFork = mergeFork(cfg)
|
configFork = bellatrixFork(cfg)
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
let dag = ChainDAGRef(
|
let dag = ChainDAGRef(
|
||||||
|
|
|
@ -216,7 +216,7 @@ template validateBeaconBlockBellatrix(
|
||||||
# shows how this gets folded into the state each block; checking this
|
# shows how this gets folded into the state each block; checking this
|
||||||
# is equivalent, without ever requiring state replay or any similarly
|
# is equivalent, without ever requiring state replay or any similarly
|
||||||
# expensive computation.
|
# expensive computation.
|
||||||
blockData.mergeData.message.body.execution_payload !=
|
blockData.bellatrixData.message.body.execution_payload !=
|
||||||
default(ExecutionPayload)
|
default(ExecutionPayload)
|
||||||
|
|
||||||
if executionEnabled:
|
if executionEnabled:
|
||||||
|
|
|
@ -734,7 +734,7 @@ proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedBeaconBlock) {.
|
||||||
writer.writeField("version", "merge")
|
writer.writeField("version", "merge")
|
||||||
when false:
|
when false:
|
||||||
# TODO SerializationError
|
# TODO SerializationError
|
||||||
writer.writeField("data", value.mergeData)
|
writer.writeField("data", value.bellatrixData)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
|
|
||||||
## ForkedSignedBeaconBlock
|
## ForkedSignedBeaconBlock
|
||||||
|
@ -823,7 +823,7 @@ proc writeValue*(writer: var JsonWriter[RestJson],
|
||||||
writer.writeField("version", "merge")
|
writer.writeField("version", "merge")
|
||||||
when false:
|
when false:
|
||||||
# TODO SerializationError
|
# TODO SerializationError
|
||||||
writer.writeField("data", value.mergeData)
|
writer.writeField("data", value.bellatrixData)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
|
|
||||||
# ForkedHashedBeaconState is used where a `ForkedBeaconState` normally would
|
# ForkedHashedBeaconState is used where a `ForkedBeaconState` normally would
|
||||||
|
@ -891,11 +891,11 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
toValue(altairData)
|
toValue(altairData)
|
||||||
of BeaconStateFork.Bellatrix:
|
of BeaconStateFork.Bellatrix:
|
||||||
try:
|
try:
|
||||||
tmp[].mergeData.data = RestJson.decode(
|
tmp[].bellatrixData.data = RestJson.decode(
|
||||||
string(data.get()), bellatrix.BeaconState, requireAllFields = true)
|
string(data.get()), bellatrix.BeaconState, requireAllFields = true)
|
||||||
except SerializationError:
|
except SerializationError:
|
||||||
reader.raiseUnexpectedValue("Incorrect altair beacon state format")
|
reader.raiseUnexpectedValue("Incorrect altair beacon state format")
|
||||||
toValue(mergeData)
|
toValue(bellatrixData)
|
||||||
|
|
||||||
proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedHashedBeaconState) {.
|
proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedHashedBeaconState) {.
|
||||||
raises: [IOError, Defect].} =
|
raises: [IOError, Defect].} =
|
||||||
|
@ -911,7 +911,7 @@ proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedHashedBeaconStat
|
||||||
writer.writeField("version", "merge")
|
writer.writeField("version", "merge")
|
||||||
when false:
|
when false:
|
||||||
# TODO SerializationError
|
# TODO SerializationError
|
||||||
writer.writeField("data", value.mergeData.data)
|
writer.writeField("data", value.bellatrixData.data)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
|
|
||||||
# Web3SignerRequest
|
# Web3SignerRequest
|
||||||
|
|
|
@ -52,9 +52,9 @@ type
|
||||||
|
|
||||||
ForkedHashedBeaconState* = object
|
ForkedHashedBeaconState* = object
|
||||||
case kind*: BeaconStateFork
|
case kind*: BeaconStateFork
|
||||||
of BeaconStateFork.Phase0: phase0Data*: phase0.HashedBeaconState
|
of BeaconStateFork.Phase0: phase0Data*: phase0.HashedBeaconState
|
||||||
of BeaconStateFork.Altair: altairData*: altair.HashedBeaconState
|
of BeaconStateFork.Altair: altairData*: altair.HashedBeaconState
|
||||||
of BeaconStateFork.Bellatrix: mergeData*: bellatrix.HashedBeaconState
|
of BeaconStateFork.Bellatrix: bellatrixData*: bellatrix.HashedBeaconState
|
||||||
|
|
||||||
BeaconBlockFork* {.pure.} = enum
|
BeaconBlockFork* {.pure.} = enum
|
||||||
Phase0
|
Phase0
|
||||||
|
@ -78,15 +78,15 @@ type
|
||||||
|
|
||||||
ForkedBeaconBlock* = object
|
ForkedBeaconBlock* = object
|
||||||
case kind*: BeaconBlockFork
|
case kind*: BeaconBlockFork
|
||||||
of BeaconBlockFork.Phase0: phase0Data*: phase0.BeaconBlock
|
of BeaconBlockFork.Phase0: phase0Data*: phase0.BeaconBlock
|
||||||
of BeaconBlockFork.Altair: altairData*: altair.BeaconBlock
|
of BeaconBlockFork.Altair: altairData*: altair.BeaconBlock
|
||||||
of BeaconBlockFork.Bellatrix: mergeData*: bellatrix.BeaconBlock
|
of BeaconBlockFork.Bellatrix: bellatrixData*: bellatrix.BeaconBlock
|
||||||
|
|
||||||
ForkedTrustedBeaconBlock* = object
|
ForkedTrustedBeaconBlock* = object
|
||||||
case kind*: BeaconBlockFork
|
case kind*: BeaconBlockFork
|
||||||
of BeaconBlockFork.Phase0: phase0Data*: phase0.TrustedBeaconBlock
|
of BeaconBlockFork.Phase0: phase0Data*: phase0.TrustedBeaconBlock
|
||||||
of BeaconBlockFork.Altair: altairData*: altair.TrustedBeaconBlock
|
of BeaconBlockFork.Altair: altairData*: altair.TrustedBeaconBlock
|
||||||
of BeaconBlockFork.Bellatrix: mergeData*: bellatrix.TrustedBeaconBlock
|
of BeaconBlockFork.Bellatrix: bellatrixData*: bellatrix.TrustedBeaconBlock
|
||||||
|
|
||||||
ForkySignedBeaconBlock* =
|
ForkySignedBeaconBlock* =
|
||||||
phase0.SignedBeaconBlock |
|
phase0.SignedBeaconBlock |
|
||||||
|
@ -95,9 +95,9 @@ type
|
||||||
|
|
||||||
ForkedSignedBeaconBlock* = object
|
ForkedSignedBeaconBlock* = object
|
||||||
case kind*: BeaconBlockFork
|
case kind*: BeaconBlockFork
|
||||||
of BeaconBlockFork.Phase0: phase0Data*: phase0.SignedBeaconBlock
|
of BeaconBlockFork.Phase0: phase0Data*: phase0.SignedBeaconBlock
|
||||||
of BeaconBlockFork.Altair: altairData*: altair.SignedBeaconBlock
|
of BeaconBlockFork.Altair: altairData*: altair.SignedBeaconBlock
|
||||||
of BeaconBlockFork.Bellatrix: mergeData*: bellatrix.SignedBeaconBlock
|
of BeaconBlockFork.Bellatrix: bellatrixData*: bellatrix.SignedBeaconBlock
|
||||||
|
|
||||||
ForkySigVerifiedSignedBeaconBlock* =
|
ForkySigVerifiedSignedBeaconBlock* =
|
||||||
phase0.SigVerifiedSignedBeaconBlock |
|
phase0.SigVerifiedSignedBeaconBlock |
|
||||||
|
@ -111,9 +111,9 @@ type
|
||||||
|
|
||||||
ForkedTrustedSignedBeaconBlock* = object
|
ForkedTrustedSignedBeaconBlock* = object
|
||||||
case kind*: BeaconBlockFork
|
case kind*: BeaconBlockFork
|
||||||
of BeaconBlockFork.Phase0: phase0Data*: phase0.TrustedSignedBeaconBlock
|
of BeaconBlockFork.Phase0: phase0Data*: phase0.TrustedSignedBeaconBlock
|
||||||
of BeaconBlockFork.Altair: altairData*: altair.TrustedSignedBeaconBlock
|
of BeaconBlockFork.Altair: altairData*: altair.TrustedSignedBeaconBlock
|
||||||
of BeaconBlockFork.Bellatrix: mergeData*: bellatrix.TrustedSignedBeaconBlock
|
of BeaconBlockFork.Bellatrix: bellatrixData*: bellatrix.TrustedSignedBeaconBlock
|
||||||
|
|
||||||
SomeForkySignedBeaconBlock* =
|
SomeForkySignedBeaconBlock* =
|
||||||
ForkySignedBeaconBlock |
|
ForkySignedBeaconBlock |
|
||||||
|
@ -152,28 +152,28 @@ template init*(T: type ForkedHashedBeaconState, data: phase0.HashedBeaconState):
|
||||||
template init*(T: type ForkedHashedBeaconState, data: altair.HashedBeaconState): T =
|
template init*(T: type ForkedHashedBeaconState, data: altair.HashedBeaconState): T =
|
||||||
T(kind: BeaconStateFork.Altair, altairData: data)
|
T(kind: BeaconStateFork.Altair, altairData: data)
|
||||||
template init*(T: type ForkedHashedBeaconState, data: bellatrix.HashedBeaconState): T =
|
template init*(T: type ForkedHashedBeaconState, data: bellatrix.HashedBeaconState): T =
|
||||||
T(kind: BeaconStateFork.Bellatrix, mergeData: data)
|
T(kind: BeaconStateFork.Bellatrix, bellatrixData: data)
|
||||||
|
|
||||||
template init*(T: type ForkedBeaconBlock, blck: phase0.BeaconBlock): T =
|
template init*(T: type ForkedBeaconBlock, blck: phase0.BeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
||||||
template init*(T: type ForkedBeaconBlock, blck: altair.BeaconBlock): T =
|
template init*(T: type ForkedBeaconBlock, blck: altair.BeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
||||||
template init*(T: type ForkedBeaconBlock, blck: bellatrix.BeaconBlock): T =
|
template init*(T: type ForkedBeaconBlock, blck: bellatrix.BeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Bellatrix, mergeData: blck)
|
T(kind: BeaconBlockFork.Bellatrix, bellatrixData: blck)
|
||||||
|
|
||||||
template init*(T: type ForkedTrustedBeaconBlock, blck: phase0.TrustedBeaconBlock): T =
|
template init*(T: type ForkedTrustedBeaconBlock, blck: phase0.TrustedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
||||||
template init*(T: type ForkedTrustedBeaconBlock, blck: altair.TrustedBeaconBlock): T =
|
template init*(T: type ForkedTrustedBeaconBlock, blck: altair.TrustedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
||||||
template init*(T: type ForkedTrustedBeaconBlock, blck: bellatrix.TrustedBeaconBlock): T =
|
template init*(T: type ForkedTrustedBeaconBlock, blck: bellatrix.TrustedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Bellatrix, mergeData: blck)
|
T(kind: BeaconBlockFork.Bellatrix, bellatrixData: blck)
|
||||||
|
|
||||||
template init*(T: type ForkedSignedBeaconBlock, blck: phase0.SignedBeaconBlock): T =
|
template init*(T: type ForkedSignedBeaconBlock, blck: phase0.SignedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
||||||
template init*(T: type ForkedSignedBeaconBlock, blck: altair.SignedBeaconBlock): T =
|
template init*(T: type ForkedSignedBeaconBlock, blck: altair.SignedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
||||||
template init*(T: type ForkedSignedBeaconBlock, blck: bellatrix.SignedBeaconBlock): T =
|
template init*(T: type ForkedSignedBeaconBlock, blck: bellatrix.SignedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Bellatrix, mergeData: blck)
|
T(kind: BeaconBlockFork.Bellatrix, bellatrixData: blck)
|
||||||
|
|
||||||
template init*(T: type ForkedSignedBeaconBlock, forked: ForkedBeaconBlock,
|
template init*(T: type ForkedSignedBeaconBlock, forked: ForkedBeaconBlock,
|
||||||
blockRoot: Eth2Digest, signature: ValidatorSig): T =
|
blockRoot: Eth2Digest, signature: ValidatorSig): T =
|
||||||
|
@ -190,16 +190,16 @@ template init*(T: type ForkedSignedBeaconBlock, forked: ForkedBeaconBlock,
|
||||||
signature: signature))
|
signature: signature))
|
||||||
of BeaconBlockFork.Bellatrix:
|
of BeaconBlockFork.Bellatrix:
|
||||||
T(kind: BeaconBlockFork.Bellatrix,
|
T(kind: BeaconBlockFork.Bellatrix,
|
||||||
mergeData: bellatrix.SignedBeaconBlock(message: forked.mergeData,
|
bellatrixData: bellatrix.SignedBeaconBlock(message: forked.bellatrixData,
|
||||||
root: blockRoot,
|
root: blockRoot,
|
||||||
signature: signature))
|
signature: signature))
|
||||||
|
|
||||||
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: phase0.TrustedSignedBeaconBlock): T =
|
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: phase0.TrustedSignedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
||||||
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: altair.TrustedSignedBeaconBlock): T =
|
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: altair.TrustedSignedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
||||||
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: bellatrix.TrustedSignedBeaconBlock): T =
|
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: bellatrix.TrustedSignedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Bellatrix, mergeData: blck)
|
T(kind: BeaconBlockFork.Bellatrix, bellatrixData: blck)
|
||||||
|
|
||||||
template toFork*[T: phase0.TrustedSignedBeaconBlock](
|
template toFork*[T: phase0.TrustedSignedBeaconBlock](
|
||||||
t: type T): BeaconBlockFork =
|
t: type T): BeaconBlockFork =
|
||||||
|
@ -220,7 +220,7 @@ template withState*(x: ForkedHashedBeaconState, body: untyped): untyped =
|
||||||
case x.kind
|
case x.kind
|
||||||
of BeaconStateFork.Bellatrix:
|
of BeaconStateFork.Bellatrix:
|
||||||
const stateFork {.inject, used.} = BeaconStateFork.Bellatrix
|
const stateFork {.inject, used.} = BeaconStateFork.Bellatrix
|
||||||
template state: untyped {.inject, used.} = x.mergeData
|
template state: untyped {.inject, used.} = x.bellatrixData
|
||||||
body
|
body
|
||||||
of BeaconStateFork.Altair:
|
of BeaconStateFork.Altair:
|
||||||
const stateFork {.inject, used.} = BeaconStateFork.Altair
|
const stateFork {.inject, used.} = BeaconStateFork.Altair
|
||||||
|
@ -259,11 +259,11 @@ func assign*(tgt: var ForkedHashedBeaconState, src: ForkedHashedBeaconState) =
|
||||||
if tgt.kind == src.kind:
|
if tgt.kind == src.kind:
|
||||||
case tgt.kind
|
case tgt.kind
|
||||||
of BeaconStateFork.Bellatrix:
|
of BeaconStateFork.Bellatrix:
|
||||||
assign(tgt.mergeData, src.mergeData):
|
assign(tgt.bellatrixData, src.bellatrixData):
|
||||||
of BeaconStateFork.Altair:
|
of BeaconStateFork.Altair:
|
||||||
assign(tgt.altairData, src.altairData):
|
assign(tgt.altairData, src.altairData):
|
||||||
of BeaconStateFork.Phase0:
|
of BeaconStateFork.Phase0:
|
||||||
assign(tgt.phase0Data, src.phase0Data):
|
assign(tgt.phase0Data, src.phase0Data):
|
||||||
else:
|
else:
|
||||||
# Ensure case object and discriminator get updated simultaneously, even
|
# Ensure case object and discriminator get updated simultaneously, even
|
||||||
# with nimOldCaseObjects. This is infrequent.
|
# with nimOldCaseObjects. This is infrequent.
|
||||||
|
@ -276,7 +276,7 @@ template getStateField*(x: ForkedHashedBeaconState, y: untyped): untyped =
|
||||||
# ```
|
# ```
|
||||||
# Without `unsafeAddr`, the `validators` list would be copied to a temporary variable.
|
# Without `unsafeAddr`, the `validators` list would be copied to a temporary variable.
|
||||||
(case x.kind
|
(case x.kind
|
||||||
of BeaconStateFork.Bellatrix: unsafeAddr x.mergeData.data.y
|
of BeaconStateFork.Bellatrix: unsafeAddr x.bellatrixData.data.y
|
||||||
of BeaconStateFork.Altair: unsafeAddr x.altairData.data.y
|
of BeaconStateFork.Altair: unsafeAddr x.altairData.data.y
|
||||||
of BeaconStateFork.Phase0: unsafeAddr x.phase0Data.data.y)[]
|
of BeaconStateFork.Phase0: unsafeAddr x.phase0Data.data.y)[]
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ template withBlck*(
|
||||||
body
|
body
|
||||||
of BeaconBlockFork.Bellatrix:
|
of BeaconBlockFork.Bellatrix:
|
||||||
const stateFork {.inject, used.} = BeaconStateFork.Bellatrix
|
const stateFork {.inject, used.} = BeaconStateFork.Bellatrix
|
||||||
template blck: untyped {.inject.} = x.mergeData
|
template blck: untyped {.inject.} = x.bellatrixData
|
||||||
body
|
body
|
||||||
|
|
||||||
func proposer_index*(x: ForkedBeaconBlock): uint64 =
|
func proposer_index*(x: ForkedBeaconBlock): uint64 =
|
||||||
|
@ -338,7 +338,7 @@ template getForkedBlockField*(x: ForkedSignedBeaconBlock | ForkedTrustedSignedBe
|
||||||
(case x.kind
|
(case x.kind
|
||||||
of BeaconBlockFork.Phase0: unsafeAddr x.phase0Data.message.y
|
of BeaconBlockFork.Phase0: unsafeAddr x.phase0Data.message.y
|
||||||
of BeaconBlockFork.Altair: unsafeAddr x.altairData.message.y
|
of BeaconBlockFork.Altair: unsafeAddr x.altairData.message.y
|
||||||
of BeaconBlockFork.Bellatrix: unsafeAddr x.mergeData.message.y)[]
|
of BeaconBlockFork.Bellatrix: unsafeAddr x.bellatrixData.message.y)[]
|
||||||
|
|
||||||
template signature*(x: ForkedSignedBeaconBlock): ValidatorSig =
|
template signature*(x: ForkedSignedBeaconBlock): ValidatorSig =
|
||||||
withBlck(x): blck.signature
|
withBlck(x): blck.signature
|
||||||
|
@ -370,8 +370,8 @@ template withStateAndBlck*(
|
||||||
case s.kind
|
case s.kind
|
||||||
of BeaconStateFork.Bellatrix:
|
of BeaconStateFork.Bellatrix:
|
||||||
const stateFork {.inject.} = BeaconStateFork.Bellatrix
|
const stateFork {.inject.} = BeaconStateFork.Bellatrix
|
||||||
template state: untyped {.inject.} = s.mergeData
|
template state: untyped {.inject.} = s.bellatrixData
|
||||||
template blck: untyped {.inject.} = b.mergeData
|
template blck: untyped {.inject.} = b.bellatrixData
|
||||||
body
|
body
|
||||||
of BeaconStateFork.Altair:
|
of BeaconStateFork.Altair:
|
||||||
const stateFork {.inject.} = BeaconStateFork.Altair
|
const stateFork {.inject.} = BeaconStateFork.Altair
|
||||||
|
@ -396,7 +396,7 @@ func altairFork*(cfg: RuntimeConfig): Fork =
|
||||||
current_version: cfg.ALTAIR_FORK_VERSION,
|
current_version: cfg.ALTAIR_FORK_VERSION,
|
||||||
epoch: cfg.ALTAIR_FORK_EPOCH)
|
epoch: cfg.ALTAIR_FORK_EPOCH)
|
||||||
|
|
||||||
func mergeFork*(cfg: RuntimeConfig): Fork =
|
func bellatrixFork*(cfg: RuntimeConfig): Fork =
|
||||||
# TODO in theory, the altair + merge forks could be in same epoch, so the
|
# TODO in theory, the altair + merge forks could be in same epoch, so the
|
||||||
# previous fork version would be the GENESIS_FORK_VERSION
|
# previous fork version would be the GENESIS_FORK_VERSION
|
||||||
Fork(
|
Fork(
|
||||||
|
@ -406,7 +406,7 @@ func mergeFork*(cfg: RuntimeConfig): Fork =
|
||||||
|
|
||||||
proc forkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Fork =
|
proc forkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Fork =
|
||||||
case cfg.stateForkAtEpoch(epoch)
|
case cfg.stateForkAtEpoch(epoch)
|
||||||
of BeaconStateFork.Bellatrix: cfg.mergeFork
|
of BeaconStateFork.Bellatrix: cfg.bellatrixFork
|
||||||
of BeaconStateFork.Altair: cfg.altairFork
|
of BeaconStateFork.Altair: cfg.altairFork
|
||||||
of BeaconStateFork.Phase0: cfg.genesisFork
|
of BeaconStateFork.Phase0: cfg.genesisFork
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ func getForkSchedule*(cfg: RuntimeConfig): array[3, Fork] =
|
||||||
## This procedure is used by HTTP REST framework and validator client.
|
## This procedure is used by HTTP REST framework and validator client.
|
||||||
##
|
##
|
||||||
## NOTE: Update this procedure when new fork will be scheduled.
|
## NOTE: Update this procedure when new fork will be scheduled.
|
||||||
[cfg.genesisFork(), cfg.altairFork(), cfg.mergeFork()]
|
[cfg.genesisFork(), cfg.altairFork(), cfg.bellatrixFork()]
|
||||||
|
|
||||||
type
|
type
|
||||||
# The first few fields of a state, shared across all forks
|
# The first few fields of a state, shared across all forks
|
||||||
|
|
|
@ -174,7 +174,7 @@ func maybeUpgradeStateToBellatrix(
|
||||||
var newState = upgrade_to_bellatrix(cfg, state.altairData.data)
|
var newState = upgrade_to_bellatrix(cfg, state.altairData.data)
|
||||||
state = (ref ForkedHashedBeaconState)(
|
state = (ref ForkedHashedBeaconState)(
|
||||||
kind: BeaconStateFork.Bellatrix,
|
kind: BeaconStateFork.Bellatrix,
|
||||||
mergeData: bellatrix.HashedBeaconState(
|
bellatrixData: bellatrix.HashedBeaconState(
|
||||||
root: hash_tree_root(newState[]), data: newState[]))[]
|
root: hash_tree_root(newState[]), data: newState[]))[]
|
||||||
|
|
||||||
proc maybeUpgradeState*(
|
proc maybeUpgradeState*(
|
||||||
|
@ -534,4 +534,4 @@ proc makeBeaconBlock*(
|
||||||
case state.kind
|
case state.kind
|
||||||
of BeaconStateFork.Phase0: makeBeaconBlock(phase0)
|
of BeaconStateFork.Phase0: makeBeaconBlock(phase0)
|
||||||
of BeaconStateFork.Altair: makeBeaconBlock(altair)
|
of BeaconStateFork.Altair: makeBeaconBlock(altair)
|
||||||
of BeaconStateFork.Bellatrix: makeBeaconBlock(merge)
|
of BeaconStateFork.Bellatrix: makeBeaconBlock(bellatrix)
|
||||||
|
|
|
@ -103,7 +103,7 @@ proc sendResponseChunk*(response: UntypedResponse,
|
||||||
response.peer.network.forkDigests.altair.data)
|
response.peer.network.forkDigests.altair.data)
|
||||||
of BeaconBlockFork.Bellatrix:
|
of BeaconBlockFork.Bellatrix:
|
||||||
response.stream.writeChunk(some ResponseCode.Success,
|
response.stream.writeChunk(some ResponseCode.Success,
|
||||||
SSZ.encode(val.mergeData),
|
SSZ.encode(val.bellatrixData),
|
||||||
response.peer.network.forkDigests.bellatrix.data)
|
response.peer.network.forkDigests.bellatrix.data)
|
||||||
|
|
||||||
func shortLog*(s: StatusMsg): auto =
|
func shortLog*(s: StatusMsg): auto =
|
||||||
|
|
|
@ -776,7 +776,7 @@ proc publishBlock*(vc: ValidatorClientRef,
|
||||||
of BeaconBlockFork.Bellatrix:
|
of BeaconBlockFork.Bellatrix:
|
||||||
raiseAssert "trying to publish merge block"
|
raiseAssert "trying to publish merge block"
|
||||||
# TODO this doesn't build due to some nim-presto error
|
# TODO this doesn't build due to some nim-presto error
|
||||||
# publishBlock(it, data.mergeData)
|
# publishBlock(it, data.bellatrixData)
|
||||||
do:
|
do:
|
||||||
if apiResponse.isErr():
|
if apiResponse.isErr():
|
||||||
debug "Unable to publish block", endpoint = node,
|
debug "Unable to publish block", endpoint = node,
|
||||||
|
|
|
@ -78,7 +78,7 @@ template saveSSZFile(filename: string, value: ForkedHashedBeaconState) =
|
||||||
case value.kind:
|
case value.kind:
|
||||||
of BeaconStateFork.Phase0: SSZ.saveFile(filename, value.phase0Data.data)
|
of BeaconStateFork.Phase0: SSZ.saveFile(filename, value.phase0Data.data)
|
||||||
of BeaconStateFork.Altair: SSZ.saveFile(filename, value.altairData.data)
|
of BeaconStateFork.Altair: SSZ.saveFile(filename, value.altairData.data)
|
||||||
of BeaconStateFork.Bellatrix: SSZ.saveFile(filename, value.mergeData.data)
|
of BeaconStateFork.Bellatrix: SSZ.saveFile(filename, value.bellatrixData.data)
|
||||||
|
|
||||||
proc doTransition(conf: NcliConf) =
|
proc doTransition(conf: NcliConf) =
|
||||||
let
|
let
|
||||||
|
|
|
@ -260,7 +260,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
|
||||||
elif T is altair.SignedBeaconBlock:
|
elif T is altair.SignedBeaconBlock:
|
||||||
addr stateData.data.altairData
|
addr stateData.data.altairData
|
||||||
elif T is bellatrix.SignedBeaconBlock:
|
elif T is bellatrix.SignedBeaconBlock:
|
||||||
addr stateData.data.mergeData
|
addr stateData.data.bellatrixData
|
||||||
else:
|
else:
|
||||||
static: doAssert false
|
static: doAssert false
|
||||||
message = makeBeaconBlock(
|
message = makeBeaconBlock(
|
||||||
|
|
|
@ -181,9 +181,9 @@ cli do(validatorsDir: string, secretsDir: string,
|
||||||
validators[proposer]).toValidatorSig())
|
validators[proposer]).toValidatorSig())
|
||||||
dump(".", signedBlock)
|
dump(".", signedBlock)
|
||||||
of BeaconBlockFork.Bellatrix:
|
of BeaconBlockFork.Bellatrix:
|
||||||
blockRoot = hash_tree_root(message.mergeData)
|
blockRoot = hash_tree_root(message.bellatrixData)
|
||||||
let signedBlock = bellatrix.SignedBeaconBlock(
|
let signedBlock = bellatrix.SignedBeaconBlock(
|
||||||
message: message.mergeData,
|
message: message.bellatrixData,
|
||||||
root: blockRoot,
|
root: blockRoot,
|
||||||
signature: get_block_signature(
|
signature: get_block_signature(
|
||||||
fork, genesis_validators_root, slot, blockRoot,
|
fork, genesis_validators_root, slot, blockRoot,
|
||||||
|
|
|
@ -36,9 +36,10 @@ proc runTest(testName, testDir, unitTestName: string) =
|
||||||
var
|
var
|
||||||
preState = newClone(parseTest(
|
preState = newClone(parseTest(
|
||||||
testPath/"pre.ssz_snappy", SSZ, bellatrix.BeaconState))
|
testPath/"pre.ssz_snappy", SSZ, bellatrix.BeaconState))
|
||||||
fhPreState = (ref ForkedHashedBeaconState)(mergeData: bellatrix.HashedBeaconState(
|
fhPreState = (ref ForkedHashedBeaconState)(
|
||||||
data: preState[], root: hash_tree_root(preState[])),
|
bellatrixData: bellatrix.HashedBeaconState(
|
||||||
kind: BeaconStateFork.Bellatrix)
|
data: preState[], root: hash_tree_root(preState[])),
|
||||||
|
kind: BeaconStateFork.Bellatrix)
|
||||||
cache = StateCache()
|
cache = StateCache()
|
||||||
info = ForkedEpochInfo()
|
info = ForkedEpochInfo()
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ proc runTest(testName, testDir, unitTestName: string) =
|
||||||
let postState = newClone(parseTest(
|
let postState = newClone(parseTest(
|
||||||
testPath/"post.ssz_snappy", SSZ, bellatrix.BeaconState))
|
testPath/"post.ssz_snappy", SSZ, bellatrix.BeaconState))
|
||||||
when false:
|
when false:
|
||||||
reportDiff(fhPreState.mergeData.data, postState)
|
reportDiff(fhPreState.bellatrixData.data, postState)
|
||||||
doAssert getStateRoot(fhPreState[]) == postState[].hash_tree_root()
|
doAssert getStateRoot(fhPreState[]) == postState[].hash_tree_root()
|
||||||
|
|
||||||
`testImpl _ blck _ testName`()
|
`testImpl _ blck _ testName`()
|
||||||
|
|
|
@ -31,7 +31,7 @@ proc runTest(identifier: string) =
|
||||||
preState = newClone(parseTest(
|
preState = newClone(parseTest(
|
||||||
testDir/"pre.ssz_snappy", SSZ, bellatrix.BeaconState))
|
testDir/"pre.ssz_snappy", SSZ, bellatrix.BeaconState))
|
||||||
fhPreState = (ref ForkedHashedBeaconState)(
|
fhPreState = (ref ForkedHashedBeaconState)(
|
||||||
mergeData: bellatrix.HashedBeaconState(
|
bellatrixData: bellatrix.HashedBeaconState(
|
||||||
data: preState[], root: hash_tree_root(preState[])),
|
data: preState[], root: hash_tree_root(preState[])),
|
||||||
kind: BeaconStateFork.Bellatrix)
|
kind: BeaconStateFork.Bellatrix)
|
||||||
cache = StateCache()
|
cache = StateCache()
|
||||||
|
@ -45,7 +45,7 @@ proc runTest(identifier: string) =
|
||||||
getStateField(fhPreState[], slot) + num_slots, cache, info, {}).isOk()
|
getStateField(fhPreState[], slot) + num_slots, cache, info, {}).isOk()
|
||||||
|
|
||||||
getStateRoot(fhPreState[]) == postState[].hash_tree_root()
|
getStateRoot(fhPreState[]) == postState[].hash_tree_root()
|
||||||
let newPreState = newClone(fhPreState.mergeData.data)
|
let newPreState = newClone(fhPreState.bellatrixData.data)
|
||||||
reportDiff(newPreState, postState)
|
reportDiff(newPreState, postState)
|
||||||
|
|
||||||
`testImpl _ slots _ identifier`()
|
`testImpl _ slots _ identifier`()
|
||||||
|
|
|
@ -248,8 +248,8 @@ suite "Beacon chain DB" & preset():
|
||||||
var db = makeTestDB(SLOTS_PER_EPOCH)
|
var db = makeTestDB(SLOTS_PER_EPOCH)
|
||||||
|
|
||||||
for state in testStatesBellatrix:
|
for state in testStatesBellatrix:
|
||||||
let root = state[].mergeData.root
|
let root = state[].bellatrixData.root
|
||||||
db.putState(root, state[].mergeData.data)
|
db.putState(root, state[].bellatrixData.data)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
db.containsState(root)
|
db.containsState(root)
|
||||||
|
@ -307,8 +307,8 @@ suite "Beacon chain DB" & preset():
|
||||||
let stateBuffer = (bellatrix.BeaconStateRef)()
|
let stateBuffer = (bellatrix.BeaconStateRef)()
|
||||||
|
|
||||||
for state in testStatesBellatrix:
|
for state in testStatesBellatrix:
|
||||||
let root = state[].mergeData.root
|
let root = state[].bellatrixData.root
|
||||||
db.putState(root, state[].mergeData.data)
|
db.putState(root, state[].bellatrixData.data)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
db.getState(root, stateBuffer[], noRollback)
|
db.getState(root, stateBuffer[], noRollback)
|
||||||
|
@ -378,7 +378,7 @@ suite "Beacon chain DB" & preset():
|
||||||
dag = init(ChainDAGRef, defaultRuntimeConfig, db, validatorMonitor, {})
|
dag = init(ChainDAGRef, defaultRuntimeConfig, db, validatorMonitor, {})
|
||||||
state = (ref ForkedHashedBeaconState)(
|
state = (ref ForkedHashedBeaconState)(
|
||||||
kind: BeaconStateFork.Bellatrix,
|
kind: BeaconStateFork.Bellatrix,
|
||||||
mergeData: bellatrix.HashedBeaconState(data: bellatrix.BeaconState(
|
bellatrixData: bellatrix.HashedBeaconState(data: bellatrix.BeaconState(
|
||||||
slot: 10.Slot)))
|
slot: 10.Slot)))
|
||||||
root = Eth2Digest()
|
root = Eth2Digest()
|
||||||
|
|
||||||
|
@ -390,8 +390,8 @@ suite "Beacon chain DB" & preset():
|
||||||
assign(state[], restoreAddr[].data)
|
assign(state[], restoreAddr[].data)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
state[].mergeData.data.slot == 10.Slot
|
state[].bellatrixData.data.slot == 10.Slot
|
||||||
not db.getState(root, state[].mergeData.data, restore)
|
not db.getState(root, state[].bellatrixData.data, restore)
|
||||||
|
|
||||||
# assign() has switched the case object fork
|
# assign() has switched the case object fork
|
||||||
state[].kind == BeaconStateFork.Phase0
|
state[].kind == BeaconStateFork.Phase0
|
||||||
|
|
|
@ -205,7 +205,7 @@ suite "Gossip validation - Extra": # Not based on preset config
|
||||||
dag.addHeadBlock(verifier, blck.altairData, nilCallback)
|
dag.addHeadBlock(verifier, blck.altairData, nilCallback)
|
||||||
of BeaconBlockFork.Bellatrix:
|
of BeaconBlockFork.Bellatrix:
|
||||||
const nilCallback = OnMergeBlockAdded(nil)
|
const nilCallback = OnMergeBlockAdded(nil)
|
||||||
dag.addHeadBlock(verifier, blck.mergeData, nilCallback)
|
dag.addHeadBlock(verifier, blck.bellatrixData, nilCallback)
|
||||||
check: added.isOk()
|
check: added.isOk()
|
||||||
dag.updateHead(added[], quarantine[])
|
dag.updateHead(added[], quarantine[])
|
||||||
dag
|
dag
|
||||||
|
|
Loading…
Reference in New Issue