forkchoiceUpdate support (#3199)
This commit is contained in:
parent
4a72def1d5
commit
57974ce61b
|
@ -421,6 +421,21 @@ proc executePayload*(p: Web3DataProviderRef,
|
||||||
payload: engine_api.ExecutionPayloadV1): Future[ExecutePayloadResponse] =
|
payload: engine_api.ExecutionPayloadV1): Future[ExecutePayloadResponse] =
|
||||||
p.web3.provider.engine_executePayloadV1(payload)
|
p.web3.provider.engine_executePayloadV1(payload)
|
||||||
|
|
||||||
|
proc forkchoiceUpdated*(p: Web3DataProviderRef,
|
||||||
|
headBlock, finalizedBlock: Eth2Digest):
|
||||||
|
Future[engine_api.ForkchoiceUpdatedResponse] =
|
||||||
|
p.web3.provider.engine_forkchoiceUpdatedV1(
|
||||||
|
ForkchoiceStateV1(
|
||||||
|
headBlockHash: headBlock.asBlockHash,
|
||||||
|
|
||||||
|
# https://hackmd.io/@n0ble/kintsugi-spec#Engine-API
|
||||||
|
# "CL client software MUST use headBlockHash value as a stub for the
|
||||||
|
# safeBlockHash parameter"
|
||||||
|
safeBlockHash: headBlock.asBlockHash,
|
||||||
|
|
||||||
|
finalizedBlockHash: finalizedBlock.asBlockHash),
|
||||||
|
none(engine_api.PayloadAttributesV1))
|
||||||
|
|
||||||
proc forkchoiceUpdated*(p: Web3DataProviderRef,
|
proc forkchoiceUpdated*(p: Web3DataProviderRef,
|
||||||
headBlock, finalizedBlock: Eth2Digest,
|
headBlock, finalizedBlock: Eth2Digest,
|
||||||
timestamp: uint64,
|
timestamp: uint64,
|
||||||
|
|
|
@ -18,6 +18,7 @@ import
|
||||||
json_serialization/std/[options, sets, net], serialization/errors,
|
json_serialization/std/[options, sets, net], serialization/errors,
|
||||||
eth/db/kvstore,
|
eth/db/kvstore,
|
||||||
eth/keys, eth/p2p/discoveryv5/[protocol, enr],
|
eth/keys, eth/p2p/discoveryv5/[protocol, enr],
|
||||||
|
web3/ethtypes,
|
||||||
|
|
||||||
# Local modules
|
# Local modules
|
||||||
../spec/datatypes/[phase0, altair, merge],
|
../spec/datatypes/[phase0, altair, merge],
|
||||||
|
@ -416,6 +417,24 @@ proc getBlockProposalEth1Data*(node: BeaconNode,
|
||||||
state, finalizedEpochRef.eth1_data,
|
state, finalizedEpochRef.eth1_data,
|
||||||
finalizedEpochRef.eth1_deposit_index)
|
finalizedEpochRef.eth1_deposit_index)
|
||||||
|
|
||||||
|
proc forkchoice_updated(state: merge.BeaconState,
|
||||||
|
head_block_hash: Eth2Digest,
|
||||||
|
finalized_block_hash: Eth2Digest,
|
||||||
|
fee_recipient: ethtypes.Address,
|
||||||
|
execution_engine: Web3DataProviderRef):
|
||||||
|
Future[Option[merge.PayloadId]] {.async.} =
|
||||||
|
let
|
||||||
|
timestamp = compute_timestamp_at_slot(state, state.slot)
|
||||||
|
random = get_randao_mix(state, get_current_epoch(state))
|
||||||
|
payloadId =
|
||||||
|
(await execution_engine.forkchoiceUpdated(
|
||||||
|
head_block_hash, finalized_block_hash, timestamp, random.data,
|
||||||
|
fee_recipient)).payloadId
|
||||||
|
return if payloadId.isSome:
|
||||||
|
some(merge.PayloadId(payloadId.get))
|
||||||
|
else:
|
||||||
|
none(merge.PayloadId)
|
||||||
|
|
||||||
proc makeBeaconBlockForHeadAndSlot*(node: BeaconNode,
|
proc makeBeaconBlockForHeadAndSlot*(node: BeaconNode,
|
||||||
randao_reveal: ValidatorSig,
|
randao_reveal: ValidatorSig,
|
||||||
validator_index: ValidatorIndex,
|
validator_index: ValidatorIndex,
|
||||||
|
|
Loading…
Reference in New Issue