Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec authored Jun 29, 2023
1 parent 1f9fa11 commit abc9fa1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
12 changes: 10 additions & 2 deletions web3/engine_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ template forkchoiceUpdated*(
payloadAttributes: Option[PayloadAttributesV2]): Future[ForkchoiceUpdatedResponse] =
engine_forkchoiceUpdatedV2(rpcClient, forkchoiceState, payloadAttributes)

template forkchoiceUpdated*(
rpcClient: RpcClient,
forkchoiceState: ForkchoiceStateV1,
payloadAttributes: Option[PayloadAttributesV3]): Future[ForkchoiceUpdatedResponse] =
engine_forkchoiceUpdatedV3(rpcClient, forkchoiceState, payloadAttributes)

template getPayload*(
rpcClient: RpcClient,
T: type ExecutionPayloadV1,
Expand Down Expand Up @@ -61,5 +67,7 @@ template newPayload*(
template newPayload*(
rpcClient: RpcClient,
payload: ExecutionPayloadV3,
versioned_hashes: seq[VersionedHash]): Future[PayloadStatusV1] =
engine_newPayloadV3(rpcClient, payload, versioned_hashes)
versionedHashes: seq[VersionedHash],
parentBeaconBlockRoot: FixedBytes[32]): Future[PayloadStatusV1] =
engine_newPayloadV3(
rpcClient, payload, versionedHashes, parentBeaconBlockRoot)
2 changes: 2 additions & 0 deletions web3/engine_api_callsigs.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/paris.md#methods
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/shanghai.md#methods
# https://github.com/ethereum/execution-apis/blob/ee3df5bc38f28ef35385cefc9d9ca18d5e502778/src/engine/cancun.md#methods

import ethtypes, engine_api_types

Expand All @@ -8,6 +9,7 @@ proc engine_newPayloadV2(payload: ExecutionPayloadV2): PayloadStatusV1
proc engine_newPayloadV3(payload: ExecutionPayloadV3, versioned_hashes: seq[VersionedHash]): PayloadStatusV1
proc engine_forkchoiceUpdatedV1(forkchoiceState: ForkchoiceStateV1, payloadAttributes: Option[PayloadAttributesV1]): ForkchoiceUpdatedResponse
proc engine_forkchoiceUpdatedV2(forkchoiceState: ForkchoiceStateV1, payloadAttributes: Option[PayloadAttributesV2]): ForkchoiceUpdatedResponse
proc engine_forkchoiceUpdatedV3(forkchoiceState: ForkchoiceStateV1, payloadAttributes: Option[PayloadAttributesV3]): ForkchoiceUpdatedResponse
proc engine_getPayloadV1(payloadId: PayloadID): ExecutionPayloadV1
proc engine_getPayloadV2(payloadId: PayloadID): GetPayloadV2Response
proc engine_getPayloadV2_exact(payloadId: PayloadID): GetPayloadV2ResponseExact
Expand Down
10 changes: 9 additions & 1 deletion web3/engine_api_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ type
suggestedFeeRecipient*: Address
withdrawals*: seq[WithdrawalV1]

# https://github.com/ethereum/execution-apis/blob/ee3df5bc38f28ef35385cefc9d9ca18d5e502778/src/engine/cancun.md#payloadattributesv3
PayloadAttributesV3* = object
timestamp*: Quantity
prevRandao*: FixedBytes[32]
suggestedFeeRecipient*: Address
withdrawals*: seq[WithdrawalV1]
parentBeaconBlockRoot*: FixedBytes[32]

# This is ugly, but see the comment on ExecutionPayloadV1OrV2.
PayloadAttributesV1OrV2* = object
timestamp*: Quantity
Expand Down Expand Up @@ -73,7 +81,7 @@ type
executionPayload*: ExecutionPayloadV2
blockValue*: UInt256

# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/experimental/blob-extension.md#response-1
# https://github.com/ethereum/execution-apis/blob/ee3df5bc38f28ef35385cefc9d9ca18d5e502778/src/engine/cancun.md#response-2
GetPayloadV3Response* = object
executionPayload*: ExecutionPayloadV3
blockValue*: UInt256
Expand Down
4 changes: 2 additions & 2 deletions web3/ethtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ type
transactions*: seq[TypedTransaction]
withdrawals*: Option[seq[WithdrawalV1]]

# https://github.com/ethereum/execution-apis/pull/417
# https://github.com/ethereum/execution-apis/blob/ee3df5bc38f28ef35385cefc9d9ca18d5e502778/src/engine/cancun.md#executionpayloadv3
ExecutionPayloadV3* = object
parentHash*: Hash256
feeRecipient*: Address
Expand All @@ -318,7 +318,7 @@ type
ExecutionPayloadV2 |
ExecutionPayloadV3

# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/experimental/blob-extension.md#BlobsBundleV1
# https://github.com/ethereum/execution-apis/blob/ee3df5bc38f28ef35385cefc9d9ca18d5e502778/src/engine/cancun.md#blobsbundlev1
BlobsBundleV1* = object
commitments*: seq[KZGCommitment]
proofs*: seq[KZGProof]
Expand Down

0 comments on commit abc9fa1

Please sign in to comment.