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
277a62a5
Commit
277a62a5
authored
Jan 17, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move helper var declarations to the package level
Remove logger
parent
546d3034
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
+12
-15
system_config.go
op-node/rollup/derive/system_config.go
+12
-15
No files found.
op-node/rollup/derive/system_config.go
View file @
277a62a5
...
...
@@ -8,7 +8,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/hashicorp/go-multierror"
"github.com/ethereum-optimism/optimism/op-node/eth"
...
...
@@ -30,17 +29,15 @@ var (
var
(
// A left-padded uint256 equal to 32.
O
neWordUint
=
common
.
Hash
{
31
:
32
}
o
neWordUint
=
common
.
Hash
{
31
:
32
}
// A left-padded uint256 equal to 64.
T
woWordUint
=
common
.
Hash
{
31
:
64
}
t
woWordUint
=
common
.
Hash
{
31
:
64
}
// 24 zero bytes (the padding for a uint64 in a 32 byte word)
U
int64Padding
=
make
([]
byte
,
24
)
u
int64Padding
=
make
([]
byte
,
24
)
// 12 zero bytes (the padding for an Ethereum address in a 32 byte word)
A
ddressPadding
=
make
([]
byte
,
12
)
a
ddressPadding
=
make
([]
byte
,
12
)
)
var
logger
=
log
.
New
(
"derive"
,
"system_config"
)
// UpdateSystemConfigWithL1Receipts filters all L1 receipts to find config updates and applies the config updates to the given sysCfg
func
UpdateSystemConfigWithL1Receipts
(
sysCfg
*
eth
.
SystemConfig
,
receipts
[]
*
types
.
Receipt
,
cfg
*
rollup
.
Config
)
error
{
var
result
error
...
...
@@ -106,19 +103,19 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
switch
updateType
{
case
SystemConfigUpdateBatcher
:
// Read the pointer, it should always equal 32.
if
word
:=
readWord
();
word
!=
O
neWordUint
{
if
word
:=
readWord
();
word
!=
o
neWordUint
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
}
// Read the length, it should also always equal 32.
if
word
:=
readWord
();
word
!=
O
neWordUint
{
if
word
:=
readWord
();
word
!=
o
neWordUint
{
return
fmt
.
Errorf
(
"expected length to be 32 bytes, but got %s"
,
word
)
}
// Indexing `word` directly is always safe here, it is guaranteed to be 32 bytes in length.
// Check that the batcher address is correctly zero-padded.
word
:=
readWord
()
if
!
bytes
.
Equal
(
word
[
:
12
],
A
ddressPadding
)
{
if
!
bytes
.
Equal
(
word
[
:
12
],
a
ddressPadding
)
{
return
fmt
.
Errorf
(
"expected version 0 batcher hash with zero padding, but got %x"
,
word
)
}
destSysCfg
.
BatcherAddr
.
SetBytes
(
word
[
12
:
])
...
...
@@ -130,12 +127,12 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
return
nil
case
SystemConfigUpdateGasConfig
:
// Read the pointer, it should always equal 32.
if
word
:=
readWord
();
word
!=
O
neWordUint
{
if
word
:=
readWord
();
word
!=
o
neWordUint
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
}
// Read the length, it should always equal 64.
if
word
:=
readWord
();
word
!=
T
woWordUint
{
if
word
:=
readWord
();
word
!=
t
woWordUint
{
return
fmt
.
Errorf
(
"expected length to be 64 bytes, but got %s"
,
word
)
}
...
...
@@ -150,19 +147,19 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
return
nil
case
SystemConfigUpdateGasLimit
:
// Read the pointer, it should always equal 32.
if
word
:=
readWord
();
word
!=
O
neWordUint
{
if
word
:=
readWord
();
word
!=
o
neWordUint
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
}
// Read the length, it should also always equal 32.
if
word
:=
readWord
();
word
!=
O
neWordUint
{
if
word
:=
readWord
();
word
!=
o
neWordUint
{
return
fmt
.
Errorf
(
"expected length to be 32 bytes, but got %s"
,
word
)
}
// Indexing `word` directly is always safe here, it is guaranteed to be 32 bytes in length.
// Check that the gas limit is correctly zero-padded.
word
:=
readWord
()
if
!
bytes
.
Equal
(
word
[
:
24
],
U
int64Padding
)
{
if
!
bytes
.
Equal
(
word
[
:
24
],
u
int64Padding
)
{
return
fmt
.
Errorf
(
"expected zero padding for gaslimit, but got %x"
,
word
)
}
destSysCfg
.
GasLimit
=
binary
.
BigEndian
.
Uint64
(
word
[
24
:
])
...
...
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