Skip to content

Commit 57a1daa

Browse files
authored
getBlobsV2 (#199)
* conflict resolved * getBlobsV2 * fix * revert random object check on BlobAndProofV2 * have a rand function for BlobAndProofV2 * another fix * addressed reviews * update link
1 parent 97784b5 commit 57a1daa

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

tests/test_json_marshalling.nim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ proc rand[T](_: type seq[T]): seq[T] =
8989
for i in 0..<3:
9090
result[i] = rand(T)
9191

92+
proc rand[T](_: type openArray[T]): array[cellsPerExternalBlob, T] =
93+
var a: array[cellsPerExternalBlob, T]
94+
for i in 0..<a.len:
95+
a[i] = rand(T)
96+
a
97+
9298
proc rand(_: type seq[seq[byte]]): seq[seq[byte]] =
9399
var z = newSeq[byte](10)
94100
discard randomBytes(z)
@@ -204,6 +210,7 @@ suite "JSON-RPC Quantity":
204210
checkRandomObject(ExecutionPayloadV3)
205211
checkRandomObject(BlobsBundleV1)
206212
checkRandomObject(BlobAndProofV1)
213+
checkRandomObject(BlobAndProofV2)
207214
checkRandomObject(ExecutionPayloadBodyV1)
208215
checkRandomObject(PayloadAttributesV1)
209216
checkRandomObject(PayloadAttributesV2)

web3/conversions.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ExecutionPayloadV1OrV2.useDefaultSerializationIn JrpcConv
6060
ExecutionPayloadV3.useDefaultSerializationIn JrpcConv
6161
BlobsBundleV1.useDefaultSerializationIn JrpcConv
6262
BlobAndProofV1.useDefaultSerializationIn JrpcConv
63+
BlobAndProofV2.useDefaultSerializationIn JrpcConv
6364
ExecutionPayloadBodyV1.useDefaultSerializationIn JrpcConv
6465
PayloadAttributesV1.useDefaultSerializationIn JrpcConv
6566
PayloadAttributesV2.useDefaultSerializationIn JrpcConv

web3/engine_api.nim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ createRpcSigsFromNim(RpcClient):
3939
proc engine_getPayloadBodiesByHashV1(hashes: seq[Hash32]): seq[Opt[ExecutionPayloadBodyV1]]
4040
proc engine_getPayloadBodiesByRangeV1(start: Quantity, count: Quantity): seq[Opt[ExecutionPayloadBodyV1]]
4141
proc engine_getBlobsV1(blob_versioned_hashes: seq[VersionedHash]): GetBlobsV1Response
42+
proc engine_getBlobsV2(blob_versioned_hashes: seq[VersionedHash]): GetBlobsV2Response
4243

4344
# https://github.com/ethereum/execution-apis/blob/9301c0697e4c7566f0929147112f6d91f65180f6/src/engine/common.md
4445
proc engine_exchangeCapabilities(methods: seq[string]): seq[string]
@@ -115,6 +116,13 @@ template getBlobs*(
115116
Future[GetBlobsV1Response] =
116117
engine_getBlobsV1(rpcClient, blob_versioned_hashes)
117118

119+
template getBlobs*(
120+
rpcClient: RpcClient,
121+
T: type GetBlobsV2Response,
122+
blob_versioned_hashes: seq[VersionedHash]):
123+
Future[GetBlobsV2Response] =
124+
engine_getBlobsV2(rpcClient, blob_versioned_hashes)
125+
118126
template newPayload*(
119127
rpcClient: RpcClient,
120128
payload: ExecutionPayloadV1): Future[PayloadStatusV1] =

web3/engine_api_types.nim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,15 @@ type
127127
proofs*: seq[KzgProof]
128128
blobs*: seq[Blob]
129129

130+
# https://github.com/ethereum/execution-apis/blob/40088597b8b4f48c45184da002e27ffc3c37641f/src/engine/cancun.md#blobandproofv1
130131
BlobAndProofV1* = object
131132
blob*: Blob
132133
proof*: KzgProof
133134

135+
BlobAndProofV2* = object
136+
blob*: Blob
137+
proofs*: array[cellsPerExternalBlob, KzgProof]
138+
134139
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.4/src/engine/shanghai.md#executionpayloadbodyv1
135140
# For optional withdrawals field, see:
136141
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.4/src/engine/shanghai.md#engine_getpayloadbodiesbyhashv1
@@ -223,6 +228,8 @@ type
223228

224229
GetBlobsV1Response* = seq[BlobAndProofV1]
225230

231+
GetBlobsV2Response* = seq[BlobAndProofV2]
232+
226233
SomeGetPayloadResponse* =
227234
ExecutionPayloadV1 |
228235
GetPayloadV2Response |

web3/primitives.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const
2929
# https://github.com/ethereum/execution-apis/blob/c4089414bbbe975bbc4bf1ccf0a3d31f76feb3e1/src/engine/cancun.md#blobsbundlev1
3030
fieldElementsPerBlob = 4096
3131

32+
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/fulu/polynomial-commitments-sampling.md#cells
33+
cellsPerExternalBlob* = 128
34+
3235
type
3336
# https://github.com/ethereum/execution-apis/blob/c4089414bbbe975bbc4bf1ccf0a3d31f76feb3e1/src/schemas/base-types.yaml
3437

0 commit comments

Comments
 (0)