Skip to content

Commit aef3d40

Browse files
g11techholgerd77
authored andcommitted
client: add proofs to blobsbundle
1 parent 7f25e6f commit aef3d40

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

packages/client/lib/miner/pendingBlock.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ interface BlobBundle {
3737
blockHash: string
3838
blobs: Uint8Array[]
3939
kzgCommitments: Uint8Array[]
40+
proofs: Uint8Array[]
4041
}
4142
/**
4243
* In the future this class should build a pending block by keeping the
@@ -323,23 +324,27 @@ export class PendingBlock {
323324
) => {
324325
let blobs: Uint8Array[] = []
325326
let kzgCommitments: Uint8Array[] = []
327+
let proofs: Uint8Array[] = []
326328
const bundle = this.blobBundles.get(payloadId)
327329
if (bundle !== undefined) {
328330
blobs = bundle.blobs
329331
kzgCommitments = bundle.kzgCommitments
332+
proofs = bundle.proofs
330333
}
331334

332335
for (let tx of txs) {
333336
tx = tx as BlobEIP4844Transaction
334337
if (tx.blobs !== undefined && tx.blobs.length > 0) {
335338
blobs = blobs.concat(tx.blobs)
336339
kzgCommitments = kzgCommitments.concat(tx.kzgCommitments!)
340+
proofs = proofs.concat(tx.kzgProofs!)
337341
}
338342
}
339343
this.blobBundles.set(payloadId, {
340344
blockHash: bytesToPrefixedHexString(blockHash),
341345
blobs,
342346
kzgCommitments,
347+
proofs,
343348
})
344349
}
345350
}

packages/client/lib/rpc/modules/engine.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ type BlobsBundleV1 = {
112112
blockHash: string
113113
kzgs: Bytes48[]
114114
blobs: Blob[]
115+
proofs: Bytes48[]
115116
}
116117

117118
type ExecutionPayloadBodyV1 = {
@@ -1074,6 +1075,7 @@ export class Engine {
10741075
blockHash: bundle.blockHash,
10751076
kzgs: bundle.kzgCommitments.map(bytesToPrefixedHexString),
10761077
blobs: bundle.blobs.map(bytesToPrefixedHexString),
1078+
proofs: bundle.proofs.map(bytesToPrefixedHexString),
10771079
}
10781080
}
10791081

packages/client/test/miner/pendingBlock.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Account,
66
Address,
77
blobsToCommitments,
8+
blobsToProofs,
89
bytesToHex,
910
bytesToPrefixedHexString,
1011
commitmentsToVersionedHashes,
@@ -277,12 +278,14 @@ tape('[PendingBlock]', async (t) => {
277278
const blobs = getBlobs('hello world')
278279
const commitments = blobsToCommitments(blobs)
279280
const versionedHashes = commitmentsToVersionedHashes(commitments)
281+
const proofs = blobsToProofs(blobs, commitments)
280282

281283
const txA01 = BlobEIP4844Transaction.fromTxData(
282284
{
283285
versionedHashes,
284286
blobs,
285287
kzgCommitments: commitments,
288+
kzgProofs: proofs,
286289
maxFeePerDataGas: 100000000n,
287290
gasLimit: 0xffffffn,
288291
maxFeePerGas: 1000000000n,
@@ -298,8 +301,13 @@ tape('[PendingBlock]', async (t) => {
298301
const parentBlock = await vm.blockchain.getCanonicalHeadBlock!()
299302
const payloadId = await pendingBlock.start(vm, parentBlock)
300303
await pendingBlock.build(payloadId)
301-
const pendingBlob = pendingBlock.blobBundles.get(bytesToPrefixedHexString(payloadId))?.blobs[0]
304+
305+
const blobBundle = pendingBlock.blobBundles.get(bytesToPrefixedHexString(payloadId))!
306+
st.ok(blobBundle !== undefined)
307+
const pendingBlob = blobBundle.blobs[0]
302308
st.ok(pendingBlob !== undefined && equalsBytes(pendingBlob, blobs[0]))
309+
const blobProof = blobBundle.proofs[0]
310+
st.ok(blobProof !== undefined && equalsBytes(blobProof, proofs[0]))
303311
st.end()
304312
})
305313
t.test('should reset td', (st) => {

0 commit comments

Comments
 (0)