Skip to content

Commit

Permalink
Fix the blobs assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Apr 12, 2024
1 parent d7b3d9b commit f75c533
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions packages/cli/test/utils/simulation/assertions/blobsAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[],
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<string, string> = {
"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;
},
};
}

0 comments on commit f75c533

Please sign in to comment.