Skip to content

Commit

Permalink
BLOCKDATA redesign (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBBB authored Dec 20, 2024
1 parent 8b8eacb commit e4b5c18
Show file tree
Hide file tree
Showing 47 changed files with 1,533 additions and 117 deletions.
8 changes: 6 additions & 2 deletions block_data/_all_block_data.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
\documentclass{article}
\documentclass[fleqn]{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{../pkg/common}
% \usepackage{../pkg/dark_theme}
\usepackage{xkeyval}
\usepackage{../pkg/std}
\usepackage{../pkg/IEEEtrantools}
\usepackage{../pkg/rom}
Expand All @@ -24,6 +24,10 @@
\usepackage{../pkg/block_data}
\usepackage{../pkg/block_hash}
\usepackage{../pkg/txn_data}
\usepackage{../pkg/iomf_done}
\usepackage{../pkg/xkeyval_macros/wcp_calls}
\usepackage{../pkg/xkeyval_macros/euc_calls}
\usepackage{../pkg/euc}

\usepackage{../pkg/draculatheme}

Expand Down
21 changes: 13 additions & 8 deletions block_data/_inputs.tex
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
\input{_local}

\section{Block data module}
\subsection{Introduction} \label{block data: intro} \input{intro}
\subsection{Columns} \label{block data: columns} \input{columns}
\subsection{Introduction} \label{block data: intro} \input{intro}
\subsection{Columns} \label{block data: columns} \input{columns}
\subsection{Module call macros} \label{block data: module calls} \input{calls}

\section{Constraints}
\subsection{Heartbeat} \label{block data: heartbeat} \input{heartbeat}
\subsection{Constancies} \label{block data: constancies} \input{constancies}
\subsection{Bytehood and byte decomposition constraints} \label{block data: byte decomposition} \input{byteDec}
\subsection{Value Constraints} \label{block data: value constraints} \input{value_constraint}
\subsection{Shorthands} \label{block data: shorthands} \input{shorthands}
\subsection{Binary constraints} \label{block data: binarities} \input{binarities}
\subsection{Unconditional constraints} \label{block data: unconditional} \input{unconditional}
\subsection{Constancies} \label{block data: constancies} \input{constancies}
\subsection{Heartbeat} \label{block data: heartbeat} \input{heartbeat}
\subsection{Representation} \label{block data: representation} \input{representation}

\section{Lookups} \label{block data: lookups} \input{lookups/_inputs}
\section{Computations and checks} \label{block data: computations and checks} \input{computations/_inputs}

\section{Lookups} \label{block data: lookups} \input{lookups/_inputs}
89 changes: 89 additions & 0 deletions block_data/_local.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
\def\rOne {\redm{1}}

\def\locIsCoinbase {\col{is\_CB}}
\def\locIsTimestamp {\col{is\_TS}}
\def\locIsNumber {\col{is\_NB}}
\def\locIsDifficulty {\col{is\_DF}}
\def\locIsGaslimit {\col{is\_GL}}
\def\locIsChainid {\col{is\_ID}}
\def\locIsBasefee {\col{is\_BF}}

\def\locIsCurrConf {\col{is\_curr}}
\def\locIsPrevConf {\col{is\_prev}}
\def\locPrevCurrWghtSum {\col{curr\_prev\_wght\_sum}}

\def\locFlagSum {\col{flag\_sum}}
\def\locWghtSum {\col{wght\_sum}}
\def\locInstSum {\col{inst\_sum}}
\def\locMaxCtSum {\col{ct\_max\_sum}}
\def\locPhaseEntry {\col{phase\_entry}}
\def\locSamePhase {\col{same\_phase}}
\def\locLegalTransitions {\col{allowable\_transitions}}
\def\locExtractor {\col{extractor}}

\def\ctMaxCoinbase {\redm{\texttt{nRows}_{\texttt{cb}}}}
\def\ctMaxTimestamp {\redm{\texttt{nRows}_{\texttt{ts}}}}
\def\ctMaxNumber {\redm{\texttt{nRows}_{\texttt{nb}}}}
\def\ctMaxDifficulty {\redm{\texttt{nRows}_{\texttt{df}}}}
\def\ctMaxGaslimit {\redm{\texttt{nRows}_{\texttt{gl}}}}
\def\ctMaxChainid {\redm{\texttt{nRows}_{\texttt{id}}}}
\def\ctMaxBasefee {\redm{\texttt{nRows}_{\texttt{bf}}}}
\def\kappaDots {\redm{\texttt{nRows}_{\texttt{xx}}}}
\def\blockDataDepth {\redm{\texttt{depth}}}

\def\exoInstruction {\col{EXO\_}\instruction}
\def\previousGasLimit {\col{prev\_gas\_limit}}
\def\maxDeviation {\col{max\_deviation}}

\def\locFirstBlockIsGenesisBlock {\col{first\_block\_is\_genesis\_block}}
\def\ethereumMinBlockGasLimit {\red{\texttt{ETHEREUM\_MIN\_BLOCK\_GAS\_LIMIT}}}
\def\lineaMinBlockGasLimit {\red{\texttt{LINEA\_MIN\_BLOCK\_GAS\_LIMIT}}}
\def\lineaMaxBlockGasLimit {\red{\texttt{LINEA\_MAX\_BLOCK\_GAS\_LIMIT}}}
\def\ethereumMinBlockGasLimitValue {\texttt{5\_000}}
\def\lineaMinBlockGasLimitValue {\texttt{61\_000\_000}}
\def\lineaMaxBlockGasLimitValue {\texttt{2\_000\_000\_000}}
\def\ethereumGasLimitAdjustmentFactor {\red{\texttt{GAS\_LIMIT\_ADJUSTMENT\_FACTOR}}}
\def\ethereumGasLimitAdjustmentFactorValue {\texttt{1024}}

\def\locIsFirstBlock {\col{is\_first\_block}}
\def\locIsntFirstBlock {\col{isnt\_first\_block}}
\def\currDataHi {\col{curr\_data\_hi}}
\def\currDataLo {\col{curr\_data\_lo}}
\def\prevDataHi {\col{prev\_data\_hi}}
\def\prevDataLo {\col{prev\_data\_lo}}

\def\currBaseFeeHi {\col{curr\_BASEFEE\_hi}}
\def\currBaseFeeLo {\col{curr\_BASEFEE\_lo}}
\def\prevBaseFeeHi {\col{prev\_BASEFEE\_hi}}
\def\prevBaseFeeLo {\col{prev\_BASEFEE\_lo}}

\def\currChainIdHi {\col{curr\_CHAINID\_hi}}
\def\currChainIdLo {\col{curr\_CHAINID\_lo}}
\def\prevChainIdHi {\col{prev\_CHAINID\_hi}}
\def\prevChainIdLo {\col{prev\_CHAINID\_lo}}

\def\currCoinbaseHi {\col{curr\_COINBASE\_hi}}
\def\currCoinbaseLo {\col{curr\_COINBASE\_lo}}
\def\prevCoinbaseHi {\col{prev\_COINBASE\_hi}}
\def\prevCoinbaseLo {\col{prev\_COINBASE\_lo}}

\def\currDifficultyHi {\col{curr\_DIFFICULTY\_hi}}
\def\currDifficultyLo {\col{curr\_DIFFICULTY\_lo}}
\def\prevDifficultyHi {\col{prev\_DIFFICULTY\_hi}}
\def\prevDifficultyLo {\col{prev\_DIFFICULTY\_lo}}

\def\currGasLimitHi {\col{curr\_GASLIMIT\_hi}}
\def\currGasLimitLo {\col{curr\_GASLIMIT\_lo}}
\def\prevGasLimitHi {\col{prev\_GASLIMIT\_hi}}
\def\prevGasLimitLo {\col{prev\_GASLIMIT\_lo}}

\def\currNumberHi {\col{curr\_NUMBER\_hi}}
\def\currNumberLo {\col{curr\_NUMBER\_lo}}
\def\prevNumberHi {\col{prev\_NUMBER\_hi}}
\def\prevNumberLo {\col{prev\_NUMBER\_lo}}

\def\currTimeStampHi {\col{curr\_TIMESTAMP\_hi}}
\def\currTimeStampLo {\col{curr\_TIMESTAMP\_lo}}
\def\prevTimeStampHi {\col{prev\_TIMESTAMP\_hi}}
\def\prevTimeStampLo {\col{prev\_TIMESTAMP\_lo}}

13 changes: 13 additions & 0 deletions block_data/binarities.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
We impose \textbf{binary} constraints on the following columns:
\begin{multicols}{3}
\begin{enumerate}
\item $\iomf$
\item $\isCoinbase$
\item $\isTimestamp$
\item $\isNumber$
\item $\isDifficulty$
\item $\isGaslimit$
\item $\isChainid$
\item $\isBasefee$
\end{enumerate}
\end{multicols}
106 changes: 106 additions & 0 deletions block_data/calls.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
We define several simple constraint systems to simplify the writing of constraints.
\[
\left\{ \begin{array}{lcl}
\wcpCallToLt {
anchorRow = i ,
relOffset = \relof ,
argOneHi = \col{a\_hi} ,
argOneLo = \col{a\_lo} ,
argTwoHi = \col{b\_hi} ,
argTwoLo = \col{b\_lo} ,
} & \define &
\left\{ \begin{array}{lcl}
\wcpFlag _{i + \relof} & = & \rOne \\
\exoInstruction _{i + \relof} & = & \inst{LT} \\
\argOneHi _{i + \relof} & = & \col{a\_hi} \\
\argOneLo _{i + \relof} & = & \col{a\_lo} \\
\argTwoHi _{i + \relof} & = & \col{b\_hi} \\
\argTwoLo _{i + \relof} & = & \col{b\_lo} \\
\res _{i + \relof} & = & 1 \\
\end{array} \right. \vspace{2mm} \\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\wcpCallToGt {
anchorRow = i ,
relOffset = \relof ,
argOneHi = \col{a\_hi} ,
argOneLo = \col{a\_lo} ,
argTwoHi = \col{b\_hi} ,
argTwoLo = \col{b\_lo} ,
} & \define &
\left\{ \begin{array}{lcl}
\wcpFlag _{i + \relof} & = & \rOne \\
\exoInstruction _{i + \relof} & = & \inst{GT} \\
\argOneHi _{i + \relof} & = & \col{a\_hi} \\
\argOneLo _{i + \relof} & = & \col{a\_lo} \\
\argTwoHi _{i + \relof} & = & \col{b\_hi} \\
\argTwoLo _{i + \relof} & = & \col{b\_lo} \\
\res _{i + \relof} & = & 1 \\
\end{array} \right. \vspace{2mm} \\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\wcpCallToLeq {
anchorRow = i ,
relOffset = \relof ,
argOneHi = \col{a\_hi} ,
argOneLo = \col{a\_lo} ,
argTwoHi = \col{b\_hi} ,
argTwoLo = \col{b\_lo} ,
} & \define &
\left\{ \begin{array}{lcl}
\wcpFlag _{i + \relof} & = & \rOne \\
\exoInstruction _{i + \relof} & = & \inst{LEQ} \\
\argOneHi _{i + \relof} & = & \col{a\_hi} \\
\argOneLo _{i + \relof} & = & \col{a\_lo} \\
\argTwoHi _{i + \relof} & = & \col{b\_hi} \\
\argTwoLo _{i + \relof} & = & \col{b\_lo} \\
\res _{i + \relof} & = & 1 \\
\end{array} \right. \vspace{2mm} \\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\wcpCallToGeq {
anchorRow = i ,
relOffset = \relof ,
argOneHi = \col{a\_hi} ,
argOneLo = \col{a\_lo} ,
argTwoHi = \col{b\_hi} ,
argTwoLo = \col{b\_lo} ,
} & \define &
\left\{ \begin{array}{lcl}
\wcpFlag _{i + \relof} & = & \rOne \\
\exoInstruction _{i + \relof} & = & \inst{GEQ} \\
\argOneHi _{i + \relof} & = & \col{a\_hi} \\
\argOneLo _{i + \relof} & = & \col{a\_lo} \\
\argTwoHi _{i + \relof} & = & \col{b\_hi} \\
\argTwoLo _{i + \relof} & = & \col{b\_lo} \\
\res _{i + \relof} & = & 1 \\
\end{array} \right. \vspace{2mm} \\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\wcpCallToIszero {
anchorRow = i ,
relOffset = \relof ,
argOneHi = \col{a\_hi} ,
argOneLo = \col{a\_lo} ,
} & \define &
\left\{ \begin{array}{lcl}
\wcpFlag _{i + \relof} & = & \rOne \\
\exoInstruction _{i + \relof} & = & \inst{ISZERO} \\
\argOneHi _{i + \relof} & = & \col{a\_hi} \\
\argOneLo _{i + \relof} & = & \col{a\_lo} \\
\argTwoHi _{i + \relof} & = & 0 \\
\argTwoLo _{i + \relof} & = & 0 \\
\res _{i + \relof} & = & \relevantValue \\
\end{array} \right. \vspace{2mm} \\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\eucCall {
anchorRow = i ,
relOffset = \relof ,
argOne = \col{a} ,
argTwo = \col{b} ,
} & \define &
\left\{ \begin{array}{lcl}
\eucFlag _{i + \relof} & = & \rOne \\
\argOneLo _{i + \relof} & = & \col{a} \\
\argTwoLo _{i + \relof} & = & \col{b} \\
\end{array} \right. \\
\end{array} \right.
\]
\saNote{}
The result of all comparisons is required to be \texttt{true} except for \inst{ISZERO}.
53 changes: 39 additions & 14 deletions block_data/columns.tex
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
We remind the reader that \ccc{} stands for ``counter-constant column.''
The first set of columns will be used to define the heartbeat of the \btcMod{} module.
\begin{enumerate}
\item $\iomf$:
nondecreasing binary column;
\item $\maxCt$:
counter-constant column;
\item $\ct$:
counter column; hovers around zero and then cycles from $0$ to $\maxCtBtcData$;
\item \blockNumberOfFirstBlockInConflation{}:
``conflation-constant'' column containing the block number\footnote{In the sense of the \evm{}} of the first block of this conflation;
\item $\relBlock$:
\ccc{} containing the relative block number;
\item $\relTxMax$:
\ccc{} containing the number of transactions in this block;
\item $\INST$:
counter column; hovers around zero and then cycles from $0$ to $\maxCt$;
\end{enumerate}
We introduce some binary columns linked to the instructions that the present module deals with:
\begin{multicols}{3}
\begin{enumerate}[resume]
\item $\isCoinbase$
\item $\isTimestamp$
\item $\isNumber$
\item $\isDifficulty$
\item $\isGaslimit$
\item $\isChainid$
\item $\isBasefee$
\end{enumerate}
\end{multicols}
\noindent The following columns contain data which is reflected in the \txnDataMod{} module.
\begin{enumerate}[resume, start=13]
\item $\instruction$:
instruction column;
\item $\blockDataHi$, $\blockDataLo$:
columns containing block data;
\item $\coinbase\high$ and $\coinbase\low$:
\ccc{} containing the
coinbase address;
Expand All @@ -21,9 +33,22 @@
\item \basefee{}:
\ccc{} containing the
base fee;
\item $\byteCol{HI\_k}$, and $\byteCol{LO\_k}$, $k = 0, 1, \dots, \llargeMO$:
\item $\wcpFlag$:
\end{enumerate}
The following columns pertain to transaction and block numbers.
\begin{enumerate}[resume]
\item \blockNumberOfFirstBlockInConflation{}:
``conflation-constant'' column containing the block number\footnote{In the sense of the \evm{}} of the first block of this conflation;
\item $\relBlock$:
\ccc{} containing the relative block number;
\item $\relTxMax$:
\ccc{} containing the number of transactions in this block;
\item $\blockDataHi$, $\blockDataLo$:
columns containing block data;
\end{enumerate}
The following columns are used in lookups from the \btcMod{} module into the \wcpMod{} and \eucMod{} modules.
\begin{enumerate}[resume]
\item $\argOneHi$, $\argOneLo$, $\argTwoHi$, $\argTwoLo$, $\res$, $\exoInstruction$
columns containing arguments for computations performed by foreign modules;
\item $\wcpFlag$, $\eucFlag$:
binary flags used as selector for lookups;
\end{enumerate}
\saNote{}
The \INST{} column is $0$ during padding then cycles through a selection of ``block data'' specific opcodes e.g. \texttt{0x\,10} (i.e. \inst{COINBASE}), \texttt{0x\,46} (i.e. \inst{CHAINID}) etc\dots{} see section~(\ref{block data: value constraints}).
7 changes: 7 additions & 0 deletions block_data/computations/_inputs.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\subsection{For \inst{COINBASE }} \label{block data: computations and checks: coinbase} \input{computations/coinbase}
\subsection{For \inst{TIMESTAMP }} \label{block data: computations and checks: timestamp} \input{computations/timestamp}
\subsection{For \inst{NUMBER }} \label{block data: computations and checks: number} \input{computations/number}
\subsection{For \inst{DIFFICULTY}} \label{block data: computations and checks: difficulty} \input{computations/difficulty}
\subsection{For \inst{GASLIMIT }} \label{block data: computations and checks: gaslimit} \input{computations/gaslimit}
\subsection{For \inst{CHAINID }} \label{block data: computations and checks: chainid} \input{computations/chainid}
\subsection{For \inst{BASEFEE }} \label{block data: computations and checks: basefee} \input{computations/basefee}
44 changes: 44 additions & 0 deletions block_data/computations/basefee.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
\begin{center}
\boxed{\text{%
The following constraints assume that
$\left\{ \begin{array}{lcl}
\isBasefee _{i - 1} & = & 0 \\
\isBasefee _{i} & = & 1 \\
\end{array} \right.$}}
\end{center}
We use the following shorthand
\[
\left\{ \begin{array}{lc l}
\currBaseFeeHi & \define & \currDataHi \\
\currBaseFeeLo & \define & \currDataLo \\
\end{array} \right.
\]
We impose the following constraints
\begin{description}
\item[\underline{\underline{Horizontalization of \inst{BASEFEE}:}}]
we impose
\[
\left\{ \begin{array}{lcl}
\currBaseFeeHi & = & 0 \\
\currBaseFeeLo & = & \basefee _{i} \\
\end{array} \right.
\]
\saNote{}
Implementations may further impose, by means of a constraint, the value returned by the \inst{BASEFEE} opcode to some network constant
$\lineaBaseFee{}$.
\item[\underline{\underline{\inst{BASEFEE} bound:}}]
\def\rowOffset{\yellowm{0}}
we impose
\[
\wcpCallToGeq{
anchorRow = i ,
relOffset = \rowOffset ,
argOneHi = \currBaseFeeHi ,
argOneLo = \currBaseFeeLo ,
argTwoHi = 0 ,
argTwoLo = 0 ,
}
\]
\saNote{}
The above ensures that $\basefee _{i} \geq 0$ is well formed (in terms of its high and low parts being $\llarge$-byte integers.)
\end{description}
Loading

0 comments on commit e4b5c18

Please sign in to comment.