-
Notifications
You must be signed in to change notification settings - Fork 20
EIP-3855: PUSH0
instruction
#145
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
Merged
+100
−34
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
\def\locIsPush {\col{is\_push}} | ||
\def\locIsPop {\col{is\_pop}} | ||
\def\locIsPushZero {\col{is\_push\_zero}} | ||
\def\locResultHi {\col{result\_hi}} | ||
\def\locResultLo {\col{result\_lo}} |
This file contains hidden or 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
13 changes: 9 additions & 4 deletions
13
hub/instruction_handling/push_pop/instructions_and_flags.tex
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
\[ | ||
\begin{array}{|l||c||c|c|c|} | ||
\begin{array}{|l||c||c|c|c|c|} | ||
\hline | ||
\INST & \tli & \stackDecPushPopFlag & \decFlag{1} & \decFlag{2} \\ \hline\hline | ||
\inst{POP} & \zero & \oneCell & \oneCell & \zero \\ \hline | ||
\inst{PUSH1-32} & \zero & \oneCell & \zero & \oneCell \\ \hline | ||
\INST & \tli & \stackDecPushPopFlag & \decFlag{1} & \decFlag{2} & \decFlag{3} \\ \hline\hline | ||
\inst{POP} & \zero & \oneCell & \oneCell & \zero & \zero \\ \hline | ||
\inst{PUSH1-32} & \zero & \oneCell & \zero & \oneCell & \zero \\ \hline | ||
\inst{PUSH0} & \zero & \oneCell & \zero & \zero & \oneCell \\ \hline | ||
\end{array} | ||
\] | ||
\saNote{} | ||
We separate the \inst{PUSH0} from the other \inst{PUSHX}, $\inst{X} \in \{ \inst{1}, \inst{2}, \dots, \inst{32} \}$, instructions. | ||
This stems from the fact that they are treated differently in the \romMod{} module: | ||
the \romMod{} module does not construct a ``push value'' for the \inst{PUSH0} instruction, and \inst{PUSH0} does not raise the \pushFlag{}. |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
\label{rom: intro: convention: PUSHX implicitly refers to PUSH1 through PUSH32 but not PUSH0} | ||
Throughout the specification of the \romMod{} module, whenever we write | ||
``\inst{PUSHX}'' we will \textbf{always} be talking about the case where $\inst{X} \neq \inst{0}$, i.e. with $\inst{X} \in \{ \inst{1}, \inst{2}, \dots, \inst{32} \}$. | ||
The \inst{PUSH0} instruction of \cite{EIP-3855} is dealt with differently than the other \inst{PUSHX} instructions, | ||
see section~(\ref{rom: columns: IS_PUSH_FLAG does not light up for PUSH0}) for more details. |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
The \romMod{} module compiles the \emph{nonempty} bytecodes, initialization codes and deployed byte codes alike, used during the execution of a conflation of blocks. | ||
The \romMod{} module compiles the \textbf{nonempty} bytecodes, initialization codes and deployed byte codes alike, used during the execution of a conflation of blocks. | ||
Its main role in the overall design is to provide the \hubMod{} module with the correct sequence of instructions. | ||
It furthermore assembles the \inst{PUSH}-values from the bytes following a \inst{PUSHX} instruction. | ||
It also tags (in)valid jump destinations as such as required by \textsc{jump destination analysis}. | ||
Most of the arithmetization below focuses on building the \romMod{} module as a seqence of padded byte codes and of extracting the correct push values from it (i.e. the $\inst{X}$-byte long arguments of actual \inst{PUSHX} instructions). | ||
It furthermore assembles the \inst{PUSH}-values from the bytes following a \inst{PUSHX} instruction, $\inst{X} \in \{ \inst{1}, \inst{2}, \dots, \inst{32} \}$. | ||
It also tags (in)valid jump destinations as such, as is required by \textsc{jump destination analysis}. | ||
Most of the arithmetization below focuses on building the \romMod{} module as a seqence of padded byte codes and of extracting the correct push values from it (i.e. the $\inst{X}$-byte long arguments of actual \inst{PUSHX} instructions). | ||
|
||
There are three kinds of accesses to bytecode that the \romMod{} module deals with, with contract deployment being subdivided into 1 or 2 phases (since deployments may fail): | ||
\begin{enumerate} | ||
\item loading the full bytecode of an already deployed smart contract to \inst{CALL} it or to \inst{EXTCODECOPY} from it (or both); | ||
\item loading the full bytecode of an already deployed smart contract to \inst{CALL}, \inst{CALLCODE}, \inst{STATICCALL} or \inst{DELEGATECALL} into it; | ||
\item loading the full bytecode of an already deployed smart contract to \inst{EXTCODECOPY} from it; | ||
\item deploying a smart contract through a deployment transaction or an (unexceptional, unaborted and no failure condition raising) \inst{CREATE(2)} instruction: | ||
\begin{enumerate} | ||
\item loading the initialization code into \romMod{}; | ||
\item and for (temporarily) successful deployments loading the bytecode that will be deployed at the relevant address into \romMod{}. | ||
\item loading the initialization code into the \romMod{} module; | ||
\item and for (temporarily) successful deployments loading the bytecode that will be (temporarily) deployed at the relevant address into the \romMod{} module. | ||
\end{enumerate} | ||
\end{enumerate} |
This file contains hidden or 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where do you manage the fact that cost of
PUSH0
is 2, while the one ofPUSH1-32
is 3? Other than that, LGTM.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The static gas is obtained via lookup to the instruction decoder. It is enough that the instruction decoder know the gas cost of
PUSH0
.