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
ec73572d
Commit
ec73572d
authored
Jan 17, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a reader instead of offsets when parsing the `SystemConfig` update event in `op-node`
parent
d8e328ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
22 deletions
+87
-22
system_config.go
op-node/rollup/derive/system_config.go
+87
-22
No files found.
op-node/rollup/derive/system_config.go
View file @
ec73572d
...
...
@@ -69,50 +69,115 @@ func ProcessSystemConfigUpdateLogEvent(destSysCfg *eth.SystemConfig, ev *types.L
}
// indexed 1
updateType
:=
ev
.
Topics
[
2
]
// unindexed data
// Create a reader of the unindexed data
reader
:=
bytes
.
NewReader
(
ev
.
Data
)
// Allocate a placeholder word to read into
word
:=
make
([]
byte
,
32
)
// Attempt to read unindexed data
switch
updateType
{
case
SystemConfigUpdateBatcher
:
if
len
(
ev
.
Data
)
!=
32
*
3
{
return
fmt
.
Errorf
(
"expected 32*3 bytes in batcher hash update, but got %d bytes"
,
len
(
ev
.
Data
))
}
if
x
:=
common
.
BytesToHash
(
ev
.
Data
[
:
32
]);
x
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
x
)
// Attempt to read the pointer, it should always equal 32.
if
_
,
err
:=
reader
.
Read
(
word
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read pointer in batcher address update"
)
}
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
}
// Attempt to read the length, it should also always equal 32.
if
_
,
err
:=
reader
.
Read
(
word
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read length in batcher address update"
)
}
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected length to be 32 bytes, but got %s"
,
word
)
}
if
x
:=
common
.
BytesToHash
(
ev
.
Data
[
32
:
64
]);
x
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected length of 1 bytes32, but got %s"
,
x
)
// Attempt to read the batcher hash
if
_
,
err
:=
reader
.
Read
(
word
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read batcher hash in batcher address update"
)
}
if
!
bytes
.
Equal
(
ev
.
Data
[
64
:
64
+
12
],
make
([]
byte
,
12
))
{
return
fmt
.
Errorf
(
"expected version 0 batcher hash with zero padding, but got %x"
,
ev
.
Data
)
// 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.
if
!
bytes
.
Equal
(
word
[
:
12
],
make
([]
byte
,
12
))
{
return
fmt
.
Errorf
(
"expected version 0 batcher hash with zero padding, but got %x"
,
word
)
}
destSysCfg
.
BatcherAddr
.
SetBytes
(
ev
.
Data
[
64
+
12
:
])
destSysCfg
.
BatcherAddr
.
SetBytes
(
word
[
12
:
])
return
nil
case
SystemConfigUpdateGasConfig
:
// left padded uint8
case
SystemConfigUpdateGasConfig
:
if
len
(
ev
.
Data
)
!=
32
*
4
{
return
fmt
.
Errorf
(
"expected 32*4 bytes in GPO params update data, but got %d"
,
len
(
ev
.
Data
))
}
if
x
:=
common
.
BytesToHash
(
ev
.
Data
[
:
32
]);
x
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
x
)
// Attempt to read the pointer, it should always equal 32.
if
_
,
err
:=
reader
.
Read
(
word
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read pointer in GPO params update"
)
}
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
}
// Attempt to read the length, it should always equal 64.
if
_
,
err
:=
reader
.
Read
(
word
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read length in GPO params update"
)
}
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
64
})
{
return
fmt
.
Errorf
(
"expected length to be 64 bytes, but got %s"
,
word
)
}
// Attempt to read the overhead
if
_
,
err
:=
reader
.
Read
(
word
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read overhead in GPO params update"
)
}
if
x
:=
common
.
BytesToHash
(
ev
.
Data
[
32
:
64
]);
x
!=
(
common
.
Hash
{
31
:
64
})
{
return
fmt
.
Errorf
(
"expected length of 2 bytes32, but got %s"
,
x
)
// Allocate a second word to read the scalar into
secondWord
:=
make
([]
byte
,
32
)
// Attempt to read the scalar
if
_
,
err
:=
reader
.
Read
(
secondWord
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read scalar in GPO params update"
)
}
copy
(
destSysCfg
.
Overhead
[
:
],
ev
.
Data
[
64
:
96
])
copy
(
destSysCfg
.
Scalar
[
:
],
ev
.
Data
[
96
:
128
])
// Set the system config's overhead and scalar values to the values read from the log
copy
(
destSysCfg
.
Overhead
[
:
],
word
)
copy
(
destSysCfg
.
Scalar
[
:
],
secondWord
)
return
nil
case
SystemConfigUpdateGasLimit
:
if
len
(
ev
.
Data
)
!=
32
*
3
{
return
fmt
.
Errorf
(
"expected 32*3 bytes in gas limit update, but got %d bytes"
,
len
(
ev
.
Data
))
}
if
x
:=
common
.
BytesToHash
(
ev
.
Data
[
:
32
]);
x
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
x
)
// Attempt to read the pointer, it should always equal 32.
if
_
,
err
:=
reader
.
Read
(
word
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read pointer in gas limit update"
)
}
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected offset to point to length location, but got %s"
,
word
)
}
// Attempt to read the length, it should also always equal 32.
if
_
,
err
:=
reader
.
Read
(
word
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read length in gas limit update"
)
}
if
common
.
BytesToHash
(
word
)
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected length to be 32 bytes, but got %s"
,
word
)
}
if
x
:=
common
.
BytesToHash
(
ev
.
Data
[
32
:
64
]);
x
!=
(
common
.
Hash
{
31
:
32
})
{
return
fmt
.
Errorf
(
"expected length of 1 bytes32, but got %s"
,
x
)
// Attempt to read the gas limit
if
_
,
err
:=
reader
.
Read
(
word
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read gas limit in gas limit update"
)
}
if
!
bytes
.
Equal
(
ev
.
Data
[
64
:
64
+
24
],
make
([]
byte
,
24
))
{
return
fmt
.
Errorf
(
"expected zero padding for gaslimit, but got %x"
,
ev
.
Data
)
// 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.
if
!
bytes
.
Equal
(
word
[
:
24
],
make
([]
byte
,
24
))
{
return
fmt
.
Errorf
(
"expected zero padding for gaslimit, but got %x"
,
word
)
}
destSysCfg
.
GasLimit
=
binary
.
BigEndian
.
Uint64
(
ev
.
Data
[
64
+
24
:
])
destSysCfg
.
GasLimit
=
binary
.
BigEndian
.
Uint64
(
word
[
24
:
])
return
nil
case
SystemConfigUpdateUnsafeBlockSigner
:
// Ignored in derivation. This configurable applies to runtime configuration outside of the derivation.
...
...
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