diff --git a/packages/tx/src/4844/tx.ts b/packages/tx/src/4844/tx.ts index a3faf3f6561..4dcd5e4e6e6 100644 --- a/packages/tx/src/4844/tx.ts +++ b/packages/tx/src/4844/tx.ts @@ -187,10 +187,26 @@ export class Blob4844Tx implements TransactionInterface maxBlobsPerTx) { + const msg = Legacy.errorMsg( + this, + `tx can contain at most ${maxBlobsPerTx} blobs (EIP-7594)`, + ) + throw EthereumJSErrorWithoutCode(msg) + } + } + + // "Old" limit (superseded by EIP-7594 starting with Osaka) const limitBlobsPerTx = this.common.param('maxBlobGasPerBlock') / this.common.param('blobGasPerBlob') if (this.blobVersionedHashes.length > limitBlobsPerTx) { - const msg = Legacy.errorMsg(this, `tx can contain at most ${limitBlobsPerTx} blobs`) + const msg = Legacy.errorMsg( + this, + `tx can contain at most ${limitBlobsPerTx} blobs (maxBlobGasPerBlock/blobGasPerBlob)`, + ) throw EthereumJSErrorWithoutCode(msg) } else if (this.blobVersionedHashes.length === 0) { const msg = Legacy.errorMsg(this, `tx should contain at least one blob`) diff --git a/packages/tx/src/params.ts b/packages/tx/src/params.ts index 311b74e239c..eac5178460c 100644 --- a/packages/tx/src/params.ts +++ b/packages/tx/src/params.ts @@ -45,6 +45,12 @@ export const paramsTx: ParamsDict = { blobGasPerBlob: 131072, // The base fee for blob gas per blob maxBlobGasPerBlock: 786432, // The max blob gas allowable per block }, + /** + * PeerDAS - Peer Data Availability Sampling + */ + 7594: { + maxBlobsPerTx: 6, // Max number of blobs per tx + }, /** * Increase calldata cost to reduce maximum block size */ diff --git a/packages/tx/test/eip4844.spec.ts b/packages/tx/test/eip4844.spec.ts index eeeb0391358..7143a7ad8ed 100644 --- a/packages/tx/test/eip4844.spec.ts +++ b/packages/tx/test/eip4844.spec.ts @@ -214,7 +214,7 @@ describe('fromTxData using from a json', () => { }) describe('EIP4844 constructor tests - invalid scenarios', () => { - const common = createCommonFromGethGenesis(eip4844GethGenesis, { + let common = createCommonFromGethGenesis(eip4844GethGenesis, { chain: 'customChain', hardfork: Hardfork.Cancun, customCrypto: { kzg }, @@ -232,11 +232,15 @@ describe('EIP4844 constructor tests - invalid scenarios', () => { const invalidVersionHash = { blobVersionedHashes: [concatBytes(new Uint8Array([3]), randomBytes(31))], } - const tooManyBlobs = { + const tooManyBlobs7 = { blobVersionedHashes: [ concatBytes(new Uint8Array([1]), randomBytes(31)), concatBytes(new Uint8Array([1]), randomBytes(31)), concatBytes(new Uint8Array([1]), randomBytes(31)), + concatBytes(new Uint8Array([1]), randomBytes(31)), + concatBytes(new Uint8Array([1]), randomBytes(31)), + concatBytes(new Uint8Array([1]), randomBytes(31)), + concatBytes(new Uint8Array([1]), randomBytes(31)), ], } try { @@ -256,10 +260,25 @@ describe('EIP4844 constructor tests - invalid scenarios', () => { ) } try { - createBlob4844Tx({ ...baseTxData, ...tooManyBlobs }, { common }) + createBlob4844Tx({ ...baseTxData, ...tooManyBlobs7 }, { common }) + } catch (err: any) { + assert.isTrue( + err.message.includes('tx can contain at most 6 blobs (maxBlobGasPerBlock/blobGasPerBlob)'), + 'throws on too many versioned hashes', + ) + } + + common = createCommonFromGethGenesis(eip4844GethGenesis, { + chain: 'customChain', + hardfork: Hardfork.Cancun, + eips: [7594], + customCrypto: { kzg }, + }) + try { + createBlob4844Tx({ ...baseTxData, ...tooManyBlobs7 }, { common }) } catch (err: any) { assert.isTrue( - err.message.includes('tx can contain at most'), + err.message.includes('tx can contain at most 6 blobs (EIP-7594)'), 'throws on too many versioned hashes', ) }