diff --git a/packages/contracts/test/contracts/L1/messaging/deposit.gas.spec.ts b/packages/contracts/test/contracts/L1/messaging/deposit.gas.spec.ts index a540edb8f668..a33c81114a14 100644 --- a/packages/contracts/test/contracts/L1/messaging/deposit.gas.spec.ts +++ b/packages/contracts/test/contracts/L1/messaging/deposit.gas.spec.ts @@ -143,7 +143,18 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => { ) const receipt = await res.wait() - console.log(' - Gas used:', receipt.gasUsed.toNumber()) + const gasUsed = receipt.gasUsed.toNumber() + const regenesis040Cost = 196_128 + console.log(' - Gas used:', gasUsed) + console.log( + ' - Absolute savings vs regenesis/0.4.0:', + regenesis040Cost - gasUsed + ) + console.log( + ' - Relative savings vs regenesis/0.4.0:', + (((regenesis040Cost - gasUsed) / regenesis040Cost) * 100).toFixed(2) + + '%' + ) // Sanity check that the message was enqueued. expect(await CanonicalTransactionChain.getQueueLength()).to.equal(2) }) @@ -163,7 +174,19 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => { ) const receipt = await res.wait() - console.log(' - Gas used:', receipt.gasUsed.toNumber()) + const gasUsed = receipt.gasUsed.toNumber() + const regenesis040Cost = 244_358 + console.log(' - Gas used:', gasUsed) + console.log( + ' - Absolute savings vs regenesis/0.4.0:', + regenesis040Cost - gasUsed + ) + console.log( + ' - Relative savings vs regenesis/0.4.0:', + (((regenesis040Cost - gasUsed) / regenesis040Cost) * 100).toFixed(2) + + '%' + ) + // Sanity check that the message was enqueued. expect(await CanonicalTransactionChain.getQueueLength()).to.equal(3) }) diff --git a/packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.gas.spec.ts b/packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.gas.spec.ts index 4aaa7410fa4d..cbaef53f923f 100644 --- a/packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.gas.spec.ts +++ b/packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.gas.spec.ts @@ -41,6 +41,19 @@ const appendSequencerBatch = async ( }) } +const printGasSavings = (gasUsed:number, regenesis040Cost:number):void => { + console.log(' - Gas used:', gasUsed) + console.log( + ' - Absolute savings vs regenesis/0.4.0:', + regenesis040Cost - gasUsed + ) + console.log( + ' - Relative savings vs regenesis/0.4.0:', + (((regenesis040Cost - gasUsed) / regenesis040Cost) * 100).toFixed(2) + + '%' + ) +} + describe('[GAS BENCHMARK] CanonicalTransactionChain', () => { let sequencer: Signer before(async () => { @@ -151,7 +164,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => { const gasUsed = receipt.gasUsed.toNumber() console.log('Benchmark complete.') - console.log('Gas used:', gasUsed) + printGasSavings(gasUsed, 1_616_390) console.log('Fixed calldata cost:', fixedCalldataCost) console.log( @@ -199,7 +212,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => { const gasUsed = receipt.gasUsed.toNumber() console.log('Benchmark complete.') - console.log('Gas used:', gasUsed) + printGasSavings(gasUsed, 1_787_052) console.log('Fixed calldata cost:', fixedCalldataCost) console.log( @@ -257,7 +270,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => { const gasUsed = receipt.gasUsed.toNumber() console.log('Benchmark complete.') - console.log('Gas used:', gasUsed) + printGasSavings(gasUsed, 2_099_387) console.log('Fixed calldata cost:', fixedCalldataCost) console.log(