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
2eb8cee5
Unverified
Commit
2eb8cee5
authored
Jul 25, 2023
by
Mark Tyneway
Committed by
GitHub
Jul 25, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6436 from ethereum-optimism/op-chain-ops/deploy-config-copy
op-chain-ops: deploy config copy
parents
c4edcd2e
d5480423
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
config.go
op-chain-ops/genesis/config.go
+16
-0
config_test.go
op-chain-ops/genesis/config_test.go
+16
-0
No files found.
op-chain-ops/genesis/config.go
View file @
2eb8cee5
...
...
@@ -169,6 +169,22 @@ type DeployConfig struct {
FundDevAccounts
bool
`json:"fundDevAccounts"`
}
// Copy will deeply copy the DeployConfig. This does a JSON roundtrip to copy
// which makes it easier to maintain, we do not need efficiency in this case.
func
(
d
*
DeployConfig
)
Copy
()
*
DeployConfig
{
raw
,
err
:=
json
.
Marshal
(
d
)
if
err
!=
nil
{
panic
(
err
)
}
cpy
:=
DeployConfig
{}
if
err
=
json
.
Unmarshal
(
raw
,
&
cpy
);
err
!=
nil
{
panic
(
err
)
}
return
&
cpy
}
// Check will ensure that the config is sane and return an error when it is not
func
(
d
*
DeployConfig
)
Check
()
error
{
if
d
.
L1StartingBlockTag
==
nil
{
...
...
op-chain-ops/genesis/config_test.go
View file @
2eb8cee5
...
...
@@ -48,3 +48,19 @@ func TestRegolithTimeAsOffset(t *testing.T) {
config
:=
&
DeployConfig
{
L2GenesisRegolithTimeOffset
:
&
regolithOffset
}
require
.
Equal
(
t
,
uint64
(
1500
+
5000
),
*
config
.
RegolithTime
(
5000
))
}
// TestCopy will copy a DeployConfig and ensure that the copy is equal to the original.
func
TestCopy
(
t
*
testing
.
T
)
{
b
,
err
:=
os
.
ReadFile
(
"testdata/test-deploy-config-full.json"
)
require
.
NoError
(
t
,
err
)
decoded
:=
new
(
DeployConfig
)
require
.
NoError
(
t
,
json
.
NewDecoder
(
bytes
.
NewReader
(
b
))
.
Decode
(
decoded
))
cpy
:=
decoded
.
Copy
()
require
.
EqualValues
(
t
,
decoded
,
cpy
)
offset
:=
hexutil
.
Uint64
(
100
)
cpy
.
L2GenesisRegolithTimeOffset
=
&
offset
require
.
NotEqual
(
t
,
decoded
,
cpy
)
}
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