Skip to content

Commit 4b4f323

Browse files
authored
Fix Nightly (#4168)
* Fix nightly * Another timeout fix
1 parent 196dc81 commit 4b4f323

File tree

2 files changed

+136
-148
lines changed

2 files changed

+136
-148
lines changed

packages/client/test/miner/pendingBlock.spec.ts

Lines changed: 121 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -350,143 +350,135 @@ describe('[PendingBlock]', async () => {
350350
)
351351
})
352352

353-
it(
354-
'construct blob bundles',
355-
async () => {
356-
const common = createCommonFromGethGenesis(eip4844GethGenesis, {
357-
chain: 'customChain',
358-
hardfork: Hardfork.Cancun,
359-
customCrypto: {
360-
kzg,
361-
},
362-
})
363-
364-
const { txPool } = setup()
365-
txPool['config'].chainCommon.setHardfork(Hardfork.Cancun)
366-
367-
// fill up the blobAndProofByHash and proofs cache before adding a blob tx
368-
// for cache pruning check
369-
const fillBlobs = getBlobs('hello world')
370-
const fillCommitments = blobsToCommitments(kzg, fillBlobs)
371-
const fillProofs = blobsToProofs(kzg, fillBlobs, fillCommitments)
372-
const fillBlobAndProof = { blob: fillBlobs[0], proof: fillProofs[0] }
373-
374-
const blobGasLimit = txPool['config'].chainCommon.param('maxBlobGasPerBlock')
375-
const blobGasPerBlob = txPool['config'].chainCommon.param('blobGasPerBlob')
376-
const allowedBlobsPerBlock = Number(blobGasLimit / blobGasPerBlob)
377-
const allowedLength = allowedBlobsPerBlock * txPool['config'].blobsAndProofsCacheBlocks
378-
379-
for (let i = 0; i < allowedLength; i++) {
380-
// this is space efficient as same object is inserted in dummy positions
381-
txPool.blobAndProofByHash.set(intToHex(i), fillBlobAndProof)
382-
}
383-
assert.strictEqual(
384-
txPool.blobAndProofByHash.size,
385-
allowedLength,
386-
'fill the cache to capacity',
387-
)
388-
389-
// Create 2 txs with 3 blobs each so that only 2 of them can be included in a build
390-
let blobs: PrefixedHexString[] = [],
391-
proofs: PrefixedHexString[] = [],
392-
versionedHashes: PrefixedHexString[] = []
393-
for (let x = 0; x <= 2; x++) {
394-
// generate unique blobs different from fillBlobs
395-
const txBlobs = [
396-
...getBlobs(`hello world-${x}1`),
397-
...getBlobs(`hello world-${x}2`),
398-
...getBlobs(`hello world-${x}3`),
399-
]
400-
assert.strictEqual(txBlobs.length, 3, '3 blobs should be created')
401-
const txCommitments = blobsToCommitments(kzg, txBlobs)
402-
const txBlobVersionedHashes = commitmentsToVersionedHashes(txCommitments)
403-
const txProofs = blobsToProofs(kzg, txBlobs, txCommitments)
404-
405-
const txA01 = createBlob4844Tx(
406-
{
407-
networkWrapperVersion: NetworkWrapperType.EIP4844,
408-
blobVersionedHashes: txBlobVersionedHashes,
409-
blobs: txBlobs,
410-
kzgCommitments: txCommitments,
411-
kzgProofs: txProofs,
412-
maxFeePerBlobGas: 100000000n,
413-
gasLimit: 0xffffffn,
414-
maxFeePerGas: Units.gwei(1),
415-
maxPriorityFeePerGas: 100000000n,
416-
to: randomBytes(20),
417-
nonce: BigInt(x),
418-
},
419-
{ common },
420-
).sign(A.privateKey)
421-
await txPool.add(txA01)
422-
423-
// accumulate for verification
424-
blobs = [...blobs, ...txBlobs]
425-
proofs = [...proofs, ...txProofs]
426-
versionedHashes = [...versionedHashes, ...txBlobVersionedHashes]
427-
}
428-
429-
assert.strictEqual(
430-
txPool.blobAndProofByHash.size,
431-
allowedLength,
432-
'cache should be prune and stay at same size',
433-
)
434-
// check if blobs and proofs are added in txpool by versioned hashes
435-
for (let i = 0; i < versionedHashes.length; i++) {
436-
const versionedHash = versionedHashes[i]
437-
const blob = blobs[i]
438-
const proof = proofs[i]
439-
440-
const blobAndProof = txPool.blobAndProofByHash.get(versionedHash) ?? {
441-
blob: '0x0',
442-
proof: '0x0',
443-
}
444-
assert.strictEqual(blob, blobAndProof.blob, 'blob should match')
445-
assert.strictEqual(proof, blobAndProof.proof, 'proof should match')
446-
}
353+
it('construct blob bundles', async () => {
354+
const common = createCommonFromGethGenesis(eip4844GethGenesis, {
355+
chain: 'customChain',
356+
hardfork: Hardfork.Cancun,
357+
customCrypto: {
358+
kzg,
359+
},
360+
})
447361

448-
// Add one other normal tx for nonce 3 which should also be not included in the build
449-
const txNorm = createFeeMarket1559Tx(
362+
const { txPool } = setup()
363+
txPool['config'].chainCommon.setHardfork(Hardfork.Cancun)
364+
365+
// fill up the blobAndProofByHash and proofs cache before adding a blob tx
366+
// for cache pruning check
367+
const fillBlobs = getBlobs('hello world')
368+
const fillCommitments = blobsToCommitments(kzg, fillBlobs)
369+
const fillProofs = blobsToProofs(kzg, fillBlobs, fillCommitments)
370+
const fillBlobAndProof = { blob: fillBlobs[0], proof: fillProofs[0] }
371+
372+
const blobGasLimit = txPool['config'].chainCommon.param('maxBlobGasPerBlock')
373+
const blobGasPerBlob = txPool['config'].chainCommon.param('blobGasPerBlob')
374+
const allowedBlobsPerBlock = Number(blobGasLimit / blobGasPerBlob)
375+
const allowedLength = allowedBlobsPerBlock * txPool['config'].blobsAndProofsCacheBlocks
376+
377+
for (let i = 0; i < allowedLength; i++) {
378+
// this is space efficient as same object is inserted in dummy positions
379+
txPool.blobAndProofByHash.set(intToHex(i), fillBlobAndProof)
380+
}
381+
assert.strictEqual(txPool.blobAndProofByHash.size, allowedLength, 'fill the cache to capacity')
382+
383+
// Create 2 txs with 3 blobs each so that only 2 of them can be included in a build
384+
let blobs: PrefixedHexString[] = [],
385+
proofs: PrefixedHexString[] = [],
386+
versionedHashes: PrefixedHexString[] = []
387+
for (let x = 0; x <= 2; x++) {
388+
// generate unique blobs different from fillBlobs
389+
const txBlobs = [
390+
...getBlobs(`hello world-${x}1`),
391+
...getBlobs(`hello world-${x}2`),
392+
...getBlobs(`hello world-${x}3`),
393+
]
394+
assert.strictEqual(txBlobs.length, 3, '3 blobs should be created')
395+
const txCommitments = blobsToCommitments(kzg, txBlobs)
396+
const txBlobVersionedHashes = commitmentsToVersionedHashes(txCommitments)
397+
const txProofs = blobsToProofs(kzg, txBlobs, txCommitments)
398+
399+
const txA01 = createBlob4844Tx(
450400
{
401+
networkWrapperVersion: NetworkWrapperType.EIP4844,
402+
blobVersionedHashes: txBlobVersionedHashes,
403+
blobs: txBlobs,
404+
kzgCommitments: txCommitments,
405+
kzgProofs: txProofs,
406+
maxFeePerBlobGas: 100000000n,
451407
gasLimit: 0xffffffn,
452408
maxFeePerGas: Units.gwei(1),
453409
maxPriorityFeePerGas: 100000000n,
454410
to: randomBytes(20),
455-
nonce: BigInt(3),
411+
nonce: BigInt(x),
456412
},
457413
{ common },
458414
).sign(A.privateKey)
459-
await txPool.add(txNorm)
460-
461-
assert.strictEqual(txPool.txsInPool, 4, '4 txs should still be in the pool')
462-
463-
const pendingBlock = new PendingBlock({ config, txPool })
464-
const blockchain = await createBlockchain({ common })
465-
const vm = await createVM({ common, blockchain })
466-
await setBalance(vm, A.address, BigInt(500000000000000000))
467-
const parentBlock = await (vm.blockchain as Blockchain).getCanonicalHeadBlock!()
468-
// stub the vm's common set hf to do nothing but stay in cancun
469-
vm.common.setHardforkBy = () => {
470-
return vm.common.hardfork()
415+
await txPool.add(txA01)
416+
417+
// accumulate for verification
418+
blobs = [...blobs, ...txBlobs]
419+
proofs = [...proofs, ...txProofs]
420+
versionedHashes = [...versionedHashes, ...txBlobVersionedHashes]
421+
}
422+
423+
assert.strictEqual(
424+
txPool.blobAndProofByHash.size,
425+
allowedLength,
426+
'cache should be prune and stay at same size',
427+
)
428+
// check if blobs and proofs are added in txpool by versioned hashes
429+
for (let i = 0; i < versionedHashes.length; i++) {
430+
const versionedHash = versionedHashes[i]
431+
const blob = blobs[i]
432+
const proof = proofs[i]
433+
434+
const blobAndProof = txPool.blobAndProofByHash.get(versionedHash) ?? {
435+
blob: '0x0',
436+
proof: '0x0',
471437
}
472-
const payloadId = await pendingBlock.start(vm, parentBlock)
473-
const [block, _receipts, _value, blobsBundles] = (await pendingBlock.build(payloadId)) ?? []
474-
475-
assert.isTrue(block !== undefined && blobsBundles !== undefined)
476-
assert.strictEqual(block!.transactions.length, 2, 'Only two blob txs should be included')
477-
assert.strictEqual(blobsBundles!.blobs.length, 6, 'maximum 6 blobs should be included')
478-
assert.strictEqual(
479-
blobsBundles!.commitments.length,
480-
6,
481-
'maximum 6 commitments should be included',
482-
)
483-
assert.strictEqual(blobsBundles!.proofs.length, 6, 'maximum 6 proofs should be included')
484-
485-
const pendingBlob = blobsBundles!.blobs[0]
486-
assert.isTrue(pendingBlob !== undefined && pendingBlob === blobs[0])
487-
const blobProof = blobsBundles!.proofs[0]
488-
assert.isTrue(blobProof !== undefined && blobProof === proofs[0])
489-
},
490-
{ timeout: 20000 },
491-
)
438+
assert.strictEqual(blob, blobAndProof.blob, 'blob should match')
439+
assert.strictEqual(proof, blobAndProof.proof, 'proof should match')
440+
}
441+
442+
// Add one other normal tx for nonce 3 which should also be not included in the build
443+
const txNorm = createFeeMarket1559Tx(
444+
{
445+
gasLimit: 0xffffffn,
446+
maxFeePerGas: Units.gwei(1),
447+
maxPriorityFeePerGas: 100000000n,
448+
to: randomBytes(20),
449+
nonce: BigInt(3),
450+
},
451+
{ common },
452+
).sign(A.privateKey)
453+
await txPool.add(txNorm)
454+
455+
assert.strictEqual(txPool.txsInPool, 4, '4 txs should still be in the pool')
456+
457+
const pendingBlock = new PendingBlock({ config, txPool })
458+
const blockchain = await createBlockchain({ common })
459+
const vm = await createVM({ common, blockchain })
460+
await setBalance(vm, A.address, BigInt(500000000000000000))
461+
const parentBlock = await (vm.blockchain as Blockchain).getCanonicalHeadBlock!()
462+
// stub the vm's common set hf to do nothing but stay in cancun
463+
vm.common.setHardforkBy = () => {
464+
return vm.common.hardfork()
465+
}
466+
const payloadId = await pendingBlock.start(vm, parentBlock)
467+
const [block, _receipts, _value, blobsBundles] = (await pendingBlock.build(payloadId)) ?? []
468+
469+
assert.isTrue(block !== undefined && blobsBundles !== undefined)
470+
assert.strictEqual(block!.transactions.length, 2, 'Only two blob txs should be included')
471+
assert.strictEqual(blobsBundles!.blobs.length, 6, 'maximum 6 blobs should be included')
472+
assert.strictEqual(
473+
blobsBundles!.commitments.length,
474+
6,
475+
'maximum 6 commitments should be included',
476+
)
477+
assert.strictEqual(blobsBundles!.proofs.length, 6, 'maximum 6 proofs should be included')
478+
479+
const pendingBlob = blobsBundles!.blobs[0]
480+
assert.isTrue(pendingBlob !== undefined && pendingBlob === blobs[0])
481+
const blobProof = blobsBundles!.proofs[0]
482+
assert.isTrue(blobProof !== undefined && blobProof === proofs[0])
483+
}, 30000)
492484
})

packages/client/test/rpc/eth/blobBaseFee.spec.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,20 @@ describe(method, () => {
104104
assert.strictEqual(res.result, '0x1')
105105
})
106106

107-
it(
108-
'call with more realistic blockchain',
109-
async () => {
110-
const { server, execution, chain } = await setupChain(eip4844GethGenesis, 'post-merge', {
111-
engine: true,
112-
hardfork: Hardfork.Cancun,
113-
customCrypto: {
114-
kzg,
115-
},
116-
})
107+
it('call with more realistic blockchain', async () => {
108+
const { server, execution, chain } = await setupChain(eip4844GethGenesis, 'post-merge', {
109+
engine: true,
110+
hardfork: Hardfork.Cancun,
111+
customCrypto: {
112+
kzg,
113+
},
114+
})
117115

118-
for (let i = 0; i < 2; i++) {
119-
await produceBlockWith4844Tx(execution, chain, [6])
120-
}
121-
const rpc = getRPCClient(server)
122-
const res = await rpc.request(method, [])
123-
assert.strictEqual(res.result, '0x1')
124-
},
125-
{ timeout: 20000 },
126-
)
116+
for (let i = 0; i < 2; i++) {
117+
await produceBlockWith4844Tx(execution, chain, [3])
118+
}
119+
const rpc = getRPCClient(server)
120+
const res = await rpc.request(method, [])
121+
assert.strictEqual(res.result, '0x1')
122+
}, 20000)
127123
})

0 commit comments

Comments
 (0)