Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/common/src/gethGenesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface GethGenesisConfig {
shanghaiTime?: number
cancunTime?: number
pragueTime?: number
osakaTime?: number
verkleTime?: number
terminalTotalDifficulty?: number
terminalTotalDifficultyPassed?: boolean
Expand Down
2 changes: 2 additions & 0 deletions packages/testdata/src/gethGenesis/eip4844GethGenesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const eip4844GethGenesis: GethGenesis = {
mergeForkBlock: 0,
shanghaiTime: 0,
cancunTime: 0,
pragueTime: 0,
osakaTime: 0,
clique: {
blockperiodseconds: 5,
epochlength: 30000,
Expand Down
18 changes: 17 additions & 1 deletion packages/tx/src/4844/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,26 @@ export class Blob4844Tx implements TransactionInterface<typeof TransactionType.B
}
}

// EIP-7594 PeerDAS: Limit of 6 blobs per transaction
if (this.common.isActivatedEIP(7594)) {
const maxBlobsPerTx = this.common.param('maxBlobsPerTx')
if (this.blobVersionedHashes.length > 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`)
Comment on lines +190 to -193
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should't this be if/else? Currently if 7594 is active we will run both the 7594 limit and the old limit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not fully sure, I think theoretically this "old" limit would technically be still intact, it just is fully superseded by the other one "by the values". So I haven't read that this is dismissed, but if someone can prove with a link happy to add if/else. Practical relevance limited though I guess.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah maybe my understanding was incorrect then, I assumed it would've been overwritten and not just superseded.

const msg = Legacy.errorMsg(
this,
`tx can contain at most ${limitBlobsPerTx} blobs (maxBlobGasPerBlock/blobGasPerBlob)`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message does not look completely correct, because maxBlobGasPerBlock/blobGasPerBlob could be 9 (osaka config: target 6 but max 9), while tx limit is 6

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the "old way" of doing it, look at the code, this is just reflecting the implementation three lines above. So this will be superseded by the 6 from Osaka then, currently this code is the active one.

Let me know if my understanding is wrong somewhere here.

)
throw EthereumJSErrorWithoutCode(msg)
} else if (this.blobVersionedHashes.length === 0) {
const msg = Legacy.errorMsg(this, `tx should contain at least one blob`)
Expand Down
6 changes: 6 additions & 0 deletions packages/tx/src/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
29 changes: 24 additions & 5 deletions packages/tx/test/eip4844.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const kzg = new microEthKZG(trustedSetup)
describe('EIP4844 addSignature tests', () => {
const common = createCommonFromGethGenesis(eip4844GethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
hardfork: Hardfork.Prague,
customCrypto: { kzg },
})

Expand Down Expand Up @@ -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 },
Expand All @@ -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 {
Expand All @@ -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',
)
}
Expand Down
Loading