From 65fbf7378d123e68e4621ec53a0d19323c93d4b8 Mon Sep 17 00:00:00 2001 From: harkamal Date: Thu, 3 Oct 2024 22:00:12 +0530 Subject: [PATCH] improvs --- packages/client/src/rpc/modules/engine/engine.ts | 10 ++++++++++ packages/client/src/service/txpool.ts | 10 ++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/client/src/rpc/modules/engine/engine.ts b/packages/client/src/rpc/modules/engine/engine.ts index 571f01c9a26..3f866bb4cef 100644 --- a/packages/client/src/rpc/modules/engine/engine.ts +++ b/packages/client/src/rpc/modules/engine/engine.ts @@ -1523,6 +1523,16 @@ export class Engine { } private async getBlobsV1(params: [[Bytes32]]): Promise<(BlobAndProofV1 | null)[]> { + const blobGasLimit = this.config.chainCommon.param('maxblobGasPerBlock') + const blobGasPerBlob = this.config.chainCommon.param('blobGasPerBlob') + const allowedBlobsPerBlock = blobGasLimit / blobGasPerBlob + if (params[0].length > allowedBlobsPerBlock) { + throw { + code: TOO_LARGE_REQUEST, + message: `More than allowedBlobsPerBlock=${allowedBlobsPerBlock} hashes queried`, + } + } + const blobsAndProof: (BlobAndProofV1 | null)[] = [] for (const versionedHashHex of params[0]) { blobsAndProof.push(this.service.txPool.blobsAndProofsByHash.get(versionedHashHex) ?? null) diff --git a/packages/client/src/service/txpool.ts b/packages/client/src/service/txpool.ts index 61ba6ef7a03..6a1ef4201a8 100644 --- a/packages/client/src/service/txpool.ts +++ b/packages/client/src/service/txpool.ts @@ -399,12 +399,10 @@ export class TxPool { } pruneBlobsAndProofsCache() { - // currently common.param errors when not achieved cancun hardfork to do the below calculation - // const blobGasLimit = this.config.chainCommon.param('maxblobGasPerBlock') - // const blobGasPerBlob = this.config.chainCommon.param('blobGasPerBlob') - // - // A better way could be figured out to get allowedBlobsPerBlock - const allowedBlobsPerBlock = 6 + const blobGasLimit = this.config.chainCommon.param('maxblobGasPerBlock') + const blobGasPerBlob = this.config.chainCommon.param('blobGasPerBlob') + const allowedBlobsPerBlock = Number(blobGasLimit / blobGasPerBlob) + const pruneLength = this.blobsAndProofsByHash.size - allowedBlobsPerBlock * this.config.blobsAndProofsCacheBlocks let pruned = 0