Skip to content

Commit

Permalink
STP call cost fix (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBBB authored Nov 28, 2024
1 parent f8a2278 commit 73d9ad2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 39 deletions.
2 changes: 1 addition & 1 deletion hub/instruction_handling/call/precompiles/generalities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
\begin{enumerate}
\item $\gasNext_{i} = \locPrcCallerGas + \locPrcReturnGas$
\item \If $\scenPrcFailure_{i} = 1$ \Then $\locPrcReturnGas = 0$.
\item \If $\scenPrcSuccess_{i} = 1$ \Then we must work on a precompile per precompile basis;
\item \If $\scenPrcSuccess_{i} = 1$ \Then \dots{} will be done on a precompile by precompile basis;
\end{enumerate}
\item[\underline{Setting \nonStackRows{}:}]
we impose
Expand Down
2 changes: 1 addition & 1 deletion stp/_local.tex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
\def\locGasCost {\col{gas\_cost}}
\def\locGasAccess {\col{gas\_access}}
\def\locGasNewAcc {\col{gas\_new\_account}}
\def\locGasTransfer {\col{gas\_transfer}}
\def\locValueTransferGasCost {\col{gas\_transfer}}
\def\locDiff {\col{gas\_diff}}
\def\locGasDiff {\locDiff}
\def\locMin {\col{gas\_min}}
Expand Down
11 changes: 0 additions & 11 deletions stp/call/constraints.tex
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@
\exoInst_{i + 2} & = & \inst{LT} \\
\end{array} \right.
\]
% Where we use the following shorthand:
% \[
% \left[ \begin{array}{lcl}
% \locGasUpfrontCall & := & \gasMxp_{i} + \locGasXtra \\
% \locGasXtra & := & \locGasAccess + \locGasNewAcc + \locGasTransfer \\
% \locGasAccess & := & \warm_{i} \cdot G_{\text{warmaccess}} \\
% & & ~ + (1 - \warm_{i}) \cdot G_{\text{coldaccountaccess}} \\
% \locGasNewAcc & := & \cctv_{i} \cdot (1 - \resLo_{i + 1}) \cdot (1 - \existence_{i}) \cdot G_{\text{newaccount}} \\
% \locGasTransfer & := & \cctv_{i} \cdot (1 - \resLo_{i + 1}) \cdot G_{\text{callvalue}} \\
% \end{array} \right]
% \]
\end{description}
These constraints thus establish $\oogx$; indeed
\[
Expand Down
4 changes: 2 additions & 2 deletions stp/call/setting.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
\item[\underline{The ``no \oogxSH{}'' case:}] \If $\oogx_{i} = 0$ \Then
\begin{enumerate}
\item $\gasUpfront_{i} = \locGasUpfrontCall$
\item $\gasPoop_{i} = \locMin$
\item $\gasPoop_{i} = \locMin$
\item $\gasStipend_{i} = \cctv_{i} \cdot \locTransfersValue \cdot G_{\text{callstipend}}$
% Where we set
% \begin{IEEEeqnarray*}{LCL}
Expand All @@ -26,7 +26,7 @@
\item[\underline{The ``\oogxSH{}'' case:}] \If $\oogx_{i} = 1$ \Then
\begin{enumerate}
\item $\gasUpfront_{i} = \locGasUpfrontCall$
\item $\gasPoop_{i} = 0$
\item $\gasPoop_{i} = 0$
\item $\gasStipend_{i} = 0$
\end{enumerate}
\end{description}
69 changes: 45 additions & 24 deletions stp/call/shorthands.tex
Original file line number Diff line number Diff line change
@@ -1,52 +1,73 @@
For greater expressivity we use the following shorthands
\[
\left\{ \begin{array}{lrl}
\locTransfersValue & \define &
\locTransfersValue & \define &
\begin{cases}
\If \locCctv = 0: & 0 \\
\If \locCctv = 1: & 1 - \resLo_{i + 1} \\
\end{cases} \\
& \equiv & \locCctv \cdot (1 - \resLo_{i + 1}) \vspace{2mm} \\
\locZeroValue & \define &
& \define &
\locCctv \cdot (1 - \resLo_{i + 1})
\vspace{2mm} \\
%%%%%%%%%%
\locZeroValue & \define &
\begin{cases}
\If \locCctv = 0: & 0 \\
\If \locCctv = 1: & \resLo_{i + 1} \\
\end{cases} \\
& \equiv & \locCctv \cdot \resLo_{i + 1} \vspace{2mm} \\
\locGasAccess & \define &
& \define & \locCctv \cdot \resLo_{i + 1}
\vspace{2mm} \\
%%%%%%%%%%
\locGasAccess & \define &
\begin{cases}
\If \locWarm = 1: & G_\text{warmaccess} \\
\If \locWarm = 1: & G_\text{warmaccess} \\
\If \locWarm = 0: & G_\text{coldaccountaccess} \\
\end{cases} \\
\locGasTransfer & \define &
\end{cases}
\vspace{2mm} \\
%%%%%%%%%%
\locValueTransferGasCost & \define &
\begin{cases}
\If \locTransfersValue = 1: & G_\text{callvalue} \\
\If \locTransfersValue = 0: & 0 \\
\If \locTransfersValue = 0: & 0 \\
\end{cases} \\
& \equiv & \locTransfersValue \cdot G_\text{callvalue} \vspace{2mm} \\
\locGasNewAcc & \define &
& \define & \locTransfersValue \cdot G_\text{callvalue}
\vspace{2mm} \\
%%%%%%%%%%
\locGasNewAcc & \define &
\begin{cases}
\If \locExists = 1 \vee \locTransfersValue = 0: & 0 \\
\If \locExists = 0 \wedge \locTransfersValue = 1: & G_\text{newaccount} \\
\If \stpCall_{i} = 0 ~ \Then & 0 \\
\If \stpCall_{i} = 1 ~ \Then &
\begin{cases}
\If \locExists = 1 \vee \locTransfersValue = 0 : & 0 \\
\If \locExists = 0 \wedge \locTransfersValue = 1 : & G_\text{newaccount} \\
\end{cases}
\end{cases} \\
& \equiv & (1 - \locExists) \cdot \locTransfersValue \cdot G_\text{newaccount} \vspace{2mm} \\
\locGasXtra & \define & \locGasAccess + \locGasTransfer + \locGasNewAcc \\
\locGasUpfrontCall & \define & \locGasMxp + \locGasXtra \vspace{2mm} \\
\locOneSixtyFourth & \define & \resLo_{i + 3} \\
\locGasCompBit & \define & \resLo_{i + 4} \\
\locDiff & \define & \locGasActl ~ - ~ \locGasUpfrontCall \\
\locLOfGasDiff & \define & \locGasDiff ~ - ~ \locOneSixtyFourth \\
\locMin & \define &
& \define &
G_\text{newaccount} \cdot
\left[ \begin{array}{cr}
\cdot & \stpCall_{i} \\
\cdot & (1 - \locExists) \\
\cdot & \locTransfersValue \\
\end{array} \right]
\vspace{2mm} \\
%%%%%%%%%%
\locGasXtra & \define & \locGasAccess + \locValueTransferGasCost + \locGasNewAcc \\
\locGasUpfrontCall & \define & \locGasMxp + \locGasXtra \vspace{2mm} \\
\locOneSixtyFourth & \define & \resLo_{i + 3} \\
\locGasCompBit & \define & \resLo_{i + 4} \\
\locDiff & \define & \locGasActl ~ - ~ \locGasUpfrontCall \\
\locLOfGasDiff & \define & \locGasDiff ~ - ~ \locOneSixtyFourth \\
\locMin & \define &
\begin{cases}
\If \locGasCompBit = 0 : & \locLOfGasDiff \\
\If \locGasCompBit = 1 : & \gasLo_{i} \\
\If \locGasCompBit = 1 : & \gasLo_{i} \\
\end{cases} \\
\end{array} \right.
\]
These are only to be used if the row index $i$ is such that
\[
\begin{cases}
\stpStamp_{i} \neq \stpStamp_{i - 1} \\
\isCall _{i} = 1 \\
\stpStamp _{i} \neq \stpStamp_{i - 1} \\
\isCall _{i} = 1 \\
\end{cases}
\]

0 comments on commit 73d9ad2

Please sign in to comment.