Skip to content

Commit

Permalink
Add EIP4844 types to engine API (#74)
Browse files Browse the repository at this point in the history
* Add EIP4844 types to engine API

* Fix typo
  • Loading branch information
henridf authored Jan 10, 2023
1 parent d596e68 commit 3358679
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
6 changes: 6 additions & 0 deletions web3/engine_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ template getPayload*(
payloadId: PayloadID): Future[GetPayloadV2Response] =
engine_getPayloadV2(rpcClient, payloadId)

template getPayload*(
rpcClient: RpcClient,
T: type GetPayloadV3Response,
payloadId: PayloadID): Future[GetPayloadV3Response] =
engine_getPayloadV3(rpcClient, payloadId)

template newPayload*(
rpcClient: RpcClient,
payload: ExecutionPayloadV1): Future[PayloadStatusV1] =
Expand Down
3 changes: 3 additions & 0 deletions web3/engine_api_callsigs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import ethtypes, engine_api_types

proc engine_newPayloadV1(payload: ExecutionPayloadV1): PayloadStatusV1
proc engine_newPayloadV2(payload: ExecutionPayloadV2): PayloadStatusV1
proc engine_newPayloadV3(payload: ExecutionPayloadV3): PayloadStatusV1
proc engine_forkchoiceUpdatedV1(forkchoiceState: ForkchoiceStateV1, payloadAttributes: Option[PayloadAttributesV1]): ForkchoiceUpdatedResponse
proc engine_forkchoiceUpdatedV2(forkchoiceState: ForkchoiceStateV1, payloadAttributes: Option[PayloadAttributesV2]): ForkchoiceUpdatedResponse
proc engine_getPayloadV1(payloadId: PayloadID): ExecutionPayloadV1
proc engine_getPayloadV2(payloadId: PayloadID): GetPayloadV2Response
proc engine_getPayloadV3(payloadId: PayloadID): GetPayloadV3Response
proc engine_exchangeTransitionConfigurationV1(transitionConfiguration: TransitionConfigurationV1): TransitionConfigurationV1
proc engine_getBlobsBundleV1(payloadId: PayloadID): BlobsBundleV1
7 changes: 6 additions & 1 deletion web3/engine_api_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ type
executionPayload*: ExecutionPayloadV2
blockValue*: Quantity

GetPayloadV3Response* = object
executionPayload*: ExecutionPayloadV3
blockValue*: Quantity

SomeGetPayloadResponse* =
ExecutionPayloadV1 |
GetPayloadV2Response
GetPayloadV2Response |
GetPayloadV3Response

const
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.1/src/engine/specification.md#errors
Expand Down
31 changes: 30 additions & 1 deletion web3/ethtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ type

Quantity* = distinct uint64

KZGCommitment* = FixedBytes[48]
Blob* = FixedBytes[4096 * 32]

EthSend* = object
source*: Address # the address the transaction is send from.
to*: Option[Address] # (optional when creating new contract) the address the transaction is directed to.
Expand Down Expand Up @@ -233,9 +236,35 @@ type
transactions*: seq[TypedTransaction]
withdrawals*: seq[WithdrawalV1]

# https://github.com/ethereum/execution-apis/blob/d072d080b92d26a1087337c7e2da4147a0ed0347/src/engine/experimental/blob-extension.md#executionpayloadv3
ExecutionPayloadV3* = object
parentHash*: BlockHash
feeRecipient*: Address
stateRoot*: BlockHash
receiptsRoot*: BlockHash
logsBloom*: FixedBytes[256]
prevRandao*: FixedBytes[32]
blockNumber*: Quantity
gasLimit*: Quantity
gasUsed*: Quantity
timestamp*: Quantity
extraData*: DynamicBytes[0, 32]
baseFeePerGas*: UInt256
excessDataGas*: UInt256
blockHash*: BlockHash
transactions*: seq[TypedTransaction]
withdrawals*: seq[WithdrawalV1]

SomeExecutionPayload* =
ExecutionPayloadV1 |
ExecutionPayloadV2
ExecutionPayloadV2 |
ExecutionPayloadV3

# https://github.com/ethereum/execution-apis/blob/d072d080b92d26a1087337c7e2da4147a0ed0347/src/engine/experimental/blob-extension.md#BlobsBundleV1
BlobsBundleV1* = object
blockHash*: BlockHash
kzgs*: seq[KZGCommitment]
blobs*: seq[Blob]

RlpEncodedBytes* = distinct seq[byte]

Expand Down

0 comments on commit 3358679

Please sign in to comment.