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
e0235219
Unverified
Commit
e0235219
authored
Jan 09, 2023
by
Mark Tyneway
Committed by
GitHub
Jan 09, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4622 from ethereum-optimism/feat/genesis-magic-check
contracts-bedrock: check-l2 checks for genesis magic
parents
bb9fbc3c
8d560e15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
6 deletions
+76
-6
config.yml
.circleci/config.yml
+7
-2
check-l2.ts
packages/contracts-bedrock/tasks/check-l2.ts
+69
-4
No files found.
.circleci/config.yml
View file @
e0235219
...
@@ -595,7 +595,7 @@ jobs:
...
@@ -595,7 +595,7 @@ jobs:
make devnet-up-deploy
make devnet-up-deploy
-
run
:
-
run
:
name
:
Check L2 config
name
:
Check L2 config
command
:
npx hardhat check-l2 --network devnetL
2
command
:
npx hardhat check-l2 --network devnetL
1 --l2-rpc-url http://localhost:9545 --l1-rpc-url http://localhost:8545
working_directory
:
packages/contracts-bedrock
working_directory
:
packages/contracts-bedrock
-
run
:
-
run
:
name
:
Deposit ERC20 through the bridge
name
:
Deposit ERC20 through the bridge
...
@@ -645,7 +645,12 @@ jobs:
...
@@ -645,7 +645,12 @@ jobs:
make devnet-up
make devnet-up
-
run
:
-
run
:
name
:
Check L2 config
name
:
Check L2 config
command
:
npx hardhat check-l2 --network devnetL2
command
:
|
npx hardhat check-l2 \
--network devnetL1 \
--l2-rpc-url http://localhost:9545 \
--l1-rpc-url http://localhost:8545 \
--l2-output-oracle-address 0x6900000000000000000000000000000000000000
working_directory
:
packages/contracts-bedrock
working_directory
:
packages/contracts-bedrock
-
run
:
-
run
:
name
:
Deposit ERC20 through the bridge
name
:
Deposit ERC20 through the bridge
...
...
packages/contracts-bedrock/tasks/check-l2.ts
View file @
e0235219
...
@@ -4,7 +4,7 @@ import { task, types } from 'hardhat/config'
...
@@ -4,7 +4,7 @@ import { task, types } from 'hardhat/config'
import
'
@nomiclabs/hardhat-ethers
'
import
'
@nomiclabs/hardhat-ethers
'
import
'
hardhat-deploy
'
import
'
hardhat-deploy
'
import
{
HardhatRuntimeEnvironment
}
from
'
hardhat/types
'
import
{
HardhatRuntimeEnvironment
}
from
'
hardhat/types
'
import
{
Contract
,
providers
,
Wallet
,
Signer
}
from
'
ethers
'
import
{
Contract
,
providers
,
Wallet
,
Signer
,
BigNumber
}
from
'
ethers
'
import
{
predeploys
}
from
'
../src
'
import
{
predeploys
}
from
'
../src
'
...
@@ -131,6 +131,62 @@ const assertProxy = async (
...
@@ -131,6 +131,62 @@ const assertProxy = async (
}
}
}
}
// checks to make sure that the genesis magic value
// was set correctly
const
checkGenesisMagic
=
async
(
hre
:
HardhatRuntimeEnvironment
,
l2Provider
:
providers
.
Provider
,
args
)
=>
{
const
magic
=
'
0x
'
+
Buffer
.
from
(
'
BEDROCK
'
).
toString
(
'
hex
'
)
let
startingBlockNumber
:
number
// We have a connection to the L1 chain, fetch the remote value
if
(
args
.
l1RpcUrl
!==
''
)
{
const
l1Provider
=
new
hre
.
ethers
.
providers
.
StaticJsonRpcProvider
(
args
.
l1RpcUrl
)
// Get the address if it was passed in via CLI
// Otherwise get the address from a hardhat deployment file
let
address
:
string
if
(
args
.
l2OutputOracleAddress
!==
''
)
{
address
=
args
.
l2OutputOracleAddress
}
else
{
const
Deployment__L2OutputOracle
=
await
hre
.
deployments
.
get
(
'
L2OutputOracle
'
)
address
=
Deployment__L2OutputOracle
.
address
}
const
abi
=
{
inputs
:
[],
name
:
'
startingBlockNumber
'
,
outputs
:
[{
internalType
:
'
uint256
'
,
name
:
''
,
type
:
'
uint256
'
}],
stateMutability
:
'
view
'
,
type
:
'
function
'
,
}
const
L2OutputOracle
=
new
hre
.
ethers
.
Contract
(
address
,
[
abi
],
l1Provider
)
startingBlockNumber
=
await
L2OutputOracle
.
startingBlockNumber
()
}
else
{
// We do not have a connection to the L1 chain, use the local config
// The `--network` flag must be set to the L1 network
startingBlockNumber
=
hre
.
deployConfig
.
l2OutputOracleStartingBlockNumber
}
// ensure that the starting block number is a number
startingBlockNumber
=
BigNumber
.
from
(
startingBlockNumber
).
toNumber
()
const
block
=
await
l2Provider
.
getBlock
(
startingBlockNumber
)
const
extradata
=
block
.
extraData
if
(
extradata
!==
magic
)
{
throw
new
Error
(
'
magic value in extradata does not match
'
)
}
}
const
check
=
{
const
check
=
{
// LegacyMessagePasser
// LegacyMessagePasser
// - check version
// - check version
...
@@ -594,8 +650,15 @@ const check = {
...
@@ -594,8 +650,15 @@ const check = {
}
}
task
(
'
check-l2
'
,
'
Checks a freshly migrated L2 system for correct migration
'
)
task
(
'
check-l2
'
,
'
Checks a freshly migrated L2 system for correct migration
'
)
.
addOptionalParam
(
'
rpcUrl
'
,
'
RPC URL of the remote node
'
,
''
,
types
.
string
)
.
addOptionalParam
(
'
l1RpcUrl
'
,
'
L1 RPC URL of node
'
,
''
,
types
.
string
)
.
addOptionalParam
(
'
l2RpcUrl
'
,
'
L2 RPC URL of node
'
,
''
,
types
.
string
)
.
addOptionalParam
(
'
chainId
'
,
'
Expected chain id
'
,
0
,
types
.
int
)
.
addOptionalParam
(
'
chainId
'
,
'
Expected chain id
'
,
0
,
types
.
int
)
.
addOptionalParam
(
'
l2OutputOracleAddress
'
,
'
Address of the L2OutputOracle oracle
'
,
''
,
types
.
string
)
.
addOptionalParam
(
.
addOptionalParam
(
'
skipPredeployCheck
'
,
'
skipPredeployCheck
'
,
'
Skip long check
'
,
'
Skip long check
'
,
...
@@ -608,9 +671,9 @@ task('check-l2', 'Checks a freshly migrated L2 system for correct migration')
...
@@ -608,9 +671,9 @@ task('check-l2', 'Checks a freshly migrated L2 system for correct migration')
let
signer
:
Signer
=
hre
.
ethers
.
provider
.
getSigner
()
let
signer
:
Signer
=
hre
.
ethers
.
provider
.
getSigner
()
if
(
args
.
r
pcUrl
!==
''
)
{
if
(
args
.
l2R
pcUrl
!==
''
)
{
console
.
log
(
'
Using CLI URL for provider instead of hardhat network
'
)
console
.
log
(
'
Using CLI URL for provider instead of hardhat network
'
)
const
provider
=
new
hre
.
ethers
.
providers
.
JsonRpcProvider
(
args
.
r
pcUrl
)
const
provider
=
new
hre
.
ethers
.
providers
.
JsonRpcProvider
(
args
.
l2R
pcUrl
)
signer
=
Wallet
.
createRandom
().
connect
(
provider
)
signer
=
Wallet
.
createRandom
().
connect
(
provider
)
}
}
...
@@ -632,6 +695,8 @@ task('check-l2', 'Checks a freshly migrated L2 system for correct migration')
...
@@ -632,6 +695,8 @@ task('check-l2', 'Checks a freshly migrated L2 system for correct migration')
await
checkPredeploys
(
hre
,
signer
.
provider
)
await
checkPredeploys
(
hre
,
signer
.
provider
)
}
}
await
checkGenesisMagic
(
hre
,
signer
.
provider
,
args
)
console
.
log
()
console
.
log
()
// Check the currently configured predeploys
// Check the currently configured predeploys
for
(
const
[
name
,
fn
]
of
Object
.
entries
(
check
))
{
for
(
const
[
name
,
fn
]
of
Object
.
entries
(
check
))
{
...
...
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