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
118e9be0
Commit
118e9be0
authored
Jul 28, 2022
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: add some comments + cleanup
parent
1475b286
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
check-l2-config.ts
packages/contracts-bedrock/tasks/check-l2-config.ts
+1
-0
genesis-l2.ts
packages/contracts-bedrock/tasks/genesis-l2.ts
+9
-1
No files found.
packages/contracts-bedrock/tasks/check-l2-config.ts
View file @
118e9be0
...
...
@@ -22,6 +22,7 @@ task('check-l2-config', 'Validate L2 config')
)
const
bridge
=
await
OptimismMintableERC20Factory
.
bridge
()
console
.
log
(
`OptimismMintableERC20Factory.bridge() ->
${
bridge
}
`
)
if
(
bridge
!==
predeploys
.
L2StandardBridge
)
{
throw
new
Error
(
`L2StandardBridge not set correctly. Got
${
bridge
}
, expected
${
predeploys
.
L2StandardBridge
}
`
...
...
packages/contracts-bedrock/tasks/genesis-l2.ts
View file @
118e9be0
...
...
@@ -58,6 +58,7 @@ const getStorageLayout = async (
throw
new
Error
(
`Cannot locate storageLayout for
${
name
}
`
)
}
// Find the contract and source from the build info
const
findContractAndSource
=
(
name
:
string
,
buildInfo
:
BuildInfo
)
=>
{
const
sources
=
buildInfo
.
output
.
sources
const
contracts
=
buildInfo
.
output
.
contracts
...
...
@@ -107,18 +108,21 @@ const replaceImmutables = async (
outputContract
.
evm
.
deployedBytecode
.
immutableReferences
const
names
=
{}
// Recursively fine all of the immutables by traversing the solc output ast
const
findNames
=
(
ast
:
any
)
=>
{
//
console.log(ast)
//
Add the name of the variable if it is an immutable
const
isImmutable
=
ast
.
mutability
===
'
immutable
'
const
isASTNode
=
typeof
ast
.
name
===
'
string
'
&&
typeof
ast
.
id
===
'
number
'
if
(
isASTNode
&&
isImmutable
)
{
names
[
ast
.
name
]
=
ast
.
id
}
// Iterate over each node
if
(
Array
.
isArray
(
ast
.
nodes
))
{
for
(
const
node
of
ast
.
nodes
)
{
findNames
(
node
)
}
}
// Handle contracts that are inherited from
if
(
Array
.
isArray
(
ast
.
baseContracts
))
{
for
(
const
baseContract
of
ast
.
baseContracts
)
{
if
(
baseContract
.
baseName
)
{
...
...
@@ -137,6 +141,7 @@ const replaceImmutables = async (
let
deployedBytecode
=
artifact
.
deployedBytecode
const
presize
=
deployedBytecode
.
length
// For each of the immutables, put the value into the bytecode
for
(
const
[
key
,
value
]
of
Object
.
entries
(
immutables
))
{
const
astId
=
names
[
key
]
if
(
!
astId
)
{
...
...
@@ -157,6 +162,7 @@ const replaceImmutables = async (
}
}
// Ensure that the bytecode is the same size
if
(
presize
!==
deployedBytecode
.
length
)
{
throw
new
Error
(
`Size mismatch! Before
${
presize
}
, after
${
deployedBytecode
.
length
}
`
...
...
@@ -369,6 +375,8 @@ task('genesis-l2', 'create a genesis config')
}
}
// Note: this currently only supports up to 32 byte values.
// Things less than 32 bytes will be left padded with 0 bytes
const
immutables
=
{
OptimismMintableERC20Factory
:
{
bridge
:
predeploys
.
L2StandardBridge
,
...
...
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