mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-23 11:48:33 +00:00
convert remaining toFork
-> kind
for consistency (#5462)
We currently have multiple ways to obtain `ConsensusFork` or `LcDataFork` from a forky type. Rename `toFork` to `kind` for a consistent API naming.
This commit is contained in:
parent
4fb95d000d
commit
7c45b8f98d
@ -779,7 +779,7 @@ proc putBlock*(
|
|||||||
db: BeaconChainDB,
|
db: BeaconChainDB,
|
||||||
value: phase0.TrustedSignedBeaconBlock | altair.TrustedSignedBeaconBlock) =
|
value: phase0.TrustedSignedBeaconBlock | altair.TrustedSignedBeaconBlock) =
|
||||||
db.withManyWrites:
|
db.withManyWrites:
|
||||||
db.blocks[type(value).toFork].putSnappySSZ(value.root.data, value)
|
db.blocks[type(value).kind].putSnappySSZ(value.root.data, value)
|
||||||
db.putBeaconBlockSummary(value.root, value.message.toBeaconBlockSummary())
|
db.putBeaconBlockSummary(value.root, value.message.toBeaconBlockSummary())
|
||||||
|
|
||||||
proc putBlock*(
|
proc putBlock*(
|
||||||
@ -787,7 +787,7 @@ proc putBlock*(
|
|||||||
value: bellatrix.TrustedSignedBeaconBlock |
|
value: bellatrix.TrustedSignedBeaconBlock |
|
||||||
capella.TrustedSignedBeaconBlock | deneb.TrustedSignedBeaconBlock) =
|
capella.TrustedSignedBeaconBlock | deneb.TrustedSignedBeaconBlock) =
|
||||||
db.withManyWrites:
|
db.withManyWrites:
|
||||||
db.blocks[type(value).toFork].putSZSSZ(value.root.data, value)
|
db.blocks[type(value).kind].putSZSSZ(value.root.data, value)
|
||||||
db.putBeaconBlockSummary(value.root, value.message.toBeaconBlockSummary())
|
db.putBeaconBlockSummary(value.root, value.message.toBeaconBlockSummary())
|
||||||
|
|
||||||
proc putBlobSidecar*(
|
proc putBlobSidecar*(
|
||||||
@ -838,14 +838,14 @@ proc putState*(
|
|||||||
db: BeaconChainDB, key: Eth2Digest,
|
db: BeaconChainDB, key: Eth2Digest,
|
||||||
value: phase0.BeaconState | altair.BeaconState) =
|
value: phase0.BeaconState | altair.BeaconState) =
|
||||||
db.updateImmutableValidators(value.validators.asSeq())
|
db.updateImmutableValidators(value.validators.asSeq())
|
||||||
db.statesNoVal[type(value).toFork()].putSnappySSZ(
|
db.statesNoVal[type(value).kind].putSnappySSZ(
|
||||||
key.data, toBeaconStateNoImmutableValidators(value))
|
key.data, toBeaconStateNoImmutableValidators(value))
|
||||||
|
|
||||||
proc putState*(
|
proc putState*(
|
||||||
db: BeaconChainDB, key: Eth2Digest,
|
db: BeaconChainDB, key: Eth2Digest,
|
||||||
value: bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState) =
|
value: bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState) =
|
||||||
db.updateImmutableValidators(value.validators.asSeq())
|
db.updateImmutableValidators(value.validators.asSeq())
|
||||||
db.statesNoVal[type(value).toFork()].putSZSSZ(
|
db.statesNoVal[type(value).kind].putSZSSZ(
|
||||||
key.data, toBeaconStateNoImmutableValidators(value))
|
key.data, toBeaconStateNoImmutableValidators(value))
|
||||||
|
|
||||||
proc putState*(db: BeaconChainDB, state: ForkyHashedBeaconState) =
|
proc putState*(db: BeaconChainDB, state: ForkyHashedBeaconState) =
|
||||||
@ -951,7 +951,7 @@ proc getBlock*(
|
|||||||
T: type phase0.TrustedSignedBeaconBlock): Opt[T] =
|
T: type phase0.TrustedSignedBeaconBlock): Opt[T] =
|
||||||
# We only store blocks that we trust in the database
|
# We only store blocks that we trust in the database
|
||||||
result.ok(default(T))
|
result.ok(default(T))
|
||||||
if db.blocks[T.toFork].getSnappySSZ(key.data, result.get) != GetResult.found:
|
if db.blocks[T.kind].getSnappySSZ(key.data, result.get) != GetResult.found:
|
||||||
# During the initial releases phase0, we stored blocks in a different table
|
# During the initial releases phase0, we stored blocks in a different table
|
||||||
result = db.v0.getPhase0Block(key)
|
result = db.v0.getPhase0Block(key)
|
||||||
else:
|
else:
|
||||||
@ -963,7 +963,7 @@ proc getBlock*(
|
|||||||
T: type altair.TrustedSignedBeaconBlock): Opt[T] =
|
T: type altair.TrustedSignedBeaconBlock): Opt[T] =
|
||||||
# We only store blocks that we trust in the database
|
# We only store blocks that we trust in the database
|
||||||
result.ok(default(T))
|
result.ok(default(T))
|
||||||
if db.blocks[T.toFork].getSnappySSZ(key.data, result.get) == GetResult.found:
|
if db.blocks[T.kind].getSnappySSZ(key.data, result.get) == GetResult.found:
|
||||||
# set root after deserializing (so it doesn't get zeroed)
|
# set root after deserializing (so it doesn't get zeroed)
|
||||||
result.get().root = key
|
result.get().root = key
|
||||||
else:
|
else:
|
||||||
@ -976,7 +976,7 @@ proc getBlock*[
|
|||||||
T: type X): Opt[T] =
|
T: type X): Opt[T] =
|
||||||
# We only store blocks that we trust in the database
|
# We only store blocks that we trust in the database
|
||||||
result.ok(default(T))
|
result.ok(default(T))
|
||||||
if db.blocks[T.toFork].getSZSSZ(key.data, result.get) == GetResult.found:
|
if db.blocks[T.kind].getSZSSZ(key.data, result.get) == GetResult.found:
|
||||||
# set root after deserializing (so it doesn't get zeroed)
|
# set root after deserializing (so it doesn't get zeroed)
|
||||||
result.get().root = key
|
result.get().root = key
|
||||||
else:
|
else:
|
||||||
@ -1022,7 +1022,7 @@ proc getBlockSSZ*(
|
|||||||
func decode(data: openArray[byte]) =
|
func decode(data: openArray[byte]) =
|
||||||
dataPtr[] = snappy.decode(data)
|
dataPtr[] = snappy.decode(data)
|
||||||
success = dataPtr[].len > 0
|
success = dataPtr[].len > 0
|
||||||
db.blocks[T.toFork].get(key.data, decode).expectDb() and success
|
db.blocks[T.kind].get(key.data, decode).expectDb() and success
|
||||||
|
|
||||||
proc getBlockSSZ*[
|
proc getBlockSSZ*[
|
||||||
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
||||||
@ -1033,7 +1033,7 @@ proc getBlockSSZ*[
|
|||||||
func decode(data: openArray[byte]) =
|
func decode(data: openArray[byte]) =
|
||||||
dataPtr[] = decodeFramed(data, checkIntegrity = false)
|
dataPtr[] = decodeFramed(data, checkIntegrity = false)
|
||||||
success = dataPtr[].len > 0
|
success = dataPtr[].len > 0
|
||||||
db.blocks[T.toFork].get(key.data, decode).expectDb() and success
|
db.blocks[T.kind].get(key.data, decode).expectDb() and success
|
||||||
|
|
||||||
proc getBlockSSZ*(
|
proc getBlockSSZ*(
|
||||||
db: BeaconChainDB, key: Eth2Digest, data: var seq[byte],
|
db: BeaconChainDB, key: Eth2Digest, data: var seq[byte],
|
||||||
@ -1077,7 +1077,7 @@ proc getBlockSZ*(
|
|||||||
func decode(data: openArray[byte]) =
|
func decode(data: openArray[byte]) =
|
||||||
dataPtr[] = snappy.encodeFramed(snappy.decode(data))
|
dataPtr[] = snappy.encodeFramed(snappy.decode(data))
|
||||||
success = dataPtr[].len > 0
|
success = dataPtr[].len > 0
|
||||||
db.blocks[T.toFork].get(key.data, decode).expectDb() and success
|
db.blocks[T.kind].get(key.data, decode).expectDb() and success
|
||||||
|
|
||||||
proc getBlockSZ*[
|
proc getBlockSZ*[
|
||||||
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
||||||
@ -1086,7 +1086,7 @@ proc getBlockSZ*[
|
|||||||
let dataPtr = addr data # Short-lived
|
let dataPtr = addr data # Short-lived
|
||||||
func decode(data: openArray[byte]) =
|
func decode(data: openArray[byte]) =
|
||||||
assign(dataPtr[], data)
|
assign(dataPtr[], data)
|
||||||
db.blocks[T.toFork].get(key.data, decode).expectDb()
|
db.blocks[T.kind].get(key.data, decode).expectDb()
|
||||||
|
|
||||||
proc getBlockSZ*(
|
proc getBlockSZ*(
|
||||||
db: BeaconChainDB, key: Eth2Digest, data: var seq[byte],
|
db: BeaconChainDB, key: Eth2Digest, data: var seq[byte],
|
||||||
@ -1258,7 +1258,7 @@ proc getState*(
|
|||||||
type T = type(output)
|
type T = type(output)
|
||||||
|
|
||||||
if not getStateOnlyMutableValidators(
|
if not getStateOnlyMutableValidators(
|
||||||
db.immutableValidators, db.statesNoVal[T.toFork], key.data, output, rollback):
|
db.immutableValidators, db.statesNoVal[T.kind], key.data, output, rollback):
|
||||||
db.v0.getState(db.immutableValidators, key, output, rollback)
|
db.v0.getState(db.immutableValidators, key, output, rollback)
|
||||||
else:
|
else:
|
||||||
true
|
true
|
||||||
@ -1278,7 +1278,7 @@ proc getState*(
|
|||||||
# https://github.com/nim-lang/Nim/issues/14126
|
# https://github.com/nim-lang/Nim/issues/14126
|
||||||
type T = type(output)
|
type T = type(output)
|
||||||
getStateOnlyMutableValidators(
|
getStateOnlyMutableValidators(
|
||||||
db.immutableValidators, db.statesNoVal[T.toFork], key.data, output,
|
db.immutableValidators, db.statesNoVal[T.kind], key.data, output,
|
||||||
rollback)
|
rollback)
|
||||||
|
|
||||||
proc getState*(
|
proc getState*(
|
||||||
@ -1340,14 +1340,14 @@ proc containsBlock*(db: BeaconChainDBV0, key: Eth2Digest): bool =
|
|||||||
proc containsBlock*(
|
proc containsBlock*(
|
||||||
db: BeaconChainDB, key: Eth2Digest,
|
db: BeaconChainDB, key: Eth2Digest,
|
||||||
T: type phase0.TrustedSignedBeaconBlock): bool =
|
T: type phase0.TrustedSignedBeaconBlock): bool =
|
||||||
db.blocks[T.toFork].contains(key.data).expectDb() or
|
db.blocks[T.kind].contains(key.data).expectDb() or
|
||||||
db.v0.containsBlock(key)
|
db.v0.containsBlock(key)
|
||||||
|
|
||||||
proc containsBlock*[
|
proc containsBlock*[
|
||||||
X: altair.TrustedSignedBeaconBlock | bellatrix.TrustedSignedBeaconBlock |
|
X: altair.TrustedSignedBeaconBlock | bellatrix.TrustedSignedBeaconBlock |
|
||||||
capella.TrustedSignedBeaconBlock | deneb.TrustedSignedBeaconBlock](
|
capella.TrustedSignedBeaconBlock | deneb.TrustedSignedBeaconBlock](
|
||||||
db: BeaconChainDB, key: Eth2Digest, T: type X): bool =
|
db: BeaconChainDB, key: Eth2Digest, T: type X): bool =
|
||||||
db.blocks[X.toFork].contains(key.data).expectDb()
|
db.blocks[X.kind].contains(key.data).expectDb()
|
||||||
|
|
||||||
proc containsBlock*(db: BeaconChainDB, key: Eth2Digest, fork: ConsensusFork): bool =
|
proc containsBlock*(db: BeaconChainDB, key: Eth2Digest, fork: ConsensusFork): bool =
|
||||||
case fork
|
case fork
|
||||||
|
@ -241,7 +241,7 @@ proc getBeaconBlockValidatorChanges*(
|
|||||||
pool.proposer_slashings, cfg, state, indices, res.proposer_slashings)
|
pool.proposer_slashings, cfg, state, indices, res.proposer_slashings)
|
||||||
getValidatorChangeMessagesForBlock(
|
getValidatorChangeMessagesForBlock(
|
||||||
pool.voluntary_exits, cfg, state, indices, res.voluntary_exits)
|
pool.voluntary_exits, cfg, state, indices, res.voluntary_exits)
|
||||||
when typeof(state).toFork() >= ConsensusFork.Capella:
|
when typeof(state).kind >= ConsensusFork.Capella:
|
||||||
# Prioritize these
|
# Prioritize these
|
||||||
getValidatorChangeMessagesForBlock(
|
getValidatorChangeMessagesForBlock(
|
||||||
pool.bls_to_execution_changes_api, cfg, state, indices,
|
pool.bls_to_execution_changes_api, cfg, state, indices,
|
||||||
|
@ -899,13 +899,13 @@ template payload(response: engine_api.GetPayloadV3Response): engine_api.Executio
|
|||||||
template toEngineWithdrawals*(withdrawals: seq[capella.Withdrawal]): seq[WithdrawalV1] =
|
template toEngineWithdrawals*(withdrawals: seq[capella.Withdrawal]): seq[WithdrawalV1] =
|
||||||
mapIt(withdrawals, toEngineWithdrawal(it))
|
mapIt(withdrawals, toEngineWithdrawal(it))
|
||||||
|
|
||||||
template toFork(T: type ExecutionPayloadV1): ConsensusFork =
|
template kind(T: type ExecutionPayloadV1): ConsensusFork =
|
||||||
ConsensusFork.Bellatrix
|
ConsensusFork.Bellatrix
|
||||||
|
|
||||||
template toFork(T: typedesc[ExecutionPayloadV1OrV2|ExecutionPayloadV2]): ConsensusFork =
|
template kind(T: typedesc[ExecutionPayloadV1OrV2|ExecutionPayloadV2]): ConsensusFork =
|
||||||
ConsensusFork.Capella
|
ConsensusFork.Capella
|
||||||
|
|
||||||
template toFork(T: type ExecutionPayloadV3): ConsensusFork =
|
template kind(T: type ExecutionPayloadV3): ConsensusFork =
|
||||||
ConsensusFork.Deneb
|
ConsensusFork.Deneb
|
||||||
|
|
||||||
proc getPayload*(m: ELManager,
|
proc getPayload*(m: ELManager,
|
||||||
@ -950,7 +950,7 @@ proc getPayload*(m: ELManager,
|
|||||||
url = m.elConnections[idx].engineUrl.url,
|
url = m.elConnections[idx].engineUrl.url,
|
||||||
err = req.error.msg
|
err = req.error.msg
|
||||||
else:
|
else:
|
||||||
const payloadFork = PayloadType.toFork
|
const payloadFork = PayloadType.kind
|
||||||
when payloadFork >= ConsensusFork.Capella:
|
when payloadFork >= ConsensusFork.Capella:
|
||||||
when payloadFork == ConsensusFork.Capella:
|
when payloadFork == ConsensusFork.Capella:
|
||||||
# TODO: The engine_api module may offer an alternative API where it is guaranteed
|
# TODO: The engine_api module may offer an alternative API where it is guaranteed
|
||||||
|
@ -183,7 +183,7 @@ proc storeBackfillBlock(
|
|||||||
# Establish blob viability before calling addbackfillBlock to avoid
|
# Establish blob viability before calling addbackfillBlock to avoid
|
||||||
# writing the block in case of blob error.
|
# writing the block in case of blob error.
|
||||||
var blobsOk = true
|
var blobsOk = true
|
||||||
when typeof(signedBlock).toFork() >= ConsensusFork.Deneb:
|
when typeof(signedBlock).kind >= ConsensusFork.Deneb:
|
||||||
if blobsOpt.isSome:
|
if blobsOpt.isSome:
|
||||||
let blobs = blobsOpt.get()
|
let blobs = blobsOpt.get()
|
||||||
let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq
|
let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq
|
||||||
@ -245,7 +245,7 @@ proc expectValidForkchoiceUpdated(
|
|||||||
finalizedBlockHash = finalizedBlockHash,
|
finalizedBlockHash = finalizedBlockHash,
|
||||||
payloadAttributes = none headBlockPayloadAttributesType)
|
payloadAttributes = none headBlockPayloadAttributesType)
|
||||||
receivedExecutionBlockHash =
|
receivedExecutionBlockHash =
|
||||||
when typeof(receivedBlock).toFork >= ConsensusFork.Bellatrix:
|
when typeof(receivedBlock).kind >= ConsensusFork.Bellatrix:
|
||||||
receivedBlock.message.body.execution_payload.block_hash
|
receivedBlock.message.body.execution_payload.block_hash
|
||||||
else:
|
else:
|
||||||
# https://github.com/nim-lang/Nim/issues/19802
|
# https://github.com/nim-lang/Nim/issues/19802
|
||||||
@ -487,7 +487,7 @@ proc storeBlock(
|
|||||||
# progress in its own sync.
|
# progress in its own sync.
|
||||||
NewPayloadStatus.noResponse
|
NewPayloadStatus.noResponse
|
||||||
else:
|
else:
|
||||||
when typeof(signedBlock).toFork() >= ConsensusFork.Bellatrix:
|
when typeof(signedBlock).kind >= ConsensusFork.Bellatrix:
|
||||||
await self.consensusManager.elManager.getExecutionValidity(signedBlock)
|
await self.consensusManager.elManager.getExecutionValidity(signedBlock)
|
||||||
else:
|
else:
|
||||||
NewPayloadStatus.valid # vacuously
|
NewPayloadStatus.valid # vacuously
|
||||||
@ -508,7 +508,7 @@ proc storeBlock(
|
|||||||
# Client software MUST validate `blockHash` value as being equivalent to
|
# Client software MUST validate `blockHash` value as being equivalent to
|
||||||
# `Keccak256(RLP(ExecutionBlockHeader))`
|
# `Keccak256(RLP(ExecutionBlockHeader))`
|
||||||
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/paris.md#specification
|
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/paris.md#specification
|
||||||
when typeof(signedBlock).toFork() >= ConsensusFork.Bellatrix:
|
when typeof(signedBlock).kind >= ConsensusFork.Bellatrix:
|
||||||
template payload(): auto = signedBlock.message.body.execution_payload
|
template payload(): auto = signedBlock.message.body.execution_payload
|
||||||
if signedBlock.message.is_execution_block and
|
if signedBlock.message.is_execution_block and
|
||||||
payload.block_hash !=
|
payload.block_hash !=
|
||||||
@ -527,7 +527,7 @@ proc storeBlock(
|
|||||||
# TODO with v1.4.0, not sure this is still relevant
|
# TODO with v1.4.0, not sure this is still relevant
|
||||||
# Establish blob viability before calling addHeadBlock to avoid
|
# Establish blob viability before calling addHeadBlock to avoid
|
||||||
# writing the block in case of blob error.
|
# writing the block in case of blob error.
|
||||||
when typeof(signedBlock).toFork() >= ConsensusFork.Deneb:
|
when typeof(signedBlock).kind >= ConsensusFork.Deneb:
|
||||||
if blobsOpt.isSome:
|
if blobsOpt.isSome:
|
||||||
let blobs = blobsOpt.get()
|
let blobs = blobsOpt.get()
|
||||||
let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq
|
let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq
|
||||||
@ -732,7 +732,7 @@ proc storeBlock(
|
|||||||
quarantined = shortLog(quarantined.root)
|
quarantined = shortLog(quarantined.root)
|
||||||
|
|
||||||
withBlck(quarantined):
|
withBlck(quarantined):
|
||||||
when typeof(forkyBlck).toFork() < ConsensusFork.Deneb:
|
when typeof(forkyBlck).kind < ConsensusFork.Deneb:
|
||||||
self[].enqueueBlock(
|
self[].enqueueBlock(
|
||||||
MsgSource.gossip, quarantined, Opt.none(BlobSidecars))
|
MsgSource.gossip, quarantined, Opt.none(BlobSidecars))
|
||||||
else:
|
else:
|
||||||
|
@ -240,7 +240,7 @@ proc processSignedBeaconBlock*(
|
|||||||
trace "Block validated"
|
trace "Block validated"
|
||||||
|
|
||||||
let blobs =
|
let blobs =
|
||||||
when typeof(signedBlock).toFork() >= ConsensusFork.Deneb:
|
when typeof(signedBlock).kind >= ConsensusFork.Deneb:
|
||||||
if self.blobQuarantine[].hasBlobs(signedBlock):
|
if self.blobQuarantine[].hasBlobs(signedBlock):
|
||||||
Opt.some(self.blobQuarantine[].popBlobs(signedBlock.root))
|
Opt.some(self.blobQuarantine[].popBlobs(signedBlock.root))
|
||||||
else:
|
else:
|
||||||
|
@ -344,7 +344,7 @@ proc initFullNode(
|
|||||||
maybeFinalized: bool):
|
maybeFinalized: bool):
|
||||||
Future[Result[void, VerifierError]] =
|
Future[Result[void, VerifierError]] =
|
||||||
withBlck(signedBlock):
|
withBlck(signedBlock):
|
||||||
when typeof(forkyBlck).toFork() >= ConsensusFork.Deneb:
|
when typeof(forkyBlck).kind >= ConsensusFork.Deneb:
|
||||||
if not blobQuarantine[].hasBlobs(forkyBlck):
|
if not blobQuarantine[].hasBlobs(forkyBlck):
|
||||||
# We don't have all the blobs for this block, so we have
|
# We don't have all the blobs for this block, so we have
|
||||||
# to put it in blobless quarantine.
|
# to put it in blobless quarantine.
|
||||||
@ -1190,7 +1190,7 @@ proc pruneBlobs(node: BeaconNode, slot: Slot) =
|
|||||||
for i in startIndex..<SLOTS_PER_EPOCH:
|
for i in startIndex..<SLOTS_PER_EPOCH:
|
||||||
let blck = node.dag.getForkedBlock(blocks[int(i)]).valueOr: continue
|
let blck = node.dag.getForkedBlock(blocks[int(i)]).valueOr: continue
|
||||||
withBlck(blck):
|
withBlck(blck):
|
||||||
when typeof(forkyBlck).toFork() < ConsensusFork.Deneb: continue
|
when typeof(forkyBlck).kind < ConsensusFork.Deneb: continue
|
||||||
else:
|
else:
|
||||||
for j in 0..len(forkyBlck.message.body.blob_kzg_commitments) - 1:
|
for j in 0..len(forkyBlck.message.body.blob_kzg_commitments) - 1:
|
||||||
if node.db.delBlobSidecar(blocks[int(i)].root, BlobIndex(j)):
|
if node.db.delBlobSidecar(blocks[int(i)].root, BlobIndex(j)):
|
||||||
|
@ -636,7 +636,7 @@ proc check_attestation*(
|
|||||||
data,
|
data,
|
||||||
get_committee_count_per_slot(state, epoch, cache))
|
get_committee_count_per_slot(state, epoch, cache))
|
||||||
|
|
||||||
? check_attestation_inclusion((typeof state).toFork, slot, state.slot)
|
? check_attestation_inclusion((typeof state).kind, slot, state.slot)
|
||||||
|
|
||||||
let committee_len = get_beacon_committee_len(
|
let committee_len = get_beacon_committee_len(
|
||||||
state, slot, committee_index, cache)
|
state, slot, committee_index, cache)
|
||||||
@ -1005,7 +1005,7 @@ proc initialize_beacon_state_from_eth1*(
|
|||||||
# at that point :)
|
# at that point :)
|
||||||
doAssert deposits.lenu64 >= SLOTS_PER_EPOCH
|
doAssert deposits.lenu64 >= SLOTS_PER_EPOCH
|
||||||
|
|
||||||
const consensusFork = typeof(execution_payload_header).toFork
|
const consensusFork = typeof(execution_payload_header).kind
|
||||||
let
|
let
|
||||||
forkVersion = cfg.forkVersion(consensusFork)
|
forkVersion = cfg.forkVersion(consensusFork)
|
||||||
fork = Fork(
|
fork = Fork(
|
||||||
|
@ -178,7 +178,7 @@ proc publishSszBlock*(
|
|||||||
): Future[RestPlainResponse] {.async.} =
|
): Future[RestPlainResponse] {.async.} =
|
||||||
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlock
|
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlock
|
||||||
let
|
let
|
||||||
consensus = typeof(blck).toFork.toString()
|
consensus = typeof(blck).kind.toString()
|
||||||
resp = await client.publishBlock(
|
resp = await client.publishBlock(
|
||||||
blck, restContentType = $OctetStreamMediaType,
|
blck, restContentType = $OctetStreamMediaType,
|
||||||
extraHeaders = @[("eth-consensus-version", consensus)])
|
extraHeaders = @[("eth-consensus-version", consensus)])
|
||||||
@ -216,7 +216,7 @@ proc publishBlockV2*(
|
|||||||
deneb.SignedBeaconBlock
|
deneb.SignedBeaconBlock
|
||||||
): Future[RestPlainResponse] {.async} =
|
): Future[RestPlainResponse] {.async} =
|
||||||
let
|
let
|
||||||
consensus = typeof(blck).toFork.toString()
|
consensus = typeof(blck).kind.toString()
|
||||||
resp = await client.publishBlockV2Plain(
|
resp = await client.publishBlockV2Plain(
|
||||||
blck, extraHeaders = @[
|
blck, extraHeaders = @[
|
||||||
("eth-consensus-version", consensus),
|
("eth-consensus-version", consensus),
|
||||||
@ -251,7 +251,7 @@ proc publishSszBlindedBlock*(
|
|||||||
): Future[RestPlainResponse] {.async.} =
|
): Future[RestPlainResponse] {.async.} =
|
||||||
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock
|
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock
|
||||||
let
|
let
|
||||||
consensus = typeof(blck).toFork.toString()
|
consensus = typeof(blck).kind.toString()
|
||||||
resp = await client.publishBlindedBlock(
|
resp = await client.publishBlindedBlock(
|
||||||
blck, restContentType = $OctetStreamMediaType,
|
blck, restContentType = $OctetStreamMediaType,
|
||||||
extraHeaders = @[("eth-consensus-version", consensus)])
|
extraHeaders = @[("eth-consensus-version", consensus)])
|
||||||
|
@ -256,27 +256,86 @@ type
|
|||||||
|
|
||||||
template kind*(
|
template kind*(
|
||||||
x: typedesc[
|
x: typedesc[
|
||||||
phase0.HashedBeaconState]): ConsensusFork =
|
phase0.BeaconState |
|
||||||
|
phase0.HashedBeaconState |
|
||||||
|
phase0.BeaconBlock |
|
||||||
|
phase0.SignedBeaconBlock |
|
||||||
|
phase0.TrustedBeaconBlock |
|
||||||
|
phase0.BeaconBlockBody |
|
||||||
|
phase0.SigVerifiedBeaconBlockBody |
|
||||||
|
phase0.TrustedBeaconBlockBody |
|
||||||
|
phase0.SigVerifiedSignedBeaconBlock |
|
||||||
|
phase0.MsgTrustedSignedBeaconBlock |
|
||||||
|
phase0.TrustedSignedBeaconBlock]): ConsensusFork =
|
||||||
ConsensusFork.Phase0
|
ConsensusFork.Phase0
|
||||||
|
|
||||||
template kind*(
|
template kind*(
|
||||||
x: typedesc[
|
x: typedesc[
|
||||||
altair.HashedBeaconState]): ConsensusFork =
|
altair.BeaconState |
|
||||||
|
altair.HashedBeaconState |
|
||||||
|
altair.BeaconBlock |
|
||||||
|
altair.SignedBeaconBlock |
|
||||||
|
altair.TrustedBeaconBlock |
|
||||||
|
altair.BeaconBlockBody |
|
||||||
|
altair.SigVerifiedBeaconBlockBody |
|
||||||
|
altair.TrustedBeaconBlockBody |
|
||||||
|
altair.SigVerifiedSignedBeaconBlock |
|
||||||
|
altair.MsgTrustedSignedBeaconBlock |
|
||||||
|
altair.TrustedSignedBeaconBlock]): ConsensusFork =
|
||||||
ConsensusFork.Altair
|
ConsensusFork.Altair
|
||||||
|
|
||||||
template kind*(
|
template kind*(
|
||||||
x: typedesc[
|
x: typedesc[
|
||||||
bellatrix.HashedBeaconState]): ConsensusFork =
|
bellatrix.BeaconState |
|
||||||
|
bellatrix.HashedBeaconState |
|
||||||
|
bellatrix.ExecutionPayload |
|
||||||
|
bellatrix.ExecutionPayloadForSigning |
|
||||||
|
bellatrix.ExecutionPayloadHeader |
|
||||||
|
bellatrix.BeaconBlock |
|
||||||
|
bellatrix.SignedBeaconBlock |
|
||||||
|
bellatrix.TrustedBeaconBlock |
|
||||||
|
bellatrix.BeaconBlockBody |
|
||||||
|
bellatrix.SigVerifiedBeaconBlockBody |
|
||||||
|
bellatrix.TrustedBeaconBlockBody |
|
||||||
|
bellatrix.SigVerifiedSignedBeaconBlock |
|
||||||
|
bellatrix.MsgTrustedSignedBeaconBlock |
|
||||||
|
bellatrix.TrustedSignedBeaconBlock]): ConsensusFork =
|
||||||
ConsensusFork.Bellatrix
|
ConsensusFork.Bellatrix
|
||||||
|
|
||||||
template kind*(
|
template kind*(
|
||||||
x: typedesc[
|
x: typedesc[
|
||||||
capella.HashedBeaconState]): ConsensusFork =
|
capella.BeaconState |
|
||||||
|
capella.HashedBeaconState |
|
||||||
|
capella.ExecutionPayload |
|
||||||
|
capella.ExecutionPayloadForSigning |
|
||||||
|
capella.ExecutionPayloadHeader |
|
||||||
|
capella.BeaconBlock |
|
||||||
|
capella.SignedBeaconBlock |
|
||||||
|
capella.TrustedBeaconBlock |
|
||||||
|
capella.BeaconBlockBody |
|
||||||
|
capella.SigVerifiedBeaconBlockBody |
|
||||||
|
capella.TrustedBeaconBlockBody |
|
||||||
|
capella.SigVerifiedSignedBeaconBlock |
|
||||||
|
capella.MsgTrustedSignedBeaconBlock |
|
||||||
|
capella.TrustedSignedBeaconBlock]): ConsensusFork =
|
||||||
ConsensusFork.Capella
|
ConsensusFork.Capella
|
||||||
|
|
||||||
template kind*(
|
template kind*(
|
||||||
x: typedesc[
|
x: typedesc[
|
||||||
deneb.HashedBeaconState]): ConsensusFork =
|
deneb.BeaconState |
|
||||||
|
deneb.HashedBeaconState |
|
||||||
|
deneb.ExecutionPayload |
|
||||||
|
deneb.ExecutionPayloadForSigning |
|
||||||
|
deneb.ExecutionPayloadHeader |
|
||||||
|
deneb.BeaconBlock |
|
||||||
|
deneb.SignedBeaconBlock |
|
||||||
|
deneb.TrustedBeaconBlock |
|
||||||
|
deneb.BeaconBlockBody |
|
||||||
|
deneb.SigVerifiedBeaconBlockBody |
|
||||||
|
deneb.TrustedBeaconBlockBody |
|
||||||
|
deneb.SigVerifiedSignedBeaconBlock |
|
||||||
|
deneb.MsgTrustedSignedBeaconBlock |
|
||||||
|
deneb.TrustedSignedBeaconBlock]): ConsensusFork =
|
||||||
ConsensusFork.Deneb
|
ConsensusFork.Deneb
|
||||||
|
|
||||||
macro getSymbolFromForkModule(fork: static ConsensusFork,
|
macro getSymbolFromForkModule(fork: static ConsensusFork,
|
||||||
@ -485,90 +544,6 @@ template toString*(kind: ConsensusFork): string =
|
|||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
"deneb"
|
"deneb"
|
||||||
|
|
||||||
template toFork*[T:
|
|
||||||
phase0.BeaconState |
|
|
||||||
phase0.HashedBeaconState |
|
|
||||||
phase0.BeaconBlock |
|
|
||||||
phase0.SignedBeaconBlock |
|
|
||||||
phase0.TrustedBeaconBlock |
|
|
||||||
phase0.BeaconBlockBody |
|
|
||||||
phase0.SigVerifiedBeaconBlockBody |
|
|
||||||
phase0.TrustedBeaconBlockBody |
|
|
||||||
phase0.SigVerifiedSignedBeaconBlock |
|
|
||||||
phase0.MsgTrustedSignedBeaconBlock |
|
|
||||||
phase0.TrustedSignedBeaconBlock](
|
|
||||||
t: type T): ConsensusFork =
|
|
||||||
ConsensusFork.Phase0
|
|
||||||
|
|
||||||
template toFork*[T:
|
|
||||||
altair.BeaconState |
|
|
||||||
altair.HashedBeaconState |
|
|
||||||
altair.BeaconBlock |
|
|
||||||
altair.SignedBeaconBlock |
|
|
||||||
altair.TrustedBeaconBlock |
|
|
||||||
altair.BeaconBlockBody |
|
|
||||||
altair.SigVerifiedBeaconBlockBody |
|
|
||||||
altair.TrustedBeaconBlockBody |
|
|
||||||
altair.SigVerifiedSignedBeaconBlock |
|
|
||||||
altair.MsgTrustedSignedBeaconBlock |
|
|
||||||
altair.TrustedSignedBeaconBlock](
|
|
||||||
t: type T): ConsensusFork =
|
|
||||||
ConsensusFork.Altair
|
|
||||||
|
|
||||||
template toFork*[T:
|
|
||||||
bellatrix.BeaconState |
|
|
||||||
bellatrix.HashedBeaconState |
|
|
||||||
bellatrix.ExecutionPayload |
|
|
||||||
bellatrix.ExecutionPayloadForSigning |
|
|
||||||
bellatrix.ExecutionPayloadHeader |
|
|
||||||
bellatrix.BeaconBlock |
|
|
||||||
bellatrix.SignedBeaconBlock |
|
|
||||||
bellatrix.TrustedBeaconBlock |
|
|
||||||
bellatrix.BeaconBlockBody |
|
|
||||||
bellatrix.SigVerifiedBeaconBlockBody |
|
|
||||||
bellatrix.TrustedBeaconBlockBody |
|
|
||||||
bellatrix.SigVerifiedSignedBeaconBlock |
|
|
||||||
bellatrix.MsgTrustedSignedBeaconBlock |
|
|
||||||
bellatrix.TrustedSignedBeaconBlock](
|
|
||||||
t: type T): ConsensusFork =
|
|
||||||
ConsensusFork.Bellatrix
|
|
||||||
|
|
||||||
template toFork*[T:
|
|
||||||
capella.BeaconState |
|
|
||||||
capella.HashedBeaconState |
|
|
||||||
capella.ExecutionPayload |
|
|
||||||
capella.ExecutionPayloadForSigning |
|
|
||||||
capella.ExecutionPayloadHeader |
|
|
||||||
capella.BeaconBlock |
|
|
||||||
capella.SignedBeaconBlock |
|
|
||||||
capella.TrustedBeaconBlock |
|
|
||||||
capella.BeaconBlockBody |
|
|
||||||
capella.SigVerifiedBeaconBlockBody |
|
|
||||||
capella.TrustedBeaconBlockBody |
|
|
||||||
capella.SigVerifiedSignedBeaconBlock |
|
|
||||||
capella.MsgTrustedSignedBeaconBlock |
|
|
||||||
capella.TrustedSignedBeaconBlock](
|
|
||||||
t: type T): ConsensusFork =
|
|
||||||
ConsensusFork.Capella
|
|
||||||
|
|
||||||
template toFork*[T:
|
|
||||||
deneb.BeaconState |
|
|
||||||
deneb.HashedBeaconState |
|
|
||||||
deneb.ExecutionPayload |
|
|
||||||
deneb.ExecutionPayloadForSigning |
|
|
||||||
deneb.ExecutionPayloadHeader |
|
|
||||||
deneb.BeaconBlock |
|
|
||||||
deneb.SignedBeaconBlock |
|
|
||||||
deneb.TrustedBeaconBlock |
|
|
||||||
deneb.BeaconBlockBody |
|
|
||||||
deneb.SigVerifiedBeaconBlockBody |
|
|
||||||
deneb.TrustedBeaconBlockBody |
|
|
||||||
deneb.SigVerifiedSignedBeaconBlock |
|
|
||||||
deneb.MsgTrustedSignedBeaconBlock |
|
|
||||||
deneb.TrustedSignedBeaconBlock](
|
|
||||||
t: type T): ConsensusFork =
|
|
||||||
ConsensusFork.Deneb
|
|
||||||
|
|
||||||
template init*(T: type ForkedEpochInfo, info: phase0.EpochInfo): T =
|
template init*(T: type ForkedEpochInfo, info: phase0.EpochInfo): T =
|
||||||
T(kind: EpochInfoFork.Phase0, phase0Data: info)
|
T(kind: EpochInfoFork.Phase0, phase0Data: info)
|
||||||
template init*(T: type ForkedEpochInfo, info: altair.EpochInfo): T =
|
template init*(T: type ForkedEpochInfo, info: altair.EpochInfo): T =
|
||||||
|
@ -349,7 +349,7 @@ func is_merge_transition_complete*(
|
|||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/sync/optimistic.md#helpers
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/sync/optimistic.md#helpers
|
||||||
func is_execution_block*(blck: SomeForkyBeaconBlock): bool =
|
func is_execution_block*(blck: SomeForkyBeaconBlock): bool =
|
||||||
when typeof(blck).toFork >= ConsensusFork.Bellatrix:
|
when typeof(blck).kind >= ConsensusFork.Bellatrix:
|
||||||
const defaultExecutionPayload =
|
const defaultExecutionPayload =
|
||||||
default(typeof(blck.body.execution_payload))
|
default(typeof(blck.body.execution_payload))
|
||||||
blck.body.execution_payload != defaultExecutionPayload
|
blck.body.execution_payload != defaultExecutionPayload
|
||||||
@ -432,22 +432,22 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader =
|
|||||||
let
|
let
|
||||||
txRoot = payload.computeTransactionsTrieRoot()
|
txRoot = payload.computeTransactionsTrieRoot()
|
||||||
withdrawalsRoot =
|
withdrawalsRoot =
|
||||||
when typeof(payload).toFork >= ConsensusFork.Capella:
|
when typeof(payload).kind >= ConsensusFork.Capella:
|
||||||
some payload.computeWithdrawalsTrieRoot()
|
some payload.computeWithdrawalsTrieRoot()
|
||||||
else:
|
else:
|
||||||
none(ExecutionHash256)
|
none(ExecutionHash256)
|
||||||
blobGasUsed =
|
blobGasUsed =
|
||||||
when typeof(payload).toFork >= ConsensusFork.Deneb:
|
when typeof(payload).kind >= ConsensusFork.Deneb:
|
||||||
some payload.blob_gas_used
|
some payload.blob_gas_used
|
||||||
else:
|
else:
|
||||||
none(uint64)
|
none(uint64)
|
||||||
excessBlobGas =
|
excessBlobGas =
|
||||||
when typeof(payload).toFork >= ConsensusFork.Deneb:
|
when typeof(payload).kind >= ConsensusFork.Deneb:
|
||||||
some payload.excess_blob_gas
|
some payload.excess_blob_gas
|
||||||
else:
|
else:
|
||||||
none(uint64)
|
none(uint64)
|
||||||
parentBeaconBlockRoot =
|
parentBeaconBlockRoot =
|
||||||
when typeof(payload).toFork >= ConsensusFork.Deneb:
|
when typeof(payload).kind >= ConsensusFork.Deneb:
|
||||||
some ExecutionHash256(data: blck.parent_root.data)
|
some ExecutionHash256(data: blck.parent_root.data)
|
||||||
else:
|
else:
|
||||||
none(ExecutionHash256)
|
none(ExecutionHash256)
|
||||||
|
@ -427,7 +427,7 @@ proc collectSignatureSets*(
|
|||||||
|
|
||||||
block:
|
block:
|
||||||
# 8. BLS to execution changes
|
# 8. BLS to execution changes
|
||||||
when typeof(signed_block).toFork() >= ConsensusFork.Capella:
|
when typeof(signed_block).kind >= ConsensusFork.Capella:
|
||||||
withState(state):
|
withState(state):
|
||||||
when consensusFork >= ConsensusFork.Capella:
|
when consensusFork >= ConsensusFork.Capella:
|
||||||
for bls_change in signed_block.message.body.bls_to_execution_changes:
|
for bls_change in signed_block.message.body.bls_to_execution_changes:
|
||||||
|
@ -297,7 +297,7 @@ proc state_transition_block*(
|
|||||||
doAssert not rollback.isNil, "use noRollback if it's ok to mess up state"
|
doAssert not rollback.isNil, "use noRollback if it's ok to mess up state"
|
||||||
|
|
||||||
let res = withState(state):
|
let res = withState(state):
|
||||||
when consensusFork == type(signedBlock).toFork:
|
when consensusFork == type(signedBlock).kind:
|
||||||
state_transition_block_aux(cfg, forkyState, signedBlock, cache, flags)
|
state_transition_block_aux(cfg, forkyState, signedBlock, cache, flags)
|
||||||
else:
|
else:
|
||||||
err("State/block fork mismatch")
|
err("State/block fork mismatch")
|
||||||
@ -482,7 +482,7 @@ proc makeBeaconBlock*(
|
|||||||
|
|
||||||
ok(blck)
|
ok(blck)
|
||||||
|
|
||||||
const payloadFork = typeof(executionPayload).toFork
|
const payloadFork = typeof(executionPayload).kind
|
||||||
when payloadFork == ConsensusFork.Bellatrix:
|
when payloadFork == ConsensusFork.Bellatrix:
|
||||||
case state.kind
|
case state.kind
|
||||||
of ConsensusFork.Phase0: makeBeaconBlock(phase0)
|
of ConsensusFork.Phase0: makeBeaconBlock(phase0)
|
||||||
|
@ -366,7 +366,7 @@ proc check_voluntary_exit*(
|
|||||||
# Verify signature
|
# Verify signature
|
||||||
if skipBlsValidation notin flags:
|
if skipBlsValidation notin flags:
|
||||||
let exitSignatureFork =
|
let exitSignatureFork =
|
||||||
when typeof(state).toFork >= ConsensusFork.Deneb:
|
when typeof(state).kind >= ConsensusFork.Deneb:
|
||||||
Fork(
|
Fork(
|
||||||
previous_version: cfg.CAPELLA_FORK_VERSION,
|
previous_version: cfg.CAPELLA_FORK_VERSION,
|
||||||
current_version: cfg.CAPELLA_FORK_VERSION,
|
current_version: cfg.CAPELLA_FORK_VERSION,
|
||||||
@ -446,7 +446,7 @@ proc process_operations(cfg: RuntimeConfig,
|
|||||||
? process_deposit(cfg, state, op, flags)
|
? process_deposit(cfg, state, op, flags)
|
||||||
for op in body.voluntary_exits:
|
for op in body.voluntary_exits:
|
||||||
? process_voluntary_exit(cfg, state, op, flags, cache)
|
? process_voluntary_exit(cfg, state, op, flags, cache)
|
||||||
when typeof(body).toFork >= ConsensusFork.Capella:
|
when typeof(body).kind >= ConsensusFork.Capella:
|
||||||
for op in body.bls_to_execution_changes:
|
for op in body.bls_to_execution_changes:
|
||||||
? process_bls_to_execution_change(cfg, state, op)
|
? process_bls_to_execution_change(cfg, state, op)
|
||||||
|
|
||||||
|
@ -840,7 +840,7 @@ func process_registry_updates*(
|
|||||||
## Queue validators eligible for activation and not dequeued for activation
|
## Queue validators eligible for activation and not dequeued for activation
|
||||||
var activation_queue: HeapQueue[(uint64, uint32)]
|
var activation_queue: HeapQueue[(uint64, uint32)]
|
||||||
let churn_limit =
|
let churn_limit =
|
||||||
when typeof(state).toFork >= ConsensusFork.Deneb:
|
when typeof(state).kind >= ConsensusFork.Deneb:
|
||||||
get_validator_activation_churn_limit(cfg, state, cache)
|
get_validator_activation_churn_limit(cfg, state, cache)
|
||||||
else:
|
else:
|
||||||
get_validator_churn_limit(cfg, state, cache)
|
get_validator_churn_limit(cfg, state, cache)
|
||||||
|
@ -469,7 +469,7 @@ proc makeBeaconBlockForHeadAndSlot*(
|
|||||||
var modified_execution_payload = execution_payload
|
var modified_execution_payload = execution_payload
|
||||||
withState(state[]):
|
withState(state[]):
|
||||||
when consensusFork >= ConsensusFork.Capella and
|
when consensusFork >= ConsensusFork.Capella and
|
||||||
PayloadType.toFork >= ConsensusFork.Capella:
|
PayloadType.kind >= ConsensusFork.Capella:
|
||||||
let withdrawals = List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD](
|
let withdrawals = List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD](
|
||||||
get_expected_withdrawals(forkyState.data))
|
get_expected_withdrawals(forkyState.data))
|
||||||
if withdrawals_root.isNone or
|
if withdrawals_root.isNone or
|
||||||
|
@ -107,7 +107,7 @@ proc routeSignedBeaconBlock*(
|
|||||||
signature = shortLog(blck.signature), error = res.error()
|
signature = shortLog(blck.signature), error = res.error()
|
||||||
return err(res.error()[1])
|
return err(res.error()[1])
|
||||||
|
|
||||||
when typeof(blck).toFork() >= ConsensusFork.Deneb:
|
when typeof(blck).kind >= ConsensusFork.Deneb:
|
||||||
if blobsOpt.isSome:
|
if blobsOpt.isSome:
|
||||||
let blobs = blobsOpt.get()
|
let blobs = blobsOpt.get()
|
||||||
let kzgCommits = blck.message.body.blob_kzg_commitments.asSeq
|
let kzgCommits = blck.message.body.blob_kzg_commitments.asSeq
|
||||||
|
@ -467,7 +467,7 @@ proc doCreateTestnet*(config: CliConfig,
|
|||||||
let outSszGenesis = outGenesis.changeFileExt "ssz"
|
let outSszGenesis = outGenesis.changeFileExt "ssz"
|
||||||
SSZ.saveFile(outSszGenesis, initialState[])
|
SSZ.saveFile(outSszGenesis, initialState[])
|
||||||
info "SSZ genesis file written",
|
info "SSZ genesis file written",
|
||||||
path = outSszGenesis, fork = toFork(typeof initialState[])
|
path = outSszGenesis, fork = kind(typeof initialState[])
|
||||||
|
|
||||||
SSZ.saveFile(
|
SSZ.saveFile(
|
||||||
config.outputDepositTreeSnapshot.string,
|
config.outputDepositTreeSnapshot.string,
|
||||||
|
@ -83,7 +83,7 @@ proc initialLoad(
|
|||||||
let
|
let
|
||||||
forkedState = loadForkedState(
|
forkedState = loadForkedState(
|
||||||
path/"anchor_state.ssz_snappy",
|
path/"anchor_state.ssz_snappy",
|
||||||
StateType.toFork)
|
StateType.kind)
|
||||||
|
|
||||||
blck = parseTest(
|
blck = parseTest(
|
||||||
path/"anchor_block.ssz_snappy",
|
path/"anchor_block.ssz_snappy",
|
||||||
@ -246,7 +246,7 @@ proc stepOnBlock(
|
|||||||
invalidatedRoots: Table[Eth2Digest, Eth2Digest]):
|
invalidatedRoots: Table[Eth2Digest, Eth2Digest]):
|
||||||
Result[BlockRef, VerifierError] =
|
Result[BlockRef, VerifierError] =
|
||||||
# 1. Validate blobs
|
# 1. Validate blobs
|
||||||
when typeof(signedBlock).toFork() >= ConsensusFork.Deneb:
|
when typeof(signedBlock).kind >= ConsensusFork.Deneb:
|
||||||
let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq
|
let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq
|
||||||
if kzgCommits.len > 0 or blobData.isSome:
|
if kzgCommits.len > 0 or blobData.isSome:
|
||||||
if blobData.isNone or kzgCommits.validate_blobs(
|
if blobData.isNone or kzgCommits.validate_blobs(
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
# beacon_chain
|
||||||
|
# Copyright (c) 2021-2023 Status Research & Development GmbH
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
{.used.}
|
{.used.}
|
||||||
|
|
||||||
import
|
import
|
||||||
@ -14,7 +21,7 @@ template testHashedBeaconState(T: type, s: Slot) =
|
|||||||
forked[] = readSszForkedHashedBeaconState(cfg, bytes)
|
forked[] = readSszForkedHashedBeaconState(cfg, bytes)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
forked.kind == T.toFork()
|
forked.kind == T.kind
|
||||||
|
|
||||||
template testTrustedSignedBeaconBlock(T: type, s: Slot) =
|
template testTrustedSignedBeaconBlock(T: type, s: Slot) =
|
||||||
let blck = (ref T)()
|
let blck = (ref T)()
|
||||||
@ -26,7 +33,7 @@ template testTrustedSignedBeaconBlock(T: type, s: Slot) =
|
|||||||
forked[] = readSszForkedSignedBeaconBlock(cfg, bytes)
|
forked[] = readSszForkedSignedBeaconBlock(cfg, bytes)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
forked.kind == T.toFork()
|
forked.kind == T.kind
|
||||||
|
|
||||||
suite "Type helpers":
|
suite "Type helpers":
|
||||||
test "BeaconBlockType":
|
test "BeaconBlockType":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user