@aztec/blob-client 4.0.0-devnet.1-patch.1 → 4.0.0-devnet.2-patch.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,7 +12,7 @@ export function describeBlobStore(getBlobStore) {
|
|
|
12
12
|
Fr.random(),
|
|
13
13
|
Fr.random()
|
|
14
14
|
];
|
|
15
|
-
const blob = Blob.fromFields(testFields);
|
|
15
|
+
const blob = await Blob.fromFields(testFields);
|
|
16
16
|
const blobHash = blob.getEthVersionedBlobHash();
|
|
17
17
|
// Store the blob
|
|
18
18
|
await blobStore.addBlobs([
|
|
@@ -28,11 +28,11 @@ export function describeBlobStore(getBlobStore) {
|
|
|
28
28
|
});
|
|
29
29
|
it('should handle multiple blobs stored and retrieved by their hashes', async ()=>{
|
|
30
30
|
// Create two different blobs
|
|
31
|
-
const blob1 = Blob.fromFields([
|
|
31
|
+
const blob1 = await Blob.fromFields([
|
|
32
32
|
Fr.random(),
|
|
33
33
|
Fr.random()
|
|
34
34
|
]);
|
|
35
|
-
const blob2 = Blob.fromFields([
|
|
35
|
+
const blob2 = await Blob.fromFields([
|
|
36
36
|
Fr.random(),
|
|
37
37
|
Fr.random(),
|
|
38
38
|
Fr.random()
|
|
@@ -64,13 +64,13 @@ export function describeBlobStore(getBlobStore) {
|
|
|
64
64
|
});
|
|
65
65
|
it('should handle retrieving subset of stored blobs', async ()=>{
|
|
66
66
|
// Store multiple blobs
|
|
67
|
-
const blob1 = Blob.fromFields([
|
|
67
|
+
const blob1 = await Blob.fromFields([
|
|
68
68
|
Fr.random()
|
|
69
69
|
]);
|
|
70
|
-
const blob2 = Blob.fromFields([
|
|
70
|
+
const blob2 = await Blob.fromFields([
|
|
71
71
|
Fr.random()
|
|
72
72
|
]);
|
|
73
|
-
const blob3 = Blob.fromFields([
|
|
73
|
+
const blob3 = await Blob.fromFields([
|
|
74
74
|
Fr.random()
|
|
75
75
|
]);
|
|
76
76
|
await blobStore.addBlobs([
|
|
@@ -90,7 +90,7 @@ export function describeBlobStore(getBlobStore) {
|
|
|
90
90
|
expect(retrievedBlobs[1]).toEqual(blob3);
|
|
91
91
|
});
|
|
92
92
|
it('should handle duplicate blob hashes in request', async ()=>{
|
|
93
|
-
const blob = Blob.fromFields([
|
|
93
|
+
const blob = await Blob.fromFields([
|
|
94
94
|
Fr.random()
|
|
95
95
|
]);
|
|
96
96
|
const blobHash = blob.getEthVersionedBlobHash();
|
|
@@ -112,8 +112,8 @@ export function describeBlobStore(getBlobStore) {
|
|
|
112
112
|
Fr.random(),
|
|
113
113
|
Fr.random()
|
|
114
114
|
];
|
|
115
|
-
const blob1 = Blob.fromFields(fields);
|
|
116
|
-
const blob2 = Blob.fromFields(fields);
|
|
115
|
+
const blob1 = await Blob.fromFields(fields);
|
|
116
|
+
const blob2 = await Blob.fromFields(fields);
|
|
117
117
|
const blobHash = blob1.getEthVersionedBlobHash();
|
|
118
118
|
// Store first blob
|
|
119
119
|
await blobStore.addBlobs([
|
package/dest/client/http.js
CHANGED
|
@@ -183,8 +183,8 @@ export class HttpBlobClient {
|
|
|
183
183
|
// Return the result, ignoring any undefined ones
|
|
184
184
|
const getFilledBlobs = ()=>resultBlobs.filter((b)=>b !== undefined);
|
|
185
185
|
// Helper to fill in results from fetched blobs
|
|
186
|
-
const fillResults = (fetchedBlobs)=>{
|
|
187
|
-
const blobs = processFetchedBlobs(fetchedBlobs, blobHashes, this.log);
|
|
186
|
+
const fillResults = async (fetchedBlobs)=>{
|
|
187
|
+
const blobs = await processFetchedBlobs(fetchedBlobs, blobHashes, this.log);
|
|
188
188
|
// Fill in any missing positions with matching blobs
|
|
189
189
|
for(let i = 0; i < blobHashes.length; i++){
|
|
190
190
|
if (resultBlobs[i] === undefined) {
|
|
@@ -236,7 +236,7 @@ export class HttpBlobClient {
|
|
|
236
236
|
...ctx
|
|
237
237
|
});
|
|
238
238
|
const blobs = await this.getBlobsFromHost(l1ConsensusHostUrl, slotNumber, l1ConsensusHostIndex);
|
|
239
|
-
const result = fillResults(blobs);
|
|
239
|
+
const result = await fillResults(blobs);
|
|
240
240
|
this.log.debug(`Got ${blobs.length} blobs from consensus host (total: ${result.length}/${blobHashes.length})`, {
|
|
241
241
|
slotNumber,
|
|
242
242
|
l1ConsensusHostUrl,
|
|
@@ -279,7 +279,7 @@ export class HttpBlobClient {
|
|
|
279
279
|
this.log.debug('No blobs found from archive client', archiveCtx);
|
|
280
280
|
} else {
|
|
281
281
|
this.log.trace(`Got ${allBlobs.length} blobs from archive client before filtering`, archiveCtx);
|
|
282
|
-
const result = fillResults(allBlobs);
|
|
282
|
+
const result = await fillResults(allBlobs);
|
|
283
283
|
this.log.debug(`Got ${allBlobs.length} blobs from archive client (total: ${result.length}/${blobHashes.length})`, archiveCtx);
|
|
284
284
|
if (result.length === blobHashes.length) {
|
|
285
285
|
return returnWithCallback(result);
|
|
@@ -320,7 +320,7 @@ export class HttpBlobClient {
|
|
|
320
320
|
});
|
|
321
321
|
const blobs = await client.getBlobsByHashes(blobHashStrings);
|
|
322
322
|
if (blobs.length > 0) {
|
|
323
|
-
const result = fillResults(blobs);
|
|
323
|
+
const result = await fillResults(blobs);
|
|
324
324
|
this.log.debug(`Got ${blobs.length} blobs from filestore (total: ${result.length}/${ctx.blobHashes.length})`, {
|
|
325
325
|
url: client.getBaseUrl(),
|
|
326
326
|
...ctx
|
|
@@ -335,7 +335,7 @@ export class HttpBlobClient {
|
|
|
335
335
|
}
|
|
336
336
|
async getBlobSidecarFrom(hostUrl, blockHashOrSlot, blobHashes = [], l1ConsensusHostIndex) {
|
|
337
337
|
const blobs = await this.getBlobsFromHost(hostUrl, blockHashOrSlot, l1ConsensusHostIndex);
|
|
338
|
-
return processFetchedBlobs(blobs, blobHashes, this.log).filter((b)=>b !== undefined);
|
|
338
|
+
return (await processFetchedBlobs(blobs, blobHashes, this.log)).filter((b)=>b !== undefined);
|
|
339
339
|
}
|
|
340
340
|
async getBlobsFromHost(hostUrl, blockHashOrSlot, l1ConsensusHostIndex) {
|
|
341
341
|
try {
|
|
@@ -530,7 +530,7 @@ function parseBlobJson(data) {
|
|
|
530
530
|
}
|
|
531
531
|
// Returns an array that maps each blob hash to the corresponding blob, or undefined if the blob is not found
|
|
532
532
|
// or the data does not match the commitment.
|
|
533
|
-
function processFetchedBlobs(blobs, blobHashes, logger) {
|
|
533
|
+
async function processFetchedBlobs(blobs, blobHashes, logger) {
|
|
534
534
|
const requestedBlobHashes = new Set(blobHashes.map(bufferToHex));
|
|
535
535
|
const hashToBlob = new Map();
|
|
536
536
|
for (const blobJson of blobs){
|
|
@@ -539,7 +539,7 @@ function processFetchedBlobs(blobs, blobHashes, logger) {
|
|
|
539
539
|
continue;
|
|
540
540
|
}
|
|
541
541
|
try {
|
|
542
|
-
const blob = Blob.fromJson(blobJson);
|
|
542
|
+
const blob = await Blob.fromJson(blobJson);
|
|
543
543
|
hashToBlob.set(hashHex, blob);
|
|
544
544
|
} catch (err) {
|
|
545
545
|
// If the above throws, it's likely that the blob commitment does not match the hash of the blob data.
|
package/dest/client/tests.js
CHANGED
|
@@ -17,7 +17,7 @@ import { makeRandomBlob } from '@aztec/blob-lib/testing';
|
|
|
17
17
|
await cleanup();
|
|
18
18
|
});
|
|
19
19
|
it('should send and retrieve blobs by hash', async ()=>{
|
|
20
|
-
const blob = makeRandomBlob(5);
|
|
20
|
+
const blob = await makeRandomBlob(5);
|
|
21
21
|
const blobHash = blob.getEthVersionedBlobHash();
|
|
22
22
|
await client.sendBlobsToFilestore([
|
|
23
23
|
blob
|
|
@@ -29,9 +29,9 @@ import { makeRandomBlob } from '@aztec/blob-lib/testing';
|
|
|
29
29
|
expect(retrievedBlobs[0]).toEqual(blob);
|
|
30
30
|
});
|
|
31
31
|
it('should handle multiple blobs', async ()=>{
|
|
32
|
-
const blobs = Array.from({
|
|
32
|
+
const blobs = await Promise.all(Array.from({
|
|
33
33
|
length: 3
|
|
34
|
-
}, ()=>makeRandomBlob(7));
|
|
34
|
+
}, ()=>makeRandomBlob(7)));
|
|
35
35
|
const blobHashes = blobs.map((blob)=>blob.getEthVersionedBlobHash());
|
|
36
36
|
await client.sendBlobsToFilestore(blobs);
|
|
37
37
|
const retrievedBlobs = await client.getBlobSidecar(blockId, blobHashes);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/blob-client",
|
|
3
|
-
"version": "4.0.0-devnet.
|
|
3
|
+
"version": "4.0.0-devnet.2-patch.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": "./dest/client/bin/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
]
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@aztec/blob-lib": "4.0.0-devnet.
|
|
60
|
-
"@aztec/ethereum": "4.0.0-devnet.
|
|
61
|
-
"@aztec/foundation": "4.0.0-devnet.
|
|
62
|
-
"@aztec/kv-store": "4.0.0-devnet.
|
|
63
|
-
"@aztec/stdlib": "4.0.0-devnet.
|
|
64
|
-
"@aztec/telemetry-client": "4.0.0-devnet.
|
|
59
|
+
"@aztec/blob-lib": "4.0.0-devnet.2-patch.1",
|
|
60
|
+
"@aztec/ethereum": "4.0.0-devnet.2-patch.1",
|
|
61
|
+
"@aztec/foundation": "4.0.0-devnet.2-patch.1",
|
|
62
|
+
"@aztec/kv-store": "4.0.0-devnet.2-patch.1",
|
|
63
|
+
"@aztec/stdlib": "4.0.0-devnet.2-patch.1",
|
|
64
|
+
"@aztec/telemetry-client": "4.0.0-devnet.2-patch.1",
|
|
65
65
|
"express": "^4.21.2",
|
|
66
66
|
"snappy": "^7.2.2",
|
|
67
67
|
"source-map-support": "^0.5.21",
|
|
@@ -13,7 +13,7 @@ export function describeBlobStore(getBlobStore: () => Promise<BlobStore>) {
|
|
|
13
13
|
it('should store and retrieve a blob by hash', async () => {
|
|
14
14
|
// Create a test blob with random fields
|
|
15
15
|
const testFields = [Fr.random(), Fr.random(), Fr.random()];
|
|
16
|
-
const blob = Blob.fromFields(testFields);
|
|
16
|
+
const blob = await Blob.fromFields(testFields);
|
|
17
17
|
const blobHash = blob.getEthVersionedBlobHash();
|
|
18
18
|
|
|
19
19
|
// Store the blob
|
|
@@ -29,8 +29,8 @@ export function describeBlobStore(getBlobStore: () => Promise<BlobStore>) {
|
|
|
29
29
|
|
|
30
30
|
it('should handle multiple blobs stored and retrieved by their hashes', async () => {
|
|
31
31
|
// Create two different blobs
|
|
32
|
-
const blob1 = Blob.fromFields([Fr.random(), Fr.random()]);
|
|
33
|
-
const blob2 = Blob.fromFields([Fr.random(), Fr.random(), Fr.random()]);
|
|
32
|
+
const blob1 = await Blob.fromFields([Fr.random(), Fr.random()]);
|
|
33
|
+
const blob2 = await Blob.fromFields([Fr.random(), Fr.random(), Fr.random()]);
|
|
34
34
|
|
|
35
35
|
const blobHash1 = blob1.getEthVersionedBlobHash();
|
|
36
36
|
const blobHash2 = blob2.getEthVersionedBlobHash();
|
|
@@ -57,9 +57,9 @@ export function describeBlobStore(getBlobStore: () => Promise<BlobStore>) {
|
|
|
57
57
|
|
|
58
58
|
it('should handle retrieving subset of stored blobs', async () => {
|
|
59
59
|
// Store multiple blobs
|
|
60
|
-
const blob1 = Blob.fromFields([Fr.random()]);
|
|
61
|
-
const blob2 = Blob.fromFields([Fr.random()]);
|
|
62
|
-
const blob3 = Blob.fromFields([Fr.random()]);
|
|
60
|
+
const blob1 = await Blob.fromFields([Fr.random()]);
|
|
61
|
+
const blob2 = await Blob.fromFields([Fr.random()]);
|
|
62
|
+
const blob3 = await Blob.fromFields([Fr.random()]);
|
|
63
63
|
|
|
64
64
|
await blobStore.addBlobs([blob1, blob2, blob3]);
|
|
65
65
|
|
|
@@ -75,7 +75,7 @@ export function describeBlobStore(getBlobStore: () => Promise<BlobStore>) {
|
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
it('should handle duplicate blob hashes in request', async () => {
|
|
78
|
-
const blob = Blob.fromFields([Fr.random()]);
|
|
78
|
+
const blob = await Blob.fromFields([Fr.random()]);
|
|
79
79
|
const blobHash = blob.getEthVersionedBlobHash();
|
|
80
80
|
|
|
81
81
|
await blobStore.addBlobs([blob]);
|
|
@@ -91,8 +91,8 @@ export function describeBlobStore(getBlobStore: () => Promise<BlobStore>) {
|
|
|
91
91
|
it('should overwrite blob when storing with same hash', async () => {
|
|
92
92
|
// Create two blobs that will have the same hash (same content)
|
|
93
93
|
const fields = [Fr.random(), Fr.random()];
|
|
94
|
-
const blob1 = Blob.fromFields(fields);
|
|
95
|
-
const blob2 = Blob.fromFields(fields);
|
|
94
|
+
const blob1 = await Blob.fromFields(fields);
|
|
95
|
+
const blob2 = await Blob.fromFields(fields);
|
|
96
96
|
|
|
97
97
|
const blobHash = blob1.getEthVersionedBlobHash();
|
|
98
98
|
|
package/src/client/http.ts
CHANGED
|
@@ -215,8 +215,8 @@ export class HttpBlobClient implements BlobClientInterface {
|
|
|
215
215
|
const getFilledBlobs = (): Blob[] => resultBlobs.filter((b): b is Blob => b !== undefined);
|
|
216
216
|
|
|
217
217
|
// Helper to fill in results from fetched blobs
|
|
218
|
-
const fillResults = (fetchedBlobs: BlobJson[]): Blob[] => {
|
|
219
|
-
const blobs = processFetchedBlobs(fetchedBlobs, blobHashes, this.log);
|
|
218
|
+
const fillResults = async (fetchedBlobs: BlobJson[]): Promise<Blob[]> => {
|
|
219
|
+
const blobs = await processFetchedBlobs(fetchedBlobs, blobHashes, this.log);
|
|
220
220
|
// Fill in any missing positions with matching blobs
|
|
221
221
|
for (let i = 0; i < blobHashes.length; i++) {
|
|
222
222
|
if (resultBlobs[i] === undefined) {
|
|
@@ -269,7 +269,7 @@ export class HttpBlobClient implements BlobClientInterface {
|
|
|
269
269
|
...ctx,
|
|
270
270
|
});
|
|
271
271
|
const blobs = await this.getBlobsFromHost(l1ConsensusHostUrl, slotNumber, l1ConsensusHostIndex);
|
|
272
|
-
const result = fillResults(blobs);
|
|
272
|
+
const result = await fillResults(blobs);
|
|
273
273
|
this.log.debug(
|
|
274
274
|
`Got ${blobs.length} blobs from consensus host (total: ${result.length}/${blobHashes.length})`,
|
|
275
275
|
{ slotNumber, l1ConsensusHostUrl, ...ctx },
|
|
@@ -312,7 +312,7 @@ export class HttpBlobClient implements BlobClientInterface {
|
|
|
312
312
|
this.log.debug('No blobs found from archive client', archiveCtx);
|
|
313
313
|
} else {
|
|
314
314
|
this.log.trace(`Got ${allBlobs.length} blobs from archive client before filtering`, archiveCtx);
|
|
315
|
-
const result = fillResults(allBlobs);
|
|
315
|
+
const result = await fillResults(allBlobs);
|
|
316
316
|
this.log.debug(
|
|
317
317
|
`Got ${allBlobs.length} blobs from archive client (total: ${result.length}/${blobHashes.length})`,
|
|
318
318
|
archiveCtx,
|
|
@@ -345,7 +345,7 @@ export class HttpBlobClient implements BlobClientInterface {
|
|
|
345
345
|
*/
|
|
346
346
|
private async tryFileStores(
|
|
347
347
|
getMissingBlobHashes: () => Buffer[],
|
|
348
|
-
fillResults: (blobs: BlobJson[]) => Blob[]
|
|
348
|
+
fillResults: (blobs: BlobJson[]) => Promise<Blob[]>,
|
|
349
349
|
ctx: { blockHash: string; blobHashes: string[] },
|
|
350
350
|
): Promise<void> {
|
|
351
351
|
// Shuffle clients for load distribution
|
|
@@ -366,7 +366,7 @@ export class HttpBlobClient implements BlobClientInterface {
|
|
|
366
366
|
});
|
|
367
367
|
const blobs = await client.getBlobsByHashes(blobHashStrings);
|
|
368
368
|
if (blobs.length > 0) {
|
|
369
|
-
const result = fillResults(blobs);
|
|
369
|
+
const result = await fillResults(blobs);
|
|
370
370
|
this.log.debug(
|
|
371
371
|
`Got ${blobs.length} blobs from filestore (total: ${result.length}/${ctx.blobHashes.length})`,
|
|
372
372
|
{
|
|
@@ -388,7 +388,7 @@ export class HttpBlobClient implements BlobClientInterface {
|
|
|
388
388
|
l1ConsensusHostIndex?: number,
|
|
389
389
|
): Promise<Blob[]> {
|
|
390
390
|
const blobs = await this.getBlobsFromHost(hostUrl, blockHashOrSlot, l1ConsensusHostIndex);
|
|
391
|
-
return processFetchedBlobs(blobs, blobHashes, this.log).filter((b): b is Blob => b !== undefined);
|
|
391
|
+
return (await processFetchedBlobs(blobs, blobHashes, this.log)).filter((b): b is Blob => b !== undefined);
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
public async getBlobsFromHost(
|
|
@@ -616,7 +616,11 @@ function parseBlobJson(data: any): BlobJson {
|
|
|
616
616
|
|
|
617
617
|
// Returns an array that maps each blob hash to the corresponding blob, or undefined if the blob is not found
|
|
618
618
|
// or the data does not match the commitment.
|
|
619
|
-
function processFetchedBlobs(
|
|
619
|
+
async function processFetchedBlobs(
|
|
620
|
+
blobs: BlobJson[],
|
|
621
|
+
blobHashes: Buffer[],
|
|
622
|
+
logger: Logger,
|
|
623
|
+
): Promise<(Blob | undefined)[]> {
|
|
620
624
|
const requestedBlobHashes = new Set<string>(blobHashes.map(bufferToHex));
|
|
621
625
|
const hashToBlob = new Map<string, Blob>();
|
|
622
626
|
for (const blobJson of blobs) {
|
|
@@ -626,7 +630,7 @@ function processFetchedBlobs(blobs: BlobJson[], blobHashes: Buffer[], logger: Lo
|
|
|
626
630
|
}
|
|
627
631
|
|
|
628
632
|
try {
|
|
629
|
-
const blob = Blob.fromJson(blobJson);
|
|
633
|
+
const blob = await Blob.fromJson(blobJson);
|
|
630
634
|
hashToBlob.set(hashHex, blob);
|
|
631
635
|
} catch (err) {
|
|
632
636
|
// If the above throws, it's likely that the blob commitment does not match the hash of the blob data.
|
package/src/client/tests.ts
CHANGED
|
@@ -28,7 +28,7 @@ export function runBlobClientTests(
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
it('should send and retrieve blobs by hash', async () => {
|
|
31
|
-
const blob = makeRandomBlob(5);
|
|
31
|
+
const blob = await makeRandomBlob(5);
|
|
32
32
|
const blobHash = blob.getEthVersionedBlobHash();
|
|
33
33
|
|
|
34
34
|
await client.sendBlobsToFilestore([blob]);
|
|
@@ -39,7 +39,7 @@ export function runBlobClientTests(
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
it('should handle multiple blobs', async () => {
|
|
42
|
-
const blobs = Array.from({ length: 3 }, () => makeRandomBlob(7));
|
|
42
|
+
const blobs = await Promise.all(Array.from({ length: 3 }, () => makeRandomBlob(7)));
|
|
43
43
|
const blobHashes = blobs.map(blob => blob.getEthVersionedBlobHash());
|
|
44
44
|
|
|
45
45
|
await client.sendBlobsToFilestore(blobs);
|