Skip to content

Commit

Permalink
New scenario/CREATE shorthand (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBBB authored Dec 9, 2024
1 parent 2b60407 commit 1952768
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 42 deletions.
45 changes: 27 additions & 18 deletions hub/instruction_handling/create/generalities/all.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
\scenCreateSum _{i} & = & 1 \\
\end{array} \right.}
\end{center}
The present section deals with generalities pertaining to \inst{CREATE}-type instructions. These constraints hold regardless of anything else.
The present section deals with generalities pertaining to \inst{CREATE}-type instructions. These constraints hold regardless of anything else.
\begin{description}
\item[\underline{Setting the stack pattern:}]
we impose $\createSP_{i - \createFirstStackRowOffset}\big[ \locIsCreateTwo \big]$;
Expand Down Expand Up @@ -47,7 +47,7 @@
\[
\locStaticx = \locIsStatic
\]
\item[\underline{Setting the module flags of miscellaneous-row $n^°(i + \createMiscRowOffset)$::}]
\item[\underline{Setting the module flags of miscellaneous-row $n^°(i + \createMiscRowOffset)$::}]
every processing path for \inst{CREATE}-type instructions contains a single \textbf{miscellaneous-row}
\[
\weightedMiscFlagSum
Expand Down Expand Up @@ -115,33 +115,42 @@
we impose \If $\miscOobFlag_{i + \createMiscRowOffset} = 1$ \Then
\[
\setOobInstructionCreate {
anchorRow = i,
relOffset = \createMiscRowOffset,
valueHi = \locValueHi,
valueLo = \locValueLo,
balance = \locCreatorBalance,
nonce = \locCreateeNonce,
hasCode = \locCreateeHasCode,
callStackDepth = \locCsd,
creatorNonce = \locCreatorNonce,
anchorRow = i ,
relOffset = \createMiscRowOffset ,
valueHi = \locValueHi ,
valueLo = \locValueLo ,
balance = \locCreatorBalance ,
nonce = \locCreateeNonce ,
hasCode = \locCreateeHasCode ,
callStackDepth = \locCsd ,
creatorNonce = \locCreatorNonce ,
}
\]
where we define the following shorthands:
\[
\left\{ \begin{array}{lclcl}
\locCreateeNonce & = & \scenCreateLoadCreatee _{i} & \cdot & \accNonce _{i + \createFirstCreateeAccountRowOffset} \\
\locCreateeHasCode & = & \scenCreateLoadCreatee _{i} & \cdot & \accHasCode _{i + \createFirstCreateeAccountRowOffset} \\
\end{array} \right.
\]
in other words
\[
\left\{ \begin{array}{lclc}
\If \locTriggerRlpAddr = 0 ~ \Then
\If \scenCreateLoadCreatee _{i} = 0 ~ \Then
\left\{ \begin{array}{lclc}
\locCreateeNonce & = & 0 \\
\locCreateeHasCode & = & 0 \\
\end{array} \right. \\
\If \locTriggerRlpAddr = 1 ~ \Then
\If \scenCreateLoadCreatee _{i} = 1 ~ \Then
\left\{ \begin{array}{lclc}
\locCreateeNonce & = & \accNonce _{i + \createFirstCreateeAccountRowOffset} \\
\locCreateeHasCode & = & \accHasCode _{i + \createFirstCreateeAccountRowOffset} \\
\end{array} \right. \\
\end{array} \right.
\]
\saNote{} We explain the conditional definitions of \locCreateeNonce{} and \locCreateeHasCode{} by the fact that the \zkEvm{} is granted access to the account of the deployment address \emph{iff} it computes that address.
\saNote{}
We explain the conditional definitions of \locCreateeNonce{} and \locCreateeHasCode{} by the fact that
the \zkEvm{} is granted access to the account of the createe \emph{iff} $\scenCreateLoadCreatee \equiv 1$.
\item[\underline{Setting the \inst{CREATE}-scenario:}]
we impose the following
\begin{enumerate}
Expand Down Expand Up @@ -199,23 +208,23 @@
\]
where we have used the following (as of yet undefined) shorthands \locTgtId{}, \locAuxId{} and \locExoSum{} which we define as follows:
\begin{enumerate}
\item \If $\locHashInitCode = 1$ \Then
\item \If $\locHashInitCode = 1$ \Then
\[
\left\{ \begin{array}{lcl}
\locTgtId & \define & \nothing \\
\locAuxId & \define & 1 + \hubStamp_{i} \\
\locExoSum & \define & \exoWeightKec \\
\end{array} \right.
\]
\item \If $\locHashInitCodeAndSendToRom = 1$ \Then
\item \If $\locHashInitCodeAndSendToRom = 1$ \Then
\[
\left\{ \begin{array}{lcl}
\locTgtId & \define & \locDepCfi \\
\locAuxId & \define & 1 + \hubStamp_{i} \\
\locExoSum & \define & \exoWeightRom + \exoWeightKec \\
\end{array} \right.
\]
\item \If $\locSendInitCodeToRom = 1$ \Then
\item \If $\locSendInitCodeToRom = 1$ \Then
\[
\left\{ \begin{array}{lcl}
\locTgtId & \define & \locDepCfi \\
Expand Down Expand Up @@ -247,7 +256,7 @@
\item \If $\scenCreateNoContextChange _{i} = 1$ \Then $\gasNext_{i} = \gasActual_{i} - \gasCost_{i}$
\item \If $\scenCreateExecutionNonEmptyInitCode _{i} = 1$ \Then
\[
\gasNext_{i} = \gasActual_{i} -
\gasNext_{i} = \gasActual_{i} -
\left[ \begin{array}{cl}
+ & \gasCost_{i} \\
+ & \locStpGasPoop \\
Expand Down
20 changes: 4 additions & 16 deletions hub/instruction_handling/create/triggers/table.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,14 @@
\renewcommand{\arraystretch}{1.5}
\begin{array}{|l|l|c|c|c|c|c|c|c|c|c|c|c|c|}
\cline{3-14}
\multicolumn{2}{c|}{} &
\createVertColStaticx &
\createVertColMxpx &
\createVertColOogx &
\columnCreateB &
\columnCreateD &
\columnCreateC &
\columnCreateF &
\columnCreateE &
\columnCreateH &
\columnCreateG &
\columnCreateJ &
\columnCreateI \\ \cline{2-14}
\multicolumn{2}{c|}{} & \createVertColStaticx & \createVertColMxpx & \createVertColOogx & \columnCreateB & \columnCreateD & \columnCreateC & \columnCreateF & \columnCreateE & \columnCreateH & \columnCreateG & \columnCreateJ & \columnCreateI \\ \cline{2-14}
\multicolumn{1}{c|}{} &  \locTriggerMxp & \rCross & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark \\ \cline{2-14}
\multicolumn{1}{c|}{} &  \locTriggerStp & \rCross & \rCross & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark \\ \cline{2-14}
\multicolumn{1}{c|}{} &  \locTriggerOob & \rCross & \rCross & \rCross & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark \\ \hline
\multirow{4}{*}{\locTriggerMmu} &  \locHashInitCode & \rCross & \rCross & \rCross & \rCross & \nonemptyCreateTwo & \nonemptyCreateTwo & \rCross & \rCross & \rCross & \rCross & \rCross & \rCross \\ \cline{2-14}
&  \locHashInitCodeAndSendToRom & \rCross & \rCross & \rCross & \rCross & \rCross & \rCross & \createTwo & \createTwo & \createTwo & \createTwo & \rCross & \rCross \\ \cline{2-14}
&  \locSendInitCodeToRom & \rCross & \rCross & \rCross & \rCross & \rCross & \rCross & \createOne & \createOne & \createOne & \createOne & \rCross & \rCross \\ \cline{2-14}
&  \locTriggerMmu & \rCross & \rCross & \rCross & \rCross & \nonemptyCreateTwo & \nonemptyCreateTwo & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \rCross & \rCross \\ \hline
&  \locHashInitCodeAndSendToRom & \rCross & \rCross & \rCross & \rCross & \rCross & \rCross & \createTwo & \createTwo & \createTwo & \createTwo & \rCross & \rCross \\ \cline{2-14}
&  \locSendInitCodeToRom & \rCross & \rCross & \rCross & \rCross & \rCross & \rCross & \createOne & \createOne & \createOne & \createOne & \rCross & \rCross \\ \cline{2-14}
&  \locTriggerMmu & \rCross & \rCross & \rCross & \rCross & \nonemptyCreateTwo & \nonemptyCreateTwo & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \rCross & \rCross \\ \hline
\multicolumn{1}{c|}{} &  \locTriggerRlpAddr & \rCross & \rCross & \rCross & \rCross & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark \\ \cline{2-14}
\multicolumn{1}{c|}{} &  \locTriggerHashInfo & \rCross & \rCross & \rCross & \rCross & \nonemptyCreateTwo & \nonemptyCreateTwo & \createTwo & \createTwo & \createTwo & \createTwo & \rCross & \rCross \\ \cline{2-14}
\multicolumn{1}{c|}{} &  \locTriggerRomLex & \rCross & \rCross & \rCross & \rCross & \rCross & \rCross & \gCheckMark & \gCheckMark & \gCheckMark & \gCheckMark & \rCross & \rCross \\ \cline{2-14}
Expand Down
21 changes: 13 additions & 8 deletions hub/scenario/shorthands/create.tex
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,20 @@
\end{array} \right]
\end{array} \right.
\]
and
and the following two equivalent shorthands which we nonetheless give two different names
\[
\scenCreateComputeAddress_{i} \define
\left[ \begin{array}{l}
% + \scenCreateException _{i} \\
% + \scenCreateAbort _{i} \\
+ \scenCreateFCond _{i} \\
+ \scenCreateExecution _{i} \\
\end{array} \right]
\left\{ \begin{array}{lcl}
\scenCreateComputeAddress _{i} & \define &
\left[ \begin{array}{l}
+ \scenCreateFCond _{i} \\
+ \scenCreateExecution _{i} \\
\end{array} \right] \vspace{2mm} \\
\scenCreateLoadCreatee _{i} & \define &
\left[ \begin{array}{l}
+ \scenCreateFCond _{i} \\
+ \scenCreateExecution _{i} \\
\end{array} \right] \\
\end{array} \right.
\]
and
\[
Expand Down
1 change: 1 addition & 0 deletions hub/scenario/tables/create.tex
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
\scenCreateSimpleRevert & \rC & \rC & \gCM & \rC & \rC & \rC & \gCM & \rC & \gCM & \rC \\ \hline
\scenCreateNoContextChange & \rC & \gCM & \gCM & \gCM & \rC & \rC & \rC & \rC & \gCM & \gCM \\ \hline
\scenCreateComputeAddress & \rC & \rC & \gCM & \gCM & \gCM & \gCM & \gCM & \gCM & \gCM & \gCM \\ \hline
\scenCreateLoadCreatee & \rC & \rC & \gCM & \gCM & \gCM & \gCM & \gCM & \gCM & \gCM & \gCM \\ \hline
\end{array}
\]
1 change: 1 addition & 0 deletions pkg/scenario.sty
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
\newcommand{\scenCreateNoContextChange} {\scenCreateColumn{no\_context\_change}}
\newcommand{\scenCreateUnexceptional} {\scenCreateColumn{unexceptional}}
\newcommand{\scenCreateComputeAddress} {\scenCreateColumn{compute\_deployment\_address}}
\newcommand{\scenCreateLoadCreatee} {\scenCreateColumn{load\_createe\_account}}
\newcommand{\scenCreateFCond} {\scenCreateColumn{failure\_condition}}
\newcommand{\scenCreateWillRevert} {\scenCreateColumn{will\_revert}}
\newcommand{\scenCreateNoCreatorStateChange} {\scenCreateColumn{no\_creator\_state\_change}}
Expand Down

0 comments on commit 1952768

Please sign in to comment.