From 79bf9479e1fba86c4526159343d69b42246786a4 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Mon, 17 Jul 2017 11:51:11 +0200 Subject: [PATCH 1/2] Implement EIP-658 https://github.com/ethereum/EIPs/pull/658 Now transaction receipts contain one byte indicating success or failure. --- Paper.tex | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/Paper.tex b/Paper.tex index c73dcffd..4b588b98 100644 --- a/Paper.tex +++ b/Paper.tex @@ -330,9 +330,9 @@ \subsubsection{Transaction Receipt} In order to encode information about a transaction concerning which it may be useful to form a zero-knowledge proof, or index and search, we encode a receipt of each transaction containing certain information from concerning its execution. Each receipt, denoted $B_\mathbf{R}[i]$ for the $i$th transaction, is placed in an index-keyed trie and the root recorded in the header as $H_e$. -The transaction receipt is a tuple of four items comprising the cumulative gas used in the block containing the transaction receipt as of immediately after the transaction has happened, $R_u$, the set of logs created through execution of the transaction, $R_\mathbf{l}$ and the Bloom filter composed from information in those logs, $R_b$: +The transaction receipt is a tuple of four items comprising the cumulative gas used in the block containing the transaction receipt as of immediately after the transaction has happened, $R_u$, the set of logs created through execution of the transaction, $R_\mathbf{l}$ and the Bloom filter composed from information in those logs, $R_b$ and the status code of the transaction, $R_{s'}$: \begin{equation} -R \equiv (R_u, R_b, R_\mathbf{l}) +R \equiv (R_u, R_b, R_\mathbf{l}, R_{s'}) \end{equation} The function $L_R$ trivially prepares a transaction receipt for being transformed into an RLP-serialised byte array: @@ -341,6 +341,11 @@ \subsubsection{Transaction Receipt} \end{equation} where $0 \in \mathbb{B}_{256}$ replaces the pre-transaction state root that existed in previous versions of the protocol. +We assert that the status code $R_{s'}$ is a single byte. +\begin{equation} +R_{s'} \in \mathbb{B}_{8} +\end{equation} + We assert $R_u$, the cumulative gas used is a positive integer and that the logs Bloom, $R_b$, is a hash of size 2048 bits (256 bytes): \begin{equation} R_u \in \mathbb{P} \quad \wedge \quad R_b \in \mathbb{B}_{256} @@ -597,11 +602,11 @@ \subsection{Execution} \boldsymbol{\sigma}_0[S(T)]_n & \equiv & \boldsymbol{\sigma}[S(T)]_n + 1 \end{eqnarray} -Evaluating $\boldsymbol{\sigma}_P$ from $\boldsymbol{\sigma}_0$ depends on the transaction type; either contract creation or message call; we define the tuple of post-execution provisional state $\boldsymbol{\sigma}_P$, remaining gas $g'$ and substate $A$: +Evaluating $\boldsymbol{\sigma}_P$ from $\boldsymbol{\sigma}_0$ depends on the transaction type; either contract creation or message call; we define the tuple of post-execution provisional state $\boldsymbol{\sigma}_P$, remaining gas $g'$, substate $A$ and status code $s'$: \begin{equation} -(\boldsymbol{\sigma}_P, g', A) \equiv \begin{cases} +(\boldsymbol{\sigma}_P, g', A, s') \equiv \begin{cases} \Lambda(\boldsymbol{\sigma}_0, S(T), T_o, &\\ \quad\quad g, T_p, T_v, T_\mathbf{i}, 0) & \text{if} \quad T_t = \varnothing \\ -\Theta_{3}(\boldsymbol{\sigma}_0, S(T), T_o, &\\ \quad\quad T_t, T_t, g, T_p, T_v, T_v, T_\mathbf{d}, 0) & \text{otherwise} +\Theta_{4}(\boldsymbol{\sigma}_0, S(T), T_o, &\\ \quad\quad T_t, T_t, g, T_p, T_v, T_v, T_\mathbf{d}, 0) & \text{otherwise} \end{cases} \end{equation} @@ -634,10 +639,11 @@ \subsection{Execution} \forall i \in A_\mathbf{s}: \boldsymbol{\sigma}'[i] & \equiv & \varnothing \end{eqnarray} -And finally, we specify $\Upsilon^g$, the total gas used in this transaction and $\Upsilon^\mathbf{l}$, the logs created by this transaction: +And finally, we specify $\Upsilon^g$, the total gas used in this transaction, $\Upsilon^\mathbf{l}$, the logs created by this transaction and $\Upsilon^{s}$, the status code of this transaction: \begin{eqnarray} \Upsilon^g(\boldsymbol{\sigma}, T) & \equiv & T_g - g' \\ -\Upsilon^\mathbf{l}(\boldsymbol{\sigma}, T) & \equiv & A_\mathbf{l} +\Upsilon^\mathbf{l}(\boldsymbol{\sigma}, T) & \equiv & A_\mathbf{l} \\ +\Upsilon^s(\boldsymbol{\sigma}, T) & \equiv & s' \end{eqnarray} These are used to help define the transaction receipt, discussed later. @@ -648,7 +654,7 @@ \section{Contract Creation} \label{ch:create} We define the creation function formally as the function $\Lambda$, which evaluates from these values, together with the state $\boldsymbol{\sigma}$ to the tuple containing the new state, remaining gas and accrued transaction substate $(\boldsymbol{\sigma}', g', A)$, as in section \ref{ch:transactions}: \begin{equation} -(\boldsymbol{\sigma}', g', A) \equiv \Lambda(\boldsymbol{\sigma}, s, o, g, p, v, \mathbf{i}, e) +(\boldsymbol{\sigma}', g', A, s') \equiv \Lambda(\boldsymbol{\sigma}, s, o, g, p, v, \mathbf{i}, e) \end{equation} The address of the new account is defined as being the rightmost 160 bits of the Keccak hash of the RLP encoding of the structure containing only the sender and the nonce. Thus we define the resultant address for the new account $a$: @@ -720,6 +726,10 @@ \section{Contract Creation} \label{ch:create} \boldsymbol{\sigma}^{**} & \text{if} \quad g^{**} Date: Mon, 28 Aug 2017 16:38:06 +0200 Subject: [PATCH 2/2] Fix the status code representation --- Paper.tex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Paper.tex b/Paper.tex index 4b588b98..52a63652 100644 --- a/Paper.tex +++ b/Paper.tex @@ -341,9 +341,9 @@ \subsubsection{Transaction Receipt} \end{equation} where $0 \in \mathbb{B}_{256}$ replaces the pre-transaction state root that existed in previous versions of the protocol. -We assert that the status code $R_{s'}$ is a single byte. +We assert that the status code $R_{s'}$ is an integer. \begin{equation} -R_{s'} \in \mathbb{B}_{8} +R_{s'} \in \mathbb{P} \end{equation} We assert $R_u$, the cumulative gas used is a positive integer and that the logs Bloom, $R_b$, is a hash of size 2048 bits (256 bytes): @@ -713,7 +713,7 @@ \section{Contract Creation} \label{ch:create} The gas remaining will be zero in any such exceptional condition, \ie if the creation was conducted as the reception of a transaction, then this doesn't affect payment of the intrinsic cost of contract creation; it is paid regardless. However, the value of the transaction is not transferred to the aborted contract's address when we are out-of-gas. -If such an exception does not occur, then the remaining gas is refunded to the originator and the now-altered state is allowed to persist. Thus formally, we may specify the resultant state, gas and substate as $(\boldsymbol{\sigma}', g', A)$ where: +If such an exception does not occur, then the remaining gas is refunded to the originator and the now-altered state is allowed to persist. Thus formally, we may specify the resultant state, gas, substate and status code as $(\boldsymbol{\sigma}', g', A, s')$ where: \begin{align} \quad g' &\equiv \begin{cases}