implement more missing capella functionality (#4344)
This commit is contained in:
parent
e965d5e0e9
commit
c8083f2c32
|
@ -966,7 +966,7 @@ proc getBlockSZ*(
|
||||||
of BeaconBlockFork.Bellatrix:
|
of BeaconBlockFork.Bellatrix:
|
||||||
getBlockSZ(db, key, data, bellatrix.TrustedSignedBeaconBlock)
|
getBlockSZ(db, key, data, bellatrix.TrustedSignedBeaconBlock)
|
||||||
of BeaconBlockFork.Capella:
|
of BeaconBlockFork.Capella:
|
||||||
raiseAssert $capellaImplementationMissing
|
getBlockSZ(db, key, data, capella.TrustedSignedBeaconBlock)
|
||||||
|
|
||||||
proc getStateOnlyMutableValidators(
|
proc getStateOnlyMutableValidators(
|
||||||
immutableValidators: openArray[ImmutableValidatorData2],
|
immutableValidators: openArray[ImmutableValidatorData2],
|
||||||
|
|
|
@ -369,6 +369,34 @@ func asEngineExecutionPayload*(executionPayload: bellatrix.ExecutionPayload):
|
||||||
blockHash: executionPayload.block_hash.asBlockHash,
|
blockHash: executionPayload.block_hash.asBlockHash,
|
||||||
transactions: mapIt(executionPayload.transactions, it.getTypedTransaction))
|
transactions: mapIt(executionPayload.transactions, it.getTypedTransaction))
|
||||||
|
|
||||||
|
from ../spec/datatypes/capella import ExecutionPayload
|
||||||
|
|
||||||
|
func asEngineExecutionPayload*(executionPayload: capella.ExecutionPayload):
|
||||||
|
ExecutionPayloadV1 =
|
||||||
|
template getTypedTransaction(tt: bellatrix.Transaction): TypedTransaction =
|
||||||
|
TypedTransaction(tt.distinctBase)
|
||||||
|
|
||||||
|
if true:
|
||||||
|
raiseAssert $capellaImplementationMissing & ": needs nim-web3 support for ExecutionPayloadV2"
|
||||||
|
|
||||||
|
engine_api.ExecutionPayloadV1(
|
||||||
|
parentHash: executionPayload.parent_hash.asBlockHash,
|
||||||
|
feeRecipient: Address(executionPayload.fee_recipient.data),
|
||||||
|
stateRoot: executionPayload.state_root.asBlockHash,
|
||||||
|
receiptsRoot: executionPayload.receipts_root.asBlockHash,
|
||||||
|
logsBloom:
|
||||||
|
FixedBytes[BYTES_PER_LOGS_BLOOM](executionPayload.logs_bloom.data),
|
||||||
|
prevRandao: executionPayload.prev_randao.asBlockHash,
|
||||||
|
blockNumber: Quantity(executionPayload.block_number),
|
||||||
|
gasLimit: Quantity(executionPayload.gas_limit),
|
||||||
|
gasUsed: Quantity(executionPayload.gas_used),
|
||||||
|
timestamp: Quantity(executionPayload.timestamp),
|
||||||
|
extraData:
|
||||||
|
DynamicBytes[0, MAX_EXTRA_DATA_BYTES](executionPayload.extra_data),
|
||||||
|
baseFeePerGas: executionPayload.base_fee_per_gas,
|
||||||
|
blockHash: executionPayload.block_hash.asBlockHash,
|
||||||
|
transactions: mapIt(executionPayload.transactions, it.getTypedTransaction))
|
||||||
|
|
||||||
func shortLog*(b: Eth1Block): string =
|
func shortLog*(b: Eth1Block): string =
|
||||||
try:
|
try:
|
||||||
&"{b.number}:{shortLog b.hash}(deposits = {b.depositCount})"
|
&"{b.number}:{shortLog b.hash}(deposits = {b.depositCount})"
|
||||||
|
|
|
@ -236,9 +236,12 @@ from ../spec/datatypes/bellatrix import SignedBeaconBlock
|
||||||
|
|
||||||
from eth/async_utils import awaitWithTimeout
|
from eth/async_utils import awaitWithTimeout
|
||||||
from ../spec/datatypes/bellatrix import ExecutionPayload, SignedBeaconBlock
|
from ../spec/datatypes/bellatrix import ExecutionPayload, SignedBeaconBlock
|
||||||
|
from ../spec/datatypes/capella import
|
||||||
|
ExecutionPayload, SignedBeaconBlock, asTrusted, shortLog
|
||||||
|
|
||||||
proc newExecutionPayload*(
|
proc newExecutionPayload*(
|
||||||
eth1Monitor: Eth1Monitor, executionPayload: bellatrix.ExecutionPayload):
|
eth1Monitor: Eth1Monitor,
|
||||||
|
executionPayload: bellatrix.ExecutionPayload | capella.ExecutionPayload):
|
||||||
Future[Opt[PayloadExecutionStatus]] {.async.} =
|
Future[Opt[PayloadExecutionStatus]] {.async.} =
|
||||||
if eth1Monitor.isNil:
|
if eth1Monitor.isNil:
|
||||||
warn "newPayload: attempting to process execution payload without Eth1Monitor. Ensure --web3-url setting is correct and JWT is configured."
|
warn "newPayload: attempting to process execution payload without Eth1Monitor. Ensure --web3-url setting is correct and JWT is configured."
|
||||||
|
@ -287,14 +290,6 @@ proc newExecutionPayload*(
|
||||||
error "newPayload failed", msg = err.msg
|
error "newPayload failed", msg = err.msg
|
||||||
return Opt.none PayloadExecutionStatus
|
return Opt.none PayloadExecutionStatus
|
||||||
|
|
||||||
# TODO when forks re-exports this, remove
|
|
||||||
from ../spec/datatypes/capella import ExecutionPayload
|
|
||||||
|
|
||||||
proc newExecutionPayload*(
|
|
||||||
eth1Monitor: Eth1Monitor, executionPayload: capella.ExecutionPayload):
|
|
||||||
Future[Opt[PayloadExecutionStatus]] {.async.} =
|
|
||||||
raiseAssert $capellaImplementationMissing
|
|
||||||
|
|
||||||
proc getExecutionValidity(
|
proc getExecutionValidity(
|
||||||
eth1Monitor: Eth1Monitor,
|
eth1Monitor: Eth1Monitor,
|
||||||
blck: phase0.SignedBeaconBlock | altair.SignedBeaconBlock):
|
blck: phase0.SignedBeaconBlock | altair.SignedBeaconBlock):
|
||||||
|
@ -302,7 +297,8 @@ proc getExecutionValidity(
|
||||||
return NewPayloadStatus.valid # vacuously
|
return NewPayloadStatus.valid # vacuously
|
||||||
|
|
||||||
proc getExecutionValidity(
|
proc getExecutionValidity(
|
||||||
eth1Monitor: Eth1Monitor, blck: bellatrix.SignedBeaconBlock):
|
eth1Monitor: Eth1Monitor,
|
||||||
|
blck: bellatrix.SignedBeaconBlock | capella.SignedBeaconBlock):
|
||||||
Future[NewPayloadStatus] {.async.} =
|
Future[NewPayloadStatus] {.async.} =
|
||||||
# Eth1 syncing is asynchronous from this
|
# Eth1 syncing is asynchronous from this
|
||||||
# TODO self.consensusManager.eth1Monitor.ttdReached
|
# TODO self.consensusManager.eth1Monitor.ttdReached
|
||||||
|
@ -336,15 +332,6 @@ proc getExecutionValidity(
|
||||||
error "getExecutionValidity: newPayload failed", err = err.msg
|
error "getExecutionValidity: newPayload failed", err = err.msg
|
||||||
return NewPayloadStatus.noResponse
|
return NewPayloadStatus.noResponse
|
||||||
|
|
||||||
# TODO drop when forks re-exports all this
|
|
||||||
from ../spec/datatypes/capella import SignedBeaconBlock, asTrusted, shortLog
|
|
||||||
|
|
||||||
proc getExecutionValidity(
|
|
||||||
eth1Monitor: Eth1Monitor,
|
|
||||||
blck: capella.SignedBeaconBlock):
|
|
||||||
Future[NewPayloadStatus] {.async.} =
|
|
||||||
raiseAssert $capellaImplementationMissing
|
|
||||||
|
|
||||||
proc storeBlock*(
|
proc storeBlock*(
|
||||||
self: ref BlockProcessor, src: MsgSource, wallTime: BeaconTime,
|
self: ref BlockProcessor, src: MsgSource, wallTime: BeaconTime,
|
||||||
signedBlock: ForkySignedBeaconBlock, queueTick: Moment = Moment.now(),
|
signedBlock: ForkySignedBeaconBlock, queueTick: Moment = Moment.now(),
|
||||||
|
|
|
@ -235,6 +235,8 @@ template toFork*[T: capella.BeaconState | capella.HashedBeaconState](
|
||||||
# T(kind: BeaconStateFork.Altair, altairData: data)
|
# T(kind: BeaconStateFork.Altair, altairData: data)
|
||||||
# template init*(T: type ForkedHashedBeaconState, data: bellatrix.HashedBeaconState): T =
|
# template init*(T: type ForkedHashedBeaconState, data: bellatrix.HashedBeaconState): T =
|
||||||
# T(kind: BeaconStateFork.Bellatrix, bellatrixData: data)
|
# T(kind: BeaconStateFork.Bellatrix, bellatrixData: data)
|
||||||
|
# template init*(T: type ForkedHashedBeaconState, data: capella.HashedBeaconState): T =
|
||||||
|
# T(kind: BeaconStateFork.Capella, capellaData: data)
|
||||||
|
|
||||||
template init*(T: type ForkedBeaconBlock, blck: phase0.BeaconBlock): T =
|
template init*(T: type ForkedBeaconBlock, blck: phase0.BeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
||||||
|
@ -242,6 +244,8 @@ template init*(T: type ForkedBeaconBlock, blck: altair.BeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
||||||
template init*(T: type ForkedBeaconBlock, blck: bellatrix.BeaconBlock): T =
|
template init*(T: type ForkedBeaconBlock, blck: bellatrix.BeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Bellatrix, bellatrixData: blck)
|
T(kind: BeaconBlockFork.Bellatrix, bellatrixData: blck)
|
||||||
|
template init*(T: type ForkedBeaconBlock, blck: capella.BeaconBlock): T =
|
||||||
|
T(kind: BeaconBlockFork.Capella, capellaData: blck)
|
||||||
|
|
||||||
template init*(T: type ForkedTrustedBeaconBlock, blck: phase0.TrustedBeaconBlock): T =
|
template init*(T: type ForkedTrustedBeaconBlock, blck: phase0.TrustedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
||||||
|
@ -249,6 +253,8 @@ template init*(T: type ForkedTrustedBeaconBlock, blck: altair.TrustedBeaconBlock
|
||||||
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
T(kind: BeaconBlockFork.Altair, altairData: blck)
|
||||||
template init*(T: type ForkedTrustedBeaconBlock, blck: bellatrix.TrustedBeaconBlock): T =
|
template init*(T: type ForkedTrustedBeaconBlock, blck: bellatrix.TrustedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Bellatrix, bellatrixData: blck)
|
T(kind: BeaconBlockFork.Bellatrix, bellatrixData: blck)
|
||||||
|
template init*(T: type ForkedTrustedBeaconBlock, blck: capella.TrustedBeaconBlock): T =
|
||||||
|
T(kind: BeaconBlockFork.Capella, capellaData: blck)
|
||||||
|
|
||||||
template init*(T: type ForkedSignedBeaconBlock, blck: phase0.SignedBeaconBlock): T =
|
template init*(T: type ForkedSignedBeaconBlock, blck: phase0.SignedBeaconBlock): T =
|
||||||
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
||||||
|
|
|
@ -204,16 +204,16 @@ proc checkSync(vc: ValidatorClientRef,
|
||||||
if not(syncInfo.is_syncing) or (syncInfo.sync_distance < SYNC_TOLERANCE):
|
if not(syncInfo.is_syncing) or (syncInfo.sync_distance < SYNC_TOLERANCE):
|
||||||
if not(syncInfo.is_optimistic.get(false)):
|
if not(syncInfo.is_optimistic.get(false)):
|
||||||
info "Beacon node is in sync", sync_distance = syncInfo.sync_distance,
|
info "Beacon node is in sync", sync_distance = syncInfo.sync_distance,
|
||||||
head_slot = syncInfo.head_slot, is_opimistic = optimistic
|
head_slot = syncInfo.head_slot, is_optimistic = optimistic
|
||||||
RestBeaconNodeStatus.Online
|
RestBeaconNodeStatus.Online
|
||||||
else:
|
else:
|
||||||
warn "Execution client not in sync (beacon node optimistically synced)",
|
warn "Execution client not in sync (beacon node optimistically synced)",
|
||||||
sync_distance = syncInfo.sync_distance,
|
sync_distance = syncInfo.sync_distance,
|
||||||
head_slot = syncInfo.head_slot, is_opimistic = optimistic
|
head_slot = syncInfo.head_slot, is_optimistic = optimistic
|
||||||
RestBeaconNodeStatus.NotSynced
|
RestBeaconNodeStatus.NotSynced
|
||||||
else:
|
else:
|
||||||
warn "Beacon node not in sync", sync_distance = syncInfo.sync_distance,
|
warn "Beacon node not in sync", sync_distance = syncInfo.sync_distance,
|
||||||
head_slot = syncInfo.head_slot, is_opimistic = optimistic
|
head_slot = syncInfo.head_slot, is_optimistic = optimistic
|
||||||
RestBeaconNodeStatus.NotSynced
|
RestBeaconNodeStatus.NotSynced
|
||||||
|
|
||||||
proc checkOnline(node: BeaconNodeServerRef) {.async.} =
|
proc checkOnline(node: BeaconNodeServerRef) {.async.} =
|
||||||
|
|
|
@ -389,7 +389,7 @@ proc getExecutionPayload[T](
|
||||||
template empty_execution_payload(): auto =
|
template empty_execution_payload(): auto =
|
||||||
withState(proposalState[]):
|
withState(proposalState[]):
|
||||||
when stateFork >= BeaconStateFork.Capella:
|
when stateFork >= BeaconStateFork.Capella:
|
||||||
raiseAssert $capellaImplementationMissing
|
raiseAssert $capellaImplementationMissing & ": beacon_chain/validators/validator_duties.nim: getExecutionPayload"
|
||||||
elif stateFork >= BeaconStateFork.Bellatrix:
|
elif stateFork >= BeaconStateFork.Bellatrix:
|
||||||
build_empty_execution_payload(forkyState.data, feeRecipient)
|
build_empty_execution_payload(forkyState.data, feeRecipient)
|
||||||
else:
|
else:
|
||||||
|
@ -475,10 +475,6 @@ proc makeBeaconBlockForHeadAndSlot*(
|
||||||
var
|
var
|
||||||
cache = StateCache()
|
cache = StateCache()
|
||||||
|
|
||||||
# Execution payload handling will need a review post-Bellatrix
|
|
||||||
if slot.epoch >= node.dag.cfg.CAPELLA_FORK_EPOCH:
|
|
||||||
raiseAssert $capellaImplementationMissing
|
|
||||||
|
|
||||||
let
|
let
|
||||||
# The clearance state already typically sits at the right slot per
|
# The clearance state already typically sits at the right slot per
|
||||||
# `advanceClearanceState`
|
# `advanceClearanceState`
|
||||||
|
|
|
@ -360,7 +360,7 @@ proc getBlockSignature*(v: AttachedValidator, fork: Fork,
|
||||||
kind: BeaconBlockFork.Bellatrix,
|
kind: BeaconBlockFork.Bellatrix,
|
||||||
bellatrixData: blck.bellatrixData.toBeaconBlockHeader)
|
bellatrixData: blck.bellatrixData.toBeaconBlockHeader)
|
||||||
of BeaconBlockFork.Capella:
|
of BeaconBlockFork.Capella:
|
||||||
raiseAssert $capellaImplementationMissing
|
raiseAssert $capellaImplementationMissing & "beacon_chain/validators/validator_pool.nim: getBlockSignature"
|
||||||
|
|
||||||
request = Web3SignerRequest.init(
|
request = Web3SignerRequest.init(
|
||||||
fork, genesis_validators_root, web3SignerBlock)
|
fork, genesis_validators_root, web3SignerBlock)
|
||||||
|
|
Loading…
Reference in New Issue