Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/pretty-dogs-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/integration-tests': patch
---

Enforce fees in docker-compose setup and test cases for fee too low and fee too high
7 changes: 2 additions & 5 deletions integration-tests/test/fee-payment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { serialize } from '@ethersproject/transactions'
import { predeploys, getContractFactory } from '@eth-optimism/contracts'

/* Imports: Internal */
import { gasPriceForL2, isLiveNetwork } from './shared/utils'
import { isLiveNetwork } from './shared/utils'
import { OptimismEnv } from './shared/env'
import { Direction } from './shared/watcher-utils'

Expand Down Expand Up @@ -173,10 +173,7 @@ describe('Fee Payment Integration Tests', async () => {
env.sequencerFeeVault.address
)

// Submit the withdrawal.
const withdrawTx = await env.sequencerFeeVault.withdraw({
gasPrice: await gasPriceForL2(env), // Will be zero on HH
})
const withdrawTx = await env.sequencerFeeVault.withdraw()

// Wait for the withdrawal to be relayed to L1.
await withdrawTx.wait()
Expand Down
39 changes: 39 additions & 0 deletions integration-tests/test/rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,45 @@ describe('Basic RPC tests', () => {
'gas required exceeds allowance'
)
})

it('should reject a transaction with too low of a fee', async () => {
if (isLiveNetwork()) {
console.log('Skipping too low of a fee test on live network')
return
}

const gasPrice = await env.gasPriceOracle.gasPrice()
await env.gasPriceOracle.setGasPrice(1000)

const tx = {
...defaultTransactionFactory(),
gasPrice: 1,
}

await expect(env.l2Wallet.sendTransaction(tx)).to.be.rejectedWith(
`gas price too low: 1 wei, use at least tx.gasPrice = 1000 wei`
)
// Reset the gas price to its original price
await env.gasPriceOracle.setGasPrice(gasPrice)
})

it('should reject a transaction with too high of a fee', async () => {
if (isLiveNetwork()) {
console.log('Skpping too high of a fee test on live network')
return
}

const gasPrice = await env.gasPriceOracle.gasPrice()
const largeGasPrice = gasPrice.mul(10)
const tx = {
...defaultTransactionFactory(),
gasPrice: largeGasPrice,
}
await expect(env.l2Wallet.sendTransaction(tx)).to.be.rejectedWith(
`gas price too high: ${largeGasPrice.toString()} wei, use at most ` +
`tx.gasPrice = ${gasPrice.toString()} wei`
)
})
})

describe('eth_call', () => {
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/test/shared/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
replicaProvider,
l1Wallet,
l2Wallet,
gasPriceOracleWallet,
fundUser,
getOvmEth,
getL1Bridge,
Expand Down Expand Up @@ -100,7 +101,7 @@ export class OptimismEnv {
.attach(ctcAddress)

const gasPriceOracle = getContractFactory('OVM_GasPriceOracle')
.connect(l2Wallet)
.connect(gasPriceOracleWallet)
.attach(predeploys.OVM_GasPriceOracle)

const sccAddress = await addressManager.getAddress('StateCommitmentChain')
Expand Down
17 changes: 15 additions & 2 deletions integration-tests/test/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const env = cleanEnv(process.env, {
ADDRESS_MANAGER: str({
default: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
}),
GAS_PRICE_ORACLE_PRIVATE_KEY: str({
default:
'0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba',
}),
L2_CHAINID: num({ default: 420 }),
IS_LIVE_NETWORK: bool({ default: false }),
})
Expand Down Expand Up @@ -77,6 +81,12 @@ export const l1Wallet = new Wallet(env.PRIVATE_KEY, l1Provider)
// if it's using non-0 gas price
export const l2Wallet = l1Wallet.connect(l2Provider)

// The owner of the GasPriceOracle on L2
export const gasPriceOracleWallet = new Wallet(
env.GAS_PRICE_ORACLE_PRIVATE_KEY,
l2Provider
)

// Predeploys
export const PROXY_SEQUENCER_ENTRYPOINT_ADDRESS =
'0x4200000000000000000000000000000000000004'
Expand Down Expand Up @@ -182,14 +192,17 @@ export const waitForL2Geth = async (

// eslint-disable-next-line @typescript-eslint/no-shadow
export const gasPriceForL2 = async (env: OptimismEnv) => {
if (await isMainnet(env)) {
// The integration tests enforce fees on L2
// which run against hardhat on L1. Update if
// geth --dev is adopted for L1
const chainId = await env.l1Wallet.getChainId()
if ((await isMainnet(env)) || chainId === 31337) {
return env.l2Wallet.getGasPrice()
}

if (isLiveNetwork()) {
return Promise.resolve(BigNumber.from(10000))
}

return Promise.resolve(BigNumber.from(0))
}

Expand Down
8 changes: 5 additions & 3 deletions ops/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ services:
DEPLOYER_PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
SEQUENCER_PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
PROPOSER_PRIVATE_KEY: "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
GAS_PRICE_ORACLE_OWNER: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
# Default hardhat account 5
GAS_PRICE_ORACLE_OWNER: "0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc"
# setting the whitelist owner to address(0) disables the whitelist
WHITELIST_OWNER: "0x0000000000000000000000000000000000000000"
L1_FEE_WALLET_ADDRESS: "0x391716d440c151c42cdf1c95c1d83a5427bca52c"
L2_CHAIN_ID: 420
L2_BLOCK_GAS_LIMIT: 11000000
L2_BLOCK_GAS_LIMIT: 15000000
BLOCK_SIGNER_ADDRESS: "0x00000398232E2064F896018496b4b44b3D62751F"
GAS_PRICE_ORACLE_OVERHEAD: "2750"
GAS_PRICE_ORACLE_SCALAR: "1500000"
Expand Down Expand Up @@ -212,4 +213,5 @@ services:
entrypoint: ./gas-oracle.sh
environment:
GAS_PRICE_ORACLE_ETHEREUM_HTTP_URL: http://l2geth:8545
GAS_PRICE_ORACLE_PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
# Default hardhat account 5
GAS_PRICE_ORACLE_PRIVATE_KEY: "0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba"
5 changes: 4 additions & 1 deletion ops/envs/geth.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ETH1_CONFIRMATION_DEPTH=0
ROLLUP_CLIENT_HTTP=
ROLLUP_POLL_INTERVAL_FLAG=500ms
ROLLUP_ENABLE_L2_GAS_POLLING=true
# ROLLUP_ENFORCE_FEES=
ROLLUP_ENFORCE_FEES=true

RPC_ENABLE=true
RPC_ADDR=0.0.0.0
Expand Down Expand Up @@ -36,3 +36,6 @@ BLOCK_SIGNER_KEY=6587ae678cf4fc9a33000cdbf9f35226b71dcc6a4684a31203241f9bcfd55d2
BLOCK_SIGNER_ADDRESS=0x00000398232E2064F896018496b4b44b3D62751F

L2_BLOCK_GAS_LIMIT=15000000

ROLLUP_FEE_THRESHOLD_DOWN=0.9
ROLLUP_FEE_THRESHOLD_UP=1.1