From f75c533837f3cc649e2b89f85c1694f8c5d718fb Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Fri, 12 Apr 2024 11:33:43 +0200 Subject: [PATCH] Fix the blobs assertion --- .../simulation/assertions/blobsAssertion.ts | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/packages/cli/test/utils/simulation/assertions/blobsAssertion.ts b/packages/cli/test/utils/simulation/assertions/blobsAssertion.ts index dc6bb6656c7c..e714f0db8d7b 100644 --- a/packages/cli/test/utils/simulation/assertions/blobsAssertion.ts +++ b/packages/cli/test/utils/simulation/assertions/blobsAssertion.ts @@ -7,7 +7,7 @@ import {generateBlobsForTransaction} from "../utils/blobs.js"; import {BlobsEIP4844Transaction} from "../web3js/blobsEIP4844Transaction.js"; const numberOfBlobs = 6; -const sentBlobs: string[] = []; +const sentBlobs: Uint8Array[] = []; export function createBlobsAssertion( nodes: NodePair[], @@ -46,7 +46,8 @@ export function createBlobsAssertion( }); const signedTx = tx.sign(fromHex(`0x${EL_GENESIS_SECRET_KEY}`)); await node.execution.provider?.extended.sendRawTransaction(toHex(signedTx.serialize())); - sentBlobs.push(...blobs.map((b) => toHex(b))); + + sentBlobs.push(...blobs.map((b) => fromHex(b))); } const blobSideCars = await node.beacon.api.beacon.getBlobSidecars(slot); @@ -76,16 +77,29 @@ export function createBlobsAssertion( for (let i = 0; i < blobs.length; i++) { if (!Buffer.from(blobs[i]).equals(Buffer.from(sentBlobs[i]))) { - errors.push([ - "Node does not have the right blobs", - { - expectedBlob: sentBlobs[i], - currentBlob: blobs[i], - }, - ]); + errors.push(["Node does not have the correct blobs", {index: i}]); } } return errors; }, + + async dump({store, nodes}) { + const result: Record = { + "expectedBlobs.txt": sentBlobs.map(toHex).join("\n"), + }; + + for (const node of nodes) { + const blobs: Uint8Array[] = []; + for (let slot = sendBlobsAtSlot; slot <= validateBlobsAt; slot++) { + if (store[node.beacon.id] !== undefined) { + blobs.push(...(store[node.beacon.id][slot] ?? [])); + } + } + + result[`blobs-${node.beacon.id}.txt`] = blobs.map(toHex).join("\n"); + } + + return result; + }, }; }