Commit 71de86d6 authored by Maurelian's avatar Maurelian Committed by Kelvin Fichter

chore(contracts): remove hardfork setting

Removes the 'hardfork' config setting, falling back to hardhat's default,
which for our current hardhat version is 'london'

fix(contracts): adjust fee math for london
parent da99cc43
---
'@eth-optimism/contracts': patch
---
Test contracts against london fork
...@@ -36,7 +36,6 @@ const config: HardhatUserConfig = { ...@@ -36,7 +36,6 @@ const config: HardhatUserConfig = {
live: false, live: false,
saveDeployments: false, saveDeployments: false,
tags: ['local'], tags: ['local'],
hardfork: 'istanbul',
}, },
optimism: { optimism: {
url: 'http://127.0.0.1:8545', url: 'http://127.0.0.1:8545',
......
...@@ -98,12 +98,11 @@ describe('L1StandardBridge', () => { ...@@ -98,12 +98,11 @@ describe('L1StandardBridge', () => {
const initialBalance = await ethers.provider.getBalance(depositer) const initialBalance = await ethers.provider.getBalance(depositer)
// alice calls deposit on the bridge and the L1 bridge calls transferFrom on the token // alice calls deposit on the bridge and the L1 bridge calls transferFrom on the token
await L1StandardBridge.connect(alice).depositETH( const res = await L1StandardBridge.connect(alice).depositETH(
FINALIZATION_GAS, FINALIZATION_GAS,
NON_NULL_BYTES32, NON_NULL_BYTES32,
{ {
value: depositAmount, value: depositAmount,
gasPrice: 0,
} }
) )
...@@ -111,8 +110,14 @@ describe('L1StandardBridge', () => { ...@@ -111,8 +110,14 @@ describe('L1StandardBridge', () => {
Mock__L1CrossDomainMessenger.smocked.sendMessage.calls[0] Mock__L1CrossDomainMessenger.smocked.sendMessage.calls[0]
const depositerBalance = await ethers.provider.getBalance(depositer) const depositerBalance = await ethers.provider.getBalance(depositer)
const receipt = await res.wait()
const depositerFeePaid = receipt.cumulativeGasUsed.mul(
receipt.effectiveGasPrice
)
expect(depositerBalance).to.equal(initialBalance.sub(depositAmount)) expect(depositerBalance).to.equal(
initialBalance.sub(depositAmount).sub(depositerFeePaid)
)
// bridge's balance is increased // bridge's balance is increased
const bridgeBalance = await ethers.provider.getBalance( const bridgeBalance = await ethers.provider.getBalance(
...@@ -143,20 +148,26 @@ describe('L1StandardBridge', () => { ...@@ -143,20 +148,26 @@ describe('L1StandardBridge', () => {
// depositor calls deposit on the bridge and the L1 bridge calls transferFrom on the token // depositor calls deposit on the bridge and the L1 bridge calls transferFrom on the token
const initialBalance = await ethers.provider.getBalance(aliceAddress) const initialBalance = await ethers.provider.getBalance(aliceAddress)
await L1StandardBridge.connect(alice).depositETHTo( const res = await L1StandardBridge.connect(alice).depositETHTo(
bobsAddress, bobsAddress,
FINALIZATION_GAS, FINALIZATION_GAS,
NON_NULL_BYTES32, NON_NULL_BYTES32,
{ {
value: depositAmount, value: depositAmount,
gasPrice: 0,
} }
) )
const depositCallToMessenger = const depositCallToMessenger =
Mock__L1CrossDomainMessenger.smocked.sendMessage.calls[0] Mock__L1CrossDomainMessenger.smocked.sendMessage.calls[0]
const depositerBalance = await ethers.provider.getBalance(aliceAddress) const depositerBalance = await ethers.provider.getBalance(aliceAddress)
expect(depositerBalance).to.equal(initialBalance.sub(depositAmount)) const receipt = await res.wait()
const depositerFeePaid = receipt.cumulativeGasUsed.mul(
receipt.effectiveGasPrice
)
expect(depositerBalance).to.equal(
initialBalance.sub(depositAmount).sub(depositerFeePaid)
)
// bridge's balance is increased // bridge's balance is increased
const bridgeBalance = await ethers.provider.getBalance( const bridgeBalance = await ethers.provider.getBalance(
...@@ -187,7 +198,6 @@ describe('L1StandardBridge', () => { ...@@ -187,7 +198,6 @@ describe('L1StandardBridge', () => {
expect( expect(
L1StandardBridge.depositETH(FINALIZATION_GAS, NON_NULL_BYTES32, { L1StandardBridge.depositETH(FINALIZATION_GAS, NON_NULL_BYTES32, {
value: depositAmount, value: depositAmount,
gasPrice: 0,
}) })
).to.be.revertedWith('Account not EOA') ).to.be.revertedWith('Account not EOA')
}) })
...@@ -250,7 +260,6 @@ describe('L1StandardBridge', () => { ...@@ -250,7 +260,6 @@ describe('L1StandardBridge', () => {
NON_NULL_BYTES32, NON_NULL_BYTES32,
{ {
value: ethers.utils.parseEther('1.0'), value: ethers.utils.parseEther('1.0'),
gasPrice: 0,
} }
) )
......
...@@ -25,8 +25,7 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => { ...@@ -25,8 +25,7 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => {
let sequencer: Signer let sequencer: Signer
let alice: Signer let alice: Signer
before(async () => { before(async () => {
;[sequencer] = await ethers.getSigners() ;[sequencer, alice] = await ethers.getSigners()
;[alice] = await ethers.getSigners()
}) })
let AddressManager: Contract let AddressManager: Contract
...@@ -139,14 +138,13 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => { ...@@ -139,14 +138,13 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => {
NON_NULL_BYTES32, NON_NULL_BYTES32,
{ {
value: depositAmount, value: depositAmount,
gasPrice: 0,
} }
) )
const receipt = await res.wait() const receipt = await res.wait()
const gasUsed = receipt.gasUsed.toNumber() const gasUsed = receipt.gasUsed.toNumber()
console.log(' - Gas used:', gasUsed) console.log(' - Gas used:', gasUsed)
expectApprox(gasUsed, 116_781, { expectApprox(gasUsed, 132_481, {
absoluteUpperDeviation: 500, absoluteUpperDeviation: 500,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your // Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value! // contracts are too efficient, consider updating the target value!
...@@ -169,11 +167,10 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => { ...@@ -169,11 +167,10 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => {
FINALIZATION_GAS, FINALIZATION_GAS,
NON_NULL_BYTES32 NON_NULL_BYTES32
) )
const receipt = await res.wait() const receipt = await res.wait()
const gasUsed = receipt.gasUsed.toNumber() const gasUsed = receipt.gasUsed.toNumber()
console.log(' - Gas used:', gasUsed) console.log(' - Gas used:', gasUsed)
expectApprox(gasUsed, 164_622, { expectApprox(gasUsed, 192_822, {
absoluteUpperDeviation: 500, absoluteUpperDeviation: 500,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your // Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value! // contracts are too efficient, consider updating the target value!
......
...@@ -157,7 +157,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => { ...@@ -157,7 +157,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
'Non-calldata overhead gas cost per transaction:', 'Non-calldata overhead gas cost per transaction:',
(gasUsed - fixedCalldataCost) / numTxs (gasUsed - fixedCalldataCost) / numTxs
) )
expectApprox(gasUsed, 1_422_181, { expectApprox(gasUsed, 1_402_638, {
absoluteUpperDeviation: 1000, absoluteUpperDeviation: 1000,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your // Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value! // contracts are too efficient, consider updating the target value!
...@@ -293,7 +293,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => { ...@@ -293,7 +293,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
console.log('Benchmark complete.') console.log('Benchmark complete.')
expectApprox(gasUsed, 189_487, { expectApprox(gasUsed, 196_687, {
absoluteUpperDeviation: 500, absoluteUpperDeviation: 500,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your // Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value! // contracts are too efficient, consider updating the target value!
...@@ -314,7 +314,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => { ...@@ -314,7 +314,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
console.log('Benchmark complete.') console.log('Benchmark complete.')
expectApprox(gasUsed, 127_500, { expectApprox(gasUsed, 134_100, {
absoluteUpperDeviation: 500, absoluteUpperDeviation: 500,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your // Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value! // contracts are too efficient, consider updating the target value!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment