Commit 5e0a3285 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

Merge pull request #2199 from tonykogias/remove-contract-references-in-integration-tests

Remove unnecessary contract references in integration-tests
parents 8f5b1d81 a4198a4a
---
'@eth-optimism/integration-tests': patch
---
Replaces contract references in integration tests with SDK CrossChainMessenger objects.
......@@ -63,7 +63,10 @@ describe('Bridged tokens', () => {
await L2__ERC20.deployed()
// Approve the L1 ERC20 to spend our money
const tx = await L1__ERC20.approve(env.l1Bridge.address, 1000000)
const tx = await L1__ERC20.approve(
env.messenger.contracts.l1.L1StandardBridge.address,
1000000
)
await tx.wait()
})
......
......@@ -5,13 +5,17 @@ import { predeploys, getContractFactory } from '@eth-optimism/contracts'
/* Imports: Internal */
import { expect } from './shared/setup'
import { hardhatTest } from './shared/utils'
import { hardhatTest, gasPriceOracleWallet } from './shared/utils'
import { OptimismEnv } from './shared/env'
const setPrices = async (env: OptimismEnv, value: number | BigNumber) => {
const gasPrice = await env.gasPriceOracle.setGasPrice(value)
const gasPrice = await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).setGasPrice(value)
await gasPrice.wait()
const baseFee = await env.gasPriceOracle.setL1BaseFee(value)
const baseFee = await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).setL1BaseFee(value)
await baseFee.wait()
}
......@@ -28,13 +32,18 @@ describe('Fee Payment Integration Tests', async () => {
async () => {
const assertGasPrice = async () => {
const gasPrice = await env.l2Wallet.getGasPrice()
const oracleGasPrice = await env.gasPriceOracle.gasPrice()
const oracleGasPrice =
await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).gasPrice()
expect(gasPrice).to.deep.equal(oracleGasPrice)
}
await assertGasPrice()
// update the gas price
const tx = await env.gasPriceOracle.setGasPrice(1000)
const tx = await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).setGasPrice(1000)
await tx.wait()
await assertGasPrice()
......@@ -47,7 +56,7 @@ describe('Fee Payment Integration Tests', async () => {
const amount = utils.parseEther('0.0000001')
const balanceBefore = await env.l2Wallet.getBalance()
const feeVaultBalanceBefore = await env.l2Wallet.provider.getBalance(
env.sequencerFeeVault.address
env.messenger.contracts.l2.OVM_SequencerFeeVault.address
)
expect(balanceBefore.gt(amount))
......@@ -66,7 +75,9 @@ describe('Fee Payment Integration Tests', async () => {
data: unsigned.data,
})
const l1Fee = await env.gasPriceOracle.getL1Fee(raw)
const l1Fee = await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).getL1Fee(raw)
const tx = await env.l2Wallet.sendTransaction(unsigned)
const receipt = await tx.wait()
......@@ -74,7 +85,7 @@ describe('Fee Payment Integration Tests', async () => {
const balanceAfter = await env.l2Wallet.getBalance()
const feeVaultBalanceAfter = await env.l2Wallet.provider.getBalance(
env.sequencerFeeVault.address
env.messenger.contracts.l2.OVM_SequencerFeeVault.address
)
const l2Fee = receipt.gasUsed.mul(tx.gasPrice)
......@@ -124,7 +135,9 @@ describe('Fee Payment Integration Tests', async () => {
data: unsigned.data,
})
const l1Fee = await OVM_GasPriceOracle.getL1Fee(raw)
const l1Fee = await OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).getL1Fee(raw)
const tx = await env.l2Wallet.sendTransaction(unsigned)
const receipt = await tx.wait()
......@@ -142,30 +155,33 @@ describe('Fee Payment Integration Tests', async () => {
})
it('should not be able to withdraw fees before the minimum is met', async () => {
await expect(env.sequencerFeeVault.withdraw()).to.be.rejected
await expect(env.messenger.contracts.l2.OVM_SequencerFeeVault.withdraw()).to
.be.rejected
})
hardhatTest(
'should be able to withdraw fees back to L1 once the minimum is met',
async () => {
const l1FeeWallet = await env.sequencerFeeVault.l1FeeWallet()
const l1FeeWallet =
await env.messenger.contracts.l2.OVM_SequencerFeeVault.l1FeeWallet()
const balanceBefore = await env.l1Wallet.provider.getBalance(l1FeeWallet)
const withdrawalAmount =
await env.sequencerFeeVault.MIN_WITHDRAWAL_AMOUNT()
await env.messenger.contracts.l2.OVM_SequencerFeeVault.MIN_WITHDRAWAL_AMOUNT()
// Transfer the minimum required to withdraw.
const tx = await env.l2Wallet.sendTransaction({
to: env.sequencerFeeVault.address,
to: env.messenger.contracts.l2.OVM_SequencerFeeVault.address,
value: withdrawalAmount,
gasLimit: 500000,
})
await tx.wait()
const vaultBalance = await env.ovmEth.balanceOf(
env.sequencerFeeVault.address
const vaultBalance = await env.messenger.contracts.l2.OVM_ETH.balanceOf(
env.messenger.contracts.l2.OVM_SequencerFeeVault.address
)
const withdrawTx = await env.sequencerFeeVault.withdraw()
const withdrawTx =
await env.messenger.contracts.l2.OVM_SequencerFeeVault.withdraw()
// Wait for the withdrawal to be relayed to L1.
await withdrawTx.wait()
......
......@@ -123,8 +123,10 @@ describe('Native ETH value integration tests', () => {
'geth RPC does not match ovmSELFBALANCE'
)
// query ovmSELFBALANCE() opcode via eth_call as another check
const ovmEthBalanceOf0 = await env.ovmEth.balanceOf(ValueCalls0.address)
const ovmEthBalanceOf1 = await env.ovmEth.balanceOf(ValueCalls1.address)
const ovmEthBalanceOf0 =
await env.messenger.contracts.l2.OVM_ETH.balanceOf(ValueCalls0.address)
const ovmEthBalanceOf1 =
await env.messenger.contracts.l2.OVM_ETH.balanceOf(ValueCalls1.address)
expect(ovmEthBalanceOf0).to.deep.eq(
BigNumber.from(expectedBalances[0]),
'geth RPC does not match OVM_ETH.balanceOf'
......
......@@ -11,6 +11,7 @@ import {
DEFAULT_TEST_GAS_L2,
envConfig,
withdrawalTest,
gasPriceOracleWallet,
} from './shared/utils'
import { OptimismEnv } from './shared/env'
......@@ -30,7 +31,7 @@ describe('Native ETH Integration Tests', async () => {
const l2BobBalance = await l2Bob.getBalance()
const l1BridgeBalance = await _env.l1Wallet.provider.getBalance(
_env.l1Bridge.address
_env.messenger.contracts.l1.L1StandardBridge.address
)
return {
......@@ -51,7 +52,8 @@ describe('Native ETH Integration Tests', async () => {
describe('estimateGas', () => {
it('Should estimate gas for ETH withdraw', async () => {
const amount = utils.parseEther('0.0000001')
const gas = await env.l2Bridge.estimateGas.withdraw(
const gas =
await env.messenger.contracts.l2.L2StandardBridge.estimateGas.withdraw(
predeploys.OVM_ETH,
amount,
0,
......@@ -67,7 +69,7 @@ describe('Native ETH Integration Tests', async () => {
const preBalances = await getBalances(env)
const { tx, receipt } = await env.waitForXDomainTransaction(
env.l1Wallet.sendTransaction({
to: env.l1Bridge.address,
to: env.messenger.contracts.l1.L1StandardBridge.address,
value: depositAmount,
gasLimit: DEFAULT_TEST_GAS_L1,
})
......@@ -91,10 +93,14 @@ describe('Native ETH Integration Tests', async () => {
const depositAmount = 10
const preBalances = await getBalances(env)
const { tx, receipt } = await env.waitForXDomainTransaction(
env.l1Bridge.depositETH(DEFAULT_TEST_GAS_L2, '0xFFFF', {
env.messenger.contracts.l1.L1StandardBridge.depositETH(
DEFAULT_TEST_GAS_L2,
'0xFFFF',
{
value: depositAmount,
gasLimit: DEFAULT_TEST_GAS_L1,
})
}
)
)
const l1FeePaid = receipt.gasUsed.mul(tx.gasPrice)
......@@ -115,10 +121,15 @@ describe('Native ETH Integration Tests', async () => {
const depositAmount = 10
const preBalances = await getBalances(env)
const depositReceipts = await env.waitForXDomainTransaction(
env.l1Bridge.depositETHTo(l2Bob.address, DEFAULT_TEST_GAS_L2, '0xFFFF', {
env.messenger.contracts.l1.L1StandardBridge.depositETHTo(
l2Bob.address,
DEFAULT_TEST_GAS_L2,
'0xFFFF',
{
value: depositAmount,
gasLimit: DEFAULT_TEST_GAS_L1,
})
}
)
)
const l1FeePaid = depositReceipts.receipt.gasUsed.mul(
......@@ -145,10 +156,14 @@ describe('Native ETH Integration Tests', async () => {
// to allow for encoding and other arguments
const data = `0x` + 'ab'.repeat(MAX_ROLLUP_TX_SIZE - 500)
const { tx, receipt } = await env.waitForXDomainTransaction(
env.l1Bridge.depositETH(ASSUMED_L2_GAS_LIMIT, data, {
env.messenger.contracts.l1.L1StandardBridge.depositETH(
ASSUMED_L2_GAS_LIMIT,
data,
{
value: depositAmount,
gasLimit: 4_000_000,
})
}
)
)
const l1FeePaid = receipt.gasUsed.mul(tx.gasPrice)
......@@ -169,9 +184,13 @@ describe('Native ETH Integration Tests', async () => {
const data = `0x` + 'ab'.repeat(MAX_ROLLUP_TX_SIZE + 1)
await expect(
env.l1Bridge.depositETH(DEFAULT_TEST_GAS_L2, data, {
env.messenger.contracts.l1.L1StandardBridge.depositETH(
DEFAULT_TEST_GAS_L2,
data,
{
value: depositAmount,
})
}
)
).to.be.reverted
})
......@@ -183,7 +202,8 @@ describe('Native ETH Integration Tests', async () => {
'Cannot run withdrawal test before any deposits...'
)
const transaction = await env.l2Bridge.withdraw(
const transaction =
await env.messenger.contracts.l2.L2StandardBridge.withdraw(
predeploys.OVM_ETH,
withdrawAmount,
DEFAULT_TEST_GAS_L2,
......@@ -224,7 +244,8 @@ describe('Native ETH Integration Tests', async () => {
'Cannot run withdrawal test before any deposits...'
)
const transaction = await env.l2Bridge.withdrawTo(
const transaction =
await env.messenger.contracts.l2.L2StandardBridge.withdrawTo(
predeploys.OVM_ETH,
l1Bob.address,
withdrawAmount,
......@@ -248,7 +269,9 @@ describe('Native ETH Integration Tests', async () => {
data: transaction.data,
})
const l1Fee = await env.gasPriceOracle.getL1Fee(raw)
const l1Fee = await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).getL1Fee(raw)
const fee = l2Fee.add(l1Fee)
const postBalances = await getBalances(env)
......@@ -275,10 +298,14 @@ describe('Native ETH Integration Tests', async () => {
// 1. deposit
const amount = utils.parseEther('1')
await env.waitForXDomainTransaction(
env.l1Bridge.depositETH(DEFAULT_TEST_GAS_L2, '0xFFFF', {
env.messenger.contracts.l1.L1StandardBridge.depositETH(
DEFAULT_TEST_GAS_L2,
'0xFFFF',
{
value: amount,
gasLimit: DEFAULT_TEST_GAS_L1,
})
}
)
)
// 2. transfer to another address
......@@ -295,9 +322,10 @@ describe('Native ETH Integration Tests', async () => {
// 3. do withdrawal
const withdrawnAmount = utils.parseEther('0.95')
const transaction = await env.l2Bridge
.connect(other)
.withdraw(
const transaction =
await env.messenger.contracts.l2.L2StandardBridge.connect(
other
).withdraw(
predeploys.OVM_ETH,
withdrawnAmount,
DEFAULT_TEST_GAS_L1,
......@@ -308,7 +336,10 @@ describe('Native ETH Integration Tests', async () => {
const receipts = await env.waitForXDomainTransaction(transaction)
// Compute the L1 portion of the fee
const l1Fee = await env.gasPriceOracle.getL1Fee(
const l1Fee =
await await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).getL1Fee(
serialize({
nonce: transaction.nonce,
value: transaction.value,
......
......@@ -44,7 +44,8 @@ describe('OVM Context: Layer 2 EVM Context', () => {
for (let i = 0; i < numTxs; i++) {
// Send a transaction from L1 to L2. This will automatically update the L1 contextual
// information like the L1 block number and L1 timestamp.
const tx = await env.l1Messenger.sendMessage(
const tx =
await env.messenger.contracts.l1.L1CrossDomainMessenger.sendMessage(
OVMContextStorage.address,
'0x',
2_000_000,
......
......@@ -26,7 +26,8 @@ describe('Queue Ingestion', () => {
// the transaction to Layer 1
const txs = []
for (let i = 0; i < numTxs; i++) {
const tx = await env.l1Messenger.sendMessage(
const tx =
await env.messenger.contracts.l1.L1CrossDomainMessenger.sendMessage(
`0x${`${i}`.repeat(40)}`,
`0x0${i}`,
1_000_000,
......@@ -46,7 +47,8 @@ describe('Queue Ingestion', () => {
receipt.remoteTx.hash
)) as any
const params = env.l2Messenger.interface.decodeFunctionData(
const params =
env.messenger.contracts.l2.L2CrossDomainMessenger.interface.decodeFunctionData(
'relayMessage',
l2Tx.data
)
......@@ -57,7 +59,9 @@ describe('Queue Ingestion', () => {
expect(params._target).to.equal('0x' + `${i}`.repeat(40))
expect(l2Tx.queueOrigin).to.equal('l1')
expect(l2Tx.l1TxOrigin.toLowerCase()).to.equal(
applyL1ToL2Alias(env.l1Messenger.address).toLowerCase()
applyL1ToL2Alias(
env.messenger.contracts.l1.L1CrossDomainMessenger.address
).toLowerCase()
)
expect(l2Tx.l1BlockNumber).to.equal(l1TxReceipt.blockNumber)
}
......
......@@ -18,6 +18,7 @@ import {
isHardhat,
hardhatTest,
envConfig,
gasPriceOracleWallet,
} from './shared/utils'
import { OptimismEnv } from './shared/env'
......@@ -149,8 +150,12 @@ describe('Basic RPC tests', () => {
const isHH = await isHardhat()
let gasPrice
if (isHH) {
gasPrice = await env.gasPriceOracle.gasPrice()
await env.gasPriceOracle.setGasPrice(1000)
gasPrice = await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).gasPrice()
await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).setGasPrice(1000)
}
const tx = {
......@@ -164,12 +169,17 @@ describe('Basic RPC tests', () => {
if (isHH) {
// Reset the gas price to its original price
await env.gasPriceOracle.setGasPrice(gasPrice)
await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).setGasPrice(gasPrice)
}
})
it('should reject a transaction with too high of a fee', async () => {
const gasPrice = await env.gasPriceOracle.gasPrice()
const gasPrice =
await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).gasPrice()
const largeGasPrice = gasPrice.mul(10)
const tx = {
...defaultTransactionFactory(),
......@@ -341,11 +351,25 @@ describe('Basic RPC tests', () => {
data: tx.data,
})
const l1Fee = await env.gasPriceOracle.getL1Fee(raw)
const l1GasPrice = await env.gasPriceOracle.l1BaseFee()
const l1GasUsed = await env.gasPriceOracle.getL1GasUsed(raw)
const scalar = await env.gasPriceOracle.scalar()
const decimals = await env.gasPriceOracle.decimals()
const l1Fee = await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).getL1Fee(raw)
const l1GasPrice =
await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).l1BaseFee()
const l1GasUsed =
await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).getL1GasUsed(raw)
const scalar =
await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).scalar()
const decimals =
await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).decimals()
const scaled = scalar.toNumber() / 10 ** decimals.toNumber()
......@@ -439,7 +463,8 @@ describe('Basic RPC tests', () => {
describe('eth_getBalance', () => {
it('should get the OVM_ETH balance', async () => {
const rpcBalance = await env.l2Provider.getBalance(env.l2Wallet.address)
const contractBalance = await env.ovmEth.balanceOf(env.l2Wallet.address)
const contractBalance =
await env.messenger.contracts.l2.OVM_ETH.balanceOf(env.l2Wallet.address)
expect(rpcBalance).to.be.deep.eq(contractBalance)
})
})
......@@ -525,9 +550,14 @@ describe('Basic RPC tests', () => {
describe('rollup_gasPrices', () => {
it('should return the L1 and L2 gas prices', async () => {
const result = await env.l2Provider.send('rollup_gasPrices', [])
const l1GasPrice = await env.gasPriceOracle.l1BaseFee()
const l2GasPrice = await env.gasPriceOracle.gasPrice()
const l1GasPrice =
await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).l1BaseFee()
const l2GasPrice =
await env.messenger.contracts.l2.OVM_GasPriceOracle.connect(
gasPriceOracleWallet
).gasPrice()
expect(BigNumber.from(result.l1GasPrice)).to.deep.eq(l1GasPrice)
expect(BigNumber.from(result.l2GasPrice)).to.deep.eq(l2GasPrice)
})
......
/* Imports: External */
import { Contract, utils, Wallet, providers, Transaction } from 'ethers'
import { utils, Wallet, providers, Transaction } from 'ethers'
import {
TransactionResponse,
TransactionReceipt,
} from '@ethersproject/providers'
import { getContractFactory, predeploys } from '@eth-optimism/contracts'
import { sleep } from '@eth-optimism/core-utils'
import {
CrossChainMessenger,
......@@ -14,18 +13,13 @@ import {
/* Imports: Internal */
import {
getAddressManager,
l1Provider,
l2Provider,
replicaProvider,
verifierProvider,
l1Wallet,
l2Wallet,
gasPriceOracleWallet,
fundUser,
getOvmEth,
getL1Bridge,
getL2Bridge,
envConfig,
} from './utils'
......@@ -38,21 +32,6 @@ export interface CrossDomainMessagePair {
/// Helper class for instantiating a test environment with a funded account
export class OptimismEnv {
// L1 Contracts
addressManager: Contract
l1Bridge: Contract
l1Messenger: Contract
l1BlockNumber: Contract
ctc: Contract
scc: Contract
// L2 Contracts
ovmEth: Contract
l2Bridge: Contract
l2Messenger: Contract
gasPriceOracle: Contract
sequencerFeeVault: Contract
// The wallets
l1Wallet: Wallet
l2Wallet: Wallet
......@@ -65,15 +44,6 @@ export class OptimismEnv {
verifierProvider: providers.JsonRpcProvider
constructor(args: any) {
this.addressManager = args.addressManager
this.l1Bridge = args.l1Bridge
this.l1Messenger = args.l1Messenger
this.l1BlockNumber = args.l1BlockNumber
this.ovmEth = args.ovmEth
this.l2Bridge = args.l2Bridge
this.l2Messenger = args.l2Messenger
this.gasPriceOracle = args.gasPriceOracle
this.sequencerFeeVault = args.sequencerFeeVault
this.l1Wallet = args.l1Wallet
this.l2Wallet = args.l2Wallet
this.messenger = args.messenger
......@@ -81,68 +51,15 @@ export class OptimismEnv {
this.l2Provider = args.l2Provider
this.replicaProvider = args.replicaProvider
this.verifierProvider = args.verifierProvider
this.ctc = args.ctc
this.scc = args.scc
}
static async new(): Promise<OptimismEnv> {
const network = await l1Provider.getNetwork()
const addressManager = getAddressManager(l1Wallet)
const l1Bridge = await getL1Bridge(l1Wallet, addressManager)
const l1MessengerAddress = await addressManager.getAddress(
'Proxy__OVM_L1CrossDomainMessenger'
)
const l2MessengerAddress = await addressManager.getAddress(
'L2CrossDomainMessenger'
)
const l1Messenger = getContractFactory('L1CrossDomainMessenger')
.connect(l1Wallet)
.attach(l1MessengerAddress)
const ovmEth = getOvmEth(l2Wallet)
const l2Bridge = await getL2Bridge(l2Wallet)
const l2Messenger = getContractFactory('L2CrossDomainMessenger')
.connect(l2Wallet)
.attach(l2MessengerAddress)
const ctcAddress = await addressManager.getAddress(
'CanonicalTransactionChain'
)
const ctc = getContractFactory('CanonicalTransactionChain')
.connect(l1Wallet)
.attach(ctcAddress)
const gasPriceOracle = getContractFactory('OVM_GasPriceOracle')
.connect(gasPriceOracleWallet)
.attach(predeploys.OVM_GasPriceOracle)
const sccAddress = await addressManager.getAddress('StateCommitmentChain')
const scc = getContractFactory('StateCommitmentChain')
.connect(l1Wallet)
.attach(sccAddress)
const sequencerFeeVault = getContractFactory('OVM_SequencerFeeVault')
.connect(l2Wallet)
.attach(predeploys.OVM_SequencerFeeVault)
const l1BlockNumber = getContractFactory('iOVM_L1BlockNumber')
.connect(l2Wallet)
.attach(predeploys.OVM_L1BlockNumber)
const messenger = new CrossChainMessenger({
l1SignerOrProvider: l1Wallet,
l2SignerOrProvider: l2Wallet,
l1ChainId: network.chainId,
contracts: {
l1: {
AddressManager: envConfig.ADDRESS_MANAGER,
L1CrossDomainMessenger: l1Messenger.address,
L1StandardBridge: l1Bridge.address,
StateCommitmentChain: sccAddress,
CanonicalTransactionChain: ctcAddress,
BondManager: await addressManager.getAddress('BondManager'),
},
},
})
// fund the user if needed
......@@ -154,17 +71,6 @@ export class OptimismEnv {
}
return new OptimismEnv({
addressManager,
l1Bridge,
ctc,
scc,
l1Messenger,
l1BlockNumber,
ovmEth,
gasPriceOracle,
sequencerFeeVault,
l2Bridge,
l2Messenger,
l1Wallet,
l2Wallet,
messenger,
......
......@@ -37,9 +37,9 @@ export const executeL1ToL2Transaction = async (
) => {
const signer = wallet.connect(env.l1Wallet.provider)
const receipt = await retryOnNonceError(async () =>
env.l1Messenger
.connect(signer)
.sendMessage(
env.messenger.contracts.l1.L1CrossDomainMessenger.connect(
signer
).sendMessage(
tx.contract.address,
tx.contract.interface.encodeFunctionData(
tx.functionName,
......@@ -61,9 +61,9 @@ export const executeL2ToL1Transaction = async (
) => {
const signer = wallet.connect(env.l2Wallet.provider)
const receipt = await retryOnNonceError(() =>
env.l2Messenger
.connect(signer)
.sendMessage(
env.messenger.contracts.l2.L2CrossDomainMessenger.connect(
signer
).sendMessage(
tx.contract.address,
tx.contract.interface.encodeFunctionData(
tx.functionName,
......
/* Imports: External */
import {
Contract,
Wallet,
constants,
providers,
BigNumber,
utils,
} from 'ethers'
import {
getContractFactory,
getContractInterface,
predeploys,
} from '@eth-optimism/contracts'
import { Wallet, providers, BigNumber, utils } from 'ethers'
import { predeploys } from '@eth-optimism/contracts'
import { remove0x } from '@eth-optimism/core-utils'
import {
CrossChainMessenger,
......@@ -71,9 +60,6 @@ const procEnv = cleanEnv(process.env, {
default:
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
}),
ADDRESS_MANAGER: str({
default: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
}),
GAS_PRICE_ORACLE_PRIVATE_KEY: str({
default:
'0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba',
......@@ -152,39 +138,6 @@ export const OVM_ETH_ADDRESS = predeploys.OVM_ETH
export const L2_CHAINID = procEnv.L2_CHAINID
export const getAddressManager = (provider: any) => {
return getContractFactory('Lib_AddressManager')
.connect(provider)
.attach(procEnv.ADDRESS_MANAGER)
}
// Gets the bridge contract
export const getL1Bridge = async (wallet: Wallet, AddressManager: Contract) => {
const l1BridgeInterface = getContractInterface('L1StandardBridge')
const ProxyBridgeAddress = await AddressManager.getAddress(
'Proxy__OVM_L1StandardBridge'
)
if (
!utils.isAddress(ProxyBridgeAddress) ||
ProxyBridgeAddress === constants.AddressZero
) {
throw new Error('Proxy__OVM_L1StandardBridge not found')
}
return new Contract(ProxyBridgeAddress, l1BridgeInterface, wallet)
}
export const getL2Bridge = async (wallet: Wallet) => {
const L2BridgeInterface = getContractInterface('L2StandardBridge')
return new Contract(predeploys.L2StandardBridge, L2BridgeInterface, wallet)
}
export const getOvmEth = (wallet: Wallet) => {
return new Contract(OVM_ETH_ADDRESS, getContractInterface('OVM_ETH'), wallet)
}
export const fundUser = async (
messenger: CrossChainMessenger,
amount: NumberLike,
......
......@@ -210,7 +210,8 @@ describe('stress tests', () => {
const tip = await env.l2Provider.getBlock('latest')
const prev = {
block: await env.l2Provider.getBlock(0),
l1BlockNumber: await env.l1BlockNumber.getL1BlockNumber({
l1BlockNumber:
await env.messenger.contracts.l2.OVM_L1BlockNumber.getL1BlockNumber({
blockTag: 0,
}),
}
......@@ -218,7 +219,8 @@ describe('stress tests', () => {
const block = await env.l2Provider.getBlock(i)
expect(block.timestamp).to.be.gte(prev.block.timestamp)
const l1BlockNumber = await env.l1BlockNumber.getL1BlockNumber({
const l1BlockNumber =
await env.messenger.contracts.l2.OVM_L1BlockNumber.getL1BlockNumber({
blockTag: i,
})
expect(l1BlockNumber.gt(prev.l1BlockNumber))
......
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