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
01319c57
Commit
01319c57
authored
May 08, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(migration): Mimic `xdm.baseGas` in `migrate.go`
parent
6d4f5253
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
5 deletions
+34
-5
migrate.go
op-chain-ops/crossdomain/migrate.go
+34
-5
No files found.
op-chain-ops/crossdomain/migrate.go
View file @
01319c57
...
...
@@ -19,6 +19,17 @@ var (
errLegacyStorageSlotNotFound
=
errors
.
New
(
"cannot find storage slot"
)
)
// Constants used by `CrossDomainMessenger.baseGas`
var
(
RelayConstantOverhead
uint64
=
200
_000
RelayPerByteDataCost
uint64
=
params
.
TxDataNonZeroGasEIP2028
MinGasDynamicOverheadNumerator
uint64
=
64
MinGasDynamicOverheadDenominator
uint64
=
63
RelayCallOverhead
uint64
=
40
_000
RelayReservedGas
uint64
=
40
_000
RelayGasCheckBuffer
uint64
=
5
_000
)
// MigrateWithdrawals will migrate a list of pending withdrawals given a StateDB.
func
MigrateWithdrawals
(
withdrawals
SafeFilteredWithdrawals
,
...
...
@@ -112,16 +123,34 @@ func MigrateWithdrawalGasLimit(data []byte, chainID *big.Int) uint64 {
// Compute the upper bound on the gas limit. This could be more
// accurate if individual 0 bytes and non zero bytes were accounted
// for.
dataCost
:=
uint64
(
len
(
data
))
*
params
.
TxDataNonZeroGasEIP2028
dataCost
:=
uint64
(
len
(
data
))
*
RelayPerByteDataCost
// Goerli has a lower gas limit than other chains.
overhead
:=
uint64
(
200
_000
)
if
chainID
.
Cmp
(
big
.
NewInt
(
420
))
!=
0
{
overhead
=
1
_000_000
var
overhead
uint64
if
chainID
.
Cmp
(
big
.
NewInt
(
420
))
==
0
{
overhead
=
uint64
(
200
_000
)
}
else
{
// Mimic `baseGas` from `CrossDomainMessenger.sol`
overhead
=
uint64
(
// Constant overhead
RelayConstantOverhead
+
// Dynamic overhead (EIP-150)
(
MinGasDynamicOverheadNumerator
*
1
_000_000
)
/
MinGasDynamicOverheadDenominator
+
// Gas reserved for the worst-case cost of 3/5 of the `CALL` opcode's dynamic gas
// factors. (Conservative)
RelayCallOverhead
+
// Relay reserved gas (to ensure execution of `relayMessage` completes after the
// subcontext finishes executing) (Conservative)
RelayReservedGas
+
// Gas reserved for the execution between the `hasMinGas` check and the `CALL`
// opcode. (Conservative)
RelayGasCheckBuffer
,
)
}
// Set the outer gas limit. This cannot be zero
// Set the outer
minimum
gas limit. This cannot be zero
gasLimit
:=
dataCost
+
overhead
// Cap the gas limit to be 25 million to prevent creating withdrawals
// that go over the block gas limit.
if
gasLimit
>
25
_000_000
{
...
...
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