Skip to content

Commit

Permalink
Simplified return data setting for return from deployment (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBBB authored Nov 20, 2024
1 parent f429370 commit 1206d35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
25 changes: 13 additions & 12 deletions hub/generalities/context/numbers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,28 @@
\item \If \big($\peekStack_{i} = 1$ \et $\haltFlag_{i} = 1$\big) \Then $\cn\new_{i} = \caller_{i}$
\end{enumerate}
\saNote{} \label{hub: generalities: context: consequences of CMC and XAHOY}
Constraints~(\ref{hub: generalities: context: whenever the context may change the final row is a context row}) and
(\ref{hub: generalities: context: exceptions lead to providing empty return data}) may seem inconspicuous and cryptic but they are \textbf{very important}.
Constraint~(\ref{hub: generalities: context: whenever the context may change the final row is a context row}) and
constraint~(\ref{hub: generalities: context: exceptions lead to providing empty return data})
may seem inconspicuous and cryptic but they are \textbf{very important}.
In light of the definition of the \CONTEXTMAYCHANGE{} flag given in section~(\ref{hub: generalities: context: cmc flag}),
constraint~(\ref{hub: generalities: context: whenever the context may change the final row is a context row})
enforces that every time the \zkEvm{} encounters
a \inst{CALL}-type instruction ($\stackDecCallFlag \equiv 1$),
a \inst{CREATE}-type instruction ($\stackDecCreateFlag \equiv 1$),
a halting instruction ($\stackDecHaltFlag \equiv 1$),
or raises an exception ($\xAhoy \equiv 1$),
a halting instruction ($\stackDecHaltFlag \equiv 1$) or
raises an exception ($\xAhoy \equiv 1$),
instruction processing \textbf{must end on a context row}.
This manifests all over instruction handling,
see section~(\ref{hub: instruction handling}),
This manifests all over instruction handling~(\ref{hub: instruction handling})
in extraneous constraints of the form
\[
\left\{ \begin{array}{l}
\nonStackRows _{i} = \texttt{<numerical value>} + \cmc_{i} \\
\texttt{<peeking flag sum>} = \texttt{<functional peeking flag sum>} + \peekContext_{i + \yellowm{\omega}} \cdot \cmc_{i} \\
\left\{ \begin{array}{lclcr}
\nonStackRows _{i} & = & \overbrace{\texttt{<numerical value>}}^{\yellowm{\omega}} & + & \cmc_{i} \\
\texttt{<peeking flag sum>} & = & \texttt{<functional flags>} & + & \peekContext_{i + \yellowm{\omega}} \cdot \cmc_{i} \\
\end{array} \right.
\]
Furthermore constraint~(\ref{hub: generalities: context: exceptions lead to providing empty return data}) ensures that
in case of an exception, this context row is one \textbf{squashing the parent context's return data.}
Furthermore,
constraint~(\ref{hub: generalities: context: exceptions lead to providing empty return data})
ensures that in case of an exception, this context row is one \textbf{squashing the parent context's return data.}

\saNote{} \label{hub: generalities: context: automatic gas checks}
Further note that $\cmc \equiv 1$ along with section~(\ref{hub: lookups: into gas}), triggers the \gasMod{} module.
Expand All @@ -60,4 +61,4 @@

\saNote{} Constraint~(\ref{hub: generalities: context: how to trigger finalization phase}) settles the question of when execution stops and the finalization phase starts.

\saNote{} We refer to section~\ref{hub: context-rows: specialized constraints} for the definition of $\executionProvidesEmptyReturnData {i}{\relof}$.
\saNote{} We refer to section~(\ref{hub: context-rows: specialized constraints}) for the definition of $\executionProvidesEmptyReturnData {i}{\relof}$.
8 changes: 4 additions & 4 deletions hub/generalities/refunds/constraints.tex
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
\end{enumerate}
The above is the transition constraint for gas refunds.

Recall that \textbf{along stack-rows} one has
Recall that \textbf{along stack-rows} (i.e. whenever $\peekStack \equiv 1$) one has
\[
\stackDecStoFlag \cdot \decFlag{1} \equiv 1 \quad \text{precisely for \inst{SSTORE}, see section~(\ref{hub: instruction handling: sto});}
\stackDecStoFlag \cdot \decFlag{2} \equiv 1 \iff \stackInst \equiv \inst{SSTORE} \text{, see section~(\ref{hub: instruction handling: sto});}
\]
\begin{enumerate}[resume]
\item \If $\cnWillRev_{i} = 1$
\Then $\refund\new_{i} = \refund_{i}$
\item \If $\peekStack_{i} = 1$ \et $\stackDecStoFlag _{i} \cdot \decFlag{1}_{i} = 0$
\item \If $\peekStack_{i} = 1$ \et $\stackDecStoFlag _{i} \cdot \decFlag{2}_{i} = 0$
\Then $\refund\new_{i} = \refund_{i}$
\item \If $\cnWillRev_{i} = 0$ \et $\peekStack_{i} = 1$ \If $\stackDecStoFlag_{i} \cdot \decFlag{1}_{i} = 1$ \Then \dots{} see section~(\ref{hub: instruction handling: sto})
\item \If $\cnWillRev_{i} = 0$ \et $\peekStack_{i} = 1$ \If $\stackDecStoFlag_{i} \cdot \decFlag{2}_{i} = 1$ \Then \dots{} see section~(\ref{hub: instruction handling: sto})
\end{enumerate}
The above thus enforces that
(\emph{a}) execution context that will revert don't contribute to the refunds
Expand Down

0 comments on commit 1206d35

Please sign in to comment.