Skip to content

Commit e4b5c18

Browse files
authored
BLOCKDATA redesign (#19)
1 parent 8b8eacb commit e4b5c18

Some content is hidden

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

47 files changed

+1533
-117
lines changed

block_data/_all_block_data.tex

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
\documentclass{article}
1+
\documentclass[fleqn]{article}
22
\usepackage[dvipsnames]{xcolor}
33
\usepackage{../pkg/common}
4-
% \usepackage{../pkg/dark_theme}
4+
\usepackage{xkeyval}
55
\usepackage{../pkg/std}
66
\usepackage{../pkg/IEEEtrantools}
77
\usepackage{../pkg/rom}
@@ -24,6 +24,10 @@
2424
\usepackage{../pkg/block_data}
2525
\usepackage{../pkg/block_hash}
2626
\usepackage{../pkg/txn_data}
27+
\usepackage{../pkg/iomf_done}
28+
\usepackage{../pkg/xkeyval_macros/wcp_calls}
29+
\usepackage{../pkg/xkeyval_macros/euc_calls}
30+
\usepackage{../pkg/euc}
2731

2832
\usepackage{../pkg/draculatheme}
2933

block_data/_inputs.tex

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
\input{_local}
2+
13
\section{Block data module}
2-
\subsection{Introduction} \label{block data: intro} \input{intro}
3-
\subsection{Columns} \label{block data: columns} \input{columns}
4+
\subsection{Introduction} \label{block data: intro} \input{intro}
5+
\subsection{Columns} \label{block data: columns} \input{columns}
6+
\subsection{Module call macros} \label{block data: module calls} \input{calls}
47

58
\section{Constraints}
6-
\subsection{Heartbeat} \label{block data: heartbeat} \input{heartbeat}
7-
\subsection{Constancies} \label{block data: constancies} \input{constancies}
8-
\subsection{Bytehood and byte decomposition constraints} \label{block data: byte decomposition} \input{byteDec}
9-
\subsection{Value Constraints} \label{block data: value constraints} \input{value_constraint}
9+
\subsection{Shorthands} \label{block data: shorthands} \input{shorthands}
10+
\subsection{Binary constraints} \label{block data: binarities} \input{binarities}
11+
\subsection{Unconditional constraints} \label{block data: unconditional} \input{unconditional}
12+
\subsection{Constancies} \label{block data: constancies} \input{constancies}
13+
\subsection{Heartbeat} \label{block data: heartbeat} \input{heartbeat}
14+
\subsection{Representation} \label{block data: representation} \input{representation}
1015

11-
\section{Lookups} \label{block data: lookups} \input{lookups/_inputs}
16+
\section{Computations and checks} \label{block data: computations and checks} \input{computations/_inputs}
1217

13-
18+
\section{Lookups} \label{block data: lookups} \input{lookups/_inputs}

block_data/_local.tex

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
\def\rOne {\redm{1}}
2+
3+
\def\locIsCoinbase {\col{is\_CB}}
4+
\def\locIsTimestamp {\col{is\_TS}}
5+
\def\locIsNumber {\col{is\_NB}}
6+
\def\locIsDifficulty {\col{is\_DF}}
7+
\def\locIsGaslimit {\col{is\_GL}}
8+
\def\locIsChainid {\col{is\_ID}}
9+
\def\locIsBasefee {\col{is\_BF}}
10+
11+
\def\locIsCurrConf {\col{is\_curr}}
12+
\def\locIsPrevConf {\col{is\_prev}}
13+
\def\locPrevCurrWghtSum {\col{curr\_prev\_wght\_sum}}
14+
15+
\def\locFlagSum {\col{flag\_sum}}
16+
\def\locWghtSum {\col{wght\_sum}}
17+
\def\locInstSum {\col{inst\_sum}}
18+
\def\locMaxCtSum {\col{ct\_max\_sum}}
19+
\def\locPhaseEntry {\col{phase\_entry}}
20+
\def\locSamePhase {\col{same\_phase}}
21+
\def\locLegalTransitions {\col{allowable\_transitions}}
22+
\def\locExtractor {\col{extractor}}
23+
24+
\def\ctMaxCoinbase {\redm{\texttt{nRows}_{\texttt{cb}}}}
25+
\def\ctMaxTimestamp {\redm{\texttt{nRows}_{\texttt{ts}}}}
26+
\def\ctMaxNumber {\redm{\texttt{nRows}_{\texttt{nb}}}}
27+
\def\ctMaxDifficulty {\redm{\texttt{nRows}_{\texttt{df}}}}
28+
\def\ctMaxGaslimit {\redm{\texttt{nRows}_{\texttt{gl}}}}
29+
\def\ctMaxChainid {\redm{\texttt{nRows}_{\texttt{id}}}}
30+
\def\ctMaxBasefee {\redm{\texttt{nRows}_{\texttt{bf}}}}
31+
\def\kappaDots {\redm{\texttt{nRows}_{\texttt{xx}}}}
32+
\def\blockDataDepth {\redm{\texttt{depth}}}
33+
34+
\def\exoInstruction {\col{EXO\_}\instruction}
35+
\def\previousGasLimit {\col{prev\_gas\_limit}}
36+
\def\maxDeviation {\col{max\_deviation}}
37+
38+
\def\locFirstBlockIsGenesisBlock {\col{first\_block\_is\_genesis\_block}}
39+
\def\ethereumMinBlockGasLimit {\red{\texttt{ETHEREUM\_MIN\_BLOCK\_GAS\_LIMIT}}}
40+
\def\lineaMinBlockGasLimit {\red{\texttt{LINEA\_MIN\_BLOCK\_GAS\_LIMIT}}}
41+
\def\lineaMaxBlockGasLimit {\red{\texttt{LINEA\_MAX\_BLOCK\_GAS\_LIMIT}}}
42+
\def\ethereumMinBlockGasLimitValue {\texttt{5\_000}}
43+
\def\lineaMinBlockGasLimitValue {\texttt{61\_000\_000}}
44+
\def\lineaMaxBlockGasLimitValue {\texttt{2\_000\_000\_000}}
45+
\def\ethereumGasLimitAdjustmentFactor {\red{\texttt{GAS\_LIMIT\_ADJUSTMENT\_FACTOR}}}
46+
\def\ethereumGasLimitAdjustmentFactorValue {\texttt{1024}}
47+
48+
\def\locIsFirstBlock {\col{is\_first\_block}}
49+
\def\locIsntFirstBlock {\col{isnt\_first\_block}}
50+
\def\currDataHi {\col{curr\_data\_hi}}
51+
\def\currDataLo {\col{curr\_data\_lo}}
52+
\def\prevDataHi {\col{prev\_data\_hi}}
53+
\def\prevDataLo {\col{prev\_data\_lo}}
54+
55+
\def\currBaseFeeHi {\col{curr\_BASEFEE\_hi}}
56+
\def\currBaseFeeLo {\col{curr\_BASEFEE\_lo}}
57+
\def\prevBaseFeeHi {\col{prev\_BASEFEE\_hi}}
58+
\def\prevBaseFeeLo {\col{prev\_BASEFEE\_lo}}
59+
60+
\def\currChainIdHi {\col{curr\_CHAINID\_hi}}
61+
\def\currChainIdLo {\col{curr\_CHAINID\_lo}}
62+
\def\prevChainIdHi {\col{prev\_CHAINID\_hi}}
63+
\def\prevChainIdLo {\col{prev\_CHAINID\_lo}}
64+
65+
\def\currCoinbaseHi {\col{curr\_COINBASE\_hi}}
66+
\def\currCoinbaseLo {\col{curr\_COINBASE\_lo}}
67+
\def\prevCoinbaseHi {\col{prev\_COINBASE\_hi}}
68+
\def\prevCoinbaseLo {\col{prev\_COINBASE\_lo}}
69+
70+
\def\currDifficultyHi {\col{curr\_DIFFICULTY\_hi}}
71+
\def\currDifficultyLo {\col{curr\_DIFFICULTY\_lo}}
72+
\def\prevDifficultyHi {\col{prev\_DIFFICULTY\_hi}}
73+
\def\prevDifficultyLo {\col{prev\_DIFFICULTY\_lo}}
74+
75+
\def\currGasLimitHi {\col{curr\_GASLIMIT\_hi}}
76+
\def\currGasLimitLo {\col{curr\_GASLIMIT\_lo}}
77+
\def\prevGasLimitHi {\col{prev\_GASLIMIT\_hi}}
78+
\def\prevGasLimitLo {\col{prev\_GASLIMIT\_lo}}
79+
80+
\def\currNumberHi {\col{curr\_NUMBER\_hi}}
81+
\def\currNumberLo {\col{curr\_NUMBER\_lo}}
82+
\def\prevNumberHi {\col{prev\_NUMBER\_hi}}
83+
\def\prevNumberLo {\col{prev\_NUMBER\_lo}}
84+
85+
\def\currTimeStampHi {\col{curr\_TIMESTAMP\_hi}}
86+
\def\currTimeStampLo {\col{curr\_TIMESTAMP\_lo}}
87+
\def\prevTimeStampHi {\col{prev\_TIMESTAMP\_hi}}
88+
\def\prevTimeStampLo {\col{prev\_TIMESTAMP\_lo}}
89+

block_data/binarities.tex

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
We impose \textbf{binary} constraints on the following columns:
2+
\begin{multicols}{3}
3+
\begin{enumerate}
4+
\item $\iomf$
5+
\item $\isCoinbase$
6+
\item $\isTimestamp$
7+
\item $\isNumber$
8+
\item $\isDifficulty$
9+
\item $\isGaslimit$
10+
\item $\isChainid$
11+
\item $\isBasefee$
12+
\end{enumerate}
13+
\end{multicols}

block_data/calls.tex

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
We define several simple constraint systems to simplify the writing of constraints.
2+
\[
3+
\left\{ \begin{array}{lcl}
4+
\wcpCallToLt {
5+
anchorRow = i ,
6+
relOffset = \relof ,
7+
argOneHi = \col{a\_hi} ,
8+
argOneLo = \col{a\_lo} ,
9+
argTwoHi = \col{b\_hi} ,
10+
argTwoLo = \col{b\_lo} ,
11+
} & \define &
12+
\left\{ \begin{array}{lcl}
13+
\wcpFlag _{i + \relof} & = & \rOne \\
14+
\exoInstruction _{i + \relof} & = & \inst{LT} \\
15+
\argOneHi _{i + \relof} & = & \col{a\_hi} \\
16+
\argOneLo _{i + \relof} & = & \col{a\_lo} \\
17+
\argTwoHi _{i + \relof} & = & \col{b\_hi} \\
18+
\argTwoLo _{i + \relof} & = & \col{b\_lo} \\
19+
\res _{i + \relof} & = & 1 \\
20+
\end{array} \right. \vspace{2mm} \\
21+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22+
\wcpCallToGt {
23+
anchorRow = i ,
24+
relOffset = \relof ,
25+
argOneHi = \col{a\_hi} ,
26+
argOneLo = \col{a\_lo} ,
27+
argTwoHi = \col{b\_hi} ,
28+
argTwoLo = \col{b\_lo} ,
29+
} & \define &
30+
\left\{ \begin{array}{lcl}
31+
\wcpFlag _{i + \relof} & = & \rOne \\
32+
\exoInstruction _{i + \relof} & = & \inst{GT} \\
33+
\argOneHi _{i + \relof} & = & \col{a\_hi} \\
34+
\argOneLo _{i + \relof} & = & \col{a\_lo} \\
35+
\argTwoHi _{i + \relof} & = & \col{b\_hi} \\
36+
\argTwoLo _{i + \relof} & = & \col{b\_lo} \\
37+
\res _{i + \relof} & = & 1 \\
38+
\end{array} \right. \vspace{2mm} \\
39+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40+
\wcpCallToLeq {
41+
anchorRow = i ,
42+
relOffset = \relof ,
43+
argOneHi = \col{a\_hi} ,
44+
argOneLo = \col{a\_lo} ,
45+
argTwoHi = \col{b\_hi} ,
46+
argTwoLo = \col{b\_lo} ,
47+
} & \define &
48+
\left\{ \begin{array}{lcl}
49+
\wcpFlag _{i + \relof} & = & \rOne \\
50+
\exoInstruction _{i + \relof} & = & \inst{LEQ} \\
51+
\argOneHi _{i + \relof} & = & \col{a\_hi} \\
52+
\argOneLo _{i + \relof} & = & \col{a\_lo} \\
53+
\argTwoHi _{i + \relof} & = & \col{b\_hi} \\
54+
\argTwoLo _{i + \relof} & = & \col{b\_lo} \\
55+
\res _{i + \relof} & = & 1 \\
56+
\end{array} \right. \vspace{2mm} \\
57+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58+
\wcpCallToGeq {
59+
anchorRow = i ,
60+
relOffset = \relof ,
61+
argOneHi = \col{a\_hi} ,
62+
argOneLo = \col{a\_lo} ,
63+
argTwoHi = \col{b\_hi} ,
64+
argTwoLo = \col{b\_lo} ,
65+
} & \define &
66+
\left\{ \begin{array}{lcl}
67+
\wcpFlag _{i + \relof} & = & \rOne \\
68+
\exoInstruction _{i + \relof} & = & \inst{GEQ} \\
69+
\argOneHi _{i + \relof} & = & \col{a\_hi} \\
70+
\argOneLo _{i + \relof} & = & \col{a\_lo} \\
71+
\argTwoHi _{i + \relof} & = & \col{b\_hi} \\
72+
\argTwoLo _{i + \relof} & = & \col{b\_lo} \\
73+
\res _{i + \relof} & = & 1 \\
74+
\end{array} \right. \vspace{2mm} \\
75+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76+
\wcpCallToIszero {
77+
anchorRow = i ,
78+
relOffset = \relof ,
79+
argOneHi = \col{a\_hi} ,
80+
argOneLo = \col{a\_lo} ,
81+
} & \define &
82+
\left\{ \begin{array}{lcl}
83+
\wcpFlag _{i + \relof} & = & \rOne \\
84+
\exoInstruction _{i + \relof} & = & \inst{ISZERO} \\
85+
\argOneHi _{i + \relof} & = & \col{a\_hi} \\
86+
\argOneLo _{i + \relof} & = & \col{a\_lo} \\
87+
\argTwoHi _{i + \relof} & = & 0 \\
88+
\argTwoLo _{i + \relof} & = & 0 \\
89+
\res _{i + \relof} & = & \relevantValue \\
90+
\end{array} \right. \vspace{2mm} \\
91+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92+
\eucCall {
93+
anchorRow = i ,
94+
relOffset = \relof ,
95+
argOne = \col{a} ,
96+
argTwo = \col{b} ,
97+
} & \define &
98+
\left\{ \begin{array}{lcl}
99+
\eucFlag _{i + \relof} & = & \rOne \\
100+
\argOneLo _{i + \relof} & = & \col{a} \\
101+
\argTwoLo _{i + \relof} & = & \col{b} \\
102+
\end{array} \right. \\
103+
\end{array} \right.
104+
\]
105+
\saNote{}
106+
The result of all comparisons is required to be \texttt{true} except for \inst{ISZERO}.

block_data/columns.tex

+39-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
We remind the reader that \ccc{} stands for ``counter-constant column.''
2+
The first set of columns will be used to define the heartbeat of the \btcMod{} module.
23
\begin{enumerate}
4+
\item $\iomf$:
5+
nondecreasing binary column;
6+
\item $\maxCt$:
7+
counter-constant column;
38
\item $\ct$:
4-
counter column; hovers around zero and then cycles from $0$ to $\maxCtBtcData$;
5-
\item \blockNumberOfFirstBlockInConflation{}:
6-
``conflation-constant'' column containing the block number\footnote{In the sense of the \evm{}} of the first block of this conflation;
7-
\item $\relBlock$:
8-
\ccc{} containing the relative block number;
9-
\item $\relTxMax$:
10-
\ccc{} containing the number of transactions in this block;
11-
\item $\INST$:
9+
counter column; hovers around zero and then cycles from $0$ to $\maxCt$;
10+
\end{enumerate}
11+
We introduce some binary columns linked to the instructions that the present module deals with:
12+
\begin{multicols}{3}
13+
\begin{enumerate}[resume]
14+
\item $\isCoinbase$
15+
\item $\isTimestamp$
16+
\item $\isNumber$
17+
\item $\isDifficulty$
18+
\item $\isGaslimit$
19+
\item $\isChainid$
20+
\item $\isBasefee$
21+
\end{enumerate}
22+
\end{multicols}
23+
\noindent The following columns contain data which is reflected in the \txnDataMod{} module.
24+
\begin{enumerate}[resume, start=13]
25+
\item $\instruction$:
1226
instruction column;
13-
\item $\blockDataHi$, $\blockDataLo$:
14-
columns containing block data;
1527
\item $\coinbase\high$ and $\coinbase\low$:
1628
\ccc{} containing the
1729
coinbase address;
@@ -21,9 +33,22 @@
2133
\item \basefee{}:
2234
\ccc{} containing the
2335
base fee;
24-
\item $\byteCol{HI\_k}$, and $\byteCol{LO\_k}$, $k = 0, 1, \dots, \llargeMO$:
25-
\item $\wcpFlag$:
36+
\end{enumerate}
37+
The following columns pertain to transaction and block numbers.
38+
\begin{enumerate}[resume]
39+
\item \blockNumberOfFirstBlockInConflation{}:
40+
``conflation-constant'' column containing the block number\footnote{In the sense of the \evm{}} of the first block of this conflation;
41+
\item $\relBlock$:
42+
\ccc{} containing the relative block number;
43+
\item $\relTxMax$:
44+
\ccc{} containing the number of transactions in this block;
45+
\item $\blockDataHi$, $\blockDataLo$:
46+
columns containing block data;
47+
\end{enumerate}
48+
The following columns are used in lookups from the \btcMod{} module into the \wcpMod{} and \eucMod{} modules.
49+
\begin{enumerate}[resume]
50+
\item $\argOneHi$, $\argOneLo$, $\argTwoHi$, $\argTwoLo$, $\res$, $\exoInstruction$
51+
columns containing arguments for computations performed by foreign modules;
52+
\item $\wcpFlag$, $\eucFlag$:
2653
binary flags used as selector for lookups;
2754
\end{enumerate}
28-
\saNote{}
29-
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}).

block_data/computations/_inputs.tex

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
\subsection{For \inst{COINBASE }} \label{block data: computations and checks: coinbase} \input{computations/coinbase}
2+
\subsection{For \inst{TIMESTAMP }} \label{block data: computations and checks: timestamp} \input{computations/timestamp}
3+
\subsection{For \inst{NUMBER }} \label{block data: computations and checks: number} \input{computations/number}
4+
\subsection{For \inst{DIFFICULTY}} \label{block data: computations and checks: difficulty} \input{computations/difficulty}
5+
\subsection{For \inst{GASLIMIT }} \label{block data: computations and checks: gaslimit} \input{computations/gaslimit}
6+
\subsection{For \inst{CHAINID }} \label{block data: computations and checks: chainid} \input{computations/chainid}
7+
\subsection{For \inst{BASEFEE }} \label{block data: computations and checks: basefee} \input{computations/basefee}

block_data/computations/basefee.tex

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
\begin{center}
2+
\boxed{\text{%
3+
The following constraints assume that
4+
$\left\{ \begin{array}{lcl}
5+
\isBasefee _{i - 1} & = & 0 \\
6+
\isBasefee _{i} & = & 1 \\
7+
\end{array} \right.$}}
8+
\end{center}
9+
We use the following shorthand
10+
\[
11+
\left\{ \begin{array}{lc l}
12+
\currBaseFeeHi & \define & \currDataHi \\
13+
\currBaseFeeLo & \define & \currDataLo \\
14+
\end{array} \right.
15+
\]
16+
We impose the following constraints
17+
\begin{description}
18+
\item[\underline{\underline{Horizontalization of \inst{BASEFEE}:}}]
19+
we impose
20+
\[
21+
\left\{ \begin{array}{lcl}
22+
\currBaseFeeHi & = & 0 \\
23+
\currBaseFeeLo & = & \basefee _{i} \\
24+
\end{array} \right.
25+
\]
26+
\saNote{}
27+
Implementations may further impose, by means of a constraint, the value returned by the \inst{BASEFEE} opcode to some network constant
28+
$\lineaBaseFee{}$.
29+
\item[\underline{\underline{\inst{BASEFEE} bound:}}]
30+
\def\rowOffset{\yellowm{0}}
31+
we impose
32+
\[
33+
\wcpCallToGeq{
34+
anchorRow = i ,
35+
relOffset = \rowOffset ,
36+
argOneHi = \currBaseFeeHi ,
37+
argOneLo = \currBaseFeeLo ,
38+
argTwoHi = 0 ,
39+
argTwoLo = 0 ,
40+
}
41+
\]
42+
\saNote{}
43+
The above ensures that $\basefee _{i} \geq 0$ is well formed (in terms of its high and low parts being $\llarge$-byte integers.)
44+
\end{description}

0 commit comments

Comments
 (0)