Skip to content

Commit 09fb30e

Browse files
amkChaOlivierBBB
andauthored
EIP 7951 Hub side (#310)
* feat: hub integration of the new precompile present in Osaka hardfork P256_Verify. This includes an add of a scenario and its binary constraint, update of common precompiles treatment with P256_Verify shorthands and table, the prc classification, prc addresses range, the success, FKTH and FKTR case, sanity checks, nsrs and flagsums --------- Signed-off-by: Olivier Bégassat <[email protected]> Co-authored-by: Olivier Bégassat <[email protected]>
1 parent 2452f95 commit 09fb30e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+476
-447
lines changed

hub/columns/context.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
When an execution context resumes after a child context finishes executing it receives return data%
8080
\footnote{Said return data may be empty e.g. after a successful deployment, if the child context ended on a \inst{STOP} or a \inst{SELFDESTRUCT}, if the child context ended on a \inst{RETURN}/\inst{REVERT} with empty data, if the child context terminated on an exception, when returning from a \inst{CALL} to a precompile which triggered an internal error, \dots} That data lives in the child context's RAM (whose \cn{} will be stored \cnReturner{}) starting at some offset (stored in \cnRdo{}) and comprising a number of bytes (stored in \cnRds{}.) Contrary to the offset / size parameters introduced previously these parameters need not be context-constant. They are updated every time execution of the present context resumes after a message call or deployment.
8181

82-
\saNote{} The above will hold true for \inst{CALL}'s to precompiled contracts, too. \inst{CALL}'s to these contracts \emph{do not} produce tangible execution contexts in the present arithmetization i.e. the \hubMod{} module never enters an execution context with $\cnCodeAddress \in \{ 1, 2, \dots, 9 \}$. Yet \textsc{ram} may have to undergo modifications. Typically (and along the happy path)
82+
\saNote{} The above will hold true for \inst{CALL}'s to precompiled contracts, too. \inst{CALL}'s to these contracts \emph{do not} produce tangible execution contexts in the present arithmetization i.e. the \hubMod{} module never enters an execution context with $\cnCodeAddress \in $ \prcAddressRange. Yet \textsc{ram} may have to undergo modifications. Typically (and along the happy path)
8383
(\emph{a})
8484
extraction of a slice of bytes from the current execution context's \textsc{ram} to be stored in some dedicated \col{DATA} module (e.g.
8585
\ecDataMod{},

hub/columns/scenarios/call.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
\end{enumerate}
1212
The columns below pertain to unexceptional, unaborted \inst{CALL}-type instructions i.e. \inst{CALL}'s that are entered.
1313
For the sake of clarity we provide our working definition of \textbf{precompiles}, \textbf{externally owned accounts} and \textbf{smart contracts}.
14-
A \textbf{precompile} is an account whose address is in the range $\{\texttt{0x01},\texttt{0x02},\dots, \texttt{0x09}\}$.
14+
A \textbf{precompile} is an account whose address is in the range \prcAddressRange.
1515
A \textbf{smart contract} is any account with nonempty bytecode.
1616
An \textbf{externally owned account} is any account that is neither a \textbf{precompile} nor a \textbf{smart contract}.
1717
This includes accounts that were created through deployments but whose bytecode is empty.

hub/columns/scenarios/precompiles.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
\item \scenBlsPairingCheck: binary column; lights up whenever the \zkEvm{} is about to deal with the memory operations pertaining to the \instBlsPairingCheck{} precompile;
1818
\item \scenBlsMapFpToGOne: binary column; lights up whenever the \zkEvm{} is about to deal with the memory operations pertaining to the \instBlsMapFpToGOne{} precompile;
1919
\item \scenBlsMapFpTwoToGTwo: binary column; lights up whenever the \zkEvm{} is about to deal with the memory operations pertaining to the \instBlsMapFpTwoToGTwo{} precompile;
20+
\item \scenPVerify: binary column; lights up whenever the \zkEvm{} is about to deal with the memory operations pertaining to the \instPVerify{} precompile;
2021
\end{enumerate}
2122
We continue with columns that will be made to contain a local copy of data relevant to the pricing and execution of precompiles.
2223
\begin{enumerate}[resume]

hub/columns/shared.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@
7474
\item $\domStamp$ and $\subStamp$:
7575
pair of stamp columns; used to prepare events for future execution;
7676
\end{enumerate}
77-
The $\oobFlag$ may only turn on for instructions that may go out of bounds. These instructions are
77+
The $\oobFlag$ may only turn on for instructions that may go out of bounds. These instructions comprise, among others, see section~(\ref{oob: intro})
7878
(\emph{a}) \inst{CALLDATALOAD} where the comparison is done against the call data size;
7979
(\emph{b}) \inst{RETURNDATALOAD} where the comparison is done against the return data size;
8080
(\emph{c}) \inst{JUMP} and \inst{JUMPI} where the comparison is done against the code size;
81+
(\emph{d}) \inst{CALL} when it is targeting a precompile, the comparison is done against the call data size;
8182
\ob{TODO: make sure list is exhaustive}
8283
\begin{enumerate}[resume]
8384
\item $\cn{}$ and $\cn{}\new$:

hub/instruction_handling/call/approach.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
\item[\textsc{Smart contracts}]
2828
are characterized by having nonempty code ($\accHasCode \equiv 1$);
2929
\item[\textsc{Precompiles}]
30-
are characterized by raising the a precompile flag (i.e. $\accTrmIsPrecompile \equiv 1$).
30+
are characterized by raising the precompile flag (i.e. $\accTrmIsPrecompile \equiv 1$).
3131
\end{description}
3232
Instruction processing beyond that point is either done in a single phase or subdivided two phases.
3333
In more detail:

hub/instruction_handling/call/generalities/lua/entry.lua.tex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@
169169
∙  PRC/ECMUL
170170
∙  PRC/ECPAIRING
171171
∙  PRC/BLAKE2f
172+
∙  PRC/POINT-EVALUATION
173+
∙  PRC/BLS-G1-ADD
174+
∙  PRC/BLS-G1-MSM
175+
∙  PRC/BLS-G2-ADD
176+
∙  PRC/BLS-G2-MSM
177+
∙  PRC/BLS-PAIRING-CHECK
178+
∙  PRC/BLS-MAP-FP-TO-G1
179+
∙  PRC/BLS-MAP-FP2-TO-G2
180+
∙  PRC/P256-VERIFY
172181
- the scenario-row carries a PREDICTION of which precompile scenario will play out
173182
∙  PRC/FAILURE_KNOWN_TO_HUB
174183
∙  PRC/FAILURE_KNOWN_TO_RAM

hub/instruction_handling/call/precompiles/_inputs.tex

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ \subsubsubsection{Flag sums and \col{nsr}'s --- I \lispTodo{}} \label{hub:
88
\subsubsubsection{Flag sums and \col{nsr}'s --- II \lispTodo{}} \label{hub: instruction handling: call: precompiles: flag sums and nsr II} \input{instruction_handling/call/precompiles/nsr_and_flagsum_II} \newpage
99
\subsubsubsection{Explicit values for \nonStackRows{} \lispNone{}} \label{hub: instruction handling: call: precompiles: explicit values of nsr} \input{instruction_handling/call/precompiles/explicit_nsr}
1010

11-
\subsubsection{Common setup for all precompiles except for \instModexp{} and \instBlake{} \lispDone{}} \label{hub: instruction handling: call: precompiles: most precompiles} \input{instruction_handling/call/precompiles/common/_inputs}
12-
\subsubsection{\instEcrecover{} \lispDone{}} \label{hub: instruction handling: call: precompiles: ecrecover} \input{instruction_handling/call/precompiles/ecrecover/_inputs}
13-
\subsubsection{\instShaTwo{} and \instRipemd{} \lispDone{}} \label{hub: instruction handling: call: precompiles: sha2 and ripemd} \input{instruction_handling/call/precompiles/sha2_ripemd/_inputs}
14-
\subsubsection{\instIdentity{} \lispDone{}} \label{hub: instruction handling: call: precompiles: identity} \input{instruction_handling/call/precompiles/identity/_inputs}
15-
\subsubsection{\instModexp{} \lispDone{}} \label{hub: instruction handling: call: precompiles: modexp} \input{instruction_handling/call/precompiles/modexp/_inputs}
16-
\subsubsection{\instEcadd{}, \instEcmul{}, \instEcpairing{} and \inst{BLS}-precompiles \lispDone{}} \label{hub: instruction handling: call: precompiles: ecadd ecmul ecpairing and bls} \input{instruction_handling/call/precompiles/ecadd_ecmul_ecpairing_bls/_inputs}
17-
\subsubsection{\instBlake{} \lispDone{}} \label{hub: instruction handling: call: precompiles: blake} \input{instruction_handling/call/precompiles/blake/_inputs}
18-
\subsubsection{\inst{BLS}-precompiles \lispTodo{}} \label{hub: instruction handling: call: precompiles: bls} \input{instruction_handling/call/precompiles/bls/_inputs}
11+
\subsubsection{Common setup for all precompiles except for \instModexp{} and \instBlake{} \lispDone{}} \label{hub: instruction handling: call: precompiles: most precompiles} \input{instruction_handling/call/precompiles/common/_inputs}
12+
\subsubsection{\instEcrecover{} \lispDone{}} \label{hub: instruction handling: call: precompiles: ecrecover} \input{instruction_handling/call/precompiles/ecrecover/_inputs}
13+
\subsubsection{\instShaTwo{} and \instRipemd{} \lispDone{}} \label{hub: instruction handling: call: precompiles: sha2 and ripemd} \input{instruction_handling/call/precompiles/sha2_ripemd/_inputs}
14+
\subsubsection{\instIdentity{} \lispDone{}} \label{hub: instruction handling: call: precompiles: identity} \input{instruction_handling/call/precompiles/identity/_inputs}
15+
\subsubsection{\instModexp{} \lispDone{}} \label{hub: instruction handling: call: precompiles: modexp} \input{instruction_handling/call/precompiles/modexp/_inputs}
16+
\subsubsection{\instEcadd{}, \instEcmul{}, \instEcpairing{}, \inst{BLS}-precompiles and \instPVerify{} \lispDone{}} \label{hub: instruction handling: call: precompiles: ecadd ecmul ecpairing bls and pverify} \input{instruction_handling/call/precompiles/ecadd_ecmul_ecpairing_bls_pverify/_inputs}
17+
\subsubsection{\instBlake{} \lispDone{}} \label{hub: instruction handling: call: precompiles: blake} \input{instruction_handling/call/precompiles/blake/_inputs}

hub/instruction_handling/call/precompiles/bls/_inputs.tex

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)