add Electra to ConsensusFork enum (#6169)
* add Electra to ConsensusFork enum * fix gnosis check
This commit is contained in:
parent
c2a2b76f93
commit
7fa32b7f02
|
@ -513,7 +513,8 @@ proc new*(T: type BeaconChainDB,
|
||||||
kvStore db.openKvStore("altair_blocks").expectDb(),
|
kvStore db.openKvStore("altair_blocks").expectDb(),
|
||||||
kvStore db.openKvStore("bellatrix_blocks").expectDb(),
|
kvStore db.openKvStore("bellatrix_blocks").expectDb(),
|
||||||
kvStore db.openKvStore("capella_blocks").expectDb(),
|
kvStore db.openKvStore("capella_blocks").expectDb(),
|
||||||
kvStore db.openKvStore("deneb_blocks").expectDb()]
|
kvStore db.openKvStore("deneb_blocks").expectDb(),
|
||||||
|
kvStore db.openKvStore("electra_blocks").expectDb()]
|
||||||
|
|
||||||
stateRoots = kvStore db.openKvStore("state_roots", true).expectDb()
|
stateRoots = kvStore db.openKvStore("state_roots", true).expectDb()
|
||||||
|
|
||||||
|
@ -522,7 +523,8 @@ proc new*(T: type BeaconChainDB,
|
||||||
kvStore db.openKvStore("altair_state_no_validators").expectDb(),
|
kvStore db.openKvStore("altair_state_no_validators").expectDb(),
|
||||||
kvStore db.openKvStore("bellatrix_state_no_validators").expectDb(),
|
kvStore db.openKvStore("bellatrix_state_no_validators").expectDb(),
|
||||||
kvStore db.openKvStore("capella_state_no_validator_pubkeys").expectDb(),
|
kvStore db.openKvStore("capella_state_no_validator_pubkeys").expectDb(),
|
||||||
kvStore db.openKvStore("deneb_state_no_validator_pubkeys").expectDb()]
|
kvStore db.openKvStore("deneb_state_no_validator_pubkeys").expectDb(),
|
||||||
|
kvStore db.openKvStore("electra_state_no_validator_pubkeys").expectDb()]
|
||||||
|
|
||||||
stateDiffs = kvStore db.openKvStore("state_diffs").expectDb()
|
stateDiffs = kvStore db.openKvStore("state_diffs").expectDb()
|
||||||
summaries = kvStore db.openKvStore("beacon_block_summaries", true).expectDb()
|
summaries = kvStore db.openKvStore("beacon_block_summaries", true).expectDb()
|
||||||
|
@ -794,7 +796,8 @@ proc putBlock*(
|
||||||
proc putBlock*(
|
proc putBlock*(
|
||||||
db: BeaconChainDB,
|
db: BeaconChainDB,
|
||||||
value: bellatrix.TrustedSignedBeaconBlock |
|
value: bellatrix.TrustedSignedBeaconBlock |
|
||||||
capella.TrustedSignedBeaconBlock | deneb.TrustedSignedBeaconBlock) =
|
capella.TrustedSignedBeaconBlock | deneb.TrustedSignedBeaconBlock |
|
||||||
|
electra.TrustedSignedBeaconBlock) =
|
||||||
db.withManyWrites:
|
db.withManyWrites:
|
||||||
db.blocks[type(value).kind].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())
|
||||||
|
@ -844,6 +847,10 @@ template toBeaconStateNoImmutableValidators(state: deneb.BeaconState):
|
||||||
DenebBeaconStateNoImmutableValidators =
|
DenebBeaconStateNoImmutableValidators =
|
||||||
isomorphicCast[DenebBeaconStateNoImmutableValidators](state)
|
isomorphicCast[DenebBeaconStateNoImmutableValidators](state)
|
||||||
|
|
||||||
|
template toBeaconStateNoImmutableValidators(state: electra.BeaconState):
|
||||||
|
ElectraBeaconStateNoImmutableValidators =
|
||||||
|
isomorphicCast[ElectraBeaconStateNoImmutableValidators](state)
|
||||||
|
|
||||||
proc putState*(
|
proc putState*(
|
||||||
db: BeaconChainDB, key: Eth2Digest,
|
db: BeaconChainDB, key: Eth2Digest,
|
||||||
value: phase0.BeaconState | altair.BeaconState) =
|
value: phase0.BeaconState | altair.BeaconState) =
|
||||||
|
@ -853,7 +860,8 @@ proc putState*(
|
||||||
|
|
||||||
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 |
|
||||||
|
electra.BeaconState) =
|
||||||
db.updateImmutableValidators(value.validators.asSeq())
|
db.updateImmutableValidators(value.validators.asSeq())
|
||||||
db.statesNoVal[type(value).kind].putSZSSZ(
|
db.statesNoVal[type(value).kind].putSZSSZ(
|
||||||
key.data, toBeaconStateNoImmutableValidators(value))
|
key.data, toBeaconStateNoImmutableValidators(value))
|
||||||
|
@ -982,7 +990,7 @@ proc getBlock*(
|
||||||
|
|
||||||
proc getBlock*[
|
proc getBlock*[
|
||||||
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
||||||
deneb.TrustedSignedBeaconBlock](
|
deneb.TrustedSignedBeaconBlock | electra.TrustedSignedBeaconBlock](
|
||||||
db: BeaconChainDB, key: Eth2Digest,
|
db: BeaconChainDB, key: Eth2Digest,
|
||||||
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
|
||||||
|
@ -1037,7 +1045,7 @@ proc getBlockSSZ*(
|
||||||
|
|
||||||
proc getBlockSSZ*[
|
proc getBlockSSZ*[
|
||||||
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
||||||
deneb.TrustedSignedBeaconBlock](
|
deneb.TrustedSignedBeaconBlock | electra.TrustedSignedBeaconBlock](
|
||||||
db: BeaconChainDB, key: Eth2Digest, data: var seq[byte], T: type X): bool =
|
db: BeaconChainDB, key: Eth2Digest, data: var seq[byte], T: type X): bool =
|
||||||
let dataPtr = addr data # Short-lived
|
let dataPtr = addr data # Short-lived
|
||||||
var success = true
|
var success = true
|
||||||
|
@ -1086,7 +1094,7 @@ proc getBlockSZ*(
|
||||||
|
|
||||||
proc getBlockSZ*[
|
proc getBlockSZ*[
|
||||||
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
X: bellatrix.TrustedSignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
||||||
deneb.TrustedSignedBeaconBlock](
|
deneb.TrustedSignedBeaconBlock | electra.TrustedSignedBeaconBlock](
|
||||||
db: BeaconChainDB, key: Eth2Digest, data: var seq[byte], T: type X): bool =
|
db: BeaconChainDB, key: Eth2Digest, data: var seq[byte], T: type X): bool =
|
||||||
let dataPtr = addr data # Short-lived
|
let dataPtr = addr data # Short-lived
|
||||||
func decode(data: openArray[byte]) =
|
func decode(data: openArray[byte]) =
|
||||||
|
@ -1184,7 +1192,7 @@ proc getStateOnlyMutableValidators(
|
||||||
proc getStateOnlyMutableValidators(
|
proc getStateOnlyMutableValidators(
|
||||||
immutableValidators: openArray[ImmutableValidatorData2],
|
immutableValidators: openArray[ImmutableValidatorData2],
|
||||||
store: KvStoreRef, key: openArray[byte],
|
store: KvStoreRef, key: openArray[byte],
|
||||||
output: var (capella.BeaconState | deneb.BeaconState),
|
output: var (capella.BeaconState | deneb.BeaconState | electra.BeaconState),
|
||||||
rollback: RollbackProc): bool =
|
rollback: RollbackProc): bool =
|
||||||
## Load state into `output` - BeaconState is large so we want to avoid
|
## Load state into `output` - BeaconState is large so we want to avoid
|
||||||
## re-allocating it if possible
|
## re-allocating it if possible
|
||||||
|
@ -1269,7 +1277,7 @@ proc getState*(
|
||||||
proc getState*(
|
proc getState*(
|
||||||
db: BeaconChainDB, key: Eth2Digest,
|
db: BeaconChainDB, key: Eth2Digest,
|
||||||
output: var (altair.BeaconState | bellatrix.BeaconState |
|
output: var (altair.BeaconState | bellatrix.BeaconState |
|
||||||
capella.BeaconState | deneb.BeaconState),
|
capella.BeaconState | deneb.BeaconState | electra.BeaconState),
|
||||||
rollback: RollbackProc): bool =
|
rollback: RollbackProc): bool =
|
||||||
## Load state into `output` - BeaconState is large so we want to avoid
|
## Load state into `output` - BeaconState is large so we want to avoid
|
||||||
## re-allocating it if possible
|
## re-allocating it if possible
|
||||||
|
@ -1489,7 +1497,7 @@ iterator getAncestorSummaries*(db: BeaconChainDB, root: Eth2Digest):
|
||||||
|
|
||||||
# Backwards compat for reading old databases, or those that for whatever
|
# Backwards compat for reading old databases, or those that for whatever
|
||||||
# reason lost a summary along the way..
|
# reason lost a summary along the way..
|
||||||
static: doAssert ConsensusFork.high == ConsensusFork.Deneb
|
static: doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||||
while true:
|
while true:
|
||||||
if db.v0.backend.getSnappySSZ(
|
if db.v0.backend.getSnappySSZ(
|
||||||
subkey(BeaconBlockSummary, res.root), res.summary) == GetResult.found:
|
subkey(BeaconBlockSummary, res.root), res.summary) == GetResult.found:
|
||||||
|
@ -1504,6 +1512,8 @@ iterator getAncestorSummaries*(db: BeaconChainDB, root: Eth2Digest):
|
||||||
res.summary = blck.get().message.toBeaconBlockSummary()
|
res.summary = blck.get().message.toBeaconBlockSummary()
|
||||||
elif (let blck = db.getBlock(res.root, deneb.TrustedSignedBeaconBlock); blck.isSome()):
|
elif (let blck = db.getBlock(res.root, deneb.TrustedSignedBeaconBlock); blck.isSome()):
|
||||||
res.summary = blck.get().message.toBeaconBlockSummary()
|
res.summary = blck.get().message.toBeaconBlockSummary()
|
||||||
|
elif (let blck = db.getBlock(res.root, electra.TrustedSignedBeaconBlock); blck.isSome()):
|
||||||
|
res.summary = blck.get().message.toBeaconBlockSummary()
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,9 @@ proc initLightClient*(
|
||||||
|
|
||||||
case node.dag.cfg.consensusForkAtEpoch(
|
case node.dag.cfg.consensusForkAtEpoch(
|
||||||
forkyBlck.message.slot.epoch)
|
forkyBlck.message.slot.epoch)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
discard
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
callForkchoiceUpdated(PayloadAttributesV3)
|
callForkchoiceUpdated(PayloadAttributesV3)
|
||||||
of ConsensusFork.Capella:
|
of ConsensusFork.Capella:
|
||||||
|
|
|
@ -329,7 +329,9 @@ type
|
||||||
optimistic* {.serializedFieldName: "execution_optimistic".}: Option[bool]
|
optimistic* {.serializedFieldName: "execution_optimistic".}: Option[bool]
|
||||||
|
|
||||||
template OnBlockAddedCallback*(kind: static ConsensusFork): auto =
|
template OnBlockAddedCallback*(kind: static ConsensusFork): auto =
|
||||||
when kind == ConsensusFork.Deneb:
|
when kind == ConsensusFork.Electra:
|
||||||
|
typedesc[OnElectraBlockAdded]
|
||||||
|
elif kind == ConsensusFork.Deneb:
|
||||||
typedesc[OnDenebBlockAdded]
|
typedesc[OnDenebBlockAdded]
|
||||||
elif kind == ConsensusFork.Capella:
|
elif kind == ConsensusFork.Capella:
|
||||||
typedesc[OnCapellaBlockAdded]
|
typedesc[OnCapellaBlockAdded]
|
||||||
|
|
|
@ -268,8 +268,11 @@ proc getForkedBlock*(db: BeaconChainDB, root: Eth2Digest):
|
||||||
Opt[ForkedTrustedSignedBeaconBlock] =
|
Opt[ForkedTrustedSignedBeaconBlock] =
|
||||||
# When we only have a digest, we don't know which fork it's from so we try
|
# When we only have a digest, we don't know which fork it's from so we try
|
||||||
# them one by one - this should be used sparingly
|
# them one by one - this should be used sparingly
|
||||||
static: doAssert high(ConsensusFork) == ConsensusFork.Deneb
|
static: doAssert high(ConsensusFork) == ConsensusFork.Electra
|
||||||
if (let blck = db.getBlock(root, deneb.TrustedSignedBeaconBlock);
|
if (let blck = db.getBlock(root, electra.TrustedSignedBeaconBlock);
|
||||||
|
blck.isSome()):
|
||||||
|
ok(ForkedTrustedSignedBeaconBlock.init(blck.get()))
|
||||||
|
elif (let blck = db.getBlock(root, deneb.TrustedSignedBeaconBlock);
|
||||||
blck.isSome()):
|
blck.isSome()):
|
||||||
ok(ForkedTrustedSignedBeaconBlock.init(blck.get()))
|
ok(ForkedTrustedSignedBeaconBlock.init(blck.get()))
|
||||||
elif (let blck = db.getBlock(root, capella.TrustedSignedBeaconBlock);
|
elif (let blck = db.getBlock(root, capella.TrustedSignedBeaconBlock);
|
||||||
|
@ -1001,6 +1004,9 @@ proc applyBlock(
|
||||||
? state_transition(
|
? state_transition(
|
||||||
dag.cfg, state, data, cache, info,
|
dag.cfg, state, data, cache, info,
|
||||||
dag.updateFlags + {slotProcessed}, noRollback)
|
dag.updateFlags + {slotProcessed}, noRollback)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra applyblock missing"
|
||||||
|
return ok()
|
||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
|
@ -1161,6 +1167,7 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
|
||||||
of ConsensusFork.Bellatrix: bellatrixFork(cfg)
|
of ConsensusFork.Bellatrix: bellatrixFork(cfg)
|
||||||
of ConsensusFork.Capella: capellaFork(cfg)
|
of ConsensusFork.Capella: capellaFork(cfg)
|
||||||
of ConsensusFork.Deneb: denebFork(cfg)
|
of ConsensusFork.Deneb: denebFork(cfg)
|
||||||
|
of ConsensusFork.Electra: electraFork(cfg)
|
||||||
stateFork = getStateField(dag.headState, fork)
|
stateFork = getStateField(dag.headState, fork)
|
||||||
|
|
||||||
# Here, we check only the `current_version` field because the spec
|
# Here, we check only the `current_version` field because the spec
|
||||||
|
@ -2395,7 +2402,7 @@ proc updateHead*(
|
||||||
|
|
||||||
if dag.headState.kind > lastHeadKind:
|
if dag.headState.kind > lastHeadKind:
|
||||||
case dag.headState.kind
|
case dag.headState.kind
|
||||||
of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix:
|
of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix, ConsensusFork.Electra:
|
||||||
discard
|
discard
|
||||||
of ConsensusFork.Capella:
|
of ConsensusFork.Capella:
|
||||||
if dag.vanityLogs.onUpgradeToCapella != nil:
|
if dag.vanityLogs.onUpgradeToCapella != nil:
|
||||||
|
|
|
@ -370,6 +370,8 @@ proc runProposalForkchoiceUpdated*(
|
||||||
let safeBlockHash = beaconHead.safeExecutionBlockHash
|
let safeBlockHash = beaconHead.safeExecutionBlockHash
|
||||||
|
|
||||||
withState(self.dag.headState):
|
withState(self.dag.headState):
|
||||||
|
debugRaiseAssert "foo"
|
||||||
|
when consensusFork != ConsensusFork.Electra:
|
||||||
template callForkchoiceUpdated(fcPayloadAttributes: auto) =
|
template callForkchoiceUpdated(fcPayloadAttributes: auto) =
|
||||||
let (status, _) = await self.elManager.forkchoiceUpdated(
|
let (status, _) = await self.elManager.forkchoiceUpdated(
|
||||||
headBlockHash, safeBlockHash,
|
headBlockHash, safeBlockHash,
|
||||||
|
@ -377,8 +379,10 @@ proc runProposalForkchoiceUpdated*(
|
||||||
payloadAttributes = some fcPayloadAttributes)
|
payloadAttributes = some fcPayloadAttributes)
|
||||||
debug "Fork-choice updated for proposal", status
|
debug "Fork-choice updated for proposal", status
|
||||||
|
|
||||||
static: doAssert high(ConsensusFork) == ConsensusFork.Deneb
|
static: doAssert high(ConsensusFork) == ConsensusFork.Electra
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "foobar"
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
callForkchoiceUpdated(PayloadAttributesV3(
|
callForkchoiceUpdated(PayloadAttributesV3(
|
||||||
timestamp: Quantity timestamp,
|
timestamp: Quantity timestamp,
|
||||||
prevRandao: FixedBytes[32] randomData,
|
prevRandao: FixedBytes[32] randomData,
|
||||||
|
|
|
@ -198,7 +198,8 @@ type
|
||||||
SomeEnginePayloadWithValue =
|
SomeEnginePayloadWithValue =
|
||||||
BellatrixExecutionPayloadWithValue |
|
BellatrixExecutionPayloadWithValue |
|
||||||
GetPayloadV2Response |
|
GetPayloadV2Response |
|
||||||
GetPayloadV3Response
|
GetPayloadV3Response |
|
||||||
|
GetPayloadV4Response
|
||||||
|
|
||||||
declareCounter failed_web3_requests,
|
declareCounter failed_web3_requests,
|
||||||
"Failed web3 requests"
|
"Failed web3 requests"
|
||||||
|
@ -530,6 +531,11 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV4):
|
||||||
List[electra.ExecutionLayerExit, MAX_EXECUTION_LAYER_EXITS_PER_PAYLOAD].init(
|
List[electra.ExecutionLayerExit, MAX_EXECUTION_LAYER_EXITS_PER_PAYLOAD].init(
|
||||||
mapIt(rpcExecutionPayload.exits, it.getExecutionLayerExit)))
|
mapIt(rpcExecutionPayload.exits, it.getExecutionLayerExit)))
|
||||||
|
|
||||||
|
func asConsensusType*(payload: engine_api.GetPayloadV4Response):
|
||||||
|
electra.ExecutionPayloadForSigning =
|
||||||
|
debugRaiseAssert "well, not empty maybe"
|
||||||
|
default(electra.ExecutionPayloadForSigning)
|
||||||
|
|
||||||
func asEngineExecutionPayload*(executionPayload: bellatrix.ExecutionPayload):
|
func asEngineExecutionPayload*(executionPayload: bellatrix.ExecutionPayload):
|
||||||
ExecutionPayloadV1 =
|
ExecutionPayloadV1 =
|
||||||
template getTypedTransaction(tt: bellatrix.Transaction): TypedTransaction =
|
template getTypedTransaction(tt: bellatrix.Transaction): TypedTransaction =
|
||||||
|
@ -804,6 +810,9 @@ proc getPayloadFromSingleEL(
|
||||||
suggestedFeeRecipient: suggestedFeeRecipient,
|
suggestedFeeRecipient: suggestedFeeRecipient,
|
||||||
withdrawals: withdrawals,
|
withdrawals: withdrawals,
|
||||||
parentBeaconBlockRoot: consensusHead.asBlockHash))
|
parentBeaconBlockRoot: consensusHead.asBlockHash))
|
||||||
|
elif GetPayloadResponseType is engine_api.GetPayloadV4Response:
|
||||||
|
debugRaiseAssert "electra"
|
||||||
|
let response = default(ForkchoiceUpdatedResponse)
|
||||||
else:
|
else:
|
||||||
static: doAssert false
|
static: doAssert false
|
||||||
|
|
||||||
|
@ -824,6 +833,9 @@ proc getPayloadFromSingleEL(
|
||||||
return BellatrixExecutionPayloadWithValue(
|
return BellatrixExecutionPayloadWithValue(
|
||||||
executionPayload: payload,
|
executionPayload: payload,
|
||||||
blockValue: computeBlockValue payload)
|
blockValue: computeBlockValue payload)
|
||||||
|
elif GetPayloadResponseType is engine_api.GetPayloadV4Response:
|
||||||
|
debugRaiseAssert "foo"
|
||||||
|
return default(engine_api.GetPayloadV4Response)
|
||||||
else:
|
else:
|
||||||
return await engine_api.getPayload(rpcClient, GetPayloadResponseType, payloadId)
|
return await engine_api.getPayload(rpcClient, GetPayloadResponseType, payloadId)
|
||||||
|
|
||||||
|
@ -839,6 +851,9 @@ template EngineApiResponseType*(T: type capella.ExecutionPayloadForSigning): typ
|
||||||
template EngineApiResponseType*(T: type deneb.ExecutionPayloadForSigning): type =
|
template EngineApiResponseType*(T: type deneb.ExecutionPayloadForSigning): type =
|
||||||
engine_api.GetPayloadV3Response
|
engine_api.GetPayloadV3Response
|
||||||
|
|
||||||
|
template EngineApiResponseType*(T: type electra.ExecutionPayloadForSigning): type =
|
||||||
|
engine_api.GetPayloadV4Response
|
||||||
|
|
||||||
template toEngineWithdrawals*(withdrawals: seq[capella.Withdrawal]): seq[WithdrawalV1] =
|
template toEngineWithdrawals*(withdrawals: seq[capella.Withdrawal]): seq[WithdrawalV1] =
|
||||||
mapIt(withdrawals, toEngineWithdrawal(it))
|
mapIt(withdrawals, toEngineWithdrawal(it))
|
||||||
|
|
||||||
|
@ -1150,6 +1165,9 @@ proc sendNewPayload*(m: ELManager, blck: SomeForkyBeaconBlock):
|
||||||
elif payload is engine_api.ExecutionPayloadV1 or
|
elif payload is engine_api.ExecutionPayloadV1 or
|
||||||
payload is engine_api.ExecutionPayloadV2:
|
payload is engine_api.ExecutionPayloadV2:
|
||||||
sendNewPayloadToSingleEL(it, payload)
|
sendNewPayloadToSingleEL(it, payload)
|
||||||
|
elif payload is engine_api.ExecutionPayloadV4:
|
||||||
|
debugRaiseAssert "similar to V3 case, check for details"
|
||||||
|
default(Future[PayloadStatusV1])
|
||||||
else:
|
else:
|
||||||
static: doAssert false
|
static: doAssert false
|
||||||
trackEngineApiRequest(it, req, "newPayload", startTime, deadline)
|
trackEngineApiRequest(it, req, "newPayload", startTime, deadline)
|
||||||
|
|
|
@ -442,7 +442,7 @@ iterator getBlockIds*(
|
||||||
# `case` ensures we're on a fork for which the `PartialBeaconState`
|
# `case` ensures we're on a fork for which the `PartialBeaconState`
|
||||||
# definition is consistent
|
# definition is consistent
|
||||||
case db.cfg.consensusForkAtEpoch(slot.epoch)
|
case db.cfg.consensusForkAtEpoch(slot.epoch)
|
||||||
of ConsensusFork.Phase0 .. ConsensusFork.Deneb:
|
of ConsensusFork.Phase0 .. ConsensusFork.Electra:
|
||||||
let stateSlot = (slot.era() + 1).start_slot()
|
let stateSlot = (slot.era() + 1).start_slot()
|
||||||
if not getPartialState(
|
if not getPartialState(
|
||||||
db, historical_roots, historical_summaries, stateSlot, state[]):
|
db, historical_roots, historical_summaries, stateSlot, state[]):
|
||||||
|
|
|
@ -716,6 +716,9 @@ proc storeBlock(
|
||||||
template callForkChoiceUpdated: auto =
|
template callForkChoiceUpdated: auto =
|
||||||
case self.consensusManager.dag.cfg.consensusForkAtEpoch(
|
case self.consensusManager.dag.cfg.consensusForkAtEpoch(
|
||||||
newHead.get.blck.bid.slot.epoch)
|
newHead.get.blck.bid.slot.epoch)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
let x = 4
|
||||||
|
debugRaiseAssert "callFCU"
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
callExpectValidFCU(payloadAttributeType = PayloadAttributesV3)
|
callExpectValidFCU(payloadAttributeType = PayloadAttributesV3)
|
||||||
of ConsensusFork.Capella:
|
of ConsensusFork.Capella:
|
||||||
|
@ -766,7 +769,8 @@ proc storeBlock(
|
||||||
quarantined = shortLog(quarantined.root)
|
quarantined = shortLog(quarantined.root)
|
||||||
|
|
||||||
withBlck(quarantined):
|
withBlck(quarantined):
|
||||||
when typeof(forkyBlck).kind < ConsensusFork.Deneb:
|
debugRaiseAssert "electra has blobs"
|
||||||
|
when typeof(forkyBlck).kind < ConsensusFork.Deneb or typeof(forkyBlck).kind == ConsensusFork.Electra:
|
||||||
self[].enqueueBlock(
|
self[].enqueueBlock(
|
||||||
MsgSource.gossip, quarantined, Opt.none(BlobSidecars))
|
MsgSource.gossip, quarantined, Opt.none(BlobSidecars))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -241,8 +241,11 @@ proc processSignedBeaconBlock*(
|
||||||
# propagation of seemingly good blocks
|
# propagation of seemingly good blocks
|
||||||
trace "Block validated"
|
trace "Block validated"
|
||||||
|
|
||||||
|
debugRaiseAssert "electra has blobs"
|
||||||
let blobs =
|
let blobs =
|
||||||
when typeof(signedBlock).kind >= ConsensusFork.Deneb:
|
when typeof(signedBlock).kind >= ConsensusFork.Electra:
|
||||||
|
Opt.none(BlobSidecars)
|
||||||
|
elif typeof(signedBlock).kind >= ConsensusFork.Deneb:
|
||||||
if self.blobQuarantine[].hasBlobs(signedBlock):
|
if self.blobQuarantine[].hasBlobs(signedBlock):
|
||||||
Opt.some(self.blobQuarantine[].popBlobs(signedBlock.root, signedBlock))
|
Opt.some(self.blobQuarantine[].popBlobs(signedBlock.root, signedBlock))
|
||||||
else:
|
else:
|
||||||
|
@ -304,7 +307,10 @@ proc processBlobSidecar*(
|
||||||
if (let o = self.quarantine[].popBlobless(block_root); o.isSome):
|
if (let o = self.quarantine[].popBlobless(block_root); o.isSome):
|
||||||
let blobless = o.unsafeGet()
|
let blobless = o.unsafeGet()
|
||||||
withBlck(blobless):
|
withBlck(blobless):
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "no electra here yet"
|
||||||
|
let x = 5
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
if self.blobQuarantine[].hasBlobs(forkyBlck):
|
if self.blobQuarantine[].hasBlobs(forkyBlck):
|
||||||
self.blockProcessor[].enqueueBlock(
|
self.blockProcessor[].enqueueBlock(
|
||||||
MsgSource.gossip, blobless,
|
MsgSource.gossip, blobless,
|
||||||
|
|
|
@ -270,7 +270,7 @@ when const_preset == "gnosis":
|
||||||
for network in [gnosisMetadata, chiadoMetadata]:
|
for network in [gnosisMetadata, chiadoMetadata]:
|
||||||
doAssert network.cfg.DENEB_FORK_EPOCH < FAR_FUTURE_EPOCH
|
doAssert network.cfg.DENEB_FORK_EPOCH < FAR_FUTURE_EPOCH
|
||||||
doAssert network.cfg.ELECTRA_FORK_EPOCH == FAR_FUTURE_EPOCH
|
doAssert network.cfg.ELECTRA_FORK_EPOCH == FAR_FUTURE_EPOCH
|
||||||
static: doAssert ConsensusFork.high == ConsensusFork.Deneb
|
static: doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||||
|
|
||||||
elif const_preset == "mainnet":
|
elif const_preset == "mainnet":
|
||||||
when incbinEnabled:
|
when incbinEnabled:
|
||||||
|
@ -333,7 +333,7 @@ elif const_preset == "mainnet":
|
||||||
for network in [mainnetMetadata, praterMetadata, sepoliaMetadata, holeskyMetadata]:
|
for network in [mainnetMetadata, praterMetadata, sepoliaMetadata, holeskyMetadata]:
|
||||||
doAssert network.cfg.DENEB_FORK_EPOCH < FAR_FUTURE_EPOCH
|
doAssert network.cfg.DENEB_FORK_EPOCH < FAR_FUTURE_EPOCH
|
||||||
doAssert network.cfg.ELECTRA_FORK_EPOCH == FAR_FUTURE_EPOCH
|
doAssert network.cfg.ELECTRA_FORK_EPOCH == FAR_FUTURE_EPOCH
|
||||||
static: doAssert ConsensusFork.high == ConsensusFork.Deneb
|
static: doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||||
|
|
||||||
proc getMetadataForNetwork*(networkName: string): Eth2NetworkMetadata =
|
proc getMetadataForNetwork*(networkName: string): Eth2NetworkMetadata =
|
||||||
template loadRuntimeMetadata(): auto =
|
template loadRuntimeMetadata(): auto =
|
||||||
|
|
|
@ -170,6 +170,8 @@ func getVanityLogs(stdoutKind: StdoutLogKind): VanityLogs =
|
||||||
|
|
||||||
func getVanityMascot(consensusFork: ConsensusFork): string =
|
func getVanityMascot(consensusFork: ConsensusFork): string =
|
||||||
case consensusFork
|
case consensusFork
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
" "
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
"🐟"
|
"🐟"
|
||||||
of ConsensusFork.Capella:
|
of ConsensusFork.Capella:
|
||||||
|
@ -402,7 +404,12 @@ proc initFullNode(
|
||||||
maybeFinalized: bool):
|
maybeFinalized: bool):
|
||||||
Future[Result[void, VerifierError]] {.async: (raises: [CancelledError]).} =
|
Future[Result[void, VerifierError]] {.async: (raises: [CancelledError]).} =
|
||||||
withBlck(signedBlock):
|
withBlck(signedBlock):
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "foo"
|
||||||
|
await blockProcessor[].addBlock(MsgSource.gossip, signedBlock,
|
||||||
|
Opt.none(BlobSidecars),
|
||||||
|
maybeFinalized = maybeFinalized)
|
||||||
|
elif consensusFork >= 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.
|
||||||
|
@ -916,7 +923,8 @@ func forkDigests(node: BeaconNode): auto =
|
||||||
node.dag.forkDigests.altair,
|
node.dag.forkDigests.altair,
|
||||||
node.dag.forkDigests.bellatrix,
|
node.dag.forkDigests.bellatrix,
|
||||||
node.dag.forkDigests.capella,
|
node.dag.forkDigests.capella,
|
||||||
node.dag.forkDigests.deneb]
|
node.dag.forkDigests.deneb,
|
||||||
|
node.dag.forkDigests.electra]
|
||||||
forkDigestsArray
|
forkDigestsArray
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#attestation-subnet-subscription
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#attestation-subnet-subscription
|
||||||
|
@ -1345,12 +1353,14 @@ proc updateGossipStatus(node: BeaconNode, slot: Slot) {.async.} =
|
||||||
|
|
||||||
let forkDigests = node.forkDigests()
|
let forkDigests = node.forkDigests()
|
||||||
|
|
||||||
|
debugRaiseAssert "check if electra has new gossip"
|
||||||
const removeMessageHandlers: array[ConsensusFork, auto] = [
|
const removeMessageHandlers: array[ConsensusFork, auto] = [
|
||||||
removePhase0MessageHandlers,
|
removePhase0MessageHandlers,
|
||||||
removeAltairMessageHandlers,
|
removeAltairMessageHandlers,
|
||||||
removeAltairMessageHandlers, # bellatrix (altair handlers, different forkDigest)
|
removeAltairMessageHandlers, # bellatrix (altair handlers, different forkDigest)
|
||||||
removeCapellaMessageHandlers,
|
removeCapellaMessageHandlers,
|
||||||
removeDenebMessageHandlers
|
removeDenebMessageHandlers,
|
||||||
|
removeDenebMessageHandlers # maybe duplicate is correct, don't know yet
|
||||||
]
|
]
|
||||||
|
|
||||||
for gossipFork in oldGossipForks:
|
for gossipFork in oldGossipForks:
|
||||||
|
@ -1361,7 +1371,8 @@ proc updateGossipStatus(node: BeaconNode, slot: Slot) {.async.} =
|
||||||
addAltairMessageHandlers,
|
addAltairMessageHandlers,
|
||||||
addAltairMessageHandlers, # bellatrix (altair handlers, different forkDigest)
|
addAltairMessageHandlers, # bellatrix (altair handlers, different forkDigest)
|
||||||
addCapellaMessageHandlers,
|
addCapellaMessageHandlers,
|
||||||
addDenebMessageHandlers
|
addDenebMessageHandlers,
|
||||||
|
addDenebMessageHandlers # repeat is probably correct
|
||||||
]
|
]
|
||||||
|
|
||||||
for gossipFork in newGossipForks:
|
for gossipFork in newGossipForks:
|
||||||
|
|
|
@ -237,6 +237,9 @@ proc installApiHandlers*(node: SigningNodeRef) =
|
||||||
(GeneralizedIndex(401), request.beaconBlockHeader.data)
|
(GeneralizedIndex(401), request.beaconBlockHeader.data)
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
(GeneralizedIndex(801), request.beaconBlockHeader.data)
|
(GeneralizedIndex(801), request.beaconBlockHeader.data)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra signing node missing"
|
||||||
|
(GeneralizedIndex(801*42), request.beaconBlockHeader.data)
|
||||||
|
|
||||||
if request.proofs.isNone() or len(request.proofs.get()) == 0:
|
if request.proofs.isNone() or len(request.proofs.get()) == 0:
|
||||||
return errorResponse(Http400, MissingMerkleProofError)
|
return errorResponse(Http400, MissingMerkleProofError)
|
||||||
|
|
|
@ -1003,7 +1003,11 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
||||||
|
|
||||||
withBlck(bdata.asSigned()):
|
withBlck(bdata.asSigned()):
|
||||||
when consensusFork <= ConsensusFork.Altair:
|
when consensusFork == ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra, beacon API missing"
|
||||||
|
let x = 5
|
||||||
|
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
||||||
|
elif consensusFork <= ConsensusFork.Altair:
|
||||||
respondSszOrJson(forkyBlck, consensusFork)
|
respondSszOrJson(forkyBlck, consensusFork)
|
||||||
else:
|
else:
|
||||||
respondSszOrJson(toSignedBlindedBeaconBlock(forkyBlck), consensusFork)
|
respondSszOrJson(toSignedBlindedBeaconBlock(forkyBlck), consensusFork)
|
||||||
|
@ -1034,7 +1038,11 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
return RestApiResponse.jsonError(Http400, BlockIncorrectFork)
|
return RestApiResponse.jsonError(Http400, BlockIncorrectFork)
|
||||||
|
|
||||||
withConsensusFork(currentEpochFork):
|
withConsensusFork(currentEpochFork):
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "beacon API builder API"
|
||||||
|
return RestApiResponse.jsonError(
|
||||||
|
Http400, $consensusFork & " builder API unsupported")
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
let
|
let
|
||||||
restBlock = decodeBodyJsonOrSsz(
|
restBlock = decodeBodyJsonOrSsz(
|
||||||
consensusFork.SignedBlindedBeaconBlock, body).valueOr:
|
consensusFork.SignedBlindedBeaconBlock, body).valueOr:
|
||||||
|
|
|
@ -57,9 +57,13 @@ proc installDebugApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
elif contentType == sszMediaType:
|
elif contentType == sszMediaType:
|
||||||
let headers = [("eth-consensus-version", state.kind.toString())]
|
let headers = [("eth-consensus-version", state.kind.toString())]
|
||||||
withState(state):
|
withState(state):
|
||||||
|
debugRaiseAssert "debug beacon API"
|
||||||
|
when consensusFork != ConsensusFork.Electra:
|
||||||
RestApiResponse.sszResponse(forkyState.data, headers)
|
RestApiResponse.sszResponse(forkyState.data, headers)
|
||||||
else:
|
else:
|
||||||
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
||||||
|
else:
|
||||||
|
RestApiResponse.jsonError(Http500, InvalidAcceptError)
|
||||||
|
|
||||||
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
RestApiResponse.jsonError(Http404, StateNotFoundError)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import ".."/[beacon_chain_db, beacon_node],
|
||||||
".."/consensus_object_pools/[blockchain_dag, spec_cache,
|
".."/consensus_object_pools/[blockchain_dag, spec_cache,
|
||||||
attestation_pool, sync_committee_msg_pool],
|
attestation_pool, sync_committee_msg_pool],
|
||||||
".."/validators/beacon_validators,
|
".."/validators/beacon_validators,
|
||||||
".."/spec/[beaconstate, forks, network],
|
".."/spec/[beaconstate, forks, network, state_transition_block],
|
||||||
".."/spec/datatypes/[phase0, altair],
|
".."/spec/datatypes/[phase0, altair],
|
||||||
"."/[rest_utils, state_ttl_cache]
|
"."/[rest_utils, state_ttl_cache]
|
||||||
|
|
||||||
|
@ -408,7 +408,10 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
return
|
return
|
||||||
withBlck(message.blck):
|
withBlck(message.blck):
|
||||||
let data =
|
let data =
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "validator API, electra"
|
||||||
|
default(phase0.BeaconBlock)
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
let blobsBundle = message.blobsBundleOpt.get()
|
let blobsBundle = message.blobsBundleOpt.get()
|
||||||
deneb.BlockContents(
|
deneb.BlockContents(
|
||||||
`block`: forkyBlck,
|
`block`: forkyBlck,
|
||||||
|
@ -522,7 +525,12 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
contextFork = node.dag.cfg.consensusForkAtEpoch(node.currentSlot.epoch)
|
contextFork = node.dag.cfg.consensusForkAtEpoch(node.currentSlot.epoch)
|
||||||
|
|
||||||
withConsensusFork(contextFork):
|
withConsensusFork(contextFork):
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
# why not, it's a true error message. also:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
return RestApiResponse.jsonError(
|
||||||
|
Http400, "Pre-Deneb builder API unsupported")
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
let res = await makeBlindedBeaconBlockForHeadAndSlot[
|
let res = await makeBlindedBeaconBlockForHeadAndSlot[
|
||||||
consensusFork.BlindedBeaconBlock](
|
consensusFork.BlindedBeaconBlock](
|
||||||
node, payloadBuilderClient, qrandao,
|
node, payloadBuilderClient, qrandao,
|
||||||
|
@ -632,7 +640,10 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
return RestApiResponse.jsonError(Http400, InvalidRandaoRevealValue)
|
return RestApiResponse.jsonError(Http400, InvalidRandaoRevealValue)
|
||||||
|
|
||||||
withConsensusFork(node.dag.cfg.consensusForkAtEpoch(qslot.epoch)):
|
withConsensusFork(node.dag.cfg.consensusForkAtEpoch(qslot.epoch)):
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "foo"
|
||||||
|
return RestApiResponse.jsonError(Http400, InvalidRandaoRevealValue)
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
let
|
let
|
||||||
message = (await node.makeMaybeBlindedBeaconBlockForHeadAndSlot(
|
message = (await node.makeMaybeBlindedBeaconBlockForHeadAndSlot(
|
||||||
consensusFork, qrandao, qgraffiti, qhead, qslot)).valueOr:
|
consensusFork, qrandao, qgraffiti, qhead, qslot)).valueOr:
|
||||||
|
|
|
@ -597,6 +597,8 @@ proc jsonResponseBlock*(t: typedesc[RestApiResponse],
|
||||||
writer.writeField("execution_optimistic", execOpt.get())
|
writer.writeField("execution_optimistic", execOpt.get())
|
||||||
writer.writeField("finalized", finalized)
|
writer.writeField("finalized", finalized)
|
||||||
withBlck(data):
|
withBlck(data):
|
||||||
|
debugRaiseAssert "foo"
|
||||||
|
when consensusFork != ConsensusFork.Electra:
|
||||||
writer.writeField("data", forkyBlck)
|
writer.writeField("data", forkyBlck)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
stream.getOutput(seq[byte])
|
stream.getOutput(seq[byte])
|
||||||
|
@ -620,6 +622,8 @@ proc jsonResponseState*(t: typedesc[RestApiResponse],
|
||||||
if execOpt.isSome():
|
if execOpt.isSome():
|
||||||
writer.writeField("execution_optimistic", execOpt.get())
|
writer.writeField("execution_optimistic", execOpt.get())
|
||||||
withState(data):
|
withState(data):
|
||||||
|
debugRaiseAssert "foo"
|
||||||
|
when consensusFork != ConsensusFork.Electra:
|
||||||
writer.writeField("data", forkyState.data)
|
writer.writeField("data", forkyState.data)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
stream.getOutput(seq[byte])
|
stream.getOutput(seq[byte])
|
||||||
|
@ -677,6 +681,8 @@ proc jsonResponseWVersion*(t: typedesc[RestApiResponse], data: auto,
|
||||||
var writer = JsonWriter[RestJson].init(stream)
|
var writer = JsonWriter[RestJson].init(stream)
|
||||||
writer.beginRecord()
|
writer.beginRecord()
|
||||||
writer.writeField("version", version.toString())
|
writer.writeField("version", version.toString())
|
||||||
|
when (not (data is electra.BeaconState)) and (not (data is electra.HashedBeaconState)) and (not (data is electra.ExecutionPayload)) and (not (data is electra.ExecutionPayloadForSigning)) and (not (data is electra.ExecutionPayloadHeader)) and (not (data is electra.BeaconBlock)) and (not (data is electra.SignedBeaconBlock)):
|
||||||
|
debugRaiseAssert "foo"
|
||||||
writer.writeField("data", data)
|
writer.writeField("data", data)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
stream.getOutput(seq[byte])
|
stream.getOutput(seq[byte])
|
||||||
|
@ -1517,6 +1523,10 @@ proc readValue*[BlockType: ProduceBlockResponseV2](
|
||||||
value = ProduceBlockResponseV2(kind: ConsensusFork.Deneb,
|
value = ProduceBlockResponseV2(kind: ConsensusFork.Deneb,
|
||||||
denebData: res)
|
denebData: res)
|
||||||
|
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra"
|
||||||
|
reader.raiseUnexpectedValue("electra missing")
|
||||||
|
|
||||||
proc readValue*[BlockType: ForkedBlindedBeaconBlock](
|
proc readValue*[BlockType: ForkedBlindedBeaconBlock](
|
||||||
reader: var JsonReader[RestJson],
|
reader: var JsonReader[RestJson],
|
||||||
value: var BlockType
|
value: var BlockType
|
||||||
|
@ -1583,6 +1593,9 @@ proc readValue*[BlockType: ForkedBlindedBeaconBlock](
|
||||||
exc.formatMsg("BlindedBlock") & "]")
|
exc.formatMsg("BlindedBlock") & "]")
|
||||||
value = ForkedBlindedBeaconBlock(kind: ConsensusFork.Deneb,
|
value = ForkedBlindedBeaconBlock(kind: ConsensusFork.Deneb,
|
||||||
denebData: res)
|
denebData: res)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra, REST reading"
|
||||||
|
reader.raiseUnexpectedValue("Incorrect electra block format")
|
||||||
|
|
||||||
proc readValue*[BlockType: Web3SignerForkedBeaconBlock](
|
proc readValue*[BlockType: Web3SignerForkedBeaconBlock](
|
||||||
reader: var JsonReader[RestJson],
|
reader: var JsonReader[RestJson],
|
||||||
|
@ -1885,6 +1898,8 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
assign(
|
assign(
|
||||||
value.denebBody.execution_payload.excess_blob_gas,
|
value.denebBody.execution_payload.excess_blob_gas,
|
||||||
ep_src.excess_blob_gas.get())
|
ep_src.excess_blob_gas.get())
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra support missing"
|
||||||
|
|
||||||
## RestPublishedBeaconBlock
|
## RestPublishedBeaconBlock
|
||||||
proc readValue*(reader: var JsonReader[RestJson],
|
proc readValue*(reader: var JsonReader[RestJson],
|
||||||
|
@ -1991,6 +2006,9 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
body: body.denebBody
|
body: body.denebBody
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra missing"
|
||||||
|
default(ForkedBeaconBlock)
|
||||||
)
|
)
|
||||||
|
|
||||||
## RestPublishedSignedBeaconBlock
|
## RestPublishedSignedBeaconBlock
|
||||||
|
@ -2104,7 +2122,9 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
reader.raiseUnexpectedValue("Length mismatch of `kzg_proofs` and `blobs`")
|
reader.raiseUnexpectedValue("Length mismatch of `kzg_proofs` and `blobs`")
|
||||||
|
|
||||||
withBlck(distinctBase(signed_message.get)):
|
withBlck(distinctBase(signed_message.get)):
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra support missing"
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
template kzg_commitments: untyped =
|
template kzg_commitments: untyped =
|
||||||
forkyBlck.message.body.blob_kzg_commitments
|
forkyBlck.message.body.blob_kzg_commitments
|
||||||
if kzg_proofs.get().len != kzg_commitments.len:
|
if kzg_proofs.get().len != kzg_commitments.len:
|
||||||
|
@ -2232,6 +2252,8 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
reader.raiseUnexpectedValue("Incorrect deneb block format")
|
reader.raiseUnexpectedValue("Incorrect deneb block format")
|
||||||
|
|
||||||
value = ForkedSignedBeaconBlock.init(res)
|
value = ForkedSignedBeaconBlock.init(res)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra support missing"
|
||||||
withBlck(value):
|
withBlck(value):
|
||||||
forkyBlck.root = hash_tree_root(forkyBlck.message)
|
forkyBlck.root = hash_tree_root(forkyBlck.message)
|
||||||
|
|
||||||
|
@ -2255,6 +2277,8 @@ proc writeValue*(
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
writer.writeField("version", "deneb")
|
writer.writeField("version", "deneb")
|
||||||
writer.writeField("data", value.denebData)
|
writer.writeField("data", value.denebData)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "writeValue RestJson Electra ForkedSignedBaconBlock"
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
|
|
||||||
# ForkedHashedBeaconState is used where a `ForkedBeaconState` normally would
|
# ForkedHashedBeaconState is used where a `ForkedBeaconState` normally would
|
||||||
|
@ -2358,6 +2382,9 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
except SerializationError:
|
except SerializationError:
|
||||||
reader.raiseUnexpectedValue("Incorrect deneb beacon state format")
|
reader.raiseUnexpectedValue("Incorrect deneb beacon state format")
|
||||||
toValue(denebData)
|
toValue(denebData)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra missing"
|
||||||
|
reader.raiseUnexpectedValue("electra missing")
|
||||||
|
|
||||||
proc writeValue*(
|
proc writeValue*(
|
||||||
writer: var JsonWriter[RestJson], value: ForkedHashedBeaconState
|
writer: var JsonWriter[RestJson], value: ForkedHashedBeaconState
|
||||||
|
@ -2379,6 +2406,8 @@ proc writeValue*(
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
writer.writeField("version", "deneb")
|
writer.writeField("version", "deneb")
|
||||||
writer.writeField("data", value.denebData.data)
|
writer.writeField("data", value.denebData.data)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "writeValue RestJson ForkedHashedBeaconState Electra missing"
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
|
|
||||||
## SomeForkedLightClientObject
|
## SomeForkedLightClientObject
|
||||||
|
@ -3302,6 +3331,9 @@ proc writeValue*(writer: var JsonWriter[RestJson],
|
||||||
if value.consensusValue.isSome():
|
if value.consensusValue.isSome():
|
||||||
writer.writeField("consensus_block_value",
|
writer.writeField("consensus_block_value",
|
||||||
$(value.consensusValue.get()))
|
$(value.consensusValue.get()))
|
||||||
|
when consensusFork == ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra JsonWriter ProduceBlockV3 missing"
|
||||||
|
else:
|
||||||
writer.writeField("data", forkyMaybeBlindedBlck)
|
writer.writeField("data", forkyMaybeBlindedBlck)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
|
|
||||||
|
@ -3328,7 +3360,9 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
reader.raiseUnexpectedValue("Field `data` is missing")
|
reader.raiseUnexpectedValue("Field `data` is missing")
|
||||||
|
|
||||||
withConsensusFork(version.get):
|
withConsensusFork(version.get):
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra missing"
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
if blinded.get:
|
if blinded.get:
|
||||||
value = ForkedMaybeBlindedBeaconBlock.init(
|
value = ForkedMaybeBlindedBeaconBlock.init(
|
||||||
RestJson.decode(
|
RestJson.decode(
|
||||||
|
@ -3458,6 +3492,9 @@ proc decodeBody*(
|
||||||
return err(RestErrorMessage.init(Http400, UnexpectedDecodeError,
|
return err(RestErrorMessage.init(Http400, UnexpectedDecodeError,
|
||||||
[version, $exc.msg]))
|
[version, $exc.msg]))
|
||||||
ok(RestPublishedSignedBeaconBlock(ForkedSignedBeaconBlock.init(blck)))
|
ok(RestPublishedSignedBeaconBlock(ForkedSignedBeaconBlock.init(blck)))
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra"
|
||||||
|
return err(RestErrorMessage.init(Http400, UnexpectedDecodeError))
|
||||||
else:
|
else:
|
||||||
err(RestErrorMessage.init(Http415, "Invalid content type",
|
err(RestErrorMessage.init(Http415, "Invalid content type",
|
||||||
[version, $body.contentType]))
|
[version, $body.contentType]))
|
||||||
|
@ -3548,6 +3585,9 @@ proc decodeBody*(
|
||||||
[version, $exc.msg]))
|
[version, $exc.msg]))
|
||||||
ok(RestPublishedSignedBlockContents(
|
ok(RestPublishedSignedBlockContents(
|
||||||
kind: ConsensusFork.Deneb, denebData: blckContents))
|
kind: ConsensusFork.Deneb, denebData: blckContents))
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra"
|
||||||
|
return err(RestErrorMessage.init(Http400, UnexpectedDecodeError))
|
||||||
else:
|
else:
|
||||||
err(RestErrorMessage.init(Http415, "Invalid content type",
|
err(RestErrorMessage.init(Http415, "Invalid content type",
|
||||||
[version, $body.contentType]))
|
[version, $body.contentType]))
|
||||||
|
@ -3677,6 +3717,10 @@ proc decodeBodyJsonOrSsz*(
|
||||||
[version, $exc.msg]))
|
[version, $exc.msg]))
|
||||||
ok(RestPublishedSignedBlockContents(
|
ok(RestPublishedSignedBlockContents(
|
||||||
kind: ConsensusFork.Deneb, denebData: blckContents))
|
kind: ConsensusFork.Deneb, denebData: blckContents))
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra"
|
||||||
|
return err(
|
||||||
|
RestErrorMessage.init(Http400, UnexpectedDecodeError))
|
||||||
else:
|
else:
|
||||||
err(RestErrorMessage.init(Http415, "Invalid content type",
|
err(RestErrorMessage.init(Http415, "Invalid content type",
|
||||||
[version, $body.contentType]))
|
[version, $body.contentType]))
|
||||||
|
@ -3820,6 +3864,9 @@ proc decodeBytes*[T: DecodeConsensysTypes](
|
||||||
let fork = ConsensusFork.decodeString(consensusVersion).valueOr:
|
let fork = ConsensusFork.decodeString(consensusVersion).valueOr:
|
||||||
return err("Invalid or Unsupported consensus version")
|
return err("Invalid or Unsupported consensus version")
|
||||||
case fork
|
case fork
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra in REST decodeBytes"
|
||||||
|
return err("Invalid or Unsupported consensus version")
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
let blckContents = ? readSszResBytes(deneb.BlockContents, value)
|
let blckContents = ? readSszResBytes(deneb.BlockContents, value)
|
||||||
ok(ProduceBlockResponseV2(kind: ConsensusFork.Deneb,
|
ok(ProduceBlockResponseV2(kind: ConsensusFork.Deneb,
|
||||||
|
@ -3844,6 +3891,9 @@ proc decodeBytes*[T: DecodeConsensysTypes](
|
||||||
let fork = ConsensusFork.decodeString(consensusVersion).valueOr:
|
let fork = ConsensusFork.decodeString(consensusVersion).valueOr:
|
||||||
return err("Invalid or Unsupported consensus version")
|
return err("Invalid or Unsupported consensus version")
|
||||||
case fork
|
case fork
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "rest decoding blinded"
|
||||||
|
err("electra missing")
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
let
|
let
|
||||||
blck = ? readSszResBytes(deneb_mev.BlindedBeaconBlock, value)
|
blck = ? readSszResBytes(deneb_mev.BlindedBeaconBlock, value)
|
||||||
|
@ -3916,7 +3966,10 @@ proc decodeBytes*[T: ProduceBlockResponseV3](
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return err("Incorrect `Eth-Consensus-Block-Value` header value")
|
return err("Incorrect `Eth-Consensus-Block-Value` header value")
|
||||||
withConsensusFork(fork):
|
withConsensusFork(fork):
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "eth2 rest serialization"
|
||||||
|
return err("electra missing")
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
if blinded:
|
if blinded:
|
||||||
let contents =
|
let contents =
|
||||||
? readSszResBytes(consensusFork.BlindedBlockContents, value)
|
? readSszResBytes(consensusFork.BlindedBlockContents, value)
|
||||||
|
|
|
@ -341,6 +341,7 @@ type
|
||||||
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.SignedBeaconBlock
|
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.SignedBeaconBlock
|
||||||
of ConsensusFork.Capella: capellaData*: capella.SignedBeaconBlock
|
of ConsensusFork.Capella: capellaData*: capella.SignedBeaconBlock
|
||||||
of ConsensusFork.Deneb: denebData*: DenebSignedBlockContents
|
of ConsensusFork.Deneb: denebData*: DenebSignedBlockContents
|
||||||
|
of ConsensusFork.Electra: electraData*: ElectraSignedBlockContents
|
||||||
|
|
||||||
RestPublishedBeaconBlock* = distinct ForkedBeaconBlock
|
RestPublishedBeaconBlock* = distinct ForkedBeaconBlock
|
||||||
|
|
||||||
|
@ -351,6 +352,7 @@ type
|
||||||
of ConsensusFork.Bellatrix: bellatrixBody*: bellatrix.BeaconBlockBody
|
of ConsensusFork.Bellatrix: bellatrixBody*: bellatrix.BeaconBlockBody
|
||||||
of ConsensusFork.Capella: capellaBody*: capella.BeaconBlockBody
|
of ConsensusFork.Capella: capellaBody*: capella.BeaconBlockBody
|
||||||
of ConsensusFork.Deneb: denebBody*: deneb.BeaconBlockBody
|
of ConsensusFork.Deneb: denebBody*: deneb.BeaconBlockBody
|
||||||
|
of ConsensusFork.Electra: electraBody*: electra.BeaconBlockBody
|
||||||
|
|
||||||
ProduceBlockResponseV2* = object
|
ProduceBlockResponseV2* = object
|
||||||
case kind*: ConsensusFork
|
case kind*: ConsensusFork
|
||||||
|
@ -359,6 +361,7 @@ type
|
||||||
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.BeaconBlock
|
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.BeaconBlock
|
||||||
of ConsensusFork.Capella: capellaData*: capella.BeaconBlock
|
of ConsensusFork.Capella: capellaData*: capella.BeaconBlock
|
||||||
of ConsensusFork.Deneb: denebData*: deneb.BlockContents
|
of ConsensusFork.Deneb: denebData*: deneb.BlockContents
|
||||||
|
of ConsensusFork.Electra: electraData*: electra.BlockContents
|
||||||
|
|
||||||
ProduceBlockResponseV3* = ForkedMaybeBlindedBeaconBlock
|
ProduceBlockResponseV3* = ForkedMaybeBlindedBeaconBlock
|
||||||
|
|
||||||
|
@ -615,6 +618,12 @@ func `==`*(a, b: RestValidatorIndex): bool =
|
||||||
template withForkyBlck*(
|
template withForkyBlck*(
|
||||||
x: RestPublishedSignedBlockContents, body: untyped): untyped =
|
x: RestPublishedSignedBlockContents, body: untyped): untyped =
|
||||||
case x.kind
|
case x.kind
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
const consensusFork {.inject, used.} = ConsensusFork.Electra
|
||||||
|
template forkyBlck: untyped {.inject, used.} = x.electraData.signed_block
|
||||||
|
template kzg_proofs: untyped {.inject, used.} = x.electraData.kzg_proofs
|
||||||
|
template blobs: untyped {.inject, used.} = x.electraData.blobs
|
||||||
|
body
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
||||||
template forkyBlck: untyped {.inject, used.} = x.denebData.signed_block
|
template forkyBlck: untyped {.inject, used.} = x.denebData.signed_block
|
||||||
|
@ -652,6 +661,9 @@ func init*(T: type ForkedSignedBeaconBlock,
|
||||||
ForkedSignedBeaconBlock.init(contents.capellaData)
|
ForkedSignedBeaconBlock.init(contents.capellaData)
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
ForkedSignedBeaconBlock.init(contents.denebData.signed_block)
|
ForkedSignedBeaconBlock.init(contents.denebData.signed_block)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra init ForkedSignedBeaconBlock from RestPublished*"
|
||||||
|
default(ForkedSignedBeaconBlock)
|
||||||
|
|
||||||
func init*(t: typedesc[RestPublishedSignedBlockContents],
|
func init*(t: typedesc[RestPublishedSignedBlockContents],
|
||||||
blck: phase0.BeaconBlock, root: Eth2Digest,
|
blck: phase0.BeaconBlock, root: Eth2Digest,
|
||||||
|
|
|
@ -46,7 +46,8 @@ type
|
||||||
Altair,
|
Altair,
|
||||||
Bellatrix,
|
Bellatrix,
|
||||||
Capella,
|
Capella,
|
||||||
Deneb
|
Deneb,
|
||||||
|
Electra
|
||||||
|
|
||||||
ForkyBeaconState* =
|
ForkyBeaconState* =
|
||||||
phase0.BeaconState |
|
phase0.BeaconState |
|
||||||
|
@ -71,6 +72,7 @@ type
|
||||||
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.HashedBeaconState
|
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.HashedBeaconState
|
||||||
of ConsensusFork.Capella: capellaData*: capella.HashedBeaconState
|
of ConsensusFork.Capella: capellaData*: capella.HashedBeaconState
|
||||||
of ConsensusFork.Deneb: denebData*: deneb.HashedBeaconState
|
of ConsensusFork.Deneb: denebData*: deneb.HashedBeaconState
|
||||||
|
of ConsensusFork.Electra: electraData*: electra.HashedBeaconState
|
||||||
|
|
||||||
ForkyExecutionPayload* =
|
ForkyExecutionPayload* =
|
||||||
bellatrix.ExecutionPayload |
|
bellatrix.ExecutionPayload |
|
||||||
|
@ -156,6 +158,7 @@ type
|
||||||
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.BeaconBlock
|
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.BeaconBlock
|
||||||
of ConsensusFork.Capella: capellaData*: capella.BeaconBlock
|
of ConsensusFork.Capella: capellaData*: capella.BeaconBlock
|
||||||
of ConsensusFork.Deneb: denebData*: deneb.BeaconBlock
|
of ConsensusFork.Deneb: denebData*: deneb.BeaconBlock
|
||||||
|
of ConsensusFork.Electra: electraData*: electra.BeaconBlock
|
||||||
|
|
||||||
ForkedMaybeBlindedBeaconBlock* = object
|
ForkedMaybeBlindedBeaconBlock* = object
|
||||||
case kind*: ConsensusFork
|
case kind*: ConsensusFork
|
||||||
|
@ -169,6 +172,8 @@ type
|
||||||
capellaData*: capella.BeaconBlock
|
capellaData*: capella.BeaconBlock
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
denebData*: deneb_mev.MaybeBlindedBeaconBlock
|
denebData*: deneb_mev.MaybeBlindedBeaconBlock
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
electraData*: electra.BeaconBlock
|
||||||
consensusValue*: Opt[UInt256]
|
consensusValue*: Opt[UInt256]
|
||||||
executionValue*: Opt[UInt256]
|
executionValue*: Opt[UInt256]
|
||||||
|
|
||||||
|
@ -183,6 +188,7 @@ type
|
||||||
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix_mev.BlindedBeaconBlock
|
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix_mev.BlindedBeaconBlock
|
||||||
of ConsensusFork.Capella: capellaData*: capella_mev.BlindedBeaconBlock
|
of ConsensusFork.Capella: capellaData*: capella_mev.BlindedBeaconBlock
|
||||||
of ConsensusFork.Deneb: denebData*: deneb_mev.BlindedBeaconBlock
|
of ConsensusFork.Deneb: denebData*: deneb_mev.BlindedBeaconBlock
|
||||||
|
of ConsensusFork.Electra: electraData*: electra.BeaconBlock
|
||||||
|
|
||||||
ForkySignedBeaconBlock* =
|
ForkySignedBeaconBlock* =
|
||||||
phase0.SignedBeaconBlock |
|
phase0.SignedBeaconBlock |
|
||||||
|
@ -199,6 +205,7 @@ type
|
||||||
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.SignedBeaconBlock
|
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.SignedBeaconBlock
|
||||||
of ConsensusFork.Capella: capellaData*: capella.SignedBeaconBlock
|
of ConsensusFork.Capella: capellaData*: capella.SignedBeaconBlock
|
||||||
of ConsensusFork.Deneb: denebData*: deneb.SignedBeaconBlock
|
of ConsensusFork.Deneb: denebData*: deneb.SignedBeaconBlock
|
||||||
|
of ConsensusFork.Electra: electraData*: electra.SignedBeaconBlock
|
||||||
|
|
||||||
ForkySignedBlindedBeaconBlock* =
|
ForkySignedBlindedBeaconBlock* =
|
||||||
phase0.SignedBeaconBlock |
|
phase0.SignedBeaconBlock |
|
||||||
|
@ -214,6 +221,7 @@ type
|
||||||
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix_mev.SignedBlindedBeaconBlock
|
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix_mev.SignedBlindedBeaconBlock
|
||||||
of ConsensusFork.Capella: capellaData*: capella_mev.SignedBlindedBeaconBlock
|
of ConsensusFork.Capella: capellaData*: capella_mev.SignedBlindedBeaconBlock
|
||||||
of ConsensusFork.Deneb: denebData*: deneb_mev.SignedBlindedBeaconBlock
|
of ConsensusFork.Deneb: denebData*: deneb_mev.SignedBlindedBeaconBlock
|
||||||
|
of ConsensusFork.Electra: electraData*: electra.SignedBeaconBlock
|
||||||
|
|
||||||
ForkySigVerifiedSignedBeaconBlock* =
|
ForkySigVerifiedSignedBeaconBlock* =
|
||||||
phase0.SigVerifiedSignedBeaconBlock |
|
phase0.SigVerifiedSignedBeaconBlock |
|
||||||
|
@ -246,6 +254,7 @@ type
|
||||||
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.MsgTrustedSignedBeaconBlock
|
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.MsgTrustedSignedBeaconBlock
|
||||||
of ConsensusFork.Capella: capellaData*: capella.MsgTrustedSignedBeaconBlock
|
of ConsensusFork.Capella: capellaData*: capella.MsgTrustedSignedBeaconBlock
|
||||||
of ConsensusFork.Deneb: denebData*: deneb.MsgTrustedSignedBeaconBlock
|
of ConsensusFork.Deneb: denebData*: deneb.MsgTrustedSignedBeaconBlock
|
||||||
|
of ConsensusFork.Electra: electraData*: electra.MsgTrustedSignedBeaconBlock
|
||||||
|
|
||||||
ForkedTrustedSignedBeaconBlock* = object
|
ForkedTrustedSignedBeaconBlock* = object
|
||||||
case kind*: ConsensusFork
|
case kind*: ConsensusFork
|
||||||
|
@ -254,6 +263,7 @@ type
|
||||||
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.TrustedSignedBeaconBlock
|
of ConsensusFork.Bellatrix: bellatrixData*: bellatrix.TrustedSignedBeaconBlock
|
||||||
of ConsensusFork.Capella: capellaData*: capella.TrustedSignedBeaconBlock
|
of ConsensusFork.Capella: capellaData*: capella.TrustedSignedBeaconBlock
|
||||||
of ConsensusFork.Deneb: denebData*: deneb.TrustedSignedBeaconBlock
|
of ConsensusFork.Deneb: denebData*: deneb.TrustedSignedBeaconBlock
|
||||||
|
of ConsensusFork.Electra: electraData*: electra.TrustedSignedBeaconBlock
|
||||||
|
|
||||||
SomeForkySignedBeaconBlock* =
|
SomeForkySignedBeaconBlock* =
|
||||||
ForkySignedBeaconBlock |
|
ForkySignedBeaconBlock |
|
||||||
|
@ -367,8 +377,28 @@ template kind*(
|
||||||
deneb_mev.SignedBlindedBeaconBlock]): ConsensusFork =
|
deneb_mev.SignedBlindedBeaconBlock]): ConsensusFork =
|
||||||
ConsensusFork.Deneb
|
ConsensusFork.Deneb
|
||||||
|
|
||||||
|
template kind*(
|
||||||
|
x: typedesc[
|
||||||
|
electra.BeaconState |
|
||||||
|
electra.HashedBeaconState |
|
||||||
|
electra.ExecutionPayload |
|
||||||
|
electra.ExecutionPayloadForSigning |
|
||||||
|
electra.ExecutionPayloadHeader |
|
||||||
|
electra.BeaconBlock |
|
||||||
|
electra.SignedBeaconBlock |
|
||||||
|
electra.TrustedBeaconBlock |
|
||||||
|
electra.BeaconBlockBody |
|
||||||
|
electra.SigVerifiedBeaconBlockBody |
|
||||||
|
electra.TrustedBeaconBlockBody |
|
||||||
|
electra.SigVerifiedSignedBeaconBlock |
|
||||||
|
electra.MsgTrustedSignedBeaconBlock |
|
||||||
|
electra.TrustedSignedBeaconBlock]): ConsensusFork =
|
||||||
|
ConsensusFork.Electra
|
||||||
|
|
||||||
template BeaconState*(kind: static ConsensusFork): auto =
|
template BeaconState*(kind: static ConsensusFork): auto =
|
||||||
when kind == ConsensusFork.Deneb:
|
when kind == ConsensusFork.Electra:
|
||||||
|
typedesc[electra.BeaconState]
|
||||||
|
elif kind == ConsensusFork.Deneb:
|
||||||
typedesc[deneb.BeaconState]
|
typedesc[deneb.BeaconState]
|
||||||
elif kind == ConsensusFork.Capella:
|
elif kind == ConsensusFork.Capella:
|
||||||
typedesc[capella.BeaconState]
|
typedesc[capella.BeaconState]
|
||||||
|
@ -396,7 +426,9 @@ template BeaconBlock*(kind: static ConsensusFork): auto =
|
||||||
static: raiseAssert "Unreachable"
|
static: raiseAssert "Unreachable"
|
||||||
|
|
||||||
template BeaconBlockBody*(kind: static ConsensusFork): auto =
|
template BeaconBlockBody*(kind: static ConsensusFork): auto =
|
||||||
when kind == ConsensusFork.Deneb:
|
when kind == ConsensusFork.Electra:
|
||||||
|
typedesc[electra.BeaconBlockBody]
|
||||||
|
elif kind == ConsensusFork.Deneb:
|
||||||
typedesc[deneb.BeaconBlockBody]
|
typedesc[deneb.BeaconBlockBody]
|
||||||
elif kind == ConsensusFork.Capella:
|
elif kind == ConsensusFork.Capella:
|
||||||
typedesc[capella.BeaconBlockBody]
|
typedesc[capella.BeaconBlockBody]
|
||||||
|
@ -410,7 +442,9 @@ template BeaconBlockBody*(kind: static ConsensusFork): auto =
|
||||||
static: raiseAssert "Unreachable"
|
static: raiseAssert "Unreachable"
|
||||||
|
|
||||||
template SignedBeaconBlock*(kind: static ConsensusFork): auto =
|
template SignedBeaconBlock*(kind: static ConsensusFork): auto =
|
||||||
when kind == ConsensusFork.Deneb:
|
when kind == ConsensusFork.Electra:
|
||||||
|
typedesc[electra.SignedBeaconBlock]
|
||||||
|
elif kind == ConsensusFork.Deneb:
|
||||||
typedesc[deneb.SignedBeaconBlock]
|
typedesc[deneb.SignedBeaconBlock]
|
||||||
elif kind == ConsensusFork.Capella:
|
elif kind == ConsensusFork.Capella:
|
||||||
typedesc[capella.SignedBeaconBlock]
|
typedesc[capella.SignedBeaconBlock]
|
||||||
|
@ -424,7 +458,9 @@ template SignedBeaconBlock*(kind: static ConsensusFork): auto =
|
||||||
static: raiseAssert "Unreachable"
|
static: raiseAssert "Unreachable"
|
||||||
|
|
||||||
template TrustedSignedBeaconBlock*(kind: static ConsensusFork): auto =
|
template TrustedSignedBeaconBlock*(kind: static ConsensusFork): auto =
|
||||||
when kind == ConsensusFork.Deneb:
|
when kind == ConsensusFork.Electra:
|
||||||
|
typedesc[electra.TrustedSignedBeaconBlock]
|
||||||
|
elif kind == ConsensusFork.Deneb:
|
||||||
typedesc[deneb.TrustedSignedBeaconBlock]
|
typedesc[deneb.TrustedSignedBeaconBlock]
|
||||||
elif kind == ConsensusFork.Capella:
|
elif kind == ConsensusFork.Capella:
|
||||||
typedesc[capella.TrustedSignedBeaconBlock]
|
typedesc[capella.TrustedSignedBeaconBlock]
|
||||||
|
@ -438,7 +474,9 @@ template TrustedSignedBeaconBlock*(kind: static ConsensusFork): auto =
|
||||||
static: raiseAssert "Unreachable"
|
static: raiseAssert "Unreachable"
|
||||||
|
|
||||||
template ExecutionPayloadForSigning*(kind: static ConsensusFork): auto =
|
template ExecutionPayloadForSigning*(kind: static ConsensusFork): auto =
|
||||||
when kind == ConsensusFork.Deneb:
|
when kind == ConsensusFork.Electra:
|
||||||
|
typedesc[electra.ExecutionPayloadForSigning]
|
||||||
|
elif kind == ConsensusFork.Deneb:
|
||||||
typedesc[deneb.ExecutionPayloadForSigning]
|
typedesc[deneb.ExecutionPayloadForSigning]
|
||||||
elif kind == ConsensusFork.Capella:
|
elif kind == ConsensusFork.Capella:
|
||||||
typedesc[capella.ExecutionPayloadForSigning]
|
typedesc[capella.ExecutionPayloadForSigning]
|
||||||
|
@ -478,7 +516,11 @@ template Forky*(
|
||||||
|
|
||||||
template withAll*(
|
template withAll*(
|
||||||
x: typedesc[ConsensusFork], body: untyped): untyped =
|
x: typedesc[ConsensusFork], body: untyped): untyped =
|
||||||
static: doAssert ConsensusFork.high == ConsensusFork.Deneb
|
static: doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||||
|
debugRaiseAssert "don't turn on electra here yet"
|
||||||
|
#block:
|
||||||
|
# const consensusFork {.inject, used.} = ConsensusFork.Electra
|
||||||
|
# body
|
||||||
block:
|
block:
|
||||||
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
||||||
body
|
body
|
||||||
|
@ -498,6 +540,9 @@ template withAll*(
|
||||||
template withConsensusFork*(
|
template withConsensusFork*(
|
||||||
x: ConsensusFork, body: untyped): untyped =
|
x: ConsensusFork, body: untyped): untyped =
|
||||||
case x
|
case x
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
const consensusFork {.inject, used.} = ConsensusFork.Electra
|
||||||
|
body
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
||||||
body
|
body
|
||||||
|
@ -516,7 +561,9 @@ template withConsensusFork*(
|
||||||
|
|
||||||
template BlockContents*(
|
template BlockContents*(
|
||||||
kind: static ConsensusFork): auto =
|
kind: static ConsensusFork): auto =
|
||||||
when kind == ConsensusFork.Deneb:
|
when kind == ConsensusFork.Electra:
|
||||||
|
typedesc[electra.BlockContents]
|
||||||
|
elif kind == ConsensusFork.Deneb:
|
||||||
typedesc[deneb.BlockContents]
|
typedesc[deneb.BlockContents]
|
||||||
elif kind == ConsensusFork.Capella:
|
elif kind == ConsensusFork.Capella:
|
||||||
typedesc[capella.BeaconBlock]
|
typedesc[capella.BeaconBlock]
|
||||||
|
@ -554,8 +601,9 @@ template PayloadAttributes*(
|
||||||
{.error: "PayloadAttributes does not support " & $kind.}
|
{.error: "PayloadAttributes does not support " & $kind.}
|
||||||
|
|
||||||
# `eth2_merkleization` cannot import `forks` (circular), so the check is here
|
# `eth2_merkleization` cannot import `forks` (circular), so the check is here
|
||||||
static: doAssert ConsensusFork.high == ConsensusFork.Deneb,
|
static: doAssert ConsensusFork.high == ConsensusFork.Electra,
|
||||||
"eth2_merkleization has been checked and `hash_tree_root` is up to date"
|
"eth2_merkleization has been checked and `hash_tree_root` is up to date"
|
||||||
|
debugRaiseAssert("this has not actually been checked for Electra, but it doesn't matter unless the electra fork is entered")
|
||||||
|
|
||||||
# TODO when https://github.com/nim-lang/Nim/issues/21086 fixed, use return type
|
# TODO when https://github.com/nim-lang/Nim/issues/21086 fixed, use return type
|
||||||
# `ref T`
|
# `ref T`
|
||||||
|
@ -601,6 +649,8 @@ template init*(T: type ForkedSignedBeaconBlock, blck: capella.SignedBeaconBlock)
|
||||||
T(kind: ConsensusFork.Capella, capellaData: blck)
|
T(kind: ConsensusFork.Capella, capellaData: blck)
|
||||||
template init*(T: type ForkedSignedBeaconBlock, blck: deneb.SignedBeaconBlock): T =
|
template init*(T: type ForkedSignedBeaconBlock, blck: deneb.SignedBeaconBlock): T =
|
||||||
T(kind: ConsensusFork.Deneb, denebData: blck)
|
T(kind: ConsensusFork.Deneb, denebData: blck)
|
||||||
|
template init*(T: type ForkedSignedBeaconBlock, blck: electra.SignedBeaconBlock): T =
|
||||||
|
T(kind: ConsensusFork.Electra, electraData: blck)
|
||||||
|
|
||||||
func init*(T: type ForkedSignedBeaconBlock, forked: ForkedBeaconBlock,
|
func init*(T: type ForkedSignedBeaconBlock, forked: ForkedBeaconBlock,
|
||||||
blockRoot: Eth2Digest, signature: ValidatorSig): T =
|
blockRoot: Eth2Digest, signature: ValidatorSig): T =
|
||||||
|
@ -630,6 +680,11 @@ func init*(T: type ForkedSignedBeaconBlock, forked: ForkedBeaconBlock,
|
||||||
denebData: deneb.SignedBeaconBlock(message: forked.denebData,
|
denebData: deneb.SignedBeaconBlock(message: forked.denebData,
|
||||||
root: blockRoot,
|
root: blockRoot,
|
||||||
signature: signature))
|
signature: signature))
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
T(kind: ConsensusFork.Electra,
|
||||||
|
electraData: electra.SignedBeaconBlock(message: forked.electraData,
|
||||||
|
root: blockRoot,
|
||||||
|
signature: signature))
|
||||||
|
|
||||||
func init*(T: type ForkedSignedBlindedBeaconBlock,
|
func init*(T: type ForkedSignedBlindedBeaconBlock,
|
||||||
forked: ForkedBlindedBeaconBlock, blockRoot: Eth2Digest,
|
forked: ForkedBlindedBeaconBlock, blockRoot: Eth2Digest,
|
||||||
|
@ -656,6 +711,11 @@ func init*(T: type ForkedSignedBlindedBeaconBlock,
|
||||||
T(kind: ConsensusFork.Deneb,
|
T(kind: ConsensusFork.Deneb,
|
||||||
denebData: deneb_mev.SignedBlindedBeaconBlock(message: forked.denebData,
|
denebData: deneb_mev.SignedBlindedBeaconBlock(message: forked.denebData,
|
||||||
signature: signature))
|
signature: signature))
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
T(kind: ConsensusFork.Electra,
|
||||||
|
electraData: electra.SignedBeaconBlock(message: forked.electraData,
|
||||||
|
root: blockRoot,
|
||||||
|
signature: signature))
|
||||||
|
|
||||||
template init*(T: type ForkedSignedBlindedBeaconBlock,
|
template init*(T: type ForkedSignedBlindedBeaconBlock,
|
||||||
blck: capella_mev.BlindedBeaconBlock, blockRoot: Eth2Digest,
|
blck: capella_mev.BlindedBeaconBlock, blockRoot: Eth2Digest,
|
||||||
|
@ -692,6 +752,8 @@ template init*(T: type ForkedTrustedSignedBeaconBlock, blck: capella.TrustedSign
|
||||||
T(kind: ConsensusFork.Capella, capellaData: blck)
|
T(kind: ConsensusFork.Capella, capellaData: blck)
|
||||||
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: deneb.TrustedSignedBeaconBlock): T =
|
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: deneb.TrustedSignedBeaconBlock): T =
|
||||||
T(kind: ConsensusFork.Deneb, denebData: blck)
|
T(kind: ConsensusFork.Deneb, denebData: blck)
|
||||||
|
template init*(T: type ForkedTrustedSignedBeaconBlock, blck: electra.TrustedSignedBeaconBlock): T =
|
||||||
|
T(kind: ConsensusFork.Electra, electraData: blck)
|
||||||
|
|
||||||
template toString*(kind: ConsensusFork): string =
|
template toString*(kind: ConsensusFork): string =
|
||||||
case kind
|
case kind
|
||||||
|
@ -705,9 +767,13 @@ template toString*(kind: ConsensusFork): string =
|
||||||
"capella"
|
"capella"
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
"deneb"
|
"deneb"
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
"electra"
|
||||||
|
|
||||||
template init*(T: typedesc[ConsensusFork], value: string): Opt[ConsensusFork] =
|
template init*(T: typedesc[ConsensusFork], value: string): Opt[ConsensusFork] =
|
||||||
case value
|
case value
|
||||||
|
of "electra":
|
||||||
|
Opt.some ConsensusFork.Electra
|
||||||
of "deneb":
|
of "deneb":
|
||||||
Opt.some ConsensusFork.Deneb
|
Opt.some ConsensusFork.Deneb
|
||||||
of "capella":
|
of "capella":
|
||||||
|
@ -732,6 +798,10 @@ template init*(T: type ForkedEpochInfo, info: altair.EpochInfo): T =
|
||||||
|
|
||||||
template withState*(x: ForkedHashedBeaconState, body: untyped): untyped =
|
template withState*(x: ForkedHashedBeaconState, body: untyped): untyped =
|
||||||
case x.kind
|
case x.kind
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
const consensusFork {.inject, used.} = ConsensusFork.Electra
|
||||||
|
template forkyState: untyped {.inject, used.} = x.electraData
|
||||||
|
body
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
||||||
template forkyState: untyped {.inject, used.} = x.denebData
|
template forkyState: untyped {.inject, used.} = x.denebData
|
||||||
|
@ -758,7 +828,9 @@ template forky*(
|
||||||
ForkedBeaconBlock |
|
ForkedBeaconBlock |
|
||||||
ForkedHashedBeaconState,
|
ForkedHashedBeaconState,
|
||||||
kind: static ConsensusFork): untyped =
|
kind: static ConsensusFork): untyped =
|
||||||
when kind == ConsensusFork.Deneb:
|
when kind == ConsensusFork.Electra:
|
||||||
|
x.electraData
|
||||||
|
elif kind == ConsensusFork.Deneb:
|
||||||
x.denebData
|
x.denebData
|
||||||
elif kind == ConsensusFork.Capella:
|
elif kind == ConsensusFork.Capella:
|
||||||
x.capellaData
|
x.capellaData
|
||||||
|
@ -830,6 +902,8 @@ func setStateRoot*(x: var ForkedHashedBeaconState, root: Eth2Digest) =
|
||||||
func consensusForkEpoch*(
|
func consensusForkEpoch*(
|
||||||
cfg: RuntimeConfig, consensusFork: ConsensusFork): Epoch =
|
cfg: RuntimeConfig, consensusFork: ConsensusFork): Epoch =
|
||||||
case consensusFork
|
case consensusFork
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
cfg.ELECTRA_FORK_EPOCH
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
cfg.DENEB_FORK_EPOCH
|
cfg.DENEB_FORK_EPOCH
|
||||||
of ConsensusFork.Capella:
|
of ConsensusFork.Capella:
|
||||||
|
@ -844,14 +918,16 @@ func consensusForkEpoch*(
|
||||||
func consensusForkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): ConsensusFork =
|
func consensusForkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): ConsensusFork =
|
||||||
## Return the current fork for the given epoch.
|
## Return the current fork for the given epoch.
|
||||||
static:
|
static:
|
||||||
doAssert high(ConsensusFork) == ConsensusFork.Deneb
|
doAssert high(ConsensusFork) == ConsensusFork.Electra
|
||||||
|
doAssert ConsensusFork.Electra > ConsensusFork.Deneb
|
||||||
doAssert ConsensusFork.Deneb > ConsensusFork.Capella
|
doAssert ConsensusFork.Deneb > ConsensusFork.Capella
|
||||||
doAssert ConsensusFork.Capella > ConsensusFork.Bellatrix
|
doAssert ConsensusFork.Capella > ConsensusFork.Bellatrix
|
||||||
doAssert ConsensusFork.Bellatrix > ConsensusFork.Altair
|
doAssert ConsensusFork.Bellatrix > ConsensusFork.Altair
|
||||||
doAssert ConsensusFork.Altair > ConsensusFork.Phase0
|
doAssert ConsensusFork.Altair > ConsensusFork.Phase0
|
||||||
doAssert GENESIS_EPOCH == 0
|
doAssert GENESIS_EPOCH == 0
|
||||||
|
|
||||||
if epoch >= cfg.DENEB_FORK_EPOCH: ConsensusFork.Deneb
|
if epoch >= cfg.ELECTRA_FORK_EPOCH: ConsensusFork.Electra
|
||||||
|
elif epoch >= cfg.DENEB_FORK_EPOCH: ConsensusFork.Deneb
|
||||||
elif epoch >= cfg.CAPELLA_FORK_EPOCH: ConsensusFork.Capella
|
elif epoch >= cfg.CAPELLA_FORK_EPOCH: ConsensusFork.Capella
|
||||||
elif epoch >= cfg.BELLATRIX_FORK_EPOCH: ConsensusFork.Bellatrix
|
elif epoch >= cfg.BELLATRIX_FORK_EPOCH: ConsensusFork.Bellatrix
|
||||||
elif epoch >= cfg.ALTAIR_FORK_EPOCH: ConsensusFork.Altair
|
elif epoch >= cfg.ALTAIR_FORK_EPOCH: ConsensusFork.Altair
|
||||||
|
@ -859,8 +935,10 @@ func consensusForkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): ConsensusFork =
|
||||||
|
|
||||||
func consensusForkForDigest*(
|
func consensusForkForDigest*(
|
||||||
forkDigests: ForkDigests, forkDigest: ForkDigest): Opt[ConsensusFork] =
|
forkDigests: ForkDigests, forkDigest: ForkDigest): Opt[ConsensusFork] =
|
||||||
static: doAssert high(ConsensusFork) == ConsensusFork.Deneb
|
static: doAssert high(ConsensusFork) == ConsensusFork.Electra
|
||||||
if forkDigest == forkDigests.deneb:
|
if forkDigest == forkDigests.electra:
|
||||||
|
ok ConsensusFork.Electra
|
||||||
|
elif forkDigest == forkDigests.deneb:
|
||||||
ok ConsensusFork.Deneb
|
ok ConsensusFork.Deneb
|
||||||
elif forkDigest == forkDigests.capella:
|
elif forkDigest == forkDigests.capella:
|
||||||
ok ConsensusFork.Capella
|
ok ConsensusFork.Capella
|
||||||
|
@ -876,6 +954,8 @@ func consensusForkForDigest*(
|
||||||
func atConsensusFork*(
|
func atConsensusFork*(
|
||||||
forkDigests: ForkDigests, consensusFork: ConsensusFork): ForkDigest =
|
forkDigests: ForkDigests, consensusFork: ConsensusFork): ForkDigest =
|
||||||
case consensusFork
|
case consensusFork
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
forkDigests.electra
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
forkDigests.deneb
|
forkDigests.deneb
|
||||||
of ConsensusFork.Capella:
|
of ConsensusFork.Capella:
|
||||||
|
@ -954,6 +1034,10 @@ template withBlck*(
|
||||||
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
||||||
template forkyBlck: untyped {.inject, used.} = x.denebData
|
template forkyBlck: untyped {.inject, used.} = x.denebData
|
||||||
body
|
body
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
const consensusFork {.inject, used.} = ConsensusFork.Electra
|
||||||
|
template forkyBlck: untyped {.inject, used.} = x.electraData
|
||||||
|
body
|
||||||
|
|
||||||
func proposer_index*(x: ForkedBeaconBlock): uint64 =
|
func proposer_index*(x: ForkedBeaconBlock): uint64 =
|
||||||
withBlck(x): forkyBlck.proposer_index
|
withBlck(x): forkyBlck.proposer_index
|
||||||
|
@ -977,7 +1061,8 @@ template getForkedBlockField*(
|
||||||
of ConsensusFork.Altair: unsafeAddr x.altairData.message.y
|
of ConsensusFork.Altair: unsafeAddr x.altairData.message.y
|
||||||
of ConsensusFork.Bellatrix: unsafeAddr x.bellatrixData.message.y
|
of ConsensusFork.Bellatrix: unsafeAddr x.bellatrixData.message.y
|
||||||
of ConsensusFork.Capella: unsafeAddr x.capellaData.message.y
|
of ConsensusFork.Capella: unsafeAddr x.capellaData.message.y
|
||||||
of ConsensusFork.Deneb: unsafeAddr x.denebData.message.y)[]
|
of ConsensusFork.Deneb: unsafeAddr x.denebData.message.y
|
||||||
|
of ConsensusFork.Electra: unsafeAddr x.electraData.message.y)[]
|
||||||
|
|
||||||
template signature*(x: ForkedSignedBeaconBlock |
|
template signature*(x: ForkedSignedBeaconBlock |
|
||||||
ForkedMsgTrustedSignedBeaconBlock |
|
ForkedMsgTrustedSignedBeaconBlock |
|
||||||
|
@ -1015,6 +1100,12 @@ template withForkyMaybeBlindedBlck*(
|
||||||
b: ForkedMaybeBlindedBeaconBlock,
|
b: ForkedMaybeBlindedBeaconBlock,
|
||||||
body: untyped): untyped =
|
body: untyped): untyped =
|
||||||
case b.kind
|
case b.kind
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
const
|
||||||
|
consensusFork {.inject, used.} = ConsensusFork.Electra
|
||||||
|
isBlinded {.inject, used.} = false
|
||||||
|
template forkyMaybeBlindedBlck: untyped {.inject, used.} = b.electraData
|
||||||
|
body
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
||||||
template d: untyped = b.denebData
|
template d: untyped = b.denebData
|
||||||
|
@ -1059,6 +1150,11 @@ template withStateAndBlck*(
|
||||||
ForkedTrustedSignedBeaconBlock,
|
ForkedTrustedSignedBeaconBlock,
|
||||||
body: untyped): untyped =
|
body: untyped): untyped =
|
||||||
case s.kind
|
case s.kind
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
const consensusFork {.inject, used.} = ConsensusFork.Electra
|
||||||
|
template forkyState: untyped {.inject.} = s.electraData
|
||||||
|
template forkyBlck: untyped {.inject.} = b.electraData
|
||||||
|
body
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
const consensusFork {.inject, used.} = ConsensusFork.Deneb
|
||||||
template forkyState: untyped {.inject.} = s.denebData
|
template forkyState: untyped {.inject.} = s.denebData
|
||||||
|
@ -1153,6 +1249,7 @@ func electraFork*(cfg: RuntimeConfig): Fork =
|
||||||
|
|
||||||
func forkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Fork =
|
func forkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Fork =
|
||||||
case cfg.consensusForkAtEpoch(epoch)
|
case cfg.consensusForkAtEpoch(epoch)
|
||||||
|
of ConsensusFork.Electra: cfg.electraFork
|
||||||
of ConsensusFork.Deneb: cfg.denebFork
|
of ConsensusFork.Deneb: cfg.denebFork
|
||||||
of ConsensusFork.Capella: cfg.capellaFork
|
of ConsensusFork.Capella: cfg.capellaFork
|
||||||
of ConsensusFork.Bellatrix: cfg.bellatrixFork
|
of ConsensusFork.Bellatrix: cfg.bellatrixFork
|
||||||
|
@ -1161,6 +1258,7 @@ func forkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Fork =
|
||||||
|
|
||||||
func forkVersionAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Version =
|
func forkVersionAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Version =
|
||||||
case cfg.consensusForkAtEpoch(epoch)
|
case cfg.consensusForkAtEpoch(epoch)
|
||||||
|
of ConsensusFork.Electra: cfg.ELECTRA_FORK_VERSION
|
||||||
of ConsensusFork.Deneb: cfg.DENEB_FORK_VERSION
|
of ConsensusFork.Deneb: cfg.DENEB_FORK_VERSION
|
||||||
of ConsensusFork.Capella: cfg.CAPELLA_FORK_VERSION
|
of ConsensusFork.Capella: cfg.CAPELLA_FORK_VERSION
|
||||||
of ConsensusFork.Bellatrix: cfg.BELLATRIX_FORK_VERSION
|
of ConsensusFork.Bellatrix: cfg.BELLATRIX_FORK_VERSION
|
||||||
|
@ -1168,9 +1266,9 @@ func forkVersionAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Version =
|
||||||
of ConsensusFork.Phase0: cfg.GENESIS_FORK_VERSION
|
of ConsensusFork.Phase0: cfg.GENESIS_FORK_VERSION
|
||||||
|
|
||||||
func nextForkEpochAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Epoch =
|
func nextForkEpochAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): Epoch =
|
||||||
static: doAssert high(ConsensusFork) == ConsensusFork.Deneb
|
|
||||||
case cfg.consensusForkAtEpoch(epoch)
|
case cfg.consensusForkAtEpoch(epoch)
|
||||||
of ConsensusFork.Deneb: FAR_FUTURE_EPOCH
|
of ConsensusFork.Electra: FAR_FUTURE_EPOCH
|
||||||
|
of ConsensusFork.Deneb: cfg.ELECTRA_FORK_EPOCH
|
||||||
of ConsensusFork.Capella: cfg.DENEB_FORK_EPOCH
|
of ConsensusFork.Capella: cfg.DENEB_FORK_EPOCH
|
||||||
of ConsensusFork.Bellatrix: cfg.CAPELLA_FORK_EPOCH
|
of ConsensusFork.Bellatrix: cfg.CAPELLA_FORK_EPOCH
|
||||||
of ConsensusFork.Altair: cfg.BELLATRIX_FORK_EPOCH
|
of ConsensusFork.Altair: cfg.BELLATRIX_FORK_EPOCH
|
||||||
|
@ -1183,6 +1281,7 @@ func forkVersion*(cfg: RuntimeConfig, consensusFork: ConsensusFork): Version =
|
||||||
of ConsensusFork.Bellatrix: cfg.BELLATRIX_FORK_VERSION
|
of ConsensusFork.Bellatrix: cfg.BELLATRIX_FORK_VERSION
|
||||||
of ConsensusFork.Capella: cfg.CAPELLA_FORK_VERSION
|
of ConsensusFork.Capella: cfg.CAPELLA_FORK_VERSION
|
||||||
of ConsensusFork.Deneb: cfg.DENEB_FORK_VERSION
|
of ConsensusFork.Deneb: cfg.DENEB_FORK_VERSION
|
||||||
|
of ConsensusFork.Electra: cfg.ELECTRA_FORK_VERSION
|
||||||
|
|
||||||
func lcDataForkAtConsensusFork*(
|
func lcDataForkAtConsensusFork*(
|
||||||
consensusFork: ConsensusFork): LightClientDataFork =
|
consensusFork: ConsensusFork): LightClientDataFork =
|
||||||
|
@ -1290,7 +1389,7 @@ func compute_fork_digest*(current_version: Version,
|
||||||
func init*(T: type ForkDigests,
|
func init*(T: type ForkDigests,
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
genesis_validators_root: Eth2Digest): T =
|
genesis_validators_root: Eth2Digest): T =
|
||||||
static: doAssert high(ConsensusFork) == ConsensusFork.Deneb
|
static: doAssert high(ConsensusFork) == ConsensusFork.Electra
|
||||||
T(
|
T(
|
||||||
phase0:
|
phase0:
|
||||||
compute_fork_digest(cfg.GENESIS_FORK_VERSION, genesis_validators_root),
|
compute_fork_digest(cfg.GENESIS_FORK_VERSION, genesis_validators_root),
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
./datatypes/[phase0, altair, bellatrix, capella, deneb],
|
./datatypes/[phase0, altair, bellatrix, capella, deneb, electra],
|
||||||
./eth2_merkleization
|
./eth2_merkleization
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -957,9 +957,13 @@ func toLightClientHeader*(
|
||||||
altair.SignedBeaconBlock | altair.TrustedSignedBeaconBlock |
|
altair.SignedBeaconBlock | altair.TrustedSignedBeaconBlock |
|
||||||
bellatrix.SignedBeaconBlock | bellatrix.TrustedSignedBeaconBlock |
|
bellatrix.SignedBeaconBlock | bellatrix.TrustedSignedBeaconBlock |
|
||||||
capella.SignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
capella.SignedBeaconBlock | capella.TrustedSignedBeaconBlock |
|
||||||
deneb.SignedBeaconBlock | deneb.TrustedSignedBeaconBlock,
|
deneb.SignedBeaconBlock | deneb.TrustedSignedBeaconBlock |
|
||||||
|
electra.SignedBeaconBlock | electra.TrustedSignedBeaconBlock,
|
||||||
kind: static LightClientDataFork): auto =
|
kind: static LightClientDataFork): auto =
|
||||||
when kind == LightClientDataFork.Deneb:
|
when blck is electra.SignedBeaconBlock or blck is electra.TrustedSignedBeaconBlock:
|
||||||
|
debugRaiseAssert "toLightClientHeader electra missing"
|
||||||
|
default(deneb.LightClientHeader)
|
||||||
|
elif kind == LightClientDataFork.Deneb:
|
||||||
blck.toDenebLightClientHeader()
|
blck.toDenebLightClientHeader()
|
||||||
elif kind == LightClientDataFork.Capella:
|
elif kind == LightClientDataFork.Capella:
|
||||||
blck.toCapellaLightClientHeader()
|
blck.toCapellaLightClientHeader()
|
||||||
|
|
|
@ -295,7 +295,10 @@ 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).kind:
|
when consensusFork == ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra state_transition_block"
|
||||||
|
err("no")
|
||||||
|
elif 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")
|
||||||
|
@ -457,6 +460,8 @@ proc makeBeaconBlockWithRewards*(
|
||||||
])
|
])
|
||||||
else:
|
else:
|
||||||
raiseAssert "Attempt to use non-Deneb payload with post-Deneb state"
|
raiseAssert "Attempt to use non-Deneb payload with post-Deneb state"
|
||||||
|
elif consensusFork == ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "makeBeaconBlock doesn't support Electra"
|
||||||
else:
|
else:
|
||||||
static: raiseAssert "Unreachable"
|
static: raiseAssert "Unreachable"
|
||||||
|
|
||||||
|
@ -480,6 +485,8 @@ proc makeBeaconBlockWithRewards*(
|
||||||
case state.kind
|
case state.kind
|
||||||
of ConsensusFork.Deneb: makeBeaconBlock(deneb)
|
of ConsensusFork.Deneb: makeBeaconBlock(deneb)
|
||||||
else: raiseAssert "Attempt to use Deneb payload with non-Deneb state"
|
else: raiseAssert "Attempt to use Deneb payload with non-Deneb state"
|
||||||
|
elif payloadFork == ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "Electra block production missing"
|
||||||
else:
|
else:
|
||||||
{.error: "Unsupported fork".}
|
{.error: "Unsupported fork".}
|
||||||
|
|
||||||
|
|
|
@ -2259,6 +2259,9 @@ proc publishBlock*(
|
||||||
publishBlock(it, data.capellaData)
|
publishBlock(it, data.capellaData)
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
publishBlock(it, data.denebData)
|
publishBlock(it, data.denebData)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra missing"
|
||||||
|
publishBlock(it, data.denebData)
|
||||||
do:
|
do:
|
||||||
if apiResponse.isErr():
|
if apiResponse.isErr():
|
||||||
handleCommunicationError()
|
handleCommunicationError()
|
||||||
|
@ -2305,6 +2308,9 @@ proc publishBlock*(
|
||||||
publishBlock(it, data.capellaData)
|
publishBlock(it, data.capellaData)
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
publishBlock(it, data.denebData)
|
publishBlock(it, data.denebData)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra in vc"
|
||||||
|
publishBlock(it, data.denebData)
|
||||||
|
|
||||||
do:
|
do:
|
||||||
if apiResponse.isErr():
|
if apiResponse.isErr():
|
||||||
|
@ -2461,6 +2467,9 @@ proc publishBlindedBlock*(
|
||||||
publishBlindedBlock(it, data.capellaData)
|
publishBlindedBlock(it, data.capellaData)
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
publishBlindedBlock(it, data.denebData)
|
publishBlindedBlock(it, data.denebData)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "vc part something"
|
||||||
|
publishBlindedBlock(it, data.denebData)
|
||||||
do:
|
do:
|
||||||
if apiResponse.isErr():
|
if apiResponse.isErr():
|
||||||
handleCommunicationError()
|
handleCommunicationError()
|
||||||
|
@ -2506,6 +2515,9 @@ proc publishBlindedBlock*(
|
||||||
publishBlindedBlock(it, data.capellaData)
|
publishBlindedBlock(it, data.capellaData)
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
publishBlindedBlock(it, data.denebData)
|
publishBlindedBlock(it, data.denebData)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "more electra vc"
|
||||||
|
publishBlindedBlock(it, data.denebData)
|
||||||
do:
|
do:
|
||||||
if apiResponse.isErr():
|
if apiResponse.isErr():
|
||||||
handleCommunicationError()
|
handleCommunicationError()
|
||||||
|
|
|
@ -38,7 +38,10 @@ func shortLog(v: Opt[UInt256]): auto =
|
||||||
|
|
||||||
func shortLog(v: ForkedMaybeBlindedBeaconBlock): auto =
|
func shortLog(v: ForkedMaybeBlindedBeaconBlock): auto =
|
||||||
withForkyMaybeBlindedBlck(v):
|
withForkyMaybeBlindedBlck(v):
|
||||||
when consensusFork < ConsensusFork.Deneb:
|
when consensusFork == ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
shortLog(default(phase0.BeaconBlock))
|
||||||
|
elif consensusFork < ConsensusFork.Deneb:
|
||||||
shortLog(forkyMaybeBlindedBlck)
|
shortLog(forkyMaybeBlindedBlck)
|
||||||
else:
|
else:
|
||||||
when isBlinded:
|
when isBlinded:
|
||||||
|
@ -109,6 +112,9 @@ proc produceBlock(
|
||||||
data: ForkedBeaconBlock.init(blck),
|
data: ForkedBeaconBlock.init(blck),
|
||||||
kzgProofsOpt: Opt.some(kzgProofs),
|
kzgProofsOpt: Opt.some(kzgProofs),
|
||||||
blobsOpt: Opt.some(blobs)))
|
blobsOpt: Opt.some(blobs)))
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
return Opt.none(PreparedBeaconBlock)
|
||||||
|
|
||||||
proc produceBlindedBlock(
|
proc produceBlindedBlock(
|
||||||
vc: ValidatorClientRef,
|
vc: ValidatorClientRef,
|
||||||
|
@ -323,9 +329,12 @@ proc publishBlockV3(vc: ValidatorClientRef, currentSlot, slot: Slot,
|
||||||
warn "Blinded block was not accepted by beacon node"
|
warn "Blinded block was not accepted by beacon node"
|
||||||
false
|
false
|
||||||
else:
|
else:
|
||||||
|
debugRaiseAssert "electra htr"
|
||||||
let
|
let
|
||||||
blockRoot = hash_tree_root(
|
blockRoot = hash_tree_root(
|
||||||
when consensusFork < ConsensusFork.Deneb:
|
when consensusFork == ConsensusFork.Electra:
|
||||||
|
default(Attestation)
|
||||||
|
elif consensusFork < ConsensusFork.Deneb:
|
||||||
forkyMaybeBlindedBlck
|
forkyMaybeBlindedBlck
|
||||||
else:
|
else:
|
||||||
forkyMaybeBlindedBlck.`block`
|
forkyMaybeBlindedBlck.`block`
|
||||||
|
@ -345,9 +354,12 @@ proc publishBlockV3(vc: ValidatorClientRef, currentSlot, slot: Slot,
|
||||||
.slashingProtection
|
.slashingProtection
|
||||||
.registerBlock(vindex, validator.pubkey, slot, signingRoot)
|
.registerBlock(vindex, validator.pubkey, slot, signingRoot)
|
||||||
|
|
||||||
|
debugRaiseAssert "electra logging"
|
||||||
logScope:
|
logScope:
|
||||||
blck = shortLog(
|
blck = shortLog(
|
||||||
when consensusFork < ConsensusFork.Deneb:
|
when consensusFork == ConsensusFork.Electra:
|
||||||
|
default(phase0.BeaconBlock)
|
||||||
|
elif consensusFork < ConsensusFork.Deneb:
|
||||||
forkyMaybeBlindedBlck
|
forkyMaybeBlindedBlck
|
||||||
else:
|
else:
|
||||||
forkyMaybeBlindedBlck.`block`
|
forkyMaybeBlindedBlck.`block`
|
||||||
|
@ -599,6 +611,9 @@ proc publishBlockV2(vc: ValidatorClientRef, currentSlot, slot: Slot,
|
||||||
signature: signature),
|
signature: signature),
|
||||||
kzg_proofs: preparedBlock.kzgProofsOpt.get,
|
kzg_proofs: preparedBlock.kzgProofsOpt.get,
|
||||||
blobs: preparedBlock.blobsOpt.get))
|
blobs: preparedBlock.blobsOpt.get))
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
default(RestPublishedSignedBlockContents)
|
||||||
|
|
||||||
res =
|
res =
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -421,6 +421,9 @@ proc getExecutionPayload(
|
||||||
PayloadType, beaconHead.blck.bid.root, executionHead, latestSafe,
|
PayloadType, beaconHead.blck.bid.root, executionHead, latestSafe,
|
||||||
latestFinalized, timestamp, random, feeRecipient, withdrawals)
|
latestFinalized, timestamp, random, feeRecipient, withdrawals)
|
||||||
|
|
||||||
|
# BlockRewards has issues resolving somehow otherwise
|
||||||
|
import ".."/spec/state_transition_block
|
||||||
|
|
||||||
proc makeBeaconBlockForHeadAndSlot*(
|
proc makeBeaconBlockForHeadAndSlot*(
|
||||||
PayloadType: type ForkyExecutionPayloadForSigning,
|
PayloadType: type ForkyExecutionPayloadForSigning,
|
||||||
node: BeaconNode, randao_reveal: ValidatorSig,
|
node: BeaconNode, randao_reveal: ValidatorSig,
|
||||||
|
@ -1195,7 +1198,10 @@ proc proposeBlock(node: BeaconNode,
|
||||||
genesis_validators_root, node.config.localBlockValueBoost)
|
genesis_validators_root, node.config.localBlockValueBoost)
|
||||||
|
|
||||||
return withConsensusFork(node.dag.cfg.consensusForkAtEpoch(slot.epoch)):
|
return withConsensusFork(node.dag.cfg.consensusForkAtEpoch(slot.epoch)):
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "can't propose electra block"
|
||||||
|
return default(BlockRef)
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
proposeBlockContinuation(
|
proposeBlockContinuation(
|
||||||
consensusFork.SignedBlindedBeaconBlock,
|
consensusFork.SignedBlindedBeaconBlock,
|
||||||
consensusFork.ExecutionPayloadForSigning)
|
consensusFork.ExecutionPayloadForSigning)
|
||||||
|
|
|
@ -535,7 +535,8 @@ proc getBlockSignature*(v: AttachedValidator, fork: Fork,
|
||||||
let web3signerRequest =
|
let web3signerRequest =
|
||||||
when blck is ForkedBlindedBeaconBlock:
|
when blck is ForkedBlindedBeaconBlock:
|
||||||
case blck.kind
|
case blck.kind
|
||||||
of ConsensusFork.Phase0 .. ConsensusFork.Capella:
|
of ConsensusFork.Phase0 .. ConsensusFork.Capella, ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "move electra case out"
|
||||||
return SignatureResult.err("Invalid blinded beacon block fork")
|
return SignatureResult.err("Invalid blinded beacon block fork")
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
case v.data.remoteType
|
case v.data.remoteType
|
||||||
|
@ -613,6 +614,9 @@ proc getBlockSignature*(v: AttachedValidator, fork: Fork,
|
||||||
Web3SignerForkedBeaconBlock(kind: ConsensusFork.Deneb,
|
Web3SignerForkedBeaconBlock(kind: ConsensusFork.Deneb,
|
||||||
data: forkyMaybeBlindedBlck.`block`.toBeaconBlockHeader),
|
data: forkyMaybeBlindedBlck.`block`.toBeaconBlockHeader),
|
||||||
proofs)
|
proofs)
|
||||||
|
elif consensusFork == ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
default(Web3SignerRequest)
|
||||||
else:
|
else:
|
||||||
case blck.kind
|
case blck.kind
|
||||||
of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix:
|
of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix:
|
||||||
|
@ -643,6 +647,9 @@ proc getBlockSignature*(v: AttachedValidator, fork: Fork,
|
||||||
Web3SignerForkedBeaconBlock(kind: ConsensusFork.Deneb,
|
Web3SignerForkedBeaconBlock(kind: ConsensusFork.Deneb,
|
||||||
data: blck.denebData.toBeaconBlockHeader),
|
data: blck.denebData.toBeaconBlockHeader),
|
||||||
proofs)
|
proofs)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "validator pool"
|
||||||
|
return SignatureResult.err("Invalid beacon block fork: electra")
|
||||||
await v.signData(web3signerRequest)
|
await v.signData(web3signerRequest)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregate-signature
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregate-signature
|
||||||
|
|
|
@ -98,6 +98,9 @@ template saveSSZFile(filename: string, value: ForkedHashedBeaconState) =
|
||||||
of ConsensusFork.Bellatrix: SSZ.saveFile(filename, value.bellatrixData.data)
|
of ConsensusFork.Bellatrix: SSZ.saveFile(filename, value.bellatrixData.data)
|
||||||
of ConsensusFork.Capella: SSZ.saveFile(filename, value.capellaData.data)
|
of ConsensusFork.Capella: SSZ.saveFile(filename, value.capellaData.data)
|
||||||
of ConsensusFork.Deneb: SSZ.saveFile(filename, value.denebData.data)
|
of ConsensusFork.Deneb: SSZ.saveFile(filename, value.denebData.data)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
let x = 5
|
||||||
except IOError:
|
except IOError:
|
||||||
raiseAssert "error saving SSZ file"
|
raiseAssert "error saving SSZ file"
|
||||||
|
|
||||||
|
|
|
@ -266,6 +266,9 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
blocks[4].add dag.db.getBlock(
|
blocks[4].add dag.db.getBlock(
|
||||||
blck.root, deneb.TrustedSignedBeaconBlock).get()
|
blck.root, deneb.TrustedSignedBeaconBlock).get()
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
let x = 5
|
||||||
|
|
||||||
let stateData = newClone(dag.headState)
|
let stateData = newClone(dag.headState)
|
||||||
|
|
||||||
|
@ -338,6 +341,9 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
doAssert dbBenchmark.getState(
|
doAssert dbBenchmark.getState(
|
||||||
forkyState.root, loadedState[4][].data, noRollback)
|
forkyState.root, loadedState[4][].data, noRollback)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
let x = 5
|
||||||
|
|
||||||
if forkyState.data.slot.epoch mod 16 == 0:
|
if forkyState.data.slot.epoch mod 16 == 0:
|
||||||
let loadedRoot = case consensusFork
|
let loadedRoot = case consensusFork
|
||||||
|
@ -346,6 +352,9 @@ proc cmdBench(conf: DbConf, cfg: RuntimeConfig) =
|
||||||
of ConsensusFork.Bellatrix: hash_tree_root(loadedState[2][].data)
|
of ConsensusFork.Bellatrix: hash_tree_root(loadedState[2][].data)
|
||||||
of ConsensusFork.Capella: hash_tree_root(loadedState[3][].data)
|
of ConsensusFork.Capella: hash_tree_root(loadedState[3][].data)
|
||||||
of ConsensusFork.Deneb: hash_tree_root(loadedState[4][].data)
|
of ConsensusFork.Deneb: hash_tree_root(loadedState[4][].data)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
ZERO_HASH
|
||||||
doAssert hash_tree_root(forkyState.data) == loadedRoot
|
doAssert hash_tree_root(forkyState.data) == loadedRoot
|
||||||
|
|
||||||
processBlocks(blocks[0])
|
processBlocks(blocks[0])
|
||||||
|
|
|
@ -472,6 +472,9 @@ cli do(slots = SLOTS_PER_EPOCH * 7,
|
||||||
if blockRatio > 0.0:
|
if blockRatio > 0.0:
|
||||||
withTimer(timers[t]):
|
withTimer(timers[t]):
|
||||||
case dag.cfg.consensusForkAtEpoch(slot.epoch)
|
case dag.cfg.consensusForkAtEpoch(slot.epoch)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
echo "no electra here"
|
||||||
|
debugRaiseAssert "no electra"
|
||||||
of ConsensusFork.Deneb: proposeDenebBlock(slot)
|
of ConsensusFork.Deneb: proposeDenebBlock(slot)
|
||||||
of ConsensusFork.Capella: proposeCapellaBlock(slot)
|
of ConsensusFork.Capella: proposeCapellaBlock(slot)
|
||||||
of ConsensusFork.Bellatrix, ConsensusFork.Altair, ConsensusFork.Phase0:
|
of ConsensusFork.Bellatrix, ConsensusFork.Altair, ConsensusFork.Phase0:
|
||||||
|
|
|
@ -221,6 +221,9 @@ cli do(validatorsDir: string, secretsDir: string,
|
||||||
fork, genesis_validators_root, slot, blockRoot,
|
fork, genesis_validators_root, slot, blockRoot,
|
||||||
validators[proposer]).toValidatorSig())
|
validators[proposer]).toValidatorSig())
|
||||||
dump(".", signedBlock)
|
dump(".", signedBlock)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert ""
|
||||||
|
let x =5
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
raiseAssert "unreachable"
|
raiseAssert "unreachable"
|
||||||
notice "Block proposed", message, blockRoot
|
notice "Block proposed", message, blockRoot
|
||||||
|
|
|
@ -47,6 +47,12 @@ func readValue*(r: var JsonReader, a: var seq[byte]) =
|
||||||
func genesisTestRuntimeConfig*(consensusFork: ConsensusFork): RuntimeConfig =
|
func genesisTestRuntimeConfig*(consensusFork: ConsensusFork): RuntimeConfig =
|
||||||
var res = defaultRuntimeConfig
|
var res = defaultRuntimeConfig
|
||||||
case consensusFork
|
case consensusFork
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
res.ELECTRA_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
res.DENEB_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
res.CAPELLA_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
res.BELLATRIX_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
res.ALTAIR_FORK_EPOCH = GENESIS_EPOCH
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
res.DENEB_FORK_EPOCH = GENESIS_EPOCH
|
res.DENEB_FORK_EPOCH = GENESIS_EPOCH
|
||||||
res.CAPELLA_FORK_EPOCH = GENESIS_EPOCH
|
res.CAPELLA_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
|
|
@ -123,13 +123,16 @@ proc loadOps(
|
||||||
let filename = step["block"].getStr()
|
let filename = step["block"].getStr()
|
||||||
doAssert step.hasKey"blobs" == step.hasKey"proofs"
|
doAssert step.hasKey"blobs" == step.hasKey"proofs"
|
||||||
withConsensusFork(fork):
|
withConsensusFork(fork):
|
||||||
|
when consensusFork != ConsensusFork.Electra:
|
||||||
let
|
let
|
||||||
blck = parseTest(
|
blck = parseTest(
|
||||||
path/filename & ".ssz_snappy",
|
path/filename & ".ssz_snappy",
|
||||||
SSZ, consensusFork.SignedBeaconBlock)
|
SSZ, consensusFork.SignedBeaconBlock)
|
||||||
|
|
||||||
blobData =
|
blobData =
|
||||||
when consensusFork >= ConsensusFork.Deneb:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "no electra support in fc test"
|
||||||
|
elif consensusFork >= ConsensusFork.Deneb:
|
||||||
if step.hasKey"blobs":
|
if step.hasKey"blobs":
|
||||||
numExtraFields += 2
|
numExtraFields += 2
|
||||||
Opt.some BlobData(
|
Opt.some BlobData(
|
||||||
|
@ -302,8 +305,13 @@ proc doRunTest(
|
||||||
|
|
||||||
let
|
let
|
||||||
stores = withConsensusFork(fork):
|
stores = withConsensusFork(fork):
|
||||||
|
when consensusFork != ConsensusFork.Electra:
|
||||||
|
# another withFoo when it statically knows, sure, ok, so this means another place it has to be disabled
|
||||||
initialLoad(
|
initialLoad(
|
||||||
path, db, consensusFork.BeaconState, consensusFork.BeaconBlock)
|
path, db, consensusFork.BeaconState, consensusFork.BeaconBlock)
|
||||||
|
else:
|
||||||
|
debugRaiseAssert "electra etc"
|
||||||
|
default(tuple[dag: ChainDAGRef, fkChoice: ref ForkChoice])
|
||||||
|
|
||||||
rng = HmacDrbgContext.new()
|
rng = HmacDrbgContext.new()
|
||||||
taskpool =
|
taskpool =
|
||||||
|
@ -335,6 +343,8 @@ proc doRunTest(
|
||||||
doAssert status.isOk == step.valid
|
doAssert status.isOk == step.valid
|
||||||
of opOnBlock:
|
of opOnBlock:
|
||||||
withBlck(step.blck):
|
withBlck(step.blck):
|
||||||
|
debugRaiseAssert "electra etc"
|
||||||
|
when typeof(forkyBlck).kind != ConsensusFork.Electra:
|
||||||
let status = stepOnBlock(
|
let status = stepOnBlock(
|
||||||
stores.dag, stores.fkChoice,
|
stores.dag, stores.fkChoice,
|
||||||
verifier, state[], stateCache,
|
verifier, state[], stateCache,
|
||||||
|
@ -396,6 +406,8 @@ template fcSuite(suiteName: static[string], testPathElem: static[string]) =
|
||||||
continue
|
continue
|
||||||
let fork = forkForPathComponent(path).valueOr:
|
let fork = forkForPathComponent(path).valueOr:
|
||||||
raiseAssert "Unknown test fork: " & testsPath
|
raiseAssert "Unknown test fork: " & testsPath
|
||||||
|
if true:
|
||||||
|
debugRaiseAssert "no electra in fc tests"
|
||||||
for kind, path in walkDir(testsPath, relative = true, checkDir = true):
|
for kind, path in walkDir(testsPath, relative = true, checkDir = true):
|
||||||
let basePath = testsPath/path/"pyspec_tests"
|
let basePath = testsPath/path/"pyspec_tests"
|
||||||
if kind != pcDir:
|
if kind != pcDir:
|
||||||
|
|
|
@ -68,6 +68,8 @@ suite "EF - Light client - Single merkle proof" & preset():
|
||||||
continue
|
continue
|
||||||
let objName = path
|
let objName = path
|
||||||
withConsensusFork(fork):
|
withConsensusFork(fork):
|
||||||
|
debugRaiseAssert ""
|
||||||
|
when consensusFork != ConsensusFork.Electra:
|
||||||
for kind, path in walkDir(suitePath, relative = true, checkDir = true):
|
for kind, path in walkDir(suitePath, relative = true, checkDir = true):
|
||||||
case objName
|
case objName
|
||||||
of "BeaconBlockBody":
|
of "BeaconBlockBody":
|
||||||
|
|
|
@ -25,12 +25,13 @@ suite "Light client" & preset():
|
||||||
headPeriod = 3.SyncCommitteePeriod
|
headPeriod = 3.SyncCommitteePeriod
|
||||||
let
|
let
|
||||||
cfg = block: # Fork schedule so that each `LightClientDataFork` is covered
|
cfg = block: # Fork schedule so that each `LightClientDataFork` is covered
|
||||||
static: doAssert ConsensusFork.high == ConsensusFork.Deneb
|
static: doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||||
var res = defaultRuntimeConfig
|
var res = defaultRuntimeConfig
|
||||||
res.ALTAIR_FORK_EPOCH = 1.Epoch
|
res.ALTAIR_FORK_EPOCH = 1.Epoch
|
||||||
res.BELLATRIX_FORK_EPOCH = 2.Epoch
|
res.BELLATRIX_FORK_EPOCH = 2.Epoch
|
||||||
res.CAPELLA_FORK_EPOCH = (EPOCHS_PER_SYNC_COMMITTEE_PERIOD * 1).Epoch
|
res.CAPELLA_FORK_EPOCH = (EPOCHS_PER_SYNC_COMMITTEE_PERIOD * 1).Epoch
|
||||||
res.DENEB_FORK_EPOCH = (EPOCHS_PER_SYNC_COMMITTEE_PERIOD * 2).Epoch
|
res.DENEB_FORK_EPOCH = (EPOCHS_PER_SYNC_COMMITTEE_PERIOD * 2).Epoch
|
||||||
|
debugRaiseAssert "don't use FAR_FUTURE_EPOCH"
|
||||||
res.ELECTRA_FORK_EPOCH = FAR_FUTURE_EPOCH
|
res.ELECTRA_FORK_EPOCH = FAR_FUTURE_EPOCH
|
||||||
res
|
res
|
||||||
altairStartSlot = cfg.ALTAIR_FORK_EPOCH.start_slot
|
altairStartSlot = cfg.ALTAIR_FORK_EPOCH.start_slot
|
||||||
|
|
|
@ -28,12 +28,13 @@ suite "Light client processor" & preset():
|
||||||
highPeriod = 5.SyncCommitteePeriod
|
highPeriod = 5.SyncCommitteePeriod
|
||||||
let
|
let
|
||||||
cfg = block: # Fork schedule so that each `LightClientDataFork` is covered
|
cfg = block: # Fork schedule so that each `LightClientDataFork` is covered
|
||||||
static: doAssert ConsensusFork.high == ConsensusFork.Deneb
|
static: doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||||
var res = defaultRuntimeConfig
|
var res = defaultRuntimeConfig
|
||||||
res.ALTAIR_FORK_EPOCH = 1.Epoch
|
res.ALTAIR_FORK_EPOCH = 1.Epoch
|
||||||
res.BELLATRIX_FORK_EPOCH = 2.Epoch
|
res.BELLATRIX_FORK_EPOCH = 2.Epoch
|
||||||
res.CAPELLA_FORK_EPOCH = (EPOCHS_PER_SYNC_COMMITTEE_PERIOD * 1).Epoch
|
res.CAPELLA_FORK_EPOCH = (EPOCHS_PER_SYNC_COMMITTEE_PERIOD * 1).Epoch
|
||||||
res.DENEB_FORK_EPOCH = (EPOCHS_PER_SYNC_COMMITTEE_PERIOD * 2).Epoch
|
res.DENEB_FORK_EPOCH = (EPOCHS_PER_SYNC_COMMITTEE_PERIOD * 2).Epoch
|
||||||
|
debugRaiseAssert "presumably FAR_FUTURE_EPOCH is less than optimal"
|
||||||
res.ELECTRA_FORK_EPOCH = FAR_FUTURE_EPOCH
|
res.ELECTRA_FORK_EPOCH = FAR_FUTURE_EPOCH
|
||||||
res
|
res
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,9 @@ func init(T: type ForkedBeaconBlock, contents: ProduceBlockResponseV2): T =
|
||||||
return ForkedBeaconBlock.init(contents.capellaData)
|
return ForkedBeaconBlock.init(contents.capellaData)
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
return ForkedBeaconBlock.init(contents.denebData.`block`)
|
return ForkedBeaconBlock.init(contents.denebData.`block`)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "probably like the deneb case"
|
||||||
|
return default(T)
|
||||||
|
|
||||||
proc getBlock(
|
proc getBlock(
|
||||||
fork: ConsensusFork,
|
fork: ConsensusFork,
|
||||||
|
@ -104,6 +107,9 @@ proc getBlock(
|
||||||
of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix: raiseAssert "Unsupported fork"
|
of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix: raiseAssert "Unsupported fork"
|
||||||
of ConsensusFork.Capella: CapellaBlock % [feeRecipient]
|
of ConsensusFork.Capella: CapellaBlock % [feeRecipient]
|
||||||
of ConsensusFork.Deneb: DenebBlockContents % [feeRecipient]
|
of ConsensusFork.Deneb: DenebBlockContents % [feeRecipient]
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra test signing node getblock"
|
||||||
|
raiseAssert "electra unsupported"
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# https://github.com/nim-lang/Nim/pull/23356
|
# https://github.com/nim-lang/Nim/pull/23356
|
||||||
raiseAssert "Arguments match the format string"
|
raiseAssert "Arguments match the format string"
|
||||||
|
@ -129,6 +135,9 @@ func init(t: typedesc[Web3SignerForkedBeaconBlock],
|
||||||
Web3SignerForkedBeaconBlock(
|
Web3SignerForkedBeaconBlock(
|
||||||
kind: ConsensusFork.Deneb,
|
kind: ConsensusFork.Deneb,
|
||||||
data: forked.denebData.toBeaconBlockHeader)
|
data: forked.denebData.toBeaconBlockHeader)
|
||||||
|
of ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "electra missing"
|
||||||
|
raiseAssert "electra missing"
|
||||||
|
|
||||||
proc createKeystore(dataDir, pubkey,
|
proc createKeystore(dataDir, pubkey,
|
||||||
store, password: string): Result[void, string] =
|
store, password: string): Result[void, string] =
|
||||||
|
|
|
@ -48,7 +48,9 @@ proc makeTestDB*(
|
||||||
# Upgrade genesis state to later fork, if required by fork schedule
|
# Upgrade genesis state to later fork, if required by fork schedule
|
||||||
cfg.maybeUpgradeState(genState[])
|
cfg.maybeUpgradeState(genState[])
|
||||||
withState(genState[]):
|
withState(genState[]):
|
||||||
when consensusFork > ConsensusFork.Phase0:
|
when consensusFork >= ConsensusFork.Electra:
|
||||||
|
debugRaiseAssert "makeTestDB electra missing"
|
||||||
|
elif consensusFork > ConsensusFork.Phase0:
|
||||||
forkyState.data.fork.previous_version =
|
forkyState.data.fork.previous_version =
|
||||||
forkyState.data.fork.current_version
|
forkyState.data.fork.current_version
|
||||||
forkyState.data.latest_block_header.body_root =
|
forkyState.data.latest_block_header.body_root =
|
||||||
|
|
|
@ -73,7 +73,7 @@ proc getTestStates*(
|
||||||
info = ForkedEpochInfo()
|
info = ForkedEpochInfo()
|
||||||
cfg = defaultRuntimeConfig
|
cfg = defaultRuntimeConfig
|
||||||
|
|
||||||
static: doAssert high(ConsensusFork) == ConsensusFork.Deneb
|
static: doAssert high(ConsensusFork) == ConsensusFork.Electra
|
||||||
if consensusFork >= ConsensusFork.Altair:
|
if consensusFork >= ConsensusFork.Altair:
|
||||||
cfg.ALTAIR_FORK_EPOCH = 1.Epoch
|
cfg.ALTAIR_FORK_EPOCH = 1.Epoch
|
||||||
if consensusFork >= ConsensusFork.Bellatrix:
|
if consensusFork >= ConsensusFork.Bellatrix:
|
||||||
|
@ -83,6 +83,8 @@ proc getTestStates*(
|
||||||
if consensusFork >= ConsensusFork.Deneb:
|
if consensusFork >= ConsensusFork.Deneb:
|
||||||
cfg.DENEB_FORK_EPOCH = 4.Epoch
|
cfg.DENEB_FORK_EPOCH = 4.Epoch
|
||||||
|
|
||||||
|
debugRaiseAssert "ELECTRA_FORK_EPOCH"
|
||||||
|
|
||||||
for i, epoch in stateEpochs:
|
for i, epoch in stateEpochs:
|
||||||
let slot = epoch.Epoch.start_slot
|
let slot = epoch.Epoch.start_slot
|
||||||
if getStateField(tmpState[], slot) < slot:
|
if getStateField(tmpState[], slot) < slot:
|
||||||
|
|
Loading…
Reference in New Issue