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
12869fe9
Commit
12869fe9
authored
Apr 19, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sdk: update withdrawal gas limit
parent
6346058d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
cross-chain-messenger.ts
packages/sdk/src/cross-chain-messenger.ts
+3
-1
message-utils.ts
packages/sdk/src/utils/message-utils.ts
+9
-2
message-utils.spec.ts
packages/sdk/test/utils/message-utils.spec.ts
+4
-2
No files found.
packages/sdk/src/cross-chain-messenger.ts
View file @
12869fe9
...
@@ -26,6 +26,7 @@ import {
...
@@ -26,6 +26,7 @@ import {
BedrockCrossChainMessageProof
,
BedrockCrossChainMessageProof
,
decodeVersionedNonce
,
decodeVersionedNonce
,
encodeVersionedNonce
,
encodeVersionedNonce
,
getChainId
,
}
from
'
@eth-optimism/core-utils
'
}
from
'
@eth-optimism/core-utils
'
import
{
getContractInterface
,
predeploys
}
from
'
@eth-optimism/contracts
'
import
{
getContractInterface
,
predeploys
}
from
'
@eth-optimism/contracts
'
import
*
as
rlp
from
'
rlp
'
import
*
as
rlp
from
'
rlp
'
...
@@ -403,7 +404,8 @@ export class CrossChainMessenger {
...
@@ -403,7 +404,8 @@ export class CrossChainMessenger {
let
gasLimit
:
BigNumber
let
gasLimit
:
BigNumber
let
messageNonce
:
BigNumber
let
messageNonce
:
BigNumber
if
(
version
.
eq
(
0
))
{
if
(
version
.
eq
(
0
))
{
gasLimit
=
migratedWithdrawalGasLimit
(
encoded
)
const
chainID
=
await
getChainId
(
this
.
l2Provider
)
gasLimit
=
migratedWithdrawalGasLimit
(
encoded
,
chainID
)
messageNonce
=
resolved
.
messageNonce
messageNonce
=
resolved
.
messageNonce
}
else
{
}
else
{
const
receipt
=
await
this
.
l2Provider
.
getTransactionReceipt
(
const
receipt
=
await
this
.
l2Provider
.
getTransactionReceipt
(
...
...
packages/sdk/src/utils/message-utils.ts
View file @
12869fe9
...
@@ -41,10 +41,17 @@ export const hashMessageHash = (messageHash: string): string => {
...
@@ -41,10 +41,17 @@ export const hashMessageHash = (messageHash: string): string => {
/**
/**
* Compute the min gas limit for a migrated withdrawal.
* Compute the min gas limit for a migrated withdrawal.
*/
*/
export
const
migratedWithdrawalGasLimit
=
(
data
:
string
):
BigNumber
=>
{
export
const
migratedWithdrawalGasLimit
=
(
data
:
string
,
chainID
:
number
):
BigNumber
=>
{
// Compute the gas limit and cap at 25 million
// Compute the gas limit and cap at 25 million
const
dataCost
=
BigNumber
.
from
(
hexDataLength
(
data
)).
mul
(
16
)
const
dataCost
=
BigNumber
.
from
(
hexDataLength
(
data
)).
mul
(
16
)
let
minGasLimit
=
dataCost
.
add
(
200
_000
)
let
overhead
=
200
_000
if
(
chainID
!==
420
)
{
overhead
=
1
_000_000
}
let
minGasLimit
=
dataCost
.
add
(
overhead
)
if
(
minGasLimit
.
gt
(
25
_000_000
))
{
if
(
minGasLimit
.
gt
(
25
_000_000
))
{
minGasLimit
=
BigNumber
.
from
(
25
_000_000
)
minGasLimit
=
BigNumber
.
from
(
25
_000_000
)
}
}
...
...
packages/sdk/test/utils/message-utils.spec.ts
View file @
12869fe9
...
@@ -7,11 +7,13 @@ import {
...
@@ -7,11 +7,13 @@ import {
hashMessageHash
,
hashMessageHash
,
}
from
'
../../src/utils/message-utils
'
}
from
'
../../src/utils/message-utils
'
const
goerliChainID
=
420
describe
(
'
Message Utils
'
,
()
=>
{
describe
(
'
Message Utils
'
,
()
=>
{
describe
(
'
migratedWithdrawalGasLimit
'
,
()
=>
{
describe
(
'
migratedWithdrawalGasLimit
'
,
()
=>
{
it
(
'
should have a max of 25 million
'
,
()
=>
{
it
(
'
should have a max of 25 million
'
,
()
=>
{
const
data
=
'
0x
'
+
'
ff
'
.
repeat
(
15
_000_000
)
const
data
=
'
0x
'
+
'
ff
'
.
repeat
(
15
_000_000
)
const
result
=
migratedWithdrawalGasLimit
(
data
)
const
result
=
migratedWithdrawalGasLimit
(
data
,
goerliChainID
)
expect
(
result
).
to
.
eq
(
BigNumber
.
from
(
25
_000_000
))
expect
(
result
).
to
.
eq
(
BigNumber
.
from
(
25
_000_000
))
})
})
...
@@ -25,7 +27,7 @@ describe('Message Utils', () => {
...
@@ -25,7 +27,7 @@ describe('Message Utils', () => {
]
]
for
(
const
test
of
tests
)
{
for
(
const
test
of
tests
)
{
const
result
=
migratedWithdrawalGasLimit
(
test
.
input
)
const
result
=
migratedWithdrawalGasLimit
(
test
.
input
,
goerliChainID
)
expect
(
result
).
to
.
eq
(
test
.
result
)
expect
(
result
).
to
.
eq
(
test
.
result
)
}
}
})
})
...
...
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