Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
386df4dc
Unverified
Commit
386df4dc
authored
Feb 28, 2022
by
Antonis Kogias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary contract references in integration-tets
parent
bdb8de13
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
240 additions
and
283 deletions
+240
-283
rare-onions-bathe.md
.changeset/rare-onions-bathe.md
+5
-0
bridged-tokens.spec.ts
integration-tests/test/bridged-tokens.spec.ts
+6
-1
fee-payment.spec.ts
integration-tests/test/fee-payment.spec.ts
+32
-16
native-eth-ovm-calls.spec.ts
integration-tests/test/native-eth-ovm-calls.spec.ts
+6
-2
native-eth.spec.ts
integration-tests/test/native-eth.spec.ts
+85
-54
ovmcontext.spec.ts
integration-tests/test/ovmcontext.spec.ts
+9
-8
queue-ingestion.spec.ts
integration-tests/test/queue-ingestion.spec.ts
+17
-13
rpc.spec.ts
integration-tests/test/rpc.spec.ts
+43
-13
env.ts
integration-tests/test/shared/env.ts
+1
-95
stress-test-helpers.ts
integration-tests/test/shared/stress-test-helpers.ts
+26
-26
utils.ts
integration-tests/test/shared/utils.ts
+2
-49
stress-tests.spec.ts
integration-tests/test/stress-tests.spec.ts
+8
-6
No files found.
.changeset/rare-onions-bathe.md
0 → 100644
View file @
386df4dc
---
'
@eth-optimism/integration-tests'
:
patch
---
Replaces contract references in integration tests with SDK CrossChainMessenger objects.
integration-tests/test/bridged-tokens.spec.ts
View file @
386df4dc
/* Imports: External */
import
{
BigNumber
,
Contract
,
ContractFactory
,
utils
,
Wallet
}
from
'
ethers
'
import
{
BigNumber
,
Contract
,
ContractFactory
,
utils
,
Wallet
}
from
'
ethers
'
import
{
ethers
}
from
'
hardhat
'
import
{
ethers
}
from
'
hardhat
'
import
{
getContractFactory
}
from
'
@eth-optimism/contracts
'
import
{
getContractFactory
}
from
'
@eth-optimism/contracts
'
import
{
MessageStatus
}
from
'
@eth-optimism/sdk
'
import
{
MessageStatus
}
from
'
@eth-optimism/sdk
'
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
/* Imports: Internal */
import
{
expect
}
from
'
./shared/setup
'
import
{
expect
}
from
'
./shared/setup
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
withdrawalTest
}
from
'
./shared/utils
'
import
{
withdrawalTest
}
from
'
./shared/utils
'
...
@@ -61,7 +63,10 @@ describe('Bridged tokens', () => {
...
@@ -61,7 +63,10 @@ describe('Bridged tokens', () => {
await
L2__ERC20
.
deployed
()
await
L2__ERC20
.
deployed
()
// Approve the L1 ERC20 to spend our money
// 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
()
await
tx
.
wait
()
})
})
...
...
integration-tests/test/fee-payment.spec.ts
View file @
386df4dc
...
@@ -5,13 +5,17 @@ import { predeploys, getContractFactory } from '@eth-optimism/contracts'
...
@@ -5,13 +5,17 @@ import { predeploys, getContractFactory } from '@eth-optimism/contracts'
/* Imports: Internal */
/* Imports: Internal */
import
{
expect
}
from
'
./shared/setup
'
import
{
expect
}
from
'
./shared/setup
'
import
{
hardhatTest
}
from
'
./shared/utils
'
import
{
hardhatTest
,
gasPriceOracleWallet
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
OptimismEnv
}
from
'
./shared/env
'
const
setPrices
=
async
(
env
:
OptimismEnv
,
value
:
number
|
BigNumber
)
=>
{
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
()
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
()
await
baseFee
.
wait
()
}
}
...
@@ -28,13 +32,18 @@ describe('Fee Payment Integration Tests', async () => {
...
@@ -28,13 +32,18 @@ describe('Fee Payment Integration Tests', async () => {
async
()
=>
{
async
()
=>
{
const
assertGasPrice
=
async
()
=>
{
const
assertGasPrice
=
async
()
=>
{
const
gasPrice
=
await
env
.
l2Wallet
.
getGasPrice
()
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
)
expect
(
gasPrice
).
to
.
deep
.
equal
(
oracleGasPrice
)
}
}
await
assertGasPrice
()
await
assertGasPrice
()
// update the gas price
// 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
tx
.
wait
()
await
assertGasPrice
()
await
assertGasPrice
()
...
@@ -47,7 +56,7 @@ describe('Fee Payment Integration Tests', async () => {
...
@@ -47,7 +56,7 @@ describe('Fee Payment Integration Tests', async () => {
const
amount
=
utils
.
parseEther
(
'
0.0000001
'
)
const
amount
=
utils
.
parseEther
(
'
0.0000001
'
)
const
balanceBefore
=
await
env
.
l2Wallet
.
getBalance
()
const
balanceBefore
=
await
env
.
l2Wallet
.
getBalance
()
const
feeVaultBalanceBefore
=
await
env
.
l2Wallet
.
provider
.
getBalance
(
const
feeVaultBalanceBefore
=
await
env
.
l2Wallet
.
provider
.
getBalance
(
env
.
s
equencerFeeVault
.
address
env
.
messenger
.
contracts
.
l2
.
OVM_S
equencerFeeVault
.
address
)
)
expect
(
balanceBefore
.
gt
(
amount
))
expect
(
balanceBefore
.
gt
(
amount
))
...
@@ -66,7 +75,9 @@ describe('Fee Payment Integration Tests', async () => {
...
@@ -66,7 +75,9 @@ describe('Fee Payment Integration Tests', async () => {
data
:
unsigned
.
data
,
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
tx
=
await
env
.
l2Wallet
.
sendTransaction
(
unsigned
)
const
receipt
=
await
tx
.
wait
()
const
receipt
=
await
tx
.
wait
()
...
@@ -74,7 +85,7 @@ describe('Fee Payment Integration Tests', async () => {
...
@@ -74,7 +85,7 @@ describe('Fee Payment Integration Tests', async () => {
const
balanceAfter
=
await
env
.
l2Wallet
.
getBalance
()
const
balanceAfter
=
await
env
.
l2Wallet
.
getBalance
()
const
feeVaultBalanceAfter
=
await
env
.
l2Wallet
.
provider
.
getBalance
(
const
feeVaultBalanceAfter
=
await
env
.
l2Wallet
.
provider
.
getBalance
(
env
.
s
equencerFeeVault
.
address
env
.
messenger
.
contracts
.
l2
.
OVM_S
equencerFeeVault
.
address
)
)
const
l2Fee
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
const
l2Fee
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
...
@@ -124,7 +135,9 @@ describe('Fee Payment Integration Tests', async () => {
...
@@ -124,7 +135,9 @@ describe('Fee Payment Integration Tests', async () => {
data
:
unsigned
.
data
,
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
tx
=
await
env
.
l2Wallet
.
sendTransaction
(
unsigned
)
const
receipt
=
await
tx
.
wait
()
const
receipt
=
await
tx
.
wait
()
...
@@ -142,30 +155,33 @@ describe('Fee Payment Integration Tests', async () => {
...
@@ -142,30 +155,33 @@ describe('Fee Payment Integration Tests', async () => {
})
})
it
(
'
should not be able to withdraw fees before the minimum is met
'
,
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
(
hardhatTest
(
'
should be able to withdraw fees back to L1 once the minimum is met
'
,
'
should be able to withdraw fees back to L1 once the minimum is met
'
,
async
()
=>
{
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
balanceBefore
=
await
env
.
l1Wallet
.
provider
.
getBalance
(
l1FeeWallet
)
const
withdrawalAmount
=
const
withdrawalAmount
=
await
env
.
s
equencerFeeVault
.
MIN_WITHDRAWAL_AMOUNT
()
await
env
.
messenger
.
contracts
.
l2
.
OVM_S
equencerFeeVault
.
MIN_WITHDRAWAL_AMOUNT
()
// Transfer the minimum required to withdraw.
// Transfer the minimum required to withdraw.
const
tx
=
await
env
.
l2Wallet
.
sendTransaction
({
const
tx
=
await
env
.
l2Wallet
.
sendTransaction
({
to
:
env
.
s
equencerFeeVault
.
address
,
to
:
env
.
messenger
.
contracts
.
l2
.
OVM_S
equencerFeeVault
.
address
,
value
:
withdrawalAmount
,
value
:
withdrawalAmount
,
gasLimit
:
500000
,
gasLimit
:
500000
,
})
})
await
tx
.
wait
()
await
tx
.
wait
()
const
vaultBalance
=
await
env
.
ovmEth
.
balanceOf
(
const
vaultBalance
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_ETH
.
balanceOf
(
env
.
s
equencerFeeVault
.
address
env
.
messenger
.
contracts
.
l2
.
OVM_S
equencerFeeVault
.
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.
// Wait for the withdrawal to be relayed to L1.
await
withdrawTx
.
wait
()
await
withdrawTx
.
wait
()
...
...
integration-tests/test/native-eth-ovm-calls.spec.ts
View file @
386df4dc
/* Imports: External */
import
{
BigNumber
,
Contract
,
ContractFactory
,
Wallet
}
from
'
ethers
'
import
{
BigNumber
,
Contract
,
ContractFactory
,
Wallet
}
from
'
ethers
'
import
{
ethers
}
from
'
hardhat
'
import
{
ethers
}
from
'
hardhat
'
/* Imports: Internal */
import
{
expect
}
from
'
./shared/setup
'
import
{
expect
}
from
'
./shared/setup
'
import
{
import
{
fundUser
,
fundUser
,
...
@@ -121,8 +123,10 @@ describe('Native ETH value integration tests', () => {
...
@@ -121,8 +123,10 @@ describe('Native ETH value integration tests', () => {
'
geth RPC does not match ovmSELFBALANCE
'
'
geth RPC does not match ovmSELFBALANCE
'
)
)
// query ovmSELFBALANCE() opcode via eth_call as another check
// query ovmSELFBALANCE() opcode via eth_call as another check
const
ovmEthBalanceOf0
=
await
env
.
ovmEth
.
balanceOf
(
ValueCalls0
.
address
)
const
ovmEthBalanceOf0
=
const
ovmEthBalanceOf1
=
await
env
.
ovmEth
.
balanceOf
(
ValueCalls1
.
address
)
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
(
expect
(
ovmEthBalanceOf0
).
to
.
deep
.
eq
(
BigNumber
.
from
(
expectedBalances
[
0
]),
BigNumber
.
from
(
expectedBalances
[
0
]),
'
geth RPC does not match OVM_ETH.balanceOf
'
'
geth RPC does not match OVM_ETH.balanceOf
'
...
...
integration-tests/test/native-eth.spec.ts
View file @
386df4dc
...
@@ -11,6 +11,7 @@ import {
...
@@ -11,6 +11,7 @@ import {
DEFAULT_TEST_GAS_L2
,
DEFAULT_TEST_GAS_L2
,
envConfig
,
envConfig
,
withdrawalTest
,
withdrawalTest
,
gasPriceOracleWallet
,
}
from
'
./shared/utils
'
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
OptimismEnv
}
from
'
./shared/env
'
...
@@ -30,7 +31,7 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -30,7 +31,7 @@ describe('Native ETH Integration Tests', async () => {
const
l2BobBalance
=
await
l2Bob
.
getBalance
()
const
l2BobBalance
=
await
l2Bob
.
getBalance
()
const
l1BridgeBalance
=
await
_env
.
l1Wallet
.
provider
.
getBalance
(
const
l1BridgeBalance
=
await
_env
.
l1Wallet
.
provider
.
getBalance
(
_env
.
l1
Bridge
.
address
_env
.
messenger
.
contracts
.
l1
.
L1Standard
Bridge
.
address
)
)
return
{
return
{
...
@@ -51,12 +52,13 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -51,12 +52,13 @@ describe('Native ETH Integration Tests', async () => {
describe
(
'
estimateGas
'
,
()
=>
{
describe
(
'
estimateGas
'
,
()
=>
{
it
(
'
Should estimate gas for ETH withdraw
'
,
async
()
=>
{
it
(
'
Should estimate gas for ETH withdraw
'
,
async
()
=>
{
const
amount
=
utils
.
parseEther
(
'
0.0000001
'
)
const
amount
=
utils
.
parseEther
(
'
0.0000001
'
)
const
gas
=
await
env
.
l2Bridge
.
estimateGas
.
withdraw
(
const
gas
=
predeploys
.
OVM_ETH
,
await
env
.
messenger
.
contracts
.
l2
.
L2StandardBridge
.
estimateGas
.
withdraw
(
amount
,
predeploys
.
OVM_ETH
,
0
,
amount
,
'
0xFFFF
'
0
,
)
'
0xFFFF
'
)
// Expect gas to be less than or equal to the target plus 1%
// Expect gas to be less than or equal to the target plus 1%
expectApprox
(
gas
,
6700060
,
{
absoluteUpperDeviation
:
1000
})
expectApprox
(
gas
,
6700060
,
{
absoluteUpperDeviation
:
1000
})
})
})
...
@@ -67,7 +69,7 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -67,7 +69,7 @@ describe('Native ETH Integration Tests', async () => {
const
preBalances
=
await
getBalances
(
env
)
const
preBalances
=
await
getBalances
(
env
)
const
{
tx
,
receipt
}
=
await
env
.
waitForXDomainTransaction
(
const
{
tx
,
receipt
}
=
await
env
.
waitForXDomainTransaction
(
env
.
l1Wallet
.
sendTransaction
({
env
.
l1Wallet
.
sendTransaction
({
to
:
env
.
l1
Bridge
.
address
,
to
:
env
.
messenger
.
contracts
.
l1
.
L1Standard
Bridge
.
address
,
value
:
depositAmount
,
value
:
depositAmount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
})
})
...
@@ -91,10 +93,14 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -91,10 +93,14 @@ describe('Native ETH Integration Tests', async () => {
const
depositAmount
=
10
const
depositAmount
=
10
const
preBalances
=
await
getBalances
(
env
)
const
preBalances
=
await
getBalances
(
env
)
const
{
tx
,
receipt
}
=
await
env
.
waitForXDomainTransaction
(
const
{
tx
,
receipt
}
=
await
env
.
waitForXDomainTransaction
(
env
.
l1Bridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
depositETH
(
value
:
depositAmount
,
DEFAULT_TEST_GAS_L2
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
'
0xFFFF
'
,
})
{
value
:
depositAmount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}
)
)
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
...
@@ -115,10 +121,15 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -115,10 +121,15 @@ describe('Native ETH Integration Tests', async () => {
const
depositAmount
=
10
const
depositAmount
=
10
const
preBalances
=
await
getBalances
(
env
)
const
preBalances
=
await
getBalances
(
env
)
const
depositReceipts
=
await
env
.
waitForXDomainTransaction
(
const
depositReceipts
=
await
env
.
waitForXDomainTransaction
(
env
.
l1Bridge
.
depositETHTo
(
l2Bob
.
address
,
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
depositETHTo
(
value
:
depositAmount
,
l2Bob
.
address
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
DEFAULT_TEST_GAS_L2
,
})
'
0xFFFF
'
,
{
value
:
depositAmount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}
)
)
)
const
l1FeePaid
=
depositReceipts
.
receipt
.
gasUsed
.
mul
(
const
l1FeePaid
=
depositReceipts
.
receipt
.
gasUsed
.
mul
(
...
@@ -145,10 +156,14 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -145,10 +156,14 @@ describe('Native ETH Integration Tests', async () => {
// to allow for encoding and other arguments
// to allow for encoding and other arguments
const
data
=
`0x`
+
'
ab
'
.
repeat
(
MAX_ROLLUP_TX_SIZE
-
500
)
const
data
=
`0x`
+
'
ab
'
.
repeat
(
MAX_ROLLUP_TX_SIZE
-
500
)
const
{
tx
,
receipt
}
=
await
env
.
waitForXDomainTransaction
(
const
{
tx
,
receipt
}
=
await
env
.
waitForXDomainTransaction
(
env
.
l1Bridge
.
depositETH
(
ASSUMED_L2_GAS_LIMIT
,
data
,
{
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
depositETH
(
value
:
depositAmount
,
ASSUMED_L2_GAS_LIMIT
,
gasLimit
:
4
_000_000
,
data
,
})
{
value
:
depositAmount
,
gasLimit
:
4
_000_000
,
}
)
)
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
...
@@ -169,9 +184,13 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -169,9 +184,13 @@ describe('Native ETH Integration Tests', async () => {
const
data
=
`0x`
+
'
ab
'
.
repeat
(
MAX_ROLLUP_TX_SIZE
+
1
)
const
data
=
`0x`
+
'
ab
'
.
repeat
(
MAX_ROLLUP_TX_SIZE
+
1
)
await
expect
(
await
expect
(
env
.
l1Bridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
data
,
{
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
depositETH
(
value
:
depositAmount
,
DEFAULT_TEST_GAS_L2
,
})
data
,
{
value
:
depositAmount
,
}
)
).
to
.
be
.
reverted
).
to
.
be
.
reverted
})
})
...
@@ -183,12 +202,13 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -183,12 +202,13 @@ describe('Native ETH Integration Tests', async () => {
'
Cannot run withdrawal test before any deposits...
'
'
Cannot run withdrawal test before any deposits...
'
)
)
const
transaction
=
await
env
.
l2Bridge
.
withdraw
(
const
transaction
=
predeploys
.
OVM_ETH
,
await
env
.
messenger
.
contracts
.
l2
.
L2StandardBridge
.
withdraw
(
withdrawAmount
,
predeploys
.
OVM_ETH
,
DEFAULT_TEST_GAS_L2
,
withdrawAmount
,
'
0xFFFF
'
DEFAULT_TEST_GAS_L2
,
)
'
0xFFFF
'
)
await
transaction
.
wait
()
await
transaction
.
wait
()
await
env
.
relayXDomainMessages
(
transaction
)
await
env
.
relayXDomainMessages
(
transaction
)
const
receipts
=
await
env
.
waitForXDomainTransaction
(
transaction
)
const
receipts
=
await
env
.
waitForXDomainTransaction
(
transaction
)
...
@@ -224,13 +244,14 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -224,13 +244,14 @@ describe('Native ETH Integration Tests', async () => {
'
Cannot run withdrawal test before any deposits...
'
'
Cannot run withdrawal test before any deposits...
'
)
)
const
transaction
=
await
env
.
l2Bridge
.
withdrawTo
(
const
transaction
=
predeploys
.
OVM_ETH
,
await
env
.
messenger
.
contracts
.
l2
.
L2StandardBridge
.
withdrawTo
(
l1Bob
.
address
,
predeploys
.
OVM_ETH
,
withdrawAmount
,
l1Bob
.
address
,
DEFAULT_TEST_GAS_L2
,
withdrawAmount
,
'
0xFFFF
'
DEFAULT_TEST_GAS_L2
,
)
'
0xFFFF
'
)
await
transaction
.
wait
()
await
transaction
.
wait
()
await
env
.
relayXDomainMessages
(
transaction
)
await
env
.
relayXDomainMessages
(
transaction
)
...
@@ -248,7 +269,9 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -248,7 +269,9 @@ describe('Native ETH Integration Tests', async () => {
data
:
transaction
.
data
,
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
fee
=
l2Fee
.
add
(
l1Fee
)
const
postBalances
=
await
getBalances
(
env
)
const
postBalances
=
await
getBalances
(
env
)
...
@@ -275,10 +298,14 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -275,10 +298,14 @@ describe('Native ETH Integration Tests', async () => {
// 1. deposit
// 1. deposit
const
amount
=
utils
.
parseEther
(
'
1
'
)
const
amount
=
utils
.
parseEther
(
'
1
'
)
await
env
.
waitForXDomainTransaction
(
await
env
.
waitForXDomainTransaction
(
env
.
l1Bridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
depositETH
(
value
:
amount
,
DEFAULT_TEST_GAS_L2
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
'
0xFFFF
'
,
})
{
value
:
amount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}
)
)
)
// 2. transfer to another address
// 2. transfer to another address
...
@@ -295,9 +322,10 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -295,9 +322,10 @@ describe('Native ETH Integration Tests', async () => {
// 3. do withdrawal
// 3. do withdrawal
const
withdrawnAmount
=
utils
.
parseEther
(
'
0.95
'
)
const
withdrawnAmount
=
utils
.
parseEther
(
'
0.95
'
)
const
transaction
=
await
env
.
l2Bridge
const
transaction
=
.
connect
(
other
)
await
env
.
messenger
.
contracts
.
l2
.
L2StandardBridge
.
connect
(
.
withdraw
(
other
).
withdraw
(
predeploys
.
OVM_ETH
,
predeploys
.
OVM_ETH
,
withdrawnAmount
,
withdrawnAmount
,
DEFAULT_TEST_GAS_L1
,
DEFAULT_TEST_GAS_L1
,
...
@@ -308,16 +336,19 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -308,16 +336,19 @@ describe('Native ETH Integration Tests', async () => {
const
receipts
=
await
env
.
waitForXDomainTransaction
(
transaction
)
const
receipts
=
await
env
.
waitForXDomainTransaction
(
transaction
)
// Compute the L1 portion of the fee
// Compute the L1 portion of the fee
const
l1Fee
=
await
env
.
gasPriceOracle
.
getL1Fee
(
const
l1Fee
=
serialize
({
await
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
nonce
:
transaction
.
nonce
,
gasPriceOracleWallet
value
:
transaction
.
value
,
).
getL1Fee
(
gasPrice
:
transaction
.
gasPrice
,
serialize
({
gasLimit
:
transaction
.
gasLimit
,
nonce
:
transaction
.
nonce
,
to
:
transaction
.
to
,
value
:
transaction
.
value
,
data
:
transaction
.
data
,
gasPrice
:
transaction
.
gasPrice
,
})
gasLimit
:
transaction
.
gasLimit
,
)
to
:
transaction
.
to
,
data
:
transaction
.
data
,
})
)
// check that correct amount was withdrawn and that fee was charged
// check that correct amount was withdrawn and that fee was charged
const
l2Fee
=
receipts
.
tx
.
gasPrice
.
mul
(
receipts
.
receipt
.
gasUsed
)
const
l2Fee
=
receipts
.
tx
.
gasPrice
.
mul
(
receipts
.
receipt
.
gasUsed
)
...
...
integration-tests/test/ovmcontext.spec.ts
View file @
386df4dc
...
@@ -44,14 +44,15 @@ describe('OVM Context: Layer 2 EVM Context', () => {
...
@@ -44,14 +44,15 @@ describe('OVM Context: Layer 2 EVM Context', () => {
for
(
let
i
=
0
;
i
<
numTxs
;
i
++
)
{
for
(
let
i
=
0
;
i
<
numTxs
;
i
++
)
{
// Send a transaction from L1 to L2. This will automatically update the L1 contextual
// Send a transaction from L1 to L2. This will automatically update the L1 contextual
// information like the L1 block number and L1 timestamp.
// information like the L1 block number and L1 timestamp.
const
tx
=
await
env
.
l1Messenger
.
sendMessage
(
const
tx
=
OVMContextStorage
.
address
,
await
env
.
messenger
.
contracts
.
l1
.
L1CrossDomainMessenger
.
sendMessage
(
'
0x
'
,
OVMContextStorage
.
address
,
2
_000_000
,
'
0x
'
,
{
2
_000_000
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
{
}
gasLimit
:
DEFAULT_TEST_GAS_L1
,
)
}
)
// Wait for the transaction to be sent over to L2.
// Wait for the transaction to be sent over to L2.
await
tx
.
wait
()
await
tx
.
wait
()
...
...
integration-tests/test/queue-ingestion.spec.ts
View file @
386df4dc
...
@@ -26,14 +26,15 @@ describe('Queue Ingestion', () => {
...
@@ -26,14 +26,15 @@ describe('Queue Ingestion', () => {
// the transaction to Layer 1
// the transaction to Layer 1
const
txs
=
[]
const
txs
=
[]
for
(
let
i
=
0
;
i
<
numTxs
;
i
++
)
{
for
(
let
i
=
0
;
i
<
numTxs
;
i
++
)
{
const
tx
=
await
env
.
l1Messenger
.
sendMessage
(
const
tx
=
`0x
${
`
${
i
}
`
.
repeat
(
40
)}
`
,
await
env
.
messenger
.
contracts
.
l1
.
L1CrossDomainMessenger
.
sendMessage
(
`0x0
${
i
}
`
,
`0x
${
`
${
i
}
`
.
repeat
(
40
)}
`
,
1
_000_000
,
`0x0
${
i
}
`
,
{
1
_000_000
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
{
}
gasLimit
:
DEFAULT_TEST_GAS_L1
,
)
}
)
await
tx
.
wait
()
await
tx
.
wait
()
txs
.
push
(
tx
)
txs
.
push
(
tx
)
}
}
...
@@ -46,10 +47,11 @@ describe('Queue Ingestion', () => {
...
@@ -46,10 +47,11 @@ describe('Queue Ingestion', () => {
receipt
.
remoteTx
.
hash
receipt
.
remoteTx
.
hash
))
as
any
))
as
any
const
params
=
env
.
l2Messenger
.
interface
.
decodeFunctionData
(
const
params
=
'
relayMessage
'
,
env
.
messenger
.
contracts
.
l2
.
L2CrossDomainMessenger
.
interface
.
decodeFunctionData
(
l2Tx
.
data
'
relayMessage
'
,
)
l2Tx
.
data
)
expect
(
params
.
_sender
.
toLowerCase
()).
to
.
equal
(
expect
(
params
.
_sender
.
toLowerCase
()).
to
.
equal
(
env
.
l1Wallet
.
address
.
toLowerCase
()
env
.
l1Wallet
.
address
.
toLowerCase
()
...
@@ -57,7 +59,9 @@ describe('Queue Ingestion', () => {
...
@@ -57,7 +59,9 @@ describe('Queue Ingestion', () => {
expect
(
params
.
_target
).
to
.
equal
(
'
0x
'
+
`
${
i
}
`
.
repeat
(
40
))
expect
(
params
.
_target
).
to
.
equal
(
'
0x
'
+
`
${
i
}
`
.
repeat
(
40
))
expect
(
l2Tx
.
queueOrigin
).
to
.
equal
(
'
l1
'
)
expect
(
l2Tx
.
queueOrigin
).
to
.
equal
(
'
l1
'
)
expect
(
l2Tx
.
l1TxOrigin
.
toLowerCase
()).
to
.
equal
(
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
)
expect
(
l2Tx
.
l1BlockNumber
).
to
.
equal
(
l1TxReceipt
.
blockNumber
)
}
}
...
...
integration-tests/test/rpc.spec.ts
View file @
386df4dc
...
@@ -17,6 +17,7 @@ import {
...
@@ -17,6 +17,7 @@ import {
isHardhat
,
isHardhat
,
hardhatTest
,
hardhatTest
,
envConfig
,
envConfig
,
gasPriceOracleWallet
,
}
from
'
./shared/utils
'
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
expect
}
from
'
./shared/setup
'
import
{
expect
}
from
'
./shared/setup
'
...
@@ -149,8 +150,12 @@ describe('Basic RPC tests', () => {
...
@@ -149,8 +150,12 @@ describe('Basic RPC tests', () => {
const
isHH
=
await
isHardhat
()
const
isHH
=
await
isHardhat
()
let
gasPrice
let
gasPrice
if
(
isHH
)
{
if
(
isHH
)
{
gasPrice
=
await
env
.
gasPriceOracle
.
gasPrice
()
gasPrice
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
await
env
.
gasPriceOracle
.
setGasPrice
(
1000
)
gasPriceOracleWallet
).
gasPrice
()
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
setGasPrice
(
1000
)
}
}
const
tx
=
{
const
tx
=
{
...
@@ -164,12 +169,17 @@ describe('Basic RPC tests', () => {
...
@@ -164,12 +169,17 @@ describe('Basic RPC tests', () => {
if
(
isHH
)
{
if
(
isHH
)
{
// Reset the gas price to its original price
// 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
()
=>
{
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
largeGasPrice
=
gasPrice
.
mul
(
10
)
const
tx
=
{
const
tx
=
{
...
defaultTransactionFactory
(),
...
defaultTransactionFactory
(),
...
@@ -341,11 +351,25 @@ describe('Basic RPC tests', () => {
...
@@ -341,11 +351,25 @@ describe('Basic RPC tests', () => {
data
:
tx
.
data
,
data
:
tx
.
data
,
})
})
const
l1Fee
=
await
env
.
gasPriceOracle
.
getL1Fee
(
raw
)
const
l1Fee
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
const
l1GasPrice
=
await
env
.
gasPriceOracle
.
l1BaseFee
()
gasPriceOracleWallet
const
l1GasUsed
=
await
env
.
gasPriceOracle
.
getL1GasUsed
(
raw
)
).
getL1Fee
(
raw
)
const
scalar
=
await
env
.
gasPriceOracle
.
scalar
()
const
l1GasPrice
=
const
decimals
=
await
env
.
gasPriceOracle
.
decimals
()
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
()
const
scaled
=
scalar
.
toNumber
()
/
10
**
decimals
.
toNumber
()
...
@@ -439,7 +463,8 @@ describe('Basic RPC tests', () => {
...
@@ -439,7 +463,8 @@ describe('Basic RPC tests', () => {
describe
(
'
eth_getBalance
'
,
()
=>
{
describe
(
'
eth_getBalance
'
,
()
=>
{
it
(
'
should get the OVM_ETH balance
'
,
async
()
=>
{
it
(
'
should get the OVM_ETH balance
'
,
async
()
=>
{
const
rpcBalance
=
await
env
.
l2Provider
.
getBalance
(
env
.
l2Wallet
.
address
)
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
)
expect
(
rpcBalance
).
to
.
be
.
deep
.
eq
(
contractBalance
)
})
})
})
})
...
@@ -525,9 +550,14 @@ describe('Basic RPC tests', () => {
...
@@ -525,9 +550,14 @@ describe('Basic RPC tests', () => {
describe
(
'
rollup_gasPrices
'
,
()
=>
{
describe
(
'
rollup_gasPrices
'
,
()
=>
{
it
(
'
should return the L1 and L2 gas prices
'
,
async
()
=>
{
it
(
'
should return the L1 and L2 gas prices
'
,
async
()
=>
{
const
result
=
await
env
.
l2Provider
.
send
(
'
rollup_gasPrices
'
,
[])
const
result
=
await
env
.
l2Provider
.
send
(
'
rollup_gasPrices
'
,
[])
const
l1GasPrice
=
await
env
.
gasPriceOracle
.
l1BaseFee
()
const
l1GasPrice
=
const
l2GasPrice
=
await
env
.
gasPriceOracle
.
gasPrice
()
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
.
l1GasPrice
)).
to
.
deep
.
eq
(
l1GasPrice
)
expect
(
BigNumber
.
from
(
result
.
l2GasPrice
)).
to
.
deep
.
eq
(
l2GasPrice
)
expect
(
BigNumber
.
from
(
result
.
l2GasPrice
)).
to
.
deep
.
eq
(
l2GasPrice
)
})
})
...
...
integration-tests/test/shared/env.ts
View file @
386df4dc
/* Imports: External */
/* Imports: External */
import
{
Contract
,
utils
,
Wallet
,
providers
,
Transaction
}
from
'
ethers
'
import
{
utils
,
Wallet
,
providers
,
Transaction
}
from
'
ethers
'
import
{
import
{
TransactionResponse
,
TransactionResponse
,
TransactionReceipt
,
TransactionReceipt
,
}
from
'
@ethersproject/providers
'
}
from
'
@ethersproject/providers
'
import
{
getContractFactory
,
predeploys
}
from
'
@eth-optimism/contracts
'
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
import
{
CrossChainMessenger
,
CrossChainMessenger
,
...
@@ -14,18 +13,13 @@ import {
...
@@ -14,18 +13,13 @@ import {
/* Imports: Internal */
/* Imports: Internal */
import
{
import
{
getAddressManager
,
l1Provider
,
l1Provider
,
l2Provider
,
l2Provider
,
replicaProvider
,
replicaProvider
,
verifierProvider
,
verifierProvider
,
l1Wallet
,
l1Wallet
,
l2Wallet
,
l2Wallet
,
gasPriceOracleWallet
,
fundUser
,
fundUser
,
getOvmEth
,
getL1Bridge
,
getL2Bridge
,
envConfig
,
envConfig
,
}
from
'
./utils
'
}
from
'
./utils
'
...
@@ -38,21 +32,6 @@ export interface CrossDomainMessagePair {
...
@@ -38,21 +32,6 @@ export interface CrossDomainMessagePair {
/// Helper class for instantiating a test environment with a funded account
/// Helper class for instantiating a test environment with a funded account
export
class
OptimismEnv
{
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
// The wallets
l1Wallet
:
Wallet
l1Wallet
:
Wallet
l2Wallet
:
Wallet
l2Wallet
:
Wallet
...
@@ -65,15 +44,6 @@ export class OptimismEnv {
...
@@ -65,15 +44,6 @@ export class OptimismEnv {
verifierProvider
:
providers
.
JsonRpcProvider
verifierProvider
:
providers
.
JsonRpcProvider
constructor
(
args
:
any
)
{
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
.
l1Wallet
=
args
.
l1Wallet
this
.
l2Wallet
=
args
.
l2Wallet
this
.
l2Wallet
=
args
.
l2Wallet
this
.
messenger
=
args
.
messenger
this
.
messenger
=
args
.
messenger
...
@@ -81,68 +51,15 @@ export class OptimismEnv {
...
@@ -81,68 +51,15 @@ export class OptimismEnv {
this
.
l2Provider
=
args
.
l2Provider
this
.
l2Provider
=
args
.
l2Provider
this
.
replicaProvider
=
args
.
replicaProvider
this
.
replicaProvider
=
args
.
replicaProvider
this
.
verifierProvider
=
args
.
verifierProvider
this
.
verifierProvider
=
args
.
verifierProvider
this
.
ctc
=
args
.
ctc
this
.
scc
=
args
.
scc
}
}
static
async
new
():
Promise
<
OptimismEnv
>
{
static
async
new
():
Promise
<
OptimismEnv
>
{
const
network
=
await
l1Provider
.
getNetwork
()
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
({
const
messenger
=
new
CrossChainMessenger
({
l1SignerOrProvider
:
l1Wallet
,
l1SignerOrProvider
:
l1Wallet
,
l2SignerOrProvider
:
l2Wallet
,
l2SignerOrProvider
:
l2Wallet
,
l1ChainId
:
network
.
chainId
,
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
// fund the user if needed
...
@@ -154,17 +71,6 @@ export class OptimismEnv {
...
@@ -154,17 +71,6 @@ export class OptimismEnv {
}
}
return
new
OptimismEnv
({
return
new
OptimismEnv
({
addressManager
,
l1Bridge
,
ctc
,
scc
,
l1Messenger
,
l1BlockNumber
,
ovmEth
,
gasPriceOracle
,
sequencerFeeVault
,
l2Bridge
,
l2Messenger
,
l1Wallet
,
l1Wallet
,
l2Wallet
,
l2Wallet
,
messenger
,
messenger
,
...
...
integration-tests/test/shared/stress-test-helpers.ts
View file @
386df4dc
...
@@ -37,19 +37,19 @@ export const executeL1ToL2Transaction = async (
...
@@ -37,19 +37,19 @@ export const executeL1ToL2Transaction = async (
)
=>
{
)
=>
{
const
signer
=
wallet
.
connect
(
env
.
l1Wallet
.
provider
)
const
signer
=
wallet
.
connect
(
env
.
l1Wallet
.
provider
)
const
receipt
=
await
retryOnNonceError
(
async
()
=>
const
receipt
=
await
retryOnNonceError
(
async
()
=>
env
.
l1Messenger
env
.
messenger
.
contracts
.
l1
.
L1CrossDomainMessenger
.
connect
(
.
connect
(
signer
)
signer
.
sendMessage
(
)
.
sendMessage
(
tx
.
contract
.
address
,
tx
.
contract
.
address
,
tx
.
contract
.
interface
.
encodeFunctionData
(
tx
.
contract
.
interface
.
encodeFunctionData
(
tx
.
functionName
,
tx
.
functionName
,
tx
.
functionParams
tx
.
functionParams
),
),
MESSAGE_GAS
,
MESSAGE_GAS
,
{
{
gasPrice
:
await
gasPriceForL1
(),
gasPrice
:
await
gasPriceForL1
(),
}
}
)
)
)
)
await
env
.
waitForXDomainTransaction
(
receipt
)
await
env
.
waitForXDomainTransaction
(
receipt
)
}
}
...
@@ -61,19 +61,19 @@ export const executeL2ToL1Transaction = async (
...
@@ -61,19 +61,19 @@ export const executeL2ToL1Transaction = async (
)
=>
{
)
=>
{
const
signer
=
wallet
.
connect
(
env
.
l2Wallet
.
provider
)
const
signer
=
wallet
.
connect
(
env
.
l2Wallet
.
provider
)
const
receipt
=
await
retryOnNonceError
(()
=>
const
receipt
=
await
retryOnNonceError
(()
=>
env
.
l2Messenger
env
.
messenger
.
contracts
.
l2
.
L2CrossDomainMessenger
.
connect
(
.
connect
(
signer
)
signer
.
sendMessage
(
)
.
sendMessage
(
tx
.
contract
.
address
,
tx
.
contract
.
address
,
tx
.
contract
.
interface
.
encodeFunctionData
(
tx
.
contract
.
interface
.
encodeFunctionData
(
tx
.
functionName
,
tx
.
functionName
,
tx
.
functionParams
tx
.
functionParams
),
),
MESSAGE_GAS
,
MESSAGE_GAS
,
{
{
gasPrice
:
gasPriceForL2
(),
gasPrice
:
gasPriceForL2
(),
}
}
)
)
)
)
await
env
.
relayXDomainMessages
(
receipt
)
await
env
.
relayXDomainMessages
(
receipt
)
...
...
integration-tests/test/shared/utils.ts
View file @
386df4dc
/* Imports: External */
/* Imports: External */
import
{
import
{
Wallet
,
providers
,
BigNumber
,
utils
}
from
'
ethers
'
Contract
,
import
{
predeploys
}
from
'
@eth-optimism/contracts
'
Wallet
,
constants
,
providers
,
BigNumber
,
utils
,
}
from
'
ethers
'
import
{
getContractFactory
,
getContractInterface
,
predeploys
,
}
from
'
@eth-optimism/contracts
'
import
{
remove0x
}
from
'
@eth-optimism/core-utils
'
import
{
remove0x
}
from
'
@eth-optimism/core-utils
'
import
{
import
{
CrossChainMessenger
,
CrossChainMessenger
,
...
@@ -71,9 +60,6 @@ const procEnv = cleanEnv(process.env, {
...
@@ -71,9 +60,6 @@ const procEnv = cleanEnv(process.env, {
default
:
default
:
'
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
'
,
'
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
'
,
}),
}),
ADDRESS_MANAGER
:
str
({
default
:
'
0x5FbDB2315678afecb367f032d93F642f64180aa3
'
,
}),
GAS_PRICE_ORACLE_PRIVATE_KEY
:
str
({
GAS_PRICE_ORACLE_PRIVATE_KEY
:
str
({
default
:
default
:
'
0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
'
,
'
0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
'
,
...
@@ -149,39 +135,6 @@ export const OVM_ETH_ADDRESS = predeploys.OVM_ETH
...
@@ -149,39 +135,6 @@ export const OVM_ETH_ADDRESS = predeploys.OVM_ETH
export
const
L2_CHAINID
=
procEnv
.
L2_CHAINID
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
(
export
const
fundUser
=
async
(
messenger
:
CrossChainMessenger
,
messenger
:
CrossChainMessenger
,
amount
:
NumberLike
,
amount
:
NumberLike
,
...
...
integration-tests/test/stress-tests.spec.ts
View file @
386df4dc
...
@@ -210,17 +210,19 @@ describe('stress tests', () => {
...
@@ -210,17 +210,19 @@ describe('stress tests', () => {
const
tip
=
await
env
.
l2Provider
.
getBlock
(
'
latest
'
)
const
tip
=
await
env
.
l2Provider
.
getBlock
(
'
latest
'
)
const
prev
=
{
const
prev
=
{
block
:
await
env
.
l2Provider
.
getBlock
(
0
),
block
:
await
env
.
l2Provider
.
getBlock
(
0
),
l1BlockNumber
:
await
env
.
l1BlockNumber
.
getL1BlockNumber
({
l1BlockNumber
:
blockTag
:
0
,
await
env
.
messenger
.
contracts
.
l2
.
OVM_L1BlockNumber
.
getL1BlockNumber
({
}),
blockTag
:
0
,
}),
}
}
for
(
let
i
=
1
;
i
<
tip
.
number
;
i
++
)
{
for
(
let
i
=
1
;
i
<
tip
.
number
;
i
++
)
{
const
block
=
await
env
.
l2Provider
.
getBlock
(
i
)
const
block
=
await
env
.
l2Provider
.
getBlock
(
i
)
expect
(
block
.
timestamp
).
to
.
be
.
gte
(
prev
.
block
.
timestamp
)
expect
(
block
.
timestamp
).
to
.
be
.
gte
(
prev
.
block
.
timestamp
)
const
l1BlockNumber
=
await
env
.
l1BlockNumber
.
getL1BlockNumber
({
const
l1BlockNumber
=
blockTag
:
i
,
await
env
.
messenger
.
contracts
.
l2
.
OVM_L1BlockNumber
.
getL1BlockNumber
({
})
blockTag
:
i
,
})
expect
(
l1BlockNumber
.
gt
(
prev
.
l1BlockNumber
))
expect
(
l1BlockNumber
.
gt
(
prev
.
l1BlockNumber
))
prev
.
block
=
block
prev
.
block
=
block
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment