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
3f4bf7a3
Unverified
Commit
3f4bf7a3
authored
Nov 19, 2021
by
Mark Tyneway
Committed by
GitHub
Nov 19, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1725 from ethereum-optimism/test/predeploys
regenesis-surgery: predeploy tests
parents
d14693e1
d5226e85
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
236 additions
and
19 deletions
+236
-19
package.json
packages/regenesis-surgery/package.json
+3
-2
predeploy.spec.ts
packages/regenesis-surgery/test/predeploy.spec.ts
+226
-13
setup.ts
packages/regenesis-surgery/test/setup.ts
+5
-0
uniswap.spec.ts
packages/regenesis-surgery/test/uniswap.spec.ts
+1
-3
yarn.lock
yarn.lock
+1
-1
No files found.
packages/regenesis-surgery/package.json
View file @
3f4bf7a3
...
...
@@ -56,13 +56,14 @@
"eslint-plugin-prettier"
:
"^3.4.0"
,
"eslint-plugin-react"
:
"^7.24.0"
,
"eslint-plugin-unicorn"
:
"^32.0.1"
,
"ethereum-waffle"
:
"^3.4.0"
,
"ethereumjs-util"
:
"^7.1.3"
,
"ethers"
:
"^5.4.5"
,
"lint-staged"
:
"11.0.0"
,
"mocha"
:
"^9.1.2"
,
"node-fetch"
:
"2.6.5"
,
"solc"
:
"0.8.7-fixed"
,
"ts-
node"
:
"^10
.0.0"
,
"ts-
mocha"
:
"^8
.0.0"
"ts-
mocha"
:
"^8
.0.0"
,
"ts-
node"
:
"^10
.0.0"
}
}
packages/regenesis-surgery/test/predeploy.spec.ts
View file @
3f4bf7a3
/* eslint-disable @typescript-eslint/no-empty-function */
describe
.
skip
(
'
predeploys
'
,
()
=>
{
import
{
ethers
,
BigNumber
,
Contract
}
from
'
ethers
'
import
{
expect
,
env
,
ERC20_ABI
}
from
'
./setup
'
import
{
AccountType
}
from
'
../scripts/types
'
import
{
GenesisJsonProvider
}
from
'
./provider
'
describe
(
'
predeploys
'
,
()
=>
{
const
predeploys
=
{
eth
:
[],
newNotEth
:
[],
noWipe
:
[],
wipe
:
[],
weth
:
[],
}
// Base genesis file only
let
genesisStateProvider
:
GenesisJsonProvider
// Old sequencer state
let
oldStateProvider
:
GenesisJsonProvider
before
(
async
()
=>
{
await
env
.
init
()
predeploys
.
eth
=
env
.
getAccountsByType
(
AccountType
.
PREDEPLOY_ETH
)
predeploys
.
newNotEth
=
env
.
getAccountsByType
(
AccountType
.
PREDEPLOY_NEW_NOT_ETH
)
predeploys
.
noWipe
=
env
.
getAccountsByType
(
AccountType
.
PREDEPLOY_NO_WIPE
)
predeploys
.
wipe
=
env
.
getAccountsByType
(
AccountType
.
PREDEPLOY_WIPE
)
predeploys
.
weth
=
env
.
getAccountsByType
(
AccountType
.
PREDEPLOY_WETH
)
genesisStateProvider
=
new
GenesisJsonProvider
(
env
.
surgeryDataSources
.
genesis
)
oldStateProvider
=
new
GenesisJsonProvider
(
env
.
surgeryDataSources
.
configs
.
stateDumpFilePath
)
})
describe
(
'
new predeploys that are not ETH
'
,
()
=>
{
it
(
'
should have the exact state specified in the base genesis file
'
,
async
()
=>
{})
for
(
const
[
i
,
account
]
of
predeploys
.
newNotEth
.
entries
())
{
describe
(
`account
${
i
}
/
${
predeploys
.
newNotEth
.
length
}
(
${
account
.
address
}
)`
,
()
=>
{
it
(
'
should have the exact state specified in the base genesis file
'
,
async
()
=>
{
const
preBytecode
=
await
genesisStateProvider
.
getCode
(
account
.
address
)
const
postBytecode
=
await
env
.
postL2Provider
.
getCode
(
account
.
address
)
expect
(
preBytecode
).
to
.
eq
(
postBytecode
)
const
dumpAccount
=
env
.
surgeryDataSources
.
dump
.
find
(
(
a
)
=>
a
.
address
===
account
.
address
)
if
(
dumpAccount
.
storage
)
{
for
(
const
key
of
Object
.
keys
(
dumpAccount
.
storage
))
{
const
pre
=
await
env
.
preL2Provider
.
getStorageAt
(
account
.
address
,
BigNumber
.
from
(
key
)
)
const
post
=
await
env
.
postL2Provider
.
getStorageAt
(
account
.
address
,
BigNumber
.
from
(
key
)
)
expect
(
pre
).
to
.
deep
.
eq
(
post
)
}
}
const
preNonce
=
await
genesisStateProvider
.
getTransactionCount
(
account
.
address
,
env
.
config
.
stateDumpHeight
)
const
postNonce
=
await
env
.
postL2Provider
.
getTransactionCount
(
account
.
address
)
expect
(
preNonce
).
to
.
deep
.
eq
(
postNonce
)
const
preBalance
=
await
genesisStateProvider
.
getBalance
(
account
.
address
,
env
.
config
.
stateDumpHeight
)
const
postBalance
=
await
env
.
postL2Provider
.
getBalance
(
account
.
address
)
expect
(
preBalance
).
to
.
deep
.
eq
(
postBalance
)
})
})
}
})
describe
(
'
predeploys where the old state should be wiped
'
,
()
=>
{
it
(
'
should have the code and storage of the base genesis file
'
,
async
()
=>
{})
for
(
const
[
i
,
account
]
of
predeploys
.
wipe
.
entries
())
{
describe
(
`account
${
i
}
/
${
predeploys
.
wipe
.
length
}
(
${
account
.
address
}
)`
,
()
=>
{
it
(
'
should have the code and storage of the base genesis file
'
,
async
()
=>
{
const
preBytecode
=
await
genesisStateProvider
.
getCode
(
account
.
address
)
const
postBytecode
=
await
env
.
postL2Provider
.
getCode
(
account
.
address
)
expect
(
preBytecode
).
to
.
eq
(
postBytecode
)
const
dumpAccount
=
env
.
surgeryDataSources
.
dump
.
find
(
(
a
)
=>
a
.
address
===
account
.
address
)
if
(
dumpAccount
.
storage
)
{
for
(
const
key
of
Object
.
keys
(
dumpAccount
.
storage
))
{
const
pre
=
await
env
.
preL2Provider
.
getStorageAt
(
account
.
address
,
BigNumber
.
from
(
key
)
)
const
post
=
await
env
.
postL2Provider
.
getStorageAt
(
account
.
address
,
BigNumber
.
from
(
key
)
)
expect
(
pre
).
to
.
deep
.
eq
(
post
)
}
}
})
it
(
'
should have the same nonce and balance as before
'
,
async
()
=>
{})
it
(
'
should have the same nonce and balance as before
'
,
async
()
=>
{
const
preNonce
=
await
oldStateProvider
.
getTransactionCount
(
account
.
address
,
env
.
config
.
stateDumpHeight
)
const
postNonce
=
await
env
.
postL2Provider
.
getTransactionCount
(
account
.
address
)
expect
(
preNonce
).
to
.
deep
.
eq
(
postNonce
)
const
preBalance
=
await
oldStateProvider
.
getBalance
(
account
.
address
,
env
.
config
.
stateDumpHeight
)
const
postBalance
=
await
env
.
postL2Provider
.
getBalance
(
account
.
address
)
expect
(
preBalance
).
to
.
deep
.
eq
(
postBalance
)
})
})
}
})
describe
(
'
predeploys where the old state should be preserved
'
,
()
=>
{
it
(
'
should have the code of the base genesis file
'
,
async
()
=>
{})
for
(
const
[
i
,
account
]
of
predeploys
.
noWipe
.
entries
())
{
describe
(
`account
${
i
}
/
${
predeploys
.
noWipe
.
length
}
(
${
account
.
address
}
)`
,
()
=>
{
it
(
'
should have the code of the base genesis file
'
,
async
()
=>
{
const
preBytecode
=
await
genesisStateProvider
.
getCode
(
account
.
address
)
const
postBytecode
=
await
env
.
postL2Provider
.
getCode
(
account
.
address
)
expect
(
preBytecode
).
to
.
eq
(
postBytecode
)
})
it
(
'
should have the combined storage of the old and new state
'
,
async
()
=>
{
const
dumpAccount
=
env
.
surgeryDataSources
.
dump
.
find
(
(
a
)
=>
a
.
address
===
account
.
address
)
if
(
dumpAccount
.
storage
)
{
for
(
const
key
of
Object
.
keys
(
dumpAccount
.
storage
))
{
const
pre
=
await
env
.
preL2Provider
.
getStorageAt
(
account
.
address
,
BigNumber
.
from
(
key
)
)
const
post
=
await
env
.
postL2Provider
.
getStorageAt
(
account
.
address
,
BigNumber
.
from
(
key
)
)
expect
(
pre
).
to
.
deep
.
eq
(
post
)
}
}
})
it
(
'
should have the combined storage of the old and new state
'
,
async
()
=>
{})
it
(
'
should have the same nonce and balance as before
'
,
async
()
=>
{
const
preNonce
=
await
oldStateProvider
.
getTransactionCount
(
account
.
address
,
env
.
config
.
stateDumpHeight
)
const
postNonce
=
await
env
.
postL2Provider
.
getTransactionCount
(
account
.
address
)
expect
(
preNonce
).
to
.
deep
.
eq
(
postNonce
)
it
(
'
should have the same nonce and balance as before
'
,
async
()
=>
{})
const
preBalance
=
await
oldStateProvider
.
getBalance
(
account
.
address
,
env
.
config
.
stateDumpHeight
)
const
postBalance
=
await
env
.
postL2Provider
.
getBalance
(
account
.
address
)
expect
(
preBalance
).
to
.
deep
.
eq
(
postBalance
)
})
})
}
})
describe
(
'
OVM_ETH
'
,
()
=>
{
it
(
'
should have disabled ERC20 features
'
,
async
()
=>
{})
if
(
!
env
.
hasLiveProviders
())
{
console
.
log
(
'
Cannot run pool contract tests without live provider
'
)
return
}
let
OVM_ETH
:
Contract
before
(
async
()
=>
{
OVM_ETH
=
new
ethers
.
Contract
(
predeploys
.
eth
[
0
].
address
,
ERC20_ABI
,
env
.
postL2Provider
)
})
it
(
'
should no recorded balance for the contracts that move to WETH9
'
,
async
()
=>
{})
for
(
const
[
i
,
account
]
of
predeploys
.
eth
.
entries
())
{
describe
(
`account
${
i
}
/
${
predeploys
.
eth
.
length
}
(
${
account
.
address
}
)`
,
()
=>
{
it
(
'
should have disabled ERC20 features
'
,
async
()
=>
{
await
expect
(
OVM_ETH
.
transfer
(
account
.
address
,
100
)
).
to
.
be
.
revertedWith
(
'
OVM_ETH: transfer is disabled pending further community discussion.
'
)
})
it
(
'
should have a new balance for WETH9 equal to the sum of the moved contract balances
'
,
async
()
=>
{})
it
(
'
should have a new balance for WETH9 equal to the sum of the moved contract balances
'
,
async
()
=>
{
// need live provider for WETH balances
})
})
}
})
describe
(
'
WETH9
'
,
()
=>
{
it
(
'
should have balances for each contract that should move
'
,
async
()
=>
{})
for
(
const
[
i
,
account
]
of
predeploys
.
weth
.
entries
())
{
describe
(
`account
${
i
}
/
${
predeploys
.
weth
.
length
}
(
${
account
.
address
}
)`
,
()
=>
{
it
(
'
should no recorded ETH balance
'
,
async
()
=>
{
const
postBalance
=
await
env
.
postL2Provider
.
getBalance
(
account
.
address
)
expect
(
postBalance
.
toNumber
()).
to
.
eq
(
0
)
})
it
(
'
should have WETH balances for each contract that should move
'
,
async
()
=>
{
if
(
!
env
.
hasLiveProviders
())
{
console
.
log
(
'
Cannot run pool contract tests without live provider
'
)
return
}
})
it
(
'
should have a balance equal to the sum of all moved balances
'
,
async
()
=>
{})
it
(
'
should have a balance equal to the sum of all moved balances
'
,
async
()
=>
{
if
(
!
env
.
hasLiveProviders
())
{
console
.
log
(
'
Cannot run pool contract tests without live provider
'
)
return
}
})
})
}
})
})
packages/regenesis-surgery/test/setup.ts
View file @
3f4bf7a3
...
...
@@ -5,6 +5,7 @@ import chaiAsPromised from 'chai-as-promised'
import
*
as
dotenv
from
'
dotenv
'
import
{
getenv
,
remove0x
}
from
'
@eth-optimism/core-utils
'
import
{
providers
,
BigNumber
}
from
'
ethers
'
import
{
solidity
}
from
'
ethereum-waffle
'
import
{
SurgeryDataSources
,
Account
,
AccountType
}
from
'
../scripts/types
'
import
{
loadSurgeryData
}
from
'
../scripts/data
'
import
{
classify
}
from
'
../scripts/classifiers
'
...
...
@@ -12,6 +13,7 @@ import { GenesisJsonProvider } from './provider'
// Chai plugins go here.
chai
.
use
(
chaiAsPromised
)
chai
.
use
(
solidity
)
const
should
=
chai
.
should
()
const
expect
=
chai
.
expect
...
...
@@ -19,6 +21,9 @@ const expect = chai.expect
dotenv
.
config
()
export
const
NUM_ACCOUNTS_DIVISOR
=
4096
export
const
ERC20_ABI
=
[
'
function balanceOf(address owner) view returns (uint256)
'
,
]
interface
TestEnvConfig
{
preL2ProviderUrl
:
string
|
null
...
...
packages/regenesis-surgery/test/uniswap.spec.ts
View file @
3f4bf7a3
...
...
@@ -2,11 +2,9 @@ import { ethers } from 'ethers'
import
{
abi
as
UNISWAP_POOL_ABI
}
from
'
@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json
'
import
{
UNISWAP_V3_NFPM_ADDRESS
}
from
'
../scripts/constants
'
import
{
getUniswapV3Factory
,
replaceWETH
}
from
'
../scripts/utils
'
import
{
expect
,
env
}
from
'
./setup
'
import
{
expect
,
env
,
ERC20_ABI
}
from
'
./setup
'
import
{
AccountType
}
from
'
../scripts/types
'
const
ERC20_ABI
=
[
'
function balanceOf(address owner) view returns (uint256)
'
]
describe
(
'
uniswap contracts
'
,
()
=>
{
before
(
async
()
=>
{
await
env
.
init
()
...
...
yarn.lock
View file @
3f4bf7a3
...
...
@@ -6861,7 +6861,7 @@ ethereum-cryptography@^0.1.2, ethereum-cryptography@^0.1.3:
secp256k1 "^4.0.1"
setimmediate "^1.0.5"
ethereum-waffle@^3.3.0:
ethereum-waffle@^3.3.0
, ethereum-waffle@^3.4.0
:
version "3.4.0"
resolved "https://registry.yarnpkg.com/ethereum-waffle/-/ethereum-waffle-3.4.0.tgz#990b3c6c26db9c2dd943bf26750a496f60c04720"
integrity sha512-ADBqZCkoSA5Isk486ntKJVjFEawIiC+3HxNqpJqONvh3YXBTNiRfXvJtGuAFLXPG91QaqkGqILEHANAo7j/olQ==
...
...
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