Skip to content

EIP 3860: Limit and meter initcode #144

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

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

OlivierBBB
Copy link
Collaborator

Implementation of #59.

@OlivierBBB OlivierBBB added hardfork shanghai EIP's for the Shanghai hardfork London to Prague London to Pectra labels Mar 31, 2025
@OlivierBBB OlivierBBB added this to the London to Prague milestone Mar 31, 2025
@OlivierBBB OlivierBBB self-assigned this Mar 31, 2025
Copy link

cla-assistant bot commented Mar 31, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

For deployments:
- enforce init_code_size ≤ 49152
- compute R(||init_code||)
- update upfrontGasCost accordingly
OOB_INST_XCREATE no longer produces "HUB predictions".
This instruction now implicitly and silently verifies that
init_code_size ≤ 49152
- new CREATE(2) maxcsx diagram
- include stack/MAXCSX into case analysis
- include stack/MAXCSX case in high level diagram
\Then $\stackIcpx _{i} = 0$
\item
\If $\stackInst _{i} \neq \inst{RETURN}$ \et $\stackCreateFlag _{i} = 0$
\Then $\stackMaxcsx _{i} = 0$
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previously only RETURN could trigger invalidCodePrefixException and maxCodeSizeException. Now CREATE(2) can trigger maxCodeSizeException, too. So split analysis.

@@ -38,6 +39,8 @@
\def\locMxpMtntop {\col{\mxpMod\_mtntop}}
%
\def\locTriggerOob {\col{trigger\_\oobMod}}
\def\locTriggerOobX {\col{trigger\_\oobMod\_X}}
\def\locTriggerOobU {\col{trigger\_\oobMod\_U}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Two different OOB module triggers to keep things clean.

U stands for unexeptional
X stands for exceptional

\item \oobDataCol{k}, for $k = 1, 2, \dots, 9$: \godGiven{}
\item
\godGiven{}
\oobDataCol{k}, for $k = 1, 2, \dots, 10$:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

10th OOB data column

\subsection{For $\oobInstDeployment$} \label{oob: populating: opcodes: deployment} \input{opcodes/deployment}
\subsection{For $\oobInstXcall$} \label{oob: populating: opcodes: exceptional calls} \input{opcodes/xcall}
\subsection{For $\oobInstCall$} \label{oob: populating: opcodes: call} \input{opcodes/call}
\subsection{For $\oobInstXcreate$} \label{oob: populating: opcodes: xcreate} \input{opcodes/xcreate}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New OOB instruction + formatting

+ & \peekingSumStandardPrefix \\
+ & \peekContext _{i + \createExceptionCallerContextRowOffset} \\
\end{array} \right]
\]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't break the mould for exceptional CREATE's. It is inefficient (one does not need the current context row) but it simplifies everything not to differentiate.

@@ -6,6 +6,7 @@
\locIsCreate & \define & \decFlag{1} _{i - \createFirstStackRowOffset} \\
\locIsCreateTwo & \define & \decFlag{2} _{i - \createFirstStackRowOffset} \\
\locStaticx & \define & \stackStaticx _{i - \createFirstStackRowOffset} \\
\locMaxcsx & \define & \stackMaxcsx _{i - \createFirstStackRowOffset} \\
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

new shorthand

\item \locTriggerMmu{}
\item \locTriggerOob{}
\item \locTriggerOobX{}
\item \locTriggerOobU{}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

trigger_OOB now split in two (trigger_OOB_X and trigger_OOB_U) as explained earlier:

  • eXcecptional
  • Unexceptional

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Important: definition of the two OOB module triggers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New HUB -> OOB interface for OOB_INST_XCREATE instruction.

@@ -22,11 +22,12 @@
\locAbortingCondition & \define & \oobDataCol {7} _{i} & \prediction \\
\locFailureCondition & \define & \oobDataCol {8} _{i} & \prediction \\
\locCreatorNonce & \define & \oobDataCol {9} _{i} \\
\locInitCodeSize & \define & \oobDataCol {10} _{i} \\
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New 10th parameter of OOB_INST_CREATE instruction

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

RAS: new macros

Copy link
Collaborator Author

@OlivierBBB OlivierBBB Apr 2, 2025

Choose a reason for hiding this comment

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

ras: typo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Inclusion of XCREATE flag into shorthands.

@@ -215,10 +219,11 @@
\oobCtMaxCdl & \define & 0 \\
\oobCtMaxXcall & \define & 0 \\
\oobCtMaxCall & \define & 2 \\
\oobCtMaxCreate & \define & 3 \\
\oobCtMaxXcreate & \define & 0 \\
\oobCtMaxCreate & \define & 4 \\
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

1 more row due to new comparison for OOB_INST_CREATE

\newcommand{\maxCtTypeTwo} {\redm{8}}
\newcommand{\maxCtTypeZero} {\redm{9}}
\newcommand{\maxCtTypeOne} {\redm{10}}
\newcommand{\maxCtTypeTwo} {\redm{10}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Didn't carefully count, may have to figure out during implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

shoukd be ok, you added only two calls so ...

%
\input{computations/init_code_does_not_exceed_max_size}
\input{computations/init_code_pricing}
%
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New Pricing rows

+ \!\!\! & \locIsDep & \!\!\! \cdot \!\!\! & G_{\text{txcreate}} \\
+ \!\!\! & \locIsDep & \!\!\! \cdot \!\!\! & \locInitCodeCost \\
+ \!\!\! & & & G_{\text{transaction}} \\
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Extra pricing cost

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Valid (deployment) transactions must enforce init_code_size ≤ 49152.

Copy link
Collaborator Author

@OlivierBBB OlivierBBB Apr 2, 2025

Choose a reason for hiding this comment

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

Transactions pay an extra $G_{\text{initcodeword}} = 2$ gas number of words required to contain the initcode.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New OOB_INST_XCREATE instruction. Enforces that init_code_size (which at this point may still be huge, whence the hi/lo parts) be > 49152 bytes long

@OlivierBBB OlivierBBB changed the title EIP 3860: Limit and meter initcode EIP 3860 Arithmetization: Limit and meter initcode Apr 6, 2025
Copy link
Contributor

@letypequividelespoubelles letypequividelespoubelles left a comment

Choose a reason for hiding this comment

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

LGTM

\newcommand{\maxCtTypeTwo} {\redm{8}}
\newcommand{\maxCtTypeZero} {\redm{9}}
\newcommand{\maxCtTypeOne} {\redm{10}}
\newcommand{\maxCtTypeTwo} {\redm{10}}
Copy link
Contributor

Choose a reason for hiding this comment

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

shoukd be ok, you added only two calls so ...

@OlivierBBB OlivierBBB changed the title EIP 3860 Arithmetization: Limit and meter initcode EIP 3860: Limit and meter initcode Apr 8, 2025
@OlivierBBB OlivierBBB linked an issue Apr 8, 2025 that may be closed by this pull request
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arithmetization hardfork shanghai EIP's for the Shanghai hardfork London to Prague London to Pectra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EIP-3860: Limit and meter initcode
2 participants