Skip to content

Commit

Permalink
Provide HUB -> RLPADDR with the correct init_code_hash (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBBB authored Dec 5, 2024
1 parent ec3f528 commit 6d7b0bc
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 34 deletions.
4 changes: 3 additions & 1 deletion hub/instruction_handling/create/_local.tex
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
\def\locMxpx {\col{STACK\_mxpx}}
\def\locOogx {\col{STACK\_oogx}}
%
\def\relevantValue {\texttt{<rel. val.>}}
\def\relevantValue {\texttt{<rel. val.>}}
%
\def\locTriggerHashInfo {\col{trigger\_\hashInfoMod}}
\def\locHashInfoStamp {\col{hash\_info\_stamp}}
\def\locHashInfoKeccakHi {\hashInfoMod\col{\_kec\_hi}}
\def\locHashInfoKeccakLo {\hashInfoMod\col{\_kec\_lo}}
\def\locInitCodeHashHi {\col{init\_code\_hash\_hi}}
\def\locInitCodeHashLo {\col{init\_code\_hash\_lo}}
\def\locInitCodeSize {\col{init\_code\_size}}
Expand Down
63 changes: 51 additions & 12 deletions hub/instruction_handling/create/generalities/unexceptional.tex
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,62 @@
\[
\left\{ \begin{array}{lcl}
% \accRlpAddrFlag _{i + \createFirstCreatorAccountRowOffset} & = & \rOne \\
\accRlpAddrRecipe _{i + \createFirstCreatorAccountRowOffset} & = & \locRlpAddrRecipe \\
\accRlpAddrDepAddrHi _{i + \createFirstCreatorAccountRowOffset} & = & \relevantValue \\
\accRlpAddrDepAddrLo _{i + \createFirstCreatorAccountRowOffset} & = & \relevantValue \\
\accRlpAddrSaltHi _{i + \createFirstCreatorAccountRowOffset} & = & \locSaltHi \\
\accRlpAddrSaltLo _{i + \createFirstCreatorAccountRowOffset} & = & \locSaltLo \\
\accRlpAddrKecHi _{i + \createFirstCreatorAccountRowOffset} & = & \locInitCodeHashHi \\
\accRlpAddrKecLo _{i + \createFirstCreatorAccountRowOffset} & = & \locInitCodeHashLo \\
\accRlpAddrRecipe _{i + \createFirstCreatorAccountRowOffset} & = & \locRlpAddrRecipe \\
\accRlpAddrDepAddrHi _{i + \createFirstCreatorAccountRowOffset} & = & \relevantValue \\
\accRlpAddrDepAddrLo _{i + \createFirstCreatorAccountRowOffset} & = & \relevantValue \\
\accRlpAddrSaltHi _{i + \createFirstCreatorAccountRowOffset} & = & \locSaltHi \\
\accRlpAddrSaltLo _{i + \createFirstCreatorAccountRowOffset} & = & \locSaltLo \\
\accRlpAddrKecHi _{i + \createFirstCreatorAccountRowOffset} & = & \locInitCodeHashHi \\
\accRlpAddrKecLo _{i + \createFirstCreatorAccountRowOffset} & = & \locInitCodeHashLo \\
\end{array} \right.
\]
where we set
\[
\locRlpAddrRecipe :=
\left[ \begin{array}{lrcl}
+ & \locIsCreate & \!\!\! \cdot \!\!\! & \addressCreationRecipeConstantStd \\
+ & \locIsCreateTwo & \!\!\! \cdot \!\!\! & \addressCreationRecipeConstantTwo \\
\end{array} \right]
\left\{ \begin{array}{lcl}
\locRlpAddrRecipe & \define &
\left[ \begin{array}{lrcl}
+ & \locIsCreate & \!\!\! \cdot \!\!\! & \addressCreationRecipeConstantStd \\
+ & \locIsCreateTwo & \!\!\! \cdot \!\!\! & \addressCreationRecipeConstantTwo \\
\end{array} \right] \vspace{2mm} \\
\locInitCodeHashHi & \define & \locIsCreateTwo \cdot
\left[ \begin{array}{crcl}
+ & \locTriggerHashInfo & \cdot & \locHashInfoKeccakHi \\
+ & (1 - \locTriggerHashInfo) & \cdot & \emptyKeccakHi \\
\end{array} \right] \vspace{2mm} \\
\locInitCodeHashLo & \define & \locIsCreateTwo \cdot
\left[ \begin{array}{crcl}
+ & \locTriggerHashInfo & \cdot & \locHashInfoKeccakLo \\
+ & (1 - \locTriggerHashInfo) & \cdot & \emptyKeccakLo \\
\end{array} \right] \\
\end{array} \right.
\]
In other words
\begin{enumerate}
\item \If $\locIsCreateTwo = 0$ \Then
\[
\left\{ \begin{array}{lclr}
\locInitCodeHashHi & \define & 0 & (\trash) \\
\locInitCodeHashLo & \define & 0 & (\trash) \\
\end{array} \right.
\]
\item \If $\locIsCreateTwo = 1$ \Then
\begin{enumerate}
\item \If $\locTriggerHashInfo = 0$
\[
\left\{ \begin{array}{lclr}
\locInitCodeHashHi & \define & \emptyKeccakHi & (\trash) \\
\locInitCodeHashLo & \define & \emptyKeccakLo & (\trash) \\
\end{array} \right.
\]
\item \If $\locTriggerHashInfo = 1$
\[
\left\{ \begin{array}{lclr}
\locInitCodeHashHi & \define & \locHashInfoKeccakHi & (\trash) \\
\locInitCodeHashLo & \define & \locHashInfoKeccakLo & (\trash) \\
\end{array} \right.
\]
\end{enumerate}
\end{enumerate}
\saNote{} We remind the reader that section~(\ref{rlpAddr: create computation constants}) defines two nonzero constants $\addressCreationRecipeConstantStd$ and $\addressCreationRecipeConstantTwo$.
\end{description}
\saNote{} The \zkEvm{} thus loads the account whose address corresponds to $I_\text{a}$ in the \cite{EYP}.
42 changes: 21 additions & 21 deletions hub/instruction_handling/create/shorthands.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
\[
\hspace*{-2.3cm}
\left\{ \begin{array}{lcl}
\locInst & \define & \stackInst _{i - \createFirstStackRowOffset} \\
\locIsCreate & \define & \decFlag{1} _{i - \createFirstStackRowOffset} \\
\locIsCreateTwo & \define & \decFlag{2} _{i - \createFirstStackRowOffset} \\
\locStaticx & \define & \stackStaticx _{i - \createFirstStackRowOffset} \\
\locMxpx & \define & \stackMxpx _{i - \createFirstStackRowOffset} \\
\locOogx & \define & \stackOogx _{i - \createFirstStackRowOffset} \\
\locOffsetHi & \define & \stackItemValHi{1} _{i - \createFirstStackRowOffset} \\
\locOffsetLo & \define & \stackItemValLo{1} _{i - \createFirstStackRowOffset} \\
\locSizeHi & \define & \stackItemValHi{2} _{i - \createFirstStackRowOffset} \\
\locSizeLo & \define & \stackItemValLo{2} _{i - \createFirstStackRowOffset} \\
\locCnWillRevert & \define & \cnWillRev _{i - \createFirstStackRowOffset} \\
\locCnRevertStamp & \define & \cnRevStamp _{i - \createFirstStackRowOffset} \\
\locInitCodeHashHi & \define & \stackHashInfoValHi _{i - \createFirstStackRowOffset} \\
\locInitCodeHashLo & \define & \stackHashInfoValLo _{i - \createFirstStackRowOffset} \\
\locInitCodeSize & \define & \stackItemValLo{2} _{i - \createFirstStackRowOffset} \\ % TODO: make sure this is doesn't fuck things up
\locInst & \define & \stackInst _{i - \createFirstStackRowOffset} \\
\locIsCreate & \define & \decFlag{1} _{i - \createFirstStackRowOffset} \\
\locIsCreateTwo & \define & \decFlag{2} _{i - \createFirstStackRowOffset} \\
\locStaticx & \define & \stackStaticx _{i - \createFirstStackRowOffset} \\
\locMxpx & \define & \stackMxpx _{i - \createFirstStackRowOffset} \\
\locOogx & \define & \stackOogx _{i - \createFirstStackRowOffset} \\
\locOffsetHi & \define & \stackItemValHi{1} _{i - \createFirstStackRowOffset} \\
\locOffsetLo & \define & \stackItemValLo{1} _{i - \createFirstStackRowOffset} \\
\locSizeHi & \define & \stackItemValHi{2} _{i - \createFirstStackRowOffset} \\
\locSizeLo & \define & \stackItemValLo{2} _{i - \createFirstStackRowOffset} \\
\locCnWillRevert & \define & \cnWillRev _{i - \createFirstStackRowOffset} \\
\locCnRevertStamp & \define & \cnRevStamp _{i - \createFirstStackRowOffset} \\
\locHashInfoKeccakHi & \define & \stackHashInfoValHi _{i - \createFirstStackRowOffset} \\
\locHashInfoKeccakLo & \define & \stackHashInfoValLo _{i - \createFirstStackRowOffset} \\
\locInitCodeSize & \define & \stackItemValLo{2} _{i - \createFirstStackRowOffset} \\ % TODO: make sure this is doesn't fuck things up
%
\locSaltHi & \define & \stackItemValHi{2} _{i - \createSecondStackRowOffset} \\
\locSaltLo & \define & \stackItemValLo{2} _{i - \createSecondStackRowOffset} \\
\locValueHi & \define & \stackItemValHi{3} _{i - \createSecondStackRowOffset} \\
\locValueLo & \define & \stackItemValLo{3} _{i - \createSecondStackRowOffset} \\
\locOutputHi & \define & \stackItemValHi{4} _{i - \createSecondStackRowOffset} \\
\locOutputLo & \define & \stackItemValLo{4} _{i - \createSecondStackRowOffset} \\
\locSaltHi & \define & \stackItemValHi{2} _{i - \createSecondStackRowOffset} \\
\locSaltLo & \define & \stackItemValLo{2} _{i - \createSecondStackRowOffset} \\
\locValueHi & \define & \stackItemValHi{3} _{i - \createSecondStackRowOffset} \\
\locValueLo & \define & \stackItemValLo{3} _{i - \createSecondStackRowOffset} \\
\locOutputHi & \define & \stackItemValHi{4} _{i - \createSecondStackRowOffset} \\
\locOutputLo & \define & \stackItemValLo{4} _{i - \createSecondStackRowOffset} \\
\end{array} \right.
\quad\text{and}\quad
\left\{ \begin{array}{lcl}
Expand Down

0 comments on commit 6d7b0bc

Please sign in to comment.