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
65afe1b2
Commit
65afe1b2
authored
Jan 17, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change `readIntoWord` -> `readWord`
parent
5a897e2a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
35 deletions
+14
-35
system_config.go
op-node/rollup/derive/system_config.go
+14
-35
No files found.
op-node/rollup/derive/system_config.go
View file @
65afe1b2
...
@@ -75,21 +75,17 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
...
@@ -75,21 +75,17 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
// Create a reader of the unindexed data
// Create a reader of the unindexed data
reader
:=
bytes
.
NewReader
(
ev
.
Data
)
reader
:=
bytes
.
NewReader
(
ev
.
Data
)
// Allocate a placeholder word to read into
word
:=
make
([]
byte
,
32
)
// Helper function to prevent code duplication.
// Helper function to prevent code duplication.
readIntoWord
:=
func
(
b
[]
byte
)
{
readWord
:=
func
()
[]
byte
{
// Sanity check that the byte array we're reading into is always 32 bytes in length.
// Allocate a new slice to return
if
len
(
b
)
!=
32
{
b
:=
make
([]
byte
,
32
)
panic
(
"invalid word length"
)
}
if
_
,
err
:=
reader
.
Read
(
b
);
err
!=
nil
{
if
_
,
err
:=
reader
.
Read
(
b
);
err
!=
nil
{
// The possible error returned by `Read` is ignored due to the length check of the unindexed data in
// The possible error returned by `Read` is ignored due to the length check of the unindexed data in
// all cases of the below switch statement. While we don't panic here, this log should *never* be emitted.
// all cases of the below switch statement. While we don't panic here, this log should *never* be emitted.
logger
.
Crit
(
"failed to read word from unindexed log data"
)
logger
.
Crit
(
"failed to read word from unindexed log data"
)
}
}
return
b
}
}
// Attempt to read unindexed data
// Attempt to read unindexed data
...
@@ -100,21 +96,18 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
...
@@ -100,21 +96,18 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
}
}
// Read the pointer, it should always equal 32.
// Read the pointer, it should always equal 32.
readIntoWord
(
word
)
if
word
:=
readWord
();
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
}
}
// Read the length, it should also always equal 32.
// Read the length, it should also always equal 32.
readIntoWord
(
word
)
if
word
:=
readWord
();
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected length to be 32 bytes, but got %s"
,
word
)
return
fmt
.
Errorf
(
"expected length to be 32 bytes, but got %s"
,
word
)
}
}
// Read the updated batcher address
readIntoWord
(
word
)
// Indexing `word` directly is always safe here, it is guaranteed to be 32 bytes in length.
// 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.
// Check that the batcher address is correctly zero-padded.
word
:=
readWord
()
if
!
bytes
.
Equal
(
word
[
:
12
],
make
([]
byte
,
12
))
{
if
!
bytes
.
Equal
(
word
[
:
12
],
make
([]
byte
,
12
))
{
return
fmt
.
Errorf
(
"expected version 0 batcher hash with zero padding, but got %x"
,
word
)
return
fmt
.
Errorf
(
"expected version 0 batcher hash with zero padding, but got %x"
,
word
)
}
}
...
@@ -126,29 +119,18 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
...
@@ -126,29 +119,18 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
}
}
// Read the pointer, it should always equal 32.
// Read the pointer, it should always equal 32.
readIntoWord
(
word
)
if
word
:=
readWord
();
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
}
}
// Read the length, it should always equal 64.
// Read the length, it should always equal 64.
readIntoWord
(
word
)
if
word
:=
readWord
();
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
64
})
{
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
64
})
{
return
fmt
.
Errorf
(
"expected length to be 64 bytes, but got %s"
,
word
)
return
fmt
.
Errorf
(
"expected length to be 64 bytes, but got %s"
,
word
)
}
}
// Read the overhead
readIntoWord
(
word
)
// Allocate a second word to read the scalar into
secondWord
:=
make
([]
byte
,
32
)
// Read the scalar
readIntoWord
(
secondWord
)
// Set the system config's overhead and scalar values to the values read from the log
// Set the system config's overhead and scalar values to the values read from the log
copy
(
destSysCfg
.
Overhead
[
:
],
word
)
copy
(
destSysCfg
.
Overhead
[
:
],
readWord
()
)
copy
(
destSysCfg
.
Scalar
[
:
],
secondWord
)
copy
(
destSysCfg
.
Scalar
[
:
],
readWord
()
)
return
nil
return
nil
case
SystemConfigUpdateGasLimit
:
case
SystemConfigUpdateGasLimit
:
if
len
(
ev
.
Data
)
!=
32
*
3
{
if
len
(
ev
.
Data
)
!=
32
*
3
{
...
@@ -156,21 +138,18 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
...
@@ -156,21 +138,18 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
}
}
// Read the pointer, it should always equal 32.
// Read the pointer, it should always equal 32.
readIntoWord
(
word
)
if
word
:=
readWord
();
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
}
}
// Read the length, it should also always equal 32.
// Read the length, it should also always equal 32.
readIntoWord
(
word
)
if
word
:=
readWord
();
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected length to be 32 bytes, but got %s"
,
word
)
return
fmt
.
Errorf
(
"expected length to be 32 bytes, but got %s"
,
word
)
}
}
// Read the gas limit
readIntoWord
(
word
)
// Indexing `word` directly is always safe here, it is guaranteed to be 32 bytes in length.
// 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.
// Check that the gas limit is correctly zero-padded.
word
:=
readWord
()
if
!
bytes
.
Equal
(
word
[
:
24
],
make
([]
byte
,
24
))
{
if
!
bytes
.
Equal
(
word
[
:
24
],
make
([]
byte
,
24
))
{
return
fmt
.
Errorf
(
"expected zero padding for gaslimit, but got %x"
,
word
)
return
fmt
.
Errorf
(
"expected zero padding for gaslimit, but got %x"
,
word
)
}
}
...
...
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