Skip to content
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

Bugfix for GAS_NEXT of CREATE's #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

OlivierBBB
Copy link
Collaborator

  • exceptional CREATE's consume all gas
  • aborted CREATE's consume only the upfront gas cost
  • CREATE's that raise the Failure Condition F consume the upfront gas cost + the 63/64ths given to the child context which they don't get back
  • CREATE's with empty init code get those 63/64ths back immediately so from the zkevm POV don't pay for it at all
  • CREATE's with nonempty init code consume the upfront_gas_cost + 63/64ths which they provide to the child context (and may et back in part)

- exceptional CREATE's consume all gas
- aborted CREATE's consume only the upfront gas cost
- CREATE's that raise the Failure Condition F consume the upfront gas
cost + the 63/64ths given to the child context which they don't get back
- CREATE's with empty init code get those 63/64ths back immediately so
from the zkevm POV don't pay for it at all
- CREATE's with nonempty init code consume the upfront ga cost + the
63/64th's which they provide to the child context (and may et back in
part)
@OlivierBBB OlivierBBB self-assigned this Dec 2, 2024
@OlivierBBB OlivierBBB linked an issue Dec 2, 2024 that may be closed by this pull request
However, if the provided initialization code is \emph{empty}, then the execution context doesn't change and gets the entire ``\texttt{(63/64)-ths}'' back immediately.
The effective gas cost is therefore the \locCreateUpfrontGasCost{}.
If the provided initialization code is \emph{nonempty} then the execution context pays the \locCreateFullGasCost{}.
It \emph{may} get some of it back later down the line.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix. The issue was with Failure Condition F raising CREATE's not following the same pattern as other scenarios in \scenCreateNoContextChange

Copy link
Collaborator Author

@OlivierBBB OlivierBBB Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, Failure Condition F in the yellow paper, around page 12. Here we only care about the state collision bit, i.e. the first line

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the associated effect on returned gas
image

@OlivierBBB OlivierBBB mentioned this pull request Dec 2, 2024
\left\{ \begin{array}{lcl}
\If \scenCreateException _{i} = 1 & \Then & \gasNext _{i} = 0 ~ (\trash) \\
\If \scenCreateAbort _{i} = 1 & \Then & \gasNext _{i} = \gasActual _{i} - \locCreateUpfrontGasCost \\
\If \scenCreateFCond _{i} = 1 & \Then & \gasNext _{i} = \gasActual _{i} - \locCreateFullGasCost \\
Copy link
Collaborator Author

@OlivierBBB OlivierBBB Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line right here is the bug fix: scenario/CREATE_FAILURE_CONDITION had wrong gas comuptation

Copy link
Contributor

@lorenzogentile404 lorenzogentile404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CREATE gas cost fix
2 participants