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
01e77768
Unverified
Commit
01e77768
authored
Aug 18, 2021
by
Kelvin Fichter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: clean up geth diff
parent
b3363ac8
Changes
28
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
231 additions
and
1067 deletions
+231
-1067
hardhat.config.ts
integration-tests/hardhat.config.ts
+0
-10
package.json
integration-tests/package.json
+2
-4
build.sh
integration-tests/scripts/build.sh
+0
-3
basic-l1-l2-communication.spec.ts
integration-tests/test/basic-l1-l2-communication.spec.ts
+8
-8
erc20.spec.ts
integration-tests/test/erc20.spec.ts
+3
-12
fee-payment.spec.ts
integration-tests/test/fee-payment.spec.ts
+2
-55
native-eth-ovm-calls.spec.ts
integration-tests/test/native-eth-ovm-calls.spec.ts
+2
-1
native-eth.spec.ts
integration-tests/test/native-eth.spec.ts
+2
-1
ovmcontext.spec.ts
integration-tests/test/ovmcontext.spec.ts
+2
-1
predeploys.spec.ts
integration-tests/test/predeploys.spec.ts
+0
-49
queue-ingestion.spec.ts
integration-tests/test/queue-ingestion.spec.ts
+2
-1
rpc.spec.ts
integration-tests/test/rpc.spec.ts
+14
-88
env.ts
integration-tests/test/shared/env.ts
+2
-1
utils.ts
integration-tests/test/shared/utils.ts
+1
-1
stress-tests.spec.ts
integration-tests/test/stress-tests.spec.ts
+11
-9
tsconfig.json
integration-tests/tsconfig.json
+1
-1
statedb.go
l2geth/core/state/statedb.go
+0
-18
state_processor.go
l2geth/core/state_processor.go
+13
-11
state_transition.go
l2geth/core/state_transition.go
+10
-55
state_transition_ovm.go
l2geth/core/state_transition_ovm.go
+0
-170
tx_pool.go
l2geth/core/tx_pool.go
+12
-25
errors.go
l2geth/core/vm/errors.go
+0
-3
evm.go
l2geth/core/vm/evm.go
+14
-272
instructions.go
l2geth/core/vm/instructions.go
+1
-6
ovm_state_manager.go
l2geth/core/vm/ovm_state_manager.go
+0
-193
api_tracer.go
l2geth/eth/api_tracer.go
+1
-9
api.go
l2geth/internal/ethapi/api.go
+12
-60
contract-deployed-artifacts.ts
packages/contracts/src/contract-deployed-artifacts.ts
+116
-0
No files found.
integration-tests/hardhat.config.ts
View file @
01e77768
...
...
@@ -3,7 +3,6 @@ import { HardhatUserConfig } from 'hardhat/types'
// Hardhat plugins
import
'
@nomiclabs/hardhat-ethers
'
import
'
@nomiclabs/hardhat-waffle
'
import
'
@eth-optimism/hardhat-ovm
'
import
'
hardhat-gas-reporter
'
const
enableGasReport
=
!!
process
.
env
.
ENABLE_GAS_REPORT
...
...
@@ -12,21 +11,12 @@ const config: HardhatUserConfig = {
networks
:
{
optimism
:
{
url
:
process
.
env
.
L2_URL
||
'
http://localhost:8545
'
,
ovm
:
true
,
},
'
optimism-live
'
:
{
url
:
process
.
env
.
L2_URL
||
'
http://localhost:8545
'
,
ovm
:
true
,
timeout
:
150000
,
},
},
mocha
:
{
timeout
:
50000
,
},
solidity
:
'
0.7.6
'
,
ovm
:
{
solcVersion
:
'
0.7.6+commit.3b061308
'
,
},
gasReporter
:
{
enabled
:
enableGasReport
,
currency
:
'
USD
'
,
...
...
integration-tests/package.json
View file @
01e77768
...
...
@@ -9,18 +9,16 @@
"lint"
:
"yarn lint:fix && yarn lint:check"
,
"lint:fix"
:
"yarn lint:check --fix"
,
"lint:check"
:
"eslint ."
,
"build:integration"
:
"
./scripts/build.sh
"
,
"build:integration"
:
"
yarn build:contracts
"
,
"build:contracts"
:
"hardhat compile"
,
"build:contracts:ovm"
:
"hardhat compile --network optimism"
,
"test:integration"
:
"hardhat --network optimism test"
,
"test:integration:live"
:
"IS_LIVE_NETWORK=true hardhat --network optimism
-live
test"
,
"test:integration:live"
:
"IS_LIVE_NETWORK=true hardhat --network optimism test"
,
"test:sync"
:
"hardhat --network optimism test sync-tests/*.spec.ts --no-compile"
,
"clean"
:
"rimraf cache artifacts artifacts-ovm cache-ovm"
},
"devDependencies"
:
{
"@eth-optimism/contracts"
:
"^0.4.14"
,
"@eth-optimism/core-utils"
:
"^0.6.1"
,
"@eth-optimism/hardhat-ovm"
:
"^0.2.4"
,
"@eth-optimism/message-relayer"
:
"^0.1.14"
,
"@ethersproject/providers"
:
"^5.4.5"
,
"@nomiclabs/hardhat-ethers"
:
"^2.0.2"
,
...
...
integration-tests/scripts/build.sh
deleted
100755 → 0
View file @
b3363ac8
yarn build:contracts &
yarn build:contracts:ovm &
wait
integration-tests/test/basic-l1-l2-communication.spec.ts
View file @
01e77768
...
...
@@ -5,13 +5,13 @@ import { Contract, ContractFactory } from 'ethers'
import
{
predeploys
,
getContractInterface
}
from
'
@eth-optimism/contracts
'
/* Imports: Internal */
import
l1SimpleStorageJson
from
'
../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json
'
import
l2SimpleStorageJson
from
'
../artifacts-ovm/contracts/SimpleStorage.sol/SimpleStorage.json
'
import
l2ReverterJson
from
'
../artifacts-ovm/contracts/Reverter.sol/Reverter.json
'
import
simpleStorageJson
from
'
../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json
'
import
l2ReverterJson
from
'
../artifacts/contracts/Reverter.sol/Reverter.json
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
import
{
OptimismEnv
,
useDynamicTimeoutForWithdrawals
}
from
'
./shared/env
'
describe
(
'
Basic L1<>L2 Communication
'
,
async
()
=>
{
// SKIP: needs message passing PR
describe
.
skip
(
'
Basic L1<>L2 Communication
'
,
async
()
=>
{
let
Factory__L1SimpleStorage
:
ContractFactory
let
Factory__L2SimpleStorage
:
ContractFactory
let
Factory__L2Reverter
:
ContractFactory
...
...
@@ -23,13 +23,13 @@ describe('Basic L1<>L2 Communication', async () => {
before
(
async
()
=>
{
env
=
await
OptimismEnv
.
new
()
Factory__L1SimpleStorage
=
new
ContractFactory
(
l1S
impleStorageJson
.
abi
,
l1S
impleStorageJson
.
bytecode
,
s
impleStorageJson
.
abi
,
s
impleStorageJson
.
bytecode
,
env
.
l1Wallet
)
Factory__L2SimpleStorage
=
new
ContractFactory
(
l2S
impleStorageJson
.
abi
,
l2S
impleStorageJson
.
bytecode
,
s
impleStorageJson
.
abi
,
s
impleStorageJson
.
bytecode
,
env
.
l2Wallet
)
Factory__L2Reverter
=
new
ContractFactory
(
...
...
integration-tests/test/erc20.spec.ts
View file @
01e77768
...
...
@@ -64,18 +64,9 @@ describe('Basic ERC20 interactions', async () => {
const
transfer
=
await
ERC20
.
transfer
(
other
.
address
,
100
)
const
receipt
=
await
transfer
.
wait
()
// The expected fee paid is the value returned by eth_estimateGas
const
gasLimit
=
await
ERC20
.
estimateGas
.
transfer
(
other
.
address
,
100
)
const
gasPrice
=
await
wallet
.
getGasPrice
()
expect
(
gasPrice
).
to
.
deep
.
equal
(
TxGasPrice
)
const
expectedFeePaid
=
gasLimit
.
mul
(
gasPrice
)
// There are two events from the transfer with the first being
// the ETH fee paid and the second of the value transfered (100)
expect
(
receipt
.
events
.
length
).
to
.
equal
(
2
)
expect
(
receipt
.
events
[
0
].
args
.
_value
).
to
.
deep
.
equal
(
expectedFeePaid
)
expect
(
receipt
.
events
[
1
].
args
.
_from
).
to
.
equal
(
wallet
.
address
)
expect
(
receipt
.
events
[
1
].
args
.
_value
.
toNumber
()).
to
.
equal
(
100
)
expect
(
receipt
.
events
.
length
).
to
.
equal
(
1
)
expect
(
receipt
.
events
[
0
].
args
.
_from
).
to
.
equal
(
wallet
.
address
)
expect
(
receipt
.
events
[
0
].
args
.
_value
.
toNumber
()).
to
.
equal
(
100
)
const
receiverBalance
=
await
ERC20
.
balanceOf
(
other
.
address
)
const
senderBalance
=
await
ERC20
.
balanceOf
(
wallet
.
address
)
...
...
integration-tests/test/fee-payment.spec.ts
View file @
01e77768
...
...
@@ -12,9 +12,8 @@ import { IS_LIVE_NETWORK } from './shared/utils'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
describe
(
'
Fee Payment Integration Tests
'
,
async
()
=>
{
const
other
=
'
0x1234123412341234123412341234123412341234
'
// SKIP: needs message passing PR
describe
.
skip
(
'
Fee Payment Integration Tests
'
,
async
()
=>
{
let
env
:
OptimismEnv
before
(
async
()
=>
{
env
=
await
OptimismEnv
.
new
()
...
...
@@ -29,58 +28,6 @@ describe('Fee Payment Integration Tests', async () => {
)
})
it
(
`Should return a gasPrice of
${
TxGasPrice
.
toString
()}
wei`
,
async
()
=>
{
const
gasPrice
=
await
env
.
l2Wallet
.
getGasPrice
()
expect
(
gasPrice
).
to
.
deep
.
eq
(
TxGasPrice
)
})
it
(
'
Should estimateGas with recoverable L2 gasLimit
'
,
async
()
=>
{
const
gas
=
await
env
.
ovmEth
.
estimateGas
.
transfer
(
other
,
utils
.
parseEther
(
'
0.0000001
'
)
)
const
tx
=
await
env
.
ovmEth
.
populateTransaction
.
transfer
(
other
,
utils
.
parseEther
(
'
0.0000001
'
)
)
const
executionGas
=
await
(
env
.
ovmEth
.
provider
as
any
).
send
(
'
eth_estimateExecutionGas
'
,
[
tx
,
true
]
)
const
decoded
=
TxGasLimit
.
decode
(
gas
)
expect
(
BigNumber
.
from
(
executionGas
)).
deep
.
eq
(
decoded
)
})
it
(
'
Paying a nonzero but acceptable gasPrice fee
'
,
async
()
=>
{
const
amount
=
utils
.
parseEther
(
'
0.0000001
'
)
const
balanceBefore
=
await
env
.
l2Wallet
.
getBalance
()
const
feeVaultBalanceBefore
=
await
env
.
l2Wallet
.
provider
.
getBalance
(
ovmSequencerFeeVault
.
address
)
expect
(
balanceBefore
.
gt
(
amount
))
const
tx
=
await
env
.
ovmEth
.
transfer
(
other
,
amount
)
const
receipt
=
await
tx
.
wait
()
expect
(
receipt
.
status
).
to
.
eq
(
1
)
const
balanceAfter
=
await
env
.
l2Wallet
.
getBalance
()
const
feeVaultBalanceAfter
=
await
env
.
l2Wallet
.
provider
.
getBalance
(
ovmSequencerFeeVault
.
address
)
const
expectedFeePaid
=
tx
.
gasPrice
.
mul
(
tx
.
gasLimit
)
// The fee paid MUST be the receipt.gasUsed, and not the tx.gasLimit
// https://github.com/ethereum-optimism/optimism/blob/0de7a2f9c96a7c4860658822231b2d6da0fefb1d/packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol#L103
expect
(
balanceBefore
.
sub
(
balanceAfter
)).
to
.
deep
.
equal
(
expectedFeePaid
.
add
(
amount
)
)
// Make sure the fee was transferred to the vault.
expect
(
feeVaultBalanceAfter
.
sub
(
feeVaultBalanceBefore
)).
to
.
deep
.
equal
(
expectedFeePaid
)
})
it
(
'
should not be able to withdraw fees before the minimum is met
'
,
async
()
=>
{
await
expect
(
ovmSequencerFeeVault
.
withdraw
()).
to
.
be
.
rejected
})
...
...
integration-tests/test/native-eth-ovm-calls.spec.ts
View file @
01e77768
...
...
@@ -13,7 +13,8 @@ import { Interface } from 'ethers/lib/utils'
chai
.
use
(
solidity
)
describe
(
'
Native ETH value integration tests
'
,
()
=>
{
// SKIP: needs message passing PR
describe
.
skip
(
'
Native ETH value integration tests
'
,
()
=>
{
let
env
:
OptimismEnv
let
wallet
:
Wallet
let
other
:
Wallet
...
...
integration-tests/test/native-eth.spec.ts
View file @
01e77768
...
...
@@ -19,7 +19,8 @@ const DEFAULT_TEST_GAS_L2 = 1_300_000
// TX size enforced by CTC:
const
MAX_ROLLUP_TX_SIZE
=
50
_000
describe
(
'
Native ETH Integration Tests
'
,
async
()
=>
{
// SKIP: needs message passing PR
describe
.
skip
(
'
Native ETH Integration Tests
'
,
async
()
=>
{
let
env
:
OptimismEnv
let
l1Bob
:
Wallet
let
l2Bob
:
Wallet
...
...
integration-tests/test/ovmcontext.spec.ts
View file @
01e77768
...
...
@@ -15,7 +15,8 @@ import { Direction } from './shared/watcher-utils'
* of a L1 to L2 transaction, both `block.number` and `block.timestamp`
* must be equal to the blocknumber/timestamp of the L1 transaction.
*/
describe
(
'
OVM Context: Layer 2 EVM Context
'
,
()
=>
{
// SKIP: needs message passing PR
describe
.
skip
(
'
OVM Context: Layer 2 EVM Context
'
,
()
=>
{
const
L2Provider
=
injectL2Context
(
l2Provider
)
let
env
:
OptimismEnv
before
(
async
()
=>
{
...
...
integration-tests/test/predeploys.spec.ts
deleted
100644 → 0
View file @
b3363ac8
import
{
expect
}
from
'
chai
'
import
{
ethers
}
from
'
hardhat
'
/* Imports: External */
import
{
Contract
,
Wallet
}
from
'
ethers
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
DEFAULT_TRANSACTION
}
from
'
./shared/utils
'
import
{
getContractInterface
}
from
'
@eth-optimism/contracts
'
describe
(
'
ECDSAContractAccount
'
,
()
=>
{
let
l2Wallet
:
Wallet
before
(
async
()
=>
{
const
env
=
await
OptimismEnv
.
new
()
l2Wallet
=
env
.
l2Wallet
})
let
ProxyEOA
:
Contract
let
messageHash
:
string
let
signature
:
string
before
(
async
()
=>
{
// Send a transaction to ensure there is a ProxyEOA deployed at l2Wallet.address
const
result
=
await
l2Wallet
.
sendTransaction
(
DEFAULT_TRANSACTION
)
await
result
.
wait
()
ProxyEOA
=
new
Contract
(
l2Wallet
.
address
,
getContractInterface
(
'
OVM_ECDSAContractAccount
'
),
l2Wallet
)
const
message
=
'
0x42
'
messageHash
=
ethers
.
utils
.
hashMessage
(
message
)
signature
=
await
l2Wallet
.
signMessage
(
message
)
})
it
(
'
should correctly evaluate isValidSignature from this wallet
'
,
async
()
=>
{
const
isValid
=
await
ProxyEOA
.
isValidSignature
(
messageHash
,
signature
)
expect
(
isValid
).
to
.
equal
(
'
0x1626ba7e
'
)
})
it
(
'
should correctly evaluate isValidSignature from other wallet
'
,
async
()
=>
{
const
otherWallet
=
Wallet
.
createRandom
().
connect
(
l2Wallet
.
provider
)
const
isValid
=
await
ProxyEOA
.
connect
(
otherWallet
).
isValidSignature
(
messageHash
,
signature
)
expect
(
isValid
).
to
.
equal
(
'
0x1626ba7e
'
)
})
})
integration-tests/test/queue-ingestion.spec.ts
View file @
01e77768
...
...
@@ -8,7 +8,8 @@ import { injectL2Context } from '@eth-optimism/core-utils'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
describe
(
'
Queue Ingestion
'
,
()
=>
{
// SKIP: needs message passing PR
describe
.
skip
(
'
Queue Ingestion
'
,
()
=>
{
let
env
:
OptimismEnv
let
l2Provider
:
providers
.
JsonRpcProvider
before
(
async
()
=>
{
...
...
integration-tests/test/rpc.spec.ts
View file @
01e77768
...
...
@@ -94,7 +94,8 @@ describe('Basic RPC tests', () => {
).
to
.
be
.
rejectedWith
(
'
Cannot submit unprotected transaction
'
)
})
it
(
'
should accept a transaction with a value
'
,
async
()
=>
{
// SKIP: needs ETH value PR
it
.
skip
(
'
should accept a transaction with a value
'
,
async
()
=>
{
const
tx
=
{
...
DEFAULT_TRANSACTION
,
chainId
:
await
env
.
l2Wallet
.
getChainId
(),
...
...
@@ -112,7 +113,8 @@ describe('Basic RPC tests', () => {
)
})
it
(
'
should reject a transaction with higher value than user balance
'
,
async
()
=>
{
// SKIP: needs ETH value PR
it
.
skip
(
'
should reject a transaction with higher value than user balance
'
,
async
()
=>
{
const
balance
=
await
env
.
l2Wallet
.
getBalance
()
const
tx
=
{
...
DEFAULT_TRANSACTION
,
...
...
@@ -126,31 +128,6 @@ describe('Basic RPC tests', () => {
)
})
it
(
'
should reject a transaction with too low of a fee
'
,
async
()
=>
{
const
tx
=
{
...
DEFAULT_TRANSACTION
,
gasLimit
:
1
,
gasPrice
:
TxGasPrice
,
}
const
fee
=
tx
.
gasPrice
.
mul
(
tx
.
gasLimit
)
await
expect
(
env
.
l2Wallet
.
sendTransaction
(
tx
)).
to
.
be
.
rejectedWith
(
`fee too low:
${
fee
}
, use at least tx.gasLimit =`
)
})
it
(
'
should reject a transaction with an incorrect gas price
'
,
async
()
=>
{
const
tx
=
{
...
DEFAULT_TRANSACTION
,
gasLimit
:
1
,
gasPrice
:
TxGasPrice
.
sub
(
1
),
}
await
expect
(
env
.
l2Wallet
.
sendTransaction
(
tx
)).
to
.
be
.
rejectedWith
(
`tx.gasPrice must be
${
TxGasPrice
.
toString
()}
`
)
})
it
(
'
should correctly report OOG for contract creations
'
,
async
()
=>
{
const
factory
=
await
ethers
.
getContractFactory
(
'
TestOOGInConstructor
'
)
...
...
@@ -193,20 +170,8 @@ describe('Basic RPC tests', () => {
).
to
.
be
.
rejectedWith
(
'
out of gas
'
)
})
it
(
'
should return the correct error message when attempting to deploy unsafe initcode
'
,
async
()
=>
{
// PUSH1 0x00 PUSH1 0x00 SSTORE
const
unsafeCode
=
'
0x6000600055
'
await
expect
(
provider
.
call
({
data
:
unsafeCode
,
})
).
to
.
be
.
revertedWith
(
'
Contract creation code contains unsafe opcodes. Did you use the right compiler or pass an unsafe constructor argument?
'
)
})
it
(
'
should allow eth_calls with nonzero value
'
,
async
()
=>
{
// SKIP: needs ETH value PR
it
.
skip
(
'
should allow eth_calls with nonzero value
'
,
async
()
=>
{
// Deploy a contract to check msg.value of the call
const
Factory__ValueContext
:
ContractFactory
=
await
ethers
.
getContractFactory
(
'
ValueContext
'
,
wallet
)
...
...
@@ -235,7 +200,7 @@ describe('Basic RPC tests', () => {
it
(
'
correctly exposes revert data for contract calls
'
,
async
()
=>
{
const
req
:
TransactionRequest
=
{
...
revertingTx
,
gasLimit
:
5980899
,
// override gas estimation
gasLimit
:
8
_000_000
,
// override gas estimation
}
const
tx
=
await
wallet
.
sendTransaction
(
req
)
...
...
@@ -258,7 +223,7 @@ describe('Basic RPC tests', () => {
it
(
'
correctly exposes revert data for contract creations
'
,
async
()
=>
{
const
req
:
TransactionRequest
=
{
...
revertingDeployTx
,
gasLimit
:
27700899
,
// override gas estimation
gasLimit
:
8
_000_000
,
// override gas estimation
}
const
tx
=
await
wallet
.
sendTransaction
(
req
)
...
...
@@ -350,7 +315,8 @@ describe('Basic RPC tests', () => {
})
describe
(
'
eth_getBalance
'
,
()
=>
{
it
(
'
should get the OVM_ETH balance
'
,
async
()
=>
{
// SKIP: needs ETH value PR
it
.
skip
(
'
should get the OVM_ETH balance
'
,
async
()
=>
{
const
rpcBalance
=
await
provider
.
getBalance
(
env
.
l2Wallet
.
address
)
const
contractBalance
=
await
env
.
ovmEth
.
balanceOf
(
env
.
l2Wallet
.
address
)
expect
(
rpcBalance
).
to
.
be
.
deep
.
eq
(
contractBalance
)
...
...
@@ -364,15 +330,7 @@ describe('Basic RPC tests', () => {
})
})
describe
(
'
eth_gasPrice
'
,
()
=>
{
it
(
'
gas price should be the fee scalar
'
,
async
()
=>
{
expect
(
await
provider
.
getGasPrice
()).
to
.
be
.
deep
.
equal
(
TxGasPrice
.
toNumber
()
)
})
})
describe
(
'
eth_estimateGas (returns the scaled fee)
'
,
()
=>
{
describe
(
'
eth_estimateGas
'
,
()
=>
{
it
(
'
gas estimation is deterministic
'
,
async
()
=>
{
let
lastEstimate
:
BigNumber
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
...
...
@@ -395,40 +353,7 @@ describe('Basic RPC tests', () => {
value
:
0
,
})
// Expect gas to be less than or equal to the target plus 1%
expectApprox
(
estimate
,
5920012
,
{
upperPercentDeviation
:
1
})
})
it
(
'
should return a gas estimate that grows with the size of data
'
,
async
()
=>
{
const
dataLen
=
[
0
,
2
,
8
,
64
,
256
]
const
l1GasPrice
=
await
env
.
l1Wallet
.
provider
.
getGasPrice
()
// Repeat this test for a series of possible transaction sizes.
for
(
const
data
of
dataLen
)
{
const
tx
=
{
to
:
'
0x
'
+
'
1234
'
.
repeat
(
10
),
value
:
'
0x0
'
,
data
:
'
0x
'
+
'
00
'
.
repeat
(
data
),
from
:
'
0x
'
+
'
1234
'
.
repeat
(
10
),
}
const
estimate
=
await
l2Provider
.
estimateGas
(
tx
)
const
l2Gaslimit
=
await
l2Provider
.
send
(
'
eth_estimateExecutionGas
'
,
[
tx
,
true
,
])
const
decoded
=
TxGasLimit
.
decode
(
estimate
)
expect
(
decoded
).
to
.
deep
.
eq
(
BigNumber
.
from
(
l2Gaslimit
))
expect
(
estimate
.
toString
().
endsWith
(
l2Gaslimit
.
toString
()))
const
l2GasPrice
=
await
env
.
gasPriceOracle
.
gasPrice
()
const
expected
=
TxGasLimit
.
encode
({
data
:
tx
.
data
,
l1GasPrice
,
l2GasLimit
:
BigNumber
.
from
(
l2Gaslimit
),
l2GasPrice
,
})
expect
(
expected
).
to
.
deep
.
eq
(
estimate
)
}
expectApprox
(
estimate
,
21000
,
{
upperPercentDeviation
:
1
})
})
it
(
'
should fail for a reverting call transaction
'
,
async
()
=>
{
...
...
@@ -442,7 +367,8 @@ describe('Basic RPC tests', () => {
})
})
describe
(
'
rollup_gasPrices
'
,
()
=>
{
// SKIP: ?
describe
.
skip
(
'
rollup_gasPrices
'
,
()
=>
{
it
(
'
should return the L1 and L2 gas prices
'
,
async
()
=>
{
const
result
=
await
provider
.
send
(
'
rollup_gasPrices
'
,
[])
const
l1GasPrice
=
await
env
.
l1Wallet
.
provider
.
getGasPrice
()
...
...
integration-tests/test/shared/env.ts
View file @
01e77768
...
...
@@ -71,7 +71,8 @@ export class OptimismEnv {
// fund the user if needed
const
balance
=
await
l2Wallet
.
getBalance
()
if
(
balance
.
isZero
())
{
await
fundUser
(
watcher
,
l1Bridge
,
utils
.
parseEther
(
'
20
'
))
// TEMPORARILY SKIP UNTIL MESSAGE PASSING WORKS
//await fundUser(watcher, l1Bridge, utils.parseEther('20'))
}
const
l1Messenger
=
getContractFactory
(
'
iOVM_L1CrossDomainMessenger
'
)
.
connect
(
l1Wallet
)
...
...
integration-tests/test/shared/utils.ts
View file @
01e77768
...
...
@@ -148,7 +148,7 @@ export const encodeSolidityRevertMessage = (_reason: string): string => {
export
const
DEFAULT_TRANSACTION
=
{
to
:
'
0x
'
+
'
1234
'
.
repeat
(
10
),
gasLimit
:
33600000000001
,
gasLimit
:
8
_000_000
,
gasPrice
:
0
,
data
:
'
0x
'
,
value
:
0
,
...
...
integration-tests/test/stress-tests.spec.ts
View file @
01e77768
...
...
@@ -15,8 +15,7 @@ import {
}
from
'
./shared/stress-test-helpers
'
/* Imports: Artifacts */
import
l1SimpleStorageJson
from
'
../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json
'
import
l2SimpleStorageJson
from
'
../artifacts-ovm/contracts/SimpleStorage.sol/SimpleStorage.json
'
import
simpleStorageJson
from
'
../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json
'
// Need a big timeout to allow for all transactions to be processed.
// For some reason I can't figure out how to set the timeout on a per-suite basis
...
...
@@ -33,13 +32,13 @@ describe('stress tests', () => {
let
L1SimpleStorage
:
Contract
beforeEach
(
async
()
=>
{
const
factory__L1SimpleStorage
=
new
ContractFactory
(
l1S
impleStorageJson
.
abi
,
l1S
impleStorageJson
.
bytecode
,
s
impleStorageJson
.
abi
,
s
impleStorageJson
.
bytecode
,
env
.
l1Wallet
)
const
factory__L2SimpleStorage
=
new
ContractFactory
(
l2S
impleStorageJson
.
abi
,
l2S
impleStorageJson
.
bytecode
,
s
impleStorageJson
.
abi
,
s
impleStorageJson
.
bytecode
,
env
.
l2Wallet
)
L1SimpleStorage
=
await
factory__L1SimpleStorage
.
deploy
()
...
...
@@ -48,7 +47,8 @@ describe('stress tests', () => {
await
L2SimpleStorage
.
deployTransaction
.
wait
()
})
describe
(
'
L1 => L2 stress tests
'
,
()
=>
{
// SKIP: needs message passing PR
describe
.
skip
(
'
L1 => L2 stress tests
'
,
()
=>
{
const
numTransactions
=
10
it
(
`
${
numTransactions
}
L1 => L2 transactions (serial)`
,
async
()
=>
{
...
...
@@ -84,7 +84,8 @@ describe('stress tests', () => {
}).
timeout
(
STRESS_TEST_TIMEOUT
)
})
describe
(
'
L2 => L1 stress tests
'
,
()
=>
{
// SKIP: needs message passing PR
describe
.
skip
(
'
L2 => L1 stress tests
'
,
()
=>
{
const
numTransactions
=
10
it
(
`
${
numTransactions
}
L2 => L1 transactions (serial)`
,
async
()
=>
{
...
...
@@ -156,7 +157,8 @@ describe('stress tests', () => {
}).
timeout
(
STRESS_TEST_TIMEOUT
)
})
describe
(
'
C-C-C-Combo breakers
'
,
()
=>
{
// SKIP: needs message passing PR
describe
.
skip
(
'
C-C-C-Combo breakers
'
,
()
=>
{
const
numTransactions
=
10
it
(
`
${
numTransactions
}
L2 transactions, L1 => L2 transactions, L2 => L1 transactions (txs serial, suites parallel)`
,
async
()
=>
{
...
...
integration-tests/tsconfig.json
View file @
01e77768
...
...
@@ -3,6 +3,6 @@
"compilerOptions"
:
{
"resolveJsonModule"
:
true
},
"include"
:
[
"./test"
,
"sync-tests/*.ts"
,
"./artifacts/**/*.json"
,
"./artifacts-ovm/**/*.json"
],
"include"
:
[
"./test"
,
"sync-tests/*.ts"
,
"./artifacts/**/*.json"
],
"files"
:
[
"./hardhat.config.ts"
]
}
l2geth/core/state/statedb.go
View file @
01e77768
...
...
@@ -31,7 +31,6 @@ import (
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
"golang.org/x/crypto/sha3"
)
type
revision
struct
{
...
...
@@ -232,23 +231,6 @@ func (s *StateDB) GetBalance(addr common.Address) *big.Int {
return
common
.
Big0
}
// UsingOVM
// Read the account's balance from the state. This is used
// because ETH is an ERC20. This function specifically looks
// up the storage slot of the users balance. It is fragile to any
// changes in storage layout.
func
(
s
*
StateDB
)
GetOVMBalance
(
addr
common
.
Address
)
*
big
.
Int
{
eth
:=
common
.
HexToAddress
(
"0x4200000000000000000000000000000000000006"
)
position
:=
big
.
NewInt
(
0
)
hasher
:=
sha3
.
NewLegacyKeccak256
()
hasher
.
Write
(
common
.
LeftPadBytes
(
addr
.
Bytes
(),
32
))
hasher
.
Write
(
common
.
LeftPadBytes
(
position
.
Bytes
(),
32
))
digest
:=
hasher
.
Sum
(
nil
)
key
:=
common
.
BytesToHash
(
digest
)
slot
:=
s
.
GetState
(
eth
,
key
)
return
slot
.
Big
()
}
func
(
s
*
StateDB
)
GetNonce
(
addr
common
.
Address
)
uint64
{
stateObject
:=
s
.
getStateObject
(
addr
)
if
stateObject
!=
nil
{
...
...
l2geth/core/state_processor.go
View file @
01e77768
...
...
@@ -19,6 +19,7 @@ package core
import
(
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
...
...
@@ -60,6 +61,10 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
allLogs
[]
*
types
.
Log
gp
=
new
(
GasPool
)
.
AddGas
(
block
.
GasLimit
())
)
// Mutate the block and state according to any hard-fork specs
if
p
.
config
.
DAOForkSupport
&&
p
.
config
.
DAOForkBlock
!=
nil
&&
p
.
config
.
DAOForkBlock
.
Cmp
(
block
.
Number
())
==
0
{
misc
.
ApplyDAOHardFork
(
statedb
)
}
// Iterate over and process the individual transactions
for
i
,
tx
:=
range
block
.
Transactions
()
{
statedb
.
Prepare
(
tx
.
Hash
(),
block
.
Hash
(),
i
)
...
...
@@ -81,20 +86,17 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
// for the transaction, gas used and an error if the transaction failed,
// indicating the block was invalid.
func
ApplyTransaction
(
config
*
params
.
ChainConfig
,
bc
ChainContext
,
author
*
common
.
Address
,
gp
*
GasPool
,
statedb
*
state
.
StateDB
,
header
*
types
.
Header
,
tx
*
types
.
Transaction
,
usedGas
*
uint64
,
cfg
vm
.
Config
)
(
*
types
.
Receipt
,
error
)
{
var
msg
Message
var
err
error
if
!
vm
.
UsingOVM
{
msg
,
err
=
tx
.
AsMessage
(
types
.
MakeSigner
(
config
,
header
.
Number
))
msg
,
err
:=
tx
.
AsMessage
(
types
.
MakeSigner
(
config
,
header
.
Number
))
if
vm
.
UsingOVM
{
if
err
!=
nil
{
return
nil
,
err
// This should only be allowed to pass if the transaction is in the ctc
// already. The presence of `Index` should specify this.
index
:=
tx
.
GetMeta
()
.
Index
if
index
==
nil
&&
msg
.
QueueOrigin
()
!=
types
.
QueueOriginL1ToL2
{
return
nil
,
err
}
}
}
else
{
// The transaction must be modified when running the OVM. The
// transaction fields that the user signs must be ABI encoded and then
// turned into the calldata of the transaction and the `to` field has to
// be updated to be the sequencer entrypoint.
decompressor
:=
config
.
StateDump
.
Accounts
[
"OVM_SequencerEntrypoint"
]
msg
,
err
=
AsOvmMessage
(
tx
,
types
.
MakeSigner
(
config
,
header
.
Number
),
decompressor
.
Address
,
header
.
GasLimit
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
l2geth/core/state_transition.go
View file @
01e77768
...
...
@@ -160,14 +160,8 @@ func (st *StateTransition) useGas(amount uint64) error {
func
(
st
*
StateTransition
)
buyGas
()
error
{
mgval
:=
new
(
big
.
Int
)
.
Mul
(
new
(
big
.
Int
)
.
SetUint64
(
st
.
msg
.
Gas
()),
st
.
gasPrice
)
// There is no native ETH, there is OVM_ETH which is an ERC20.
// Sufficient user balance is checked when the user sends the transaction
// via RPC through very similar checks as to when a transaction enters
// the layer one mempool. Deposits skip the check
if
!
vm
.
UsingOVM
{
if
st
.
state
.
GetBalance
(
st
.
msg
.
From
())
.
Cmp
(
mgval
)
<
0
{
return
errInsufficientBalanceForGas
}
if
st
.
state
.
GetBalance
(
st
.
msg
.
From
())
.
Cmp
(
mgval
)
<
0
{
return
errInsufficientBalanceForGas
}
if
err
:=
st
.
gp
.
SubGas
(
st
.
msg
.
Gas
());
err
!=
nil
{
return
err
...
...
@@ -175,11 +169,7 @@ func (st *StateTransition) buyGas() error {
st
.
gas
+=
st
.
msg
.
Gas
()
st
.
initialGas
=
st
.
msg
.
Gas
()
// Do not subtract the gas from the user balance when running OVM.
// This is handled in the Solidity contracts to enable to fraud proof
if
!
vm
.
UsingOVM
{
st
.
state
.
SubBalance
(
st
.
msg
.
From
(),
mgval
)
}
st
.
state
.
SubBalance
(
st
.
msg
.
From
(),
mgval
)
return
nil
}
...
...
@@ -211,26 +201,13 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo
if
err
=
st
.
preCheck
();
err
!=
nil
{
return
}
if
vm
.
UsingOVM
{
// When the execution is not an `eth_call`, abi encode the user transaction
// and place it in the calldata of the msg struct so that the user
// transaction can be passed to the system contracts via the calldata
if
st
.
evm
.
EthCallSender
==
nil
{
st
.
msg
,
err
=
toExecutionManagerRun
(
st
.
evm
,
st
.
msg
)
}
st
.
data
=
st
.
msg
.
Data
()
if
err
!=
nil
{
return
nil
,
0
,
false
,
err
}
}
msg
:=
st
.
msg
sender
:=
vm
.
AccountRef
(
msg
.
From
())
homestead
:=
st
.
evm
.
ChainConfig
()
.
IsHomestead
(
st
.
evm
.
BlockNumber
)
istanbul
:=
st
.
evm
.
ChainConfig
()
.
IsIstanbul
(
st
.
evm
.
BlockNumber
)
contractCreation
:=
msg
.
To
()
==
nil
// Pay intrinsic gas
gas
,
err
:=
IntrinsicGas
(
st
.
data
,
contractCreation
,
homestead
,
istanbul
)
if
err
!=
nil
{
return
nil
,
0
,
false
,
err
...
...
@@ -247,52 +224,30 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo
vmerr
error
)
if
vm
.
UsingOVM
{
to
:=
"<nil>"
if
msg
.
To
()
!=
nil
{
to
=
msg
.
To
()
.
Hex
()
}
l1MessageSender
:=
"<nil>"
if
msg
.
L1MessageSender
()
!=
nil
{
l1MessageSender
=
msg
.
L1MessageSender
()
.
Hex
()
}
if
st
.
evm
.
EthCallSender
==
nil
{
log
.
Debug
(
"Applying transaction"
,
"from"
,
sender
.
Address
()
.
Hex
(),
"to"
,
to
,
"nonce"
,
msg
.
Nonce
(),
"gasPrice"
,
msg
.
GasPrice
()
.
Uint64
(),
"gasLimit"
,
msg
.
Gas
(),
"value"
,
msg
.
Value
()
.
Uint64
(),
"l1MessageSender"
,
l1MessageSender
,
"data"
,
hexutil
.
Encode
(
msg
.
Data
()))
}
}
if
contractCreation
{
ret
,
_
,
st
.
gas
,
vmerr
=
evm
.
Create
(
sender
,
st
.
data
,
st
.
gas
,
st
.
value
)
}
else
{
// Increment the nonce for the next transaction
if
!
vm
.
UsingOVM
{
// Do not set the nonce because that is handled in the Solidity
// contracts.
st
.
state
.
SetNonce
(
msg
.
From
(),
st
.
state
.
GetNonce
(
msg
.
From
())
+
1
)
}
st
.
state
.
SetNonce
(
msg
.
From
(),
st
.
state
.
GetNonce
(
msg
.
From
())
+
1
)
ret
,
st
.
gas
,
vmerr
=
evm
.
Call
(
sender
,
st
.
to
(),
st
.
data
,
st
.
gas
,
st
.
value
)
}
if
vmerr
!=
nil
{
log
.
Debug
(
"VM returned with error"
,
"err"
,
vmerr
,
"ret"
,
hexutil
.
Encode
(
ret
))
// The only possible consensus-error would be if there wasn't
// sufficient balance to make the transfer happen. The first
// balance transfer may never fail.
if
vmerr
==
vm
.
ErrInsufficientBalance
{
return
nil
,
0
,
false
,
vmerr
}
}
st
.
refundGas
()
st
.
state
.
AddBalance
(
evm
.
Coinbase
,
new
(
big
.
Int
)
.
Mul
(
new
(
big
.
Int
)
.
SetUint64
(
st
.
gasUsed
()),
st
.
gasPrice
))
if
!
vm
.
UsingOVM
{
// Do not pay the gas to the coinbase address when running the OVM
st
.
state
.
AddBalance
(
evm
.
Coinbase
,
new
(
big
.
Int
)
.
Mul
(
new
(
big
.
Int
)
.
SetUint64
(
st
.
gasUsed
()),
st
.
gasPrice
))
}
return
ret
,
st
.
gasUsed
(),
vmerr
!=
nil
,
err
}
func
(
st
*
StateTransition
)
refundGas
()
{
// Do not refund any gas when running the OVM
if
vm
.
UsingOVM
{
return
}
// Apply refund counter, capped to half of the used gas.
refund
:=
st
.
gasUsed
()
/
2
if
refund
>
st
.
state
.
GetRefund
()
{
...
...
l2geth/core/state_transition_ovm.go
deleted
100644 → 0
View file @
b3363ac8
package
core
import
(
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/rollup/dump"
)
var
ZeroAddress
=
common
.
HexToAddress
(
"0x0000000000000000000000000000000000000000"
)
type
ovmTransaction
struct
{
Timestamp
*
big
.
Int
`json:"timestamp"`
BlockNumber
*
big
.
Int
`json:"blockNumber"`
L1QueueOrigin
uint8
`json:"l1QueueOrigin"`
L1TxOrigin
common
.
Address
`json:"l1TxOrigin"`
Entrypoint
common
.
Address
`json:"entrypoint"`
GasLimit
*
big
.
Int
`json:"gasLimit"`
Data
[]
uint8
`json:"data"`
}
func
toExecutionManagerRun
(
evm
*
vm
.
EVM
,
msg
Message
)
(
Message
,
error
)
{
to
:=
msg
.
To
()
if
to
==
nil
{
to
=
&
common
.
Address
{}
}
l1MsgSender
:=
msg
.
L1MessageSender
()
if
l1MsgSender
==
nil
{
l1MsgSender
=
&
common
.
Address
{}
}
tx
:=
ovmTransaction
{
evm
.
Context
.
Time
,
msg
.
L1BlockNumber
(),
uint8
(
msg
.
QueueOrigin
()),
*
l1MsgSender
,
*
to
,
big
.
NewInt
(
int64
(
msg
.
Gas
())),
msg
.
Data
(),
}
var
abi
=
evm
.
Context
.
OvmExecutionManager
.
ABI
var
args
=
[]
interface
{}{
tx
,
evm
.
Context
.
OvmStateManager
.
Address
,
}
ret
,
err
:=
abi
.
Pack
(
"run"
,
args
...
)
if
err
!=
nil
{
return
nil
,
err
}
outputmsg
,
err
:=
modMessage
(
msg
,
msg
.
From
(),
&
evm
.
Context
.
OvmExecutionManager
.
Address
,
ret
,
evm
.
Context
.
GasLimit
,
)
if
err
!=
nil
{
return
nil
,
err
}
return
outputmsg
,
nil
}
func
AsOvmMessage
(
tx
*
types
.
Transaction
,
signer
types
.
Signer
,
decompressor
common
.
Address
,
gasLimit
uint64
)
(
Message
,
error
)
{
msg
,
err
:=
tx
.
AsMessage
(
signer
)
if
err
!=
nil
{
// This should only be allowed to pass if the transaction is in the ctc
// already. The presence of `Index` should specify this.
index
:=
tx
.
GetMeta
()
.
Index
if
index
==
nil
{
return
msg
,
fmt
.
Errorf
(
"Cannot convert tx to message in asOvmMessage: %w"
,
err
)
}
}
// Queue origin L1ToL2 transactions do not go through the
// sequencer entrypoint. The calldata is expected to be in the
// correct format when deserialized from the EVM events, see
// rollup/sync_service.go.
if
msg
.
QueueOrigin
()
==
types
.
QueueOriginL1ToL2
{
return
msg
,
nil
}
// Sequencer transactions get sent to the "sequencer entrypoint," a contract that decompresses
// the incoming transaction data.
outmsg
,
err
:=
modMessage
(
msg
,
msg
.
From
(),
&
decompressor
,
tx
.
GetMeta
()
.
RawTransaction
,
gasLimit
,
)
if
err
!=
nil
{
return
msg
,
fmt
.
Errorf
(
"Cannot mod message: %w"
,
err
)
}
return
outmsg
,
nil
}
func
EncodeSimulatedMessage
(
msg
Message
,
timestamp
,
blockNumber
*
big
.
Int
,
executionManager
,
stateManager
dump
.
OvmDumpAccount
)
(
Message
,
error
)
{
to
:=
msg
.
To
()
if
to
==
nil
{
to
=
&
common
.
Address
{
0
}
}
value
:=
msg
.
Value
()
if
value
==
nil
{
value
=
common
.
Big0
}
tx
:=
ovmTransaction
{
timestamp
,
blockNumber
,
uint8
(
msg
.
QueueOrigin
()),
*
msg
.
L1MessageSender
(),
*
to
,
new
(
big
.
Int
)
.
SetUint64
(
msg
.
Gas
()),
msg
.
Data
(),
}
from
:=
msg
.
From
()
var
args
=
[]
interface
{}{
tx
,
from
,
value
,
stateManager
.
Address
,
}
output
,
err
:=
executionManager
.
ABI
.
Pack
(
"simulateMessage"
,
args
...
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Cannot pack simulateMessage: %w"
,
err
)
}
return
modMessage
(
msg
,
common
.
Address
{},
&
executionManager
.
Address
,
output
,
msg
.
Gas
(),
)
}
func
modMessage
(
msg
Message
,
from
common
.
Address
,
to
*
common
.
Address
,
data
[]
byte
,
gasLimit
uint64
,
)
(
Message
,
error
)
{
outmsg
:=
types
.
NewMessage
(
from
,
to
,
msg
.
Nonce
(),
common
.
Big0
,
gasLimit
,
msg
.
GasPrice
(),
data
,
false
,
msg
.
L1MessageSender
(),
msg
.
L1BlockNumber
(),
msg
.
QueueOrigin
(),
)
return
outmsg
,
nil
}
l2geth/core/tx_pool.go
View file @
01e77768
...
...
@@ -539,14 +539,8 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
}
// Ensure the transaction doesn't exceed the current block limit gas.
if
vm
.
UsingOVM
{
if
pool
.
currentMaxGas
<
tx
.
L2Gas
()
{
return
ErrGasLimit
}
}
else
{
if
pool
.
currentMaxGas
<
tx
.
Gas
()
{
return
ErrGasLimit
}
if
pool
.
currentMaxGas
<
tx
.
Gas
()
{
return
ErrGasLimit
}
// Make sure the transaction is signed properly
...
...
@@ -571,22 +565,16 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
}
// Transactor should have enough funds to cover the costs
// cost == V + GP * GL
if
vm
.
UsingOVM
{
if
pool
.
currentState
.
GetOVMBalance
(
from
)
.
Cmp
(
tx
.
Cost
())
<
0
{
return
ErrInsufficientFunds
}
}
else
{
if
pool
.
currentState
.
GetBalance
(
from
)
.
Cmp
(
tx
.
Cost
())
<
0
{
return
ErrInsufficientFunds
}
// Ensure the transaction has more gas than the basic tx fee.
intrGas
,
err
:=
IntrinsicGas
(
tx
.
Data
(),
tx
.
To
()
==
nil
,
true
,
pool
.
istanbul
)
if
err
!=
nil
{
return
err
}
if
tx
.
Gas
()
<
intrGas
{
return
ErrIntrinsicGas
}
if
pool
.
currentState
.
GetBalance
(
from
)
.
Cmp
(
tx
.
Cost
())
<
0
{
return
ErrInsufficientFunds
}
// Ensure the transaction has more gas than the basic tx fee.
intrGas
,
err
:=
IntrinsicGas
(
tx
.
Data
(),
tx
.
To
()
==
nil
,
true
,
pool
.
istanbul
)
if
err
!=
nil
{
return
err
}
if
tx
.
Gas
()
<
intrGas
{
return
ErrIntrinsicGas
}
return
nil
}
...
...
@@ -599,7 +587,6 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// whitelisted, preventing any associated transaction from being dropped out of the pool
// due to pricing constraints.
func
(
pool
*
TxPool
)
add
(
tx
*
types
.
Transaction
,
local
bool
)
(
replaced
bool
,
err
error
)
{
log
.
Debug
(
"received tx"
,
"gas"
,
tx
.
Gas
(),
"gasprice"
,
tx
.
GasPrice
()
.
Uint64
())
// If the transaction is already known, discard it
hash
:=
tx
.
Hash
()
if
pool
.
all
.
Get
(
hash
)
!=
nil
{
...
...
l2geth/core/vm/errors.go
View file @
01e77768
...
...
@@ -27,7 +27,4 @@ var (
ErrInsufficientBalance
=
errors
.
New
(
"insufficient balance for transfer"
)
ErrContractAddressCollision
=
errors
.
New
(
"contract address collision"
)
ErrNoCompatibleInterpreter
=
errors
.
New
(
"no compatible interpreter"
)
ErrOvmExecutionFailed
=
errors
.
New
(
"ovm execution failed"
)
ErrOvmCreationFailed
=
errors
.
New
(
"creation called by non-Execution Manager contract"
)
ErrOvmSandboxEscape
=
errors
.
New
(
"ovm execution escaped from sandbox"
)
)
l2geth/core/vm/evm.go
View file @
01e77768
This diff is collapsed.
Click to expand it.
l2geth/core/vm/instructions.go
View file @
01e77768
...
...
@@ -897,14 +897,9 @@ func makeLog(size int) executionFunc {
topics
[
i
]
=
common
.
BigToHash
(
stack
.
pop
())
}
contractAddr
:=
contract
.
Address
()
if
UsingOVM
{
contractAddr
=
interpreter
.
evm
.
OvmADDRESS
()
}
d
:=
memory
.
GetCopy
(
mStart
.
Int64
(),
mSize
.
Int64
())
interpreter
.
evm
.
StateDB
.
AddLog
(
&
types
.
Log
{
Address
:
contract
Addr
,
Address
:
contract
.
Address
()
,
Topics
:
topics
,
Data
:
d
,
// This is a non-consensus field, but assigned here because
...
...
l2geth/core/vm/ovm_state_manager.go
deleted
100644 → 0
View file @
b3363ac8
package
vm
import
(
"errors"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
)
type
stateManagerFunction
func
(
*
EVM
,
*
Contract
,
map
[
string
]
interface
{})
([]
interface
{},
error
)
var
funcs
=
map
[
string
]
stateManagerFunction
{
"owner"
:
owner
,
"setAccountNonce"
:
setAccountNonce
,
"getAccountNonce"
:
getAccountNonce
,
"getAccountEthAddress"
:
getAccountEthAddress
,
"getContractStorage"
:
getContractStorage
,
"putContractStorage"
:
putContractStorage
,
"isAuthenticated"
:
nativeFunctionTrue
,
"hasAccount"
:
nativeFunctionTrue
,
"hasEmptyAccount"
:
hasEmptyAccount
,
"hasContractStorage"
:
nativeFunctionTrue
,
"testAndSetAccountLoaded"
:
testAndSetAccount
,
"testAndSetAccountChanged"
:
testAndSetAccount
,
"testAndSetContractStorageLoaded"
:
testAndSetContractStorageLoaded
,
"testAndSetContractStorageChanged"
:
testAndSetContractStorageChanged
,
"incrementTotalUncommittedAccounts"
:
nativeFunctionVoid
,
"incrementTotalUncommittedContractStorage"
:
nativeFunctionVoid
,
"initPendingAccount"
:
nativeFunctionVoid
,
"commitPendingAccount"
:
nativeFunctionVoid
,
}
func
callStateManager
(
input
[]
byte
,
evm
*
EVM
,
contract
*
Contract
)
(
ret
[]
byte
,
err
error
)
{
method
,
err
:=
evm
.
Context
.
OvmStateManager
.
ABI
.
MethodById
(
input
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot find method id %s: %w"
,
input
,
err
)
}
var
inputArgs
=
make
(
map
[
string
]
interface
{})
if
err
:=
method
.
Inputs
.
UnpackIntoMap
(
inputArgs
,
input
[
4
:
]);
err
!=
nil
{
return
nil
,
err
}
fn
,
exist
:=
funcs
[
method
.
RawName
]
if
!
exist
{
return
nil
,
fmt
.
Errorf
(
"Native OVM_StateManager function not found for method '%s'"
,
method
.
RawName
)
}
outputArgs
,
err
:=
fn
(
evm
,
contract
,
inputArgs
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot execute state manager function: %w"
,
err
)
}
returndata
,
err
:=
method
.
Outputs
.
PackValues
(
outputArgs
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot pack returndata: %w"
,
err
)
}
return
returndata
,
nil
}
func
owner
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
origin
:=
evm
.
Context
.
Origin
return
[]
interface
{}{
origin
},
nil
}
func
setAccountNonce
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
address
,
ok
:=
args
[
"_address"
]
.
(
common
.
Address
)
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse address arg in setAccountNonce"
)
}
nonce
,
ok
:=
args
[
"_nonce"
]
.
(
*
big
.
Int
)
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse nonce arg in setAccountNonce"
)
}
evm
.
StateDB
.
SetNonce
(
address
,
nonce
.
Uint64
())
return
[]
interface
{}{},
nil
}
func
getAccountNonce
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
address
,
ok
:=
args
[
"_address"
]
.
(
common
.
Address
)
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse address arg in getAccountNonce"
)
}
nonce
:=
evm
.
StateDB
.
GetNonce
(
address
)
return
[]
interface
{}{
new
(
big
.
Int
)
.
SetUint64
(
nonce
)},
nil
}
func
getAccountEthAddress
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
address
,
ok
:=
args
[
"_address"
]
.
(
common
.
Address
)
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse address arg in getAccountEthAddress"
)
}
return
[]
interface
{}{
address
},
nil
}
func
getContractStorage
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
address
,
ok
:=
args
[
"_contract"
]
.
(
common
.
Address
)
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse contract arg in getContractStorage"
)
}
_key
,
ok
:=
args
[
"_key"
]
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse key arg in getContractStorage"
)
}
key
:=
toHash
(
_key
)
val
:=
evm
.
StateDB
.
GetState
(
address
,
key
)
if
evm
.
Context
.
EthCallSender
==
nil
{
log
.
Debug
(
"Got contract storage"
,
"address"
,
address
.
Hex
(),
"key"
,
key
.
Hex
(),
"val"
,
val
.
Hex
())
}
return
[]
interface
{}{
val
},
nil
}
func
putContractStorage
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
address
,
ok
:=
args
[
"_contract"
]
.
(
common
.
Address
)
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse address arg in putContractStorage"
)
}
_key
,
ok
:=
args
[
"_key"
]
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse key arg in putContractStorage"
)
}
key
:=
toHash
(
_key
)
_value
,
ok
:=
args
[
"_value"
]
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse value arg in putContractStorage"
)
}
val
:=
toHash
(
_value
)
if
evm
.
Context
.
EthCallSender
==
nil
{
log
.
Debug
(
"Put contract storage"
,
"address"
,
address
.
Hex
(),
"key"
,
key
.
Hex
(),
"val"
,
val
.
Hex
())
}
evm
.
StateDB
.
SetState
(
address
,
key
,
val
)
return
[]
interface
{}{},
nil
}
func
testAndSetAccount
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
return
[]
interface
{}{
true
},
nil
}
func
testAndSetContractStorageLoaded
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
return
testAndSetContractStorage
(
evm
,
contract
,
args
,
false
)
}
func
testAndSetContractStorageChanged
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
return
testAndSetContractStorage
(
evm
,
contract
,
args
,
true
)
}
func
testAndSetContractStorage
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{},
changed
bool
)
([]
interface
{},
error
)
{
address
,
ok
:=
args
[
"_contract"
]
.
(
common
.
Address
)
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse address arg in putContractStorage"
)
}
_key
,
ok
:=
args
[
"_key"
]
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse key arg in putContractStorage"
)
}
key
:=
toHash
(
_key
)
if
evm
.
Context
.
EthCallSender
==
nil
{
log
.
Debug
(
"Test and Set Contract Storage"
,
"address"
,
address
.
Hex
(),
"key"
,
key
.
Hex
(),
"changed"
,
changed
)
}
return
[]
interface
{}{
true
},
nil
}
func
hasEmptyAccount
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
address
,
ok
:=
args
[
"_address"
]
.
(
common
.
Address
)
if
!
ok
{
return
nil
,
errors
.
New
(
"Could not parse address arg in hasEmptyAccount"
)
}
contractHash
:=
evm
.
StateDB
.
GetCodeHash
(
address
)
if
evm
.
StateDB
.
GetNonce
(
address
)
!=
0
||
(
contractHash
!=
(
common
.
Hash
{})
&&
contractHash
!=
emptyCodeHash
)
{
return
[]
interface
{}{
false
},
nil
}
return
[]
interface
{}{
true
},
nil
}
func
nativeFunctionTrue
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
return
[]
interface
{}{
true
},
nil
}
func
nativeFunctionVoid
(
evm
*
EVM
,
contract
*
Contract
,
args
map
[
string
]
interface
{})
([]
interface
{},
error
)
{
return
[]
interface
{}{},
nil
}
func
toHash
(
arg
interface
{})
common
.
Hash
{
b
:=
arg
.
([
32
]
uint8
)
return
common
.
BytesToHash
(
b
[
:
])
}
l2geth/eth/api_tracer.go
View file @
01e77768
...
...
@@ -805,15 +805,7 @@ func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, ree
for
idx
,
tx
:=
range
block
.
Transactions
()
{
// Assemble the transaction call message and return if the requested offset
var
msg
core
.
Message
if
!
vm
.
UsingOVM
{
msg
,
_
=
tx
.
AsMessage
(
signer
)
}
else
{
msg
,
err
=
core
.
AsOvmMessage
(
tx
,
signer
,
common
.
HexToAddress
(
"0x4200000000000000000000000000000000000005"
),
block
.
Header
()
.
GasLimit
)
if
err
!=
nil
{
return
nil
,
vm
.
Context
{},
nil
,
err
}
}
msg
,
_
:=
tx
.
AsMessage
(
signer
)
context
:=
core
.
NewEVMContext
(
msg
,
block
.
Header
(),
api
.
eth
.
blockchain
,
nil
)
if
idx
==
txIndex
{
return
msg
,
context
,
statedb
,
nil
...
...
l2geth/internal/ethapi/api.go
View file @
01e77768
...
...
@@ -54,7 +54,10 @@ const (
)
var
errOVMUnsupported
=
errors
.
New
(
"OVM: Unsupported RPC Method"
)
var
bigDefaultGasPrice
=
new
(
big
.
Int
)
.
SetUint64
(
defaultGasPrice
)
// TEMPORARY: Set the gas price to 0 until message passing and ETH value work again.
// Otherwise the integration tests won't pass because the accounts have no ETH.
var
bigDefaultGasPrice
=
new
(
big
.
Int
)
.
SetUint64
(
0
)
// PublicEthereumAPI provides an API to access Ethereum related information.
// It offers only methods that operate on public data that is freely available to anyone.
...
...
@@ -539,7 +542,7 @@ func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Add
if
state
==
nil
||
err
!=
nil
{
return
nil
,
err
}
return
(
*
hexutil
.
Big
)(
state
.
Get
OVM
Balance
(
address
)),
state
.
Error
()
return
(
*
hexutil
.
Big
)(
state
.
GetBalance
(
address
)),
state
.
Error
()
}
// Result structs for GetProof
...
...
@@ -860,16 +863,12 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
data
=
[]
byte
(
*
args
.
Data
)
}
// Currently, the blocknumber and timestamp actually refer to the L1BlockNumber and L1Timestamp
// attached to each transaction. We need to modify the blocknumber and timestamp to reflect this,
// or else the result of `eth_call` will not be correct.
blockNumber
:=
header
.
Number
timestamp
:=
new
(
big
.
Int
)
.
SetUint64
(
header
.
Time
)
// Create new call message
var
msg
core
.
Message
msg
=
types
.
NewMessage
(
addr
,
args
.
To
,
0
,
value
,
gas
,
gasPrice
,
data
,
false
,
&
addr
,
nil
,
types
.
QueueOriginSequencer
)
if
vm
.
UsingOVM
{
cfg
:=
b
.
ChainConfig
()
executionManager
:=
cfg
.
StateDump
.
Accounts
[
"OVM_ExecutionManager"
]
stateManager
:=
cfg
.
StateDump
.
Accounts
[
"OVM_StateManager"
]
block
,
err
:=
b
.
BlockByNumber
(
ctx
,
rpc
.
BlockNumber
(
header
.
Number
.
Uint64
()))
if
err
!=
nil
{
return
nil
,
0
,
false
,
err
...
...
@@ -885,12 +884,11 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
timestamp
=
new
(
big
.
Int
)
.
SetUint64
(
tx
.
L1Timestamp
())
}
}
msg
,
err
=
core
.
EncodeSimulatedMessage
(
msg
,
timestamp
,
blockNumber
,
executionManager
,
stateManager
)
if
err
!=
nil
{
return
nil
,
0
,
false
,
err
}
}
// Create new call message
msg
:=
types
.
NewMessage
(
addr
,
args
.
To
,
0
,
value
,
gas
,
gasPrice
,
data
,
false
,
&
addr
,
nil
,
types
.
QueueOriginSequencer
)
// Setup context so it may be cancelled the call has completed
// or, in case of unmetered gas, setup a context with a timeout.
var
cancel
context
.
CancelFunc
...
...
@@ -918,8 +916,8 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
// Setup the gas pool (also for unmetered requests)
// and apply the message.
gp
:=
new
(
core
.
GasPool
)
.
AddGas
(
math
.
MaxUint64
)
// Modify the blocknumber and timestamp based on the L1BlockNumber and L1Timestamp from above.
if
vm
.
UsingOVM
{
evm
.
Context
.
EthCallSender
=
&
addr
evm
.
Context
.
BlockNumber
=
blockNumber
evm
.
Context
.
Time
=
timestamp
}
...
...
@@ -966,37 +964,6 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOr
// fees can compensate for the additional costs the sequencer pays for publishing the
// transaction calldata
func
DoEstimateGas
(
ctx
context
.
Context
,
b
Backend
,
args
CallArgs
,
blockNrOrHash
rpc
.
BlockNumberOrHash
,
gasCap
*
big
.
Int
)
(
hexutil
.
Uint64
,
error
)
{
// 1. get the gas that would be used by the transaction
gasUsed
,
err
:=
legacyDoEstimateGas
(
ctx
,
b
,
args
,
blockNrOrHash
,
gasCap
)
if
err
!=
nil
{
return
0
,
err
}
// 2a. fetch the data price, depends on how the sequencer has chosen to update their values based on the
// l1 gas prices
l1GasPrice
,
err
:=
b
.
SuggestL1GasPrice
(
ctx
)
if
err
!=
nil
{
return
0
,
err
}
// 2b. fetch the execution gas price, by the typical mempool dynamics
l2GasPrice
,
err
:=
b
.
SuggestL2GasPrice
(
ctx
)
if
err
!=
nil
{
return
0
,
err
}
data
:=
[]
byte
{}
if
args
.
Data
!=
nil
{
data
=
*
args
.
Data
}
// 3. calculate the fee using just the calldata. The additional overhead of
// RLP encoding is covered inside of EncodeL2GasLimit
l2GasLimit
:=
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
gasUsed
))
fee
:=
fees
.
EncodeTxGasLimit
(
data
,
l1GasPrice
,
l2GasLimit
,
l2GasPrice
)
if
!
fee
.
IsUint64
()
{
return
0
,
fmt
.
Errorf
(
"estimate gas overflow: %s"
,
fee
)
}
return
(
hexutil
.
Uint64
)(
fee
.
Uint64
()),
nil
}
func
legacyDoEstimateGas
(
ctx
context
.
Context
,
b
Backend
,
args
CallArgs
,
blockNrOrHash
rpc
.
BlockNumberOrHash
,
gasCap
*
big
.
Int
)
(
hexutil
.
Uint64
,
error
)
{
// Binary search the gas requirement, as it may be higher than the amount used
var
(
lo
uint64
=
params
.
TxGas
-
1
...
...
@@ -1078,21 +1045,6 @@ func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (h
return
DoEstimateGas
(
ctx
,
s
.
b
,
args
,
blockNrOrHash
,
s
.
b
.
RPCGasCap
())
}
// EstimateExecutionGas returns an estimate of the amount of gas needed to execute the
// given transaction against the current pending block.
func
(
s
*
PublicBlockChainAPI
)
EstimateExecutionGas
(
ctx
context
.
Context
,
args
CallArgs
,
round
*
bool
)
(
hexutil
.
Uint64
,
error
)
{
blockNrOrHash
:=
rpc
.
BlockNumberOrHashWithNumber
(
rpc
.
PendingBlockNumber
)
estimate
,
err
:=
legacyDoEstimateGas
(
ctx
,
s
.
b
,
args
,
blockNrOrHash
,
s
.
b
.
RPCGasCap
())
if
err
!=
nil
{
return
estimate
,
err
}
if
round
!=
nil
&&
*
round
{
rounded
:=
fees
.
Ceilmod
(
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
estimate
)),
fees
.
BigTenThousand
)
estimate
=
(
hexutil
.
Uint64
)(
rounded
.
Uint64
())
}
return
estimate
,
nil
}
// ExecutionResult groups all structured logs emitted by the EVM
// while replaying a transaction in debug mode as well as transaction
// execution status, the amount of gas used and the return value
...
...
packages/contracts/src/contract-deployed-artifacts.ts
0 → 100644
View file @
01e77768
/* eslint-disable @typescript-eslint/no-var-requires, no-empty */
/*
THIS FILE IS AUTOMATICALLY GENERATED.
DO NOT EDIT.
*/
const
goerli__Lib_AddressManager
=
require
(
'
../deployments/goerli/Lib_AddressManager.json
'
)
const
goerli__mockOVM_BondManager
=
require
(
'
../deployments/goerli/mockOVM_BondManager.json
'
)
const
goerli__OVM_CanonicalTransactionChain
=
require
(
'
../deployments/goerli/OVM_CanonicalTransactionChain.json
'
)
const
goerli__OVM_ChainStorageContainer_CTC_batches
=
require
(
'
../deployments/goerli/OVM_ChainStorageContainer-CTC-batches.json
'
)
const
goerli__OVM_ChainStorageContainer_CTC_queue
=
require
(
'
../deployments/goerli/OVM_ChainStorageContainer-CTC-queue.json
'
)
const
goerli__OVM_ChainStorageContainer_SCC_batches
=
require
(
'
../deployments/goerli/OVM_ChainStorageContainer-SCC-batches.json
'
)
const
goerli__OVM_ExecutionManager
=
require
(
'
../deployments/goerli/OVM_ExecutionManager.json
'
)
const
goerli__OVM_FraudVerifier
=
require
(
'
../deployments/goerli/OVM_FraudVerifier.json
'
)
const
goerli__OVM_L1CrossDomainMessenger
=
require
(
'
../deployments/goerli/OVM_L1CrossDomainMessenger.json
'
)
const
goerli__OVM_L1ETHGateway
=
require
(
'
../deployments/goerli/OVM_L1ETHGateway.json
'
)
const
goerli__OVM_L1MultiMessageRelayer
=
require
(
'
../deployments/goerli/OVM_L1MultiMessageRelayer.json
'
)
const
goerli__OVM_SafetyChecker
=
require
(
'
../deployments/goerli/OVM_SafetyChecker.json
'
)
const
goerli__OVM_StateCommitmentChain
=
require
(
'
../deployments/goerli/OVM_StateCommitmentChain.json
'
)
const
goerli__OVM_StateManagerFactory
=
require
(
'
../deployments/goerli/OVM_StateManagerFactory.json
'
)
const
goerli__OVM_StateTransitionerFactory
=
require
(
'
../deployments/goerli/OVM_StateTransitionerFactory.json
'
)
const
goerli__Proxy__OVM_L1CrossDomainMessenger
=
require
(
'
../deployments/goerli/Proxy__OVM_L1CrossDomainMessenger.json
'
)
const
goerli__Proxy__OVM_L1ETHGateway
=
require
(
'
../deployments/goerli/Proxy__OVM_L1ETHGateway.json
'
)
const
goerli__Proxy__OVM_L1StandardBridge
=
require
(
'
../deployments/goerli/Proxy__OVM_L1StandardBridge.json
'
)
const
kovan__Lib_AddressManager
=
require
(
'
../deployments/kovan/Lib_AddressManager.json
'
)
const
kovan__mockOVM_BondManager
=
require
(
'
../deployments/kovan/mockOVM_BondManager.json
'
)
const
kovan__OVM_CanonicalTransactionChain
=
require
(
'
../deployments/kovan/OVM_CanonicalTransactionChain.json
'
)
const
kovan__OVM_ChainStorageContainer_CTC_batches
=
require
(
'
../deployments/kovan/OVM_ChainStorageContainer-CTC-batches.json
'
)
const
kovan__OVM_ChainStorageContainer_CTC_queue
=
require
(
'
../deployments/kovan/OVM_ChainStorageContainer-CTC-queue.json
'
)
const
kovan__OVM_ChainStorageContainer_SCC_batches
=
require
(
'
../deployments/kovan/OVM_ChainStorageContainer-SCC-batches.json
'
)
const
kovan__OVM_ExecutionManager
=
require
(
'
../deployments/kovan/OVM_ExecutionManager.json
'
)
const
kovan__OVM_FraudVerifier
=
require
(
'
../deployments/kovan/OVM_FraudVerifier.json
'
)
const
kovan__OVM_L1CrossDomainMessenger
=
require
(
'
../deployments/kovan/OVM_L1CrossDomainMessenger.json
'
)
const
kovan__OVM_L1MultiMessageRelayer
=
require
(
'
../deployments/kovan/OVM_L1MultiMessageRelayer.json
'
)
const
kovan__OVM_SafetyChecker
=
require
(
'
../deployments/kovan/OVM_SafetyChecker.json
'
)
const
kovan__OVM_StateCommitmentChain
=
require
(
'
../deployments/kovan/OVM_StateCommitmentChain.json
'
)
const
kovan__OVM_StateManagerFactory
=
require
(
'
../deployments/kovan/OVM_StateManagerFactory.json
'
)
const
kovan__OVM_StateTransitionerFactory
=
require
(
'
../deployments/kovan/OVM_StateTransitionerFactory.json
'
)
const
kovan__Proxy__OVM_L1CrossDomainMessenger
=
require
(
'
../deployments/kovan/Proxy__OVM_L1CrossDomainMessenger.json
'
)
const
kovan__Proxy__OVM_L1StandardBridge
=
require
(
'
../deployments/kovan/Proxy__OVM_L1StandardBridge.json
'
)
const
mainnet__Lib_AddressManager
=
require
(
'
../deployments/mainnet/Lib_AddressManager.json
'
)
const
mainnet__mockOVM_BondManager
=
require
(
'
../deployments/mainnet/mockOVM_BondManager.json
'
)
const
mainnet__OVM_CanonicalTransactionChain
=
require
(
'
../deployments/mainnet/OVM_CanonicalTransactionChain.json
'
)
const
mainnet__OVM_ChainStorageContainer_CTC_batches
=
require
(
'
../deployments/mainnet/OVM_ChainStorageContainer-CTC-batches.json
'
)
const
mainnet__OVM_ChainStorageContainer_CTC_queue
=
require
(
'
../deployments/mainnet/OVM_ChainStorageContainer-CTC-queue.json
'
)
const
mainnet__OVM_ChainStorageContainer_SCC_batches
=
require
(
'
../deployments/mainnet/OVM_ChainStorageContainer-SCC-batches.json
'
)
const
mainnet__OVM_ExecutionManager
=
require
(
'
../deployments/mainnet/OVM_ExecutionManager.json
'
)
const
mainnet__OVM_FraudVerifier
=
require
(
'
../deployments/mainnet/OVM_FraudVerifier.json
'
)
const
mainnet__OVM_L1CrossDomainMessenger
=
require
(
'
../deployments/mainnet/OVM_L1CrossDomainMessenger.json
'
)
const
mainnet__OVM_L1MultiMessageRelayer
=
require
(
'
../deployments/mainnet/OVM_L1MultiMessageRelayer.json
'
)
const
mainnet__OVM_SafetyChecker
=
require
(
'
../deployments/mainnet/OVM_SafetyChecker.json
'
)
const
mainnet__OVM_StateCommitmentChain
=
require
(
'
../deployments/mainnet/OVM_StateCommitmentChain.json
'
)
const
mainnet__OVM_StateManagerFactory
=
require
(
'
../deployments/mainnet/OVM_StateManagerFactory.json
'
)
const
mainnet__OVM_StateTransitionerFactory
=
require
(
'
../deployments/mainnet/OVM_StateTransitionerFactory.json
'
)
const
mainnet__Proxy__OVM_L1CrossDomainMessenger
=
require
(
'
../deployments/mainnet/Proxy__OVM_L1CrossDomainMessenger.json
'
)
const
mainnet__Proxy__OVM_L1StandardBridge
=
require
(
'
../deployments/mainnet/Proxy__OVM_L1StandardBridge.json
'
)
const
optimistic_kovan__OVM_GasPriceOracle
=
require
(
'
../deployments/optimistic-kovan/OVM_GasPriceOracle.json
'
)
const
optimistic_kovan__OVM_L2StandardTokenFactory
=
require
(
'
../deployments/optimistic-kovan/OVM_L2StandardTokenFactory.json
'
)
export
const
getDeployedContractArtifact
=
(
name
:
string
,
network
:
string
):
any
=>
{
return
{
goerli__Lib_AddressManager
:
goerli__Lib_AddressManager
,
goerli__mockOVM_BondManager
:
goerli__mockOVM_BondManager
,
goerli__OVM_CanonicalTransactionChain
:
goerli__OVM_CanonicalTransactionChain
,
goerli__OVM_ChainStorageContainer_CTC_batches
:
goerli__OVM_ChainStorageContainer_CTC_batches
,
goerli__OVM_ChainStorageContainer_CTC_queue
:
goerli__OVM_ChainStorageContainer_CTC_queue
,
goerli__OVM_ChainStorageContainer_SCC_batches
:
goerli__OVM_ChainStorageContainer_SCC_batches
,
goerli__OVM_ExecutionManager
:
goerli__OVM_ExecutionManager
,
goerli__OVM_FraudVerifier
:
goerli__OVM_FraudVerifier
,
goerli__OVM_L1CrossDomainMessenger
:
goerli__OVM_L1CrossDomainMessenger
,
goerli__OVM_L1ETHGateway
:
goerli__OVM_L1ETHGateway
,
goerli__OVM_L1MultiMessageRelayer
:
goerli__OVM_L1MultiMessageRelayer
,
goerli__OVM_SafetyChecker
:
goerli__OVM_SafetyChecker
,
goerli__OVM_StateCommitmentChain
:
goerli__OVM_StateCommitmentChain
,
goerli__OVM_StateManagerFactory
:
goerli__OVM_StateManagerFactory
,
goerli__OVM_StateTransitionerFactory
:
goerli__OVM_StateTransitionerFactory
,
goerli__Proxy__OVM_L1CrossDomainMessenger
:
goerli__Proxy__OVM_L1CrossDomainMessenger
,
goerli__Proxy__OVM_L1ETHGateway
:
goerli__Proxy__OVM_L1ETHGateway
,
goerli__Proxy__OVM_L1StandardBridge
:
goerli__Proxy__OVM_L1StandardBridge
,
kovan__Lib_AddressManager
:
kovan__Lib_AddressManager
,
kovan__mockOVM_BondManager
:
kovan__mockOVM_BondManager
,
kovan__OVM_CanonicalTransactionChain
:
kovan__OVM_CanonicalTransactionChain
,
kovan__OVM_ChainStorageContainer_CTC_batches
:
kovan__OVM_ChainStorageContainer_CTC_batches
,
kovan__OVM_ChainStorageContainer_CTC_queue
:
kovan__OVM_ChainStorageContainer_CTC_queue
,
kovan__OVM_ChainStorageContainer_SCC_batches
:
kovan__OVM_ChainStorageContainer_SCC_batches
,
kovan__OVM_ExecutionManager
:
kovan__OVM_ExecutionManager
,
kovan__OVM_FraudVerifier
:
kovan__OVM_FraudVerifier
,
kovan__OVM_L1CrossDomainMessenger
:
kovan__OVM_L1CrossDomainMessenger
,
kovan__OVM_L1MultiMessageRelayer
:
kovan__OVM_L1MultiMessageRelayer
,
kovan__OVM_SafetyChecker
:
kovan__OVM_SafetyChecker
,
kovan__OVM_StateCommitmentChain
:
kovan__OVM_StateCommitmentChain
,
kovan__OVM_StateManagerFactory
:
kovan__OVM_StateManagerFactory
,
kovan__OVM_StateTransitionerFactory
:
kovan__OVM_StateTransitionerFactory
,
kovan__Proxy__OVM_L1CrossDomainMessenger
:
kovan__Proxy__OVM_L1CrossDomainMessenger
,
kovan__Proxy__OVM_L1StandardBridge
:
kovan__Proxy__OVM_L1StandardBridge
,
mainnet__Lib_AddressManager
:
mainnet__Lib_AddressManager
,
mainnet__mockOVM_BondManager
:
mainnet__mockOVM_BondManager
,
mainnet__OVM_CanonicalTransactionChain
:
mainnet__OVM_CanonicalTransactionChain
,
mainnet__OVM_ChainStorageContainer_CTC_batches
:
mainnet__OVM_ChainStorageContainer_CTC_batches
,
mainnet__OVM_ChainStorageContainer_CTC_queue
:
mainnet__OVM_ChainStorageContainer_CTC_queue
,
mainnet__OVM_ChainStorageContainer_SCC_batches
:
mainnet__OVM_ChainStorageContainer_SCC_batches
,
mainnet__OVM_ExecutionManager
:
mainnet__OVM_ExecutionManager
,
mainnet__OVM_FraudVerifier
:
mainnet__OVM_FraudVerifier
,
mainnet__OVM_L1CrossDomainMessenger
:
mainnet__OVM_L1CrossDomainMessenger
,
mainnet__OVM_L1MultiMessageRelayer
:
mainnet__OVM_L1MultiMessageRelayer
,
mainnet__OVM_SafetyChecker
:
mainnet__OVM_SafetyChecker
,
mainnet__OVM_StateCommitmentChain
:
mainnet__OVM_StateCommitmentChain
,
mainnet__OVM_StateManagerFactory
:
mainnet__OVM_StateManagerFactory
,
mainnet__OVM_StateTransitionerFactory
:
mainnet__OVM_StateTransitionerFactory
,
mainnet__Proxy__OVM_L1CrossDomainMessenger
:
mainnet__Proxy__OVM_L1CrossDomainMessenger
,
mainnet__Proxy__OVM_L1StandardBridge
:
mainnet__Proxy__OVM_L1StandardBridge
,
optimistic_kovan__OVM_GasPriceOracle
:
optimistic_kovan__OVM_GasPriceOracle
,
optimistic_kovan__OVM_L2StandardTokenFactory
:
optimistic_kovan__OVM_L2StandardTokenFactory
}[(
network
+
'
__
'
+
name
).
replace
(
/-/g
,
'
_
'
)]
}
\ No newline at end of file
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