-
Notifications
You must be signed in to change notification settings - Fork 545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(relayer): estimate l1 batch commit gas #659
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colinlyguo
force-pushed
the
feat-estimate-l1-batch-commit-gas
branch
6 times, most recently
from
July 20, 2023 05:42
3fe2276
to
801f109
Compare
colinlyguo
force-pushed
the
feat-estimate-l1-batch-commit-gas
branch
from
July 20, 2023 05:49
801f109
to
9f3709a
Compare
zimpha
reviewed
Jul 20, 2023
zimpha
previously approved these changes
Jul 22, 2023
HAOYUatHZ
reviewed
Jul 24, 2023
HAOYUatHZ
reviewed
Jul 24, 2023
Codecov upload limit reached
|
Thegaram
reviewed
Jul 24, 2023
zimpha
reviewed
Jul 27, 2023
zimpha
previously approved these changes
Jul 28, 2023
Thegaram
reviewed
Jul 28, 2023
zimpha
previously approved these changes
Jul 31, 2023
Thegaram
previously approved these changes
Jul 31, 2023
Thegaram
approved these changes
Jul 31, 2023
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose or design rationale of this PR
Describe your change. Make sure to answer these three questions: What does this PR do? Why does it do it? How does it do it?
What does this PR do?
Improving gas estimation for the relayer's batchCommit transactions to prevent exceeding the gas limit of the L1 block.
Why does it do it?
Previous gas estimation is very trivial and only acts as a placeholder.
How does it do it?
Summing gas usage of
SLOAD
,SSTORE
,STATICCALL
,keccak
withinbatchCommit
function of the contract. These operations represent the major components of gas consumption.calldata
:Gtxdatanonzero
), 4 gas per zero byte (Gtxdatazero
).SLOAD
:cold sload
inScrollChain
, cost2100
gas each, 5 timesaddress public messageQueue
cold sload
inL1MessageQueue
, cost2100
gas each,numL1Messages
timeswarm sload
inScrollChain
, cost100
gas each,numBlocks-1
timesaddress public messageQueue
SSTORE
:sstore with zero original value
inScrollChain
, cost20000
gas each, 1 timeSTATICCALL
: staticcall_messageQueue.getCrossDomainMessage
L1MessageQueue
, cost100
each,numL1Messages
timesL1MessageQueue
, cost2600
gas each, 1 timeL1MessageQueue
, cost100
gas each,numL1Messages-1
timeskeccak
: cost30 + 6 * ceil(size / 32)
gas each time89 + 32 * ceil(parent-batch-header-length / 256)
89 + 32 * ceil(current-batch-header-length / 256)
numChunks
times chunk data hash, with size:58 * numBlocks + 32 * numTxs
32 * numChunks
tx payload size
PR title
Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:
Deployment tag versioning
Has
tag
incommon/version.go
been updated?Breaking change label
Does this PR have the
breaking-change
label?