-
Notifications
You must be signed in to change notification settings - Fork 20
EIP-7623: Increase calldata cost #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
OlivierBBB
wants to merge
13
commits into
main
Choose a base branch
from
EIP-7623-increase-calldata-cost
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
49367be
feat: EIP-7623 documentation
OlivierBBB 832f752
ras
OlivierBBB ca40d6a
ras: make it compile again
OlivierBBB 8a8ec5f
feat: gas limit must cover transaction_floor_cost
OlivierBBB a49c8fd
feat: transactions cost at least transaction_floor_cost
OlivierBBB 84ce08c
feat: reorganization of code
OlivierBBB 5652452
fix: new CT_MAX constants + renamings
OlivierBBB 7010227
feat: using xkeyval for "smallWcpCall" macros
OlivierBBB 58bebb8
feat: use the new macros everywhere
OlivierBBB 92c46a1
Merge branch 'main' into EIP-7623-increase-calldata-cost
OlivierBBB 55641ee
Merge branch 'main' into EIP-7623-increase-calldata-cost
OlivierBBB fc0915d
Merge branch 'main' into EIP-7623-increase-calldata-cost
OlivierBBB e58e332
Merge branch 'main' into EIP-7623-increase-calldata-cost
OlivierBBB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Notes | ||
|
||
This EIP affects two parts of transaction processing: initialization and finalization. | ||
|
||
## Transaction validity | ||
|
||
```java | ||
long upfrontTransactionGasCost = 21_000 | ||
+ (isDeployment ? 32_000 : 0) | ||
+ dataCost(payload) | ||
+ accessListCost(accessList) | ||
+ (isDeployment ? initializationCodeWordCost(payload) : 0) | ||
+ accountDelegationCost(); | ||
|
||
long transactionFloorCost = 21_000 + 10 * weightedTokenCount(payload); | ||
|
||
dataCost(payload) = 4 * weightedTokenCount(payload); | ||
weightedTokenCount(payload) = numberOfZeroBytes(payload) + 4 * numberOfNonzeroBytes(payload); | ||
``` | ||
|
||
Transaction validity encompasses all the usual checks (nonce, balance, comparing `upfrontTransactionGasCost` to `tx.gasLimit()`, ...) and a new check: | ||
|
||
```java | ||
boolean validTransaction = ... // nonce, balance, ... | ||
∧ upfrontTransactionGasCost ≤ tx.gasLimit() | ||
∧ transactionFloorCost ≤ tx.gasLimit() | ||
∧ ...; | ||
``` | ||
|
||
The initial amount of gas the root frame starts with remains the same: | ||
|
||
```java | ||
long gasAvailableForExecution = tx.gasLimit() - upfrontTransactionGasCost; | ||
``` | ||
|
||
## Transaction finalization | ||
|
||
Transaction finalization works just as previously but a floor price `transactionFloorCost` applies to the transaction. This amounts to | ||
|
||
```java | ||
long gasLimit = tx.gasLimit() | ||
long gasRemaining = frame.getRemainingGas() | ||
long effectiveRefund = min( frame.accruedRefunds(), (gasLimit - gasRemaining) / 5) | ||
|
||
long consumedGas = max( gasLimit - gasRemaining - effectiveRefund, transactionFloorCost ) // this is new: previously just "gasLimit - gasRemaining - effectiveRefund" | ||
|
||
senderAccount.getEndOfTransactionGasRefund( effectiveGasPrice, gasLimit, consumedGas ) // something à la "sender.balance += effectiveGasPrice * (gasLimit - consumedGas)" | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
\begin{center} | ||
\boxed{\text{The constraints below assume that } \locAbs_{i} \neq \locAbs_{i - 1}.} | ||
\end{center} | ||
The present section constrains the columns that offload comparisons to the \wcpMod{} module. | ||
The following constraints hold for all transaction types: | ||
\begin{description} | ||
\input{computations/max_nonce_check} | ||
\input{computations/balance_must_cover_value_and_gas} | ||
\input{computations/gas_limit_must_cover_upfront_gas_cost} | ||
\input{computations/gas_limit_must_cover_transaction_floor_cost} | ||
\input{computations/refunds_upper_limit} | ||
\input{computations/refunds_effective} | ||
\input{computations/refunds_vs_floor_cost} | ||
\input{computations/call_data_emptyness_check} | ||
\input{computations/max_gas_price_vs_basefee} | ||
\end{description} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
\begin{center} | ||
\boxed{\text{The constraints below assume that } | ||
\left\{ \begin{array}{lcl} | ||
\locAbs_{i} & \neq & \locAbs_{i - 1} \\ | ||
\txIsTypeTwo_{i} & = & 1 \\ | ||
\end{array} \right.} | ||
\end{center} | ||
The following constraints apply to type 2 transactions only: | ||
\begin{description} | ||
\input{computations/eip_1559_max_fee_vs_max_priority_fee} | ||
\input{computations/eip_1559_effective_gas_price} | ||
\end{description} | ||
|
24 changes: 24 additions & 0 deletions
24
txn_data/computations/balance_must_cover_value_and_gas.tex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
\item[\underline{\underline{Row n$^\circ(i + \balanceRowOffset)$: initial balance must cover value and gas:}}] | ||
we impose that | ||
\[ | ||
\left\{\begin{array}{l} | ||
\smallCallToLeq { | ||
anchorRow = i , | ||
relOffset = \balanceRowOffset , | ||
argOneLo = \locValue + \locMaxFee \cdot \locGasLimit , | ||
argTwoLo = \txInitialBalance _{i} , | ||
} | ||
% {i}{\balanceRowOffset} | ||
% {\locValue + \locMaxFee \cdot \locGasLimit} | ||
% {\txInitialBalance_{i}} | ||
\vspace{2mm} | ||
\\ | ||
\resultMustBeTrue { | ||
anchorRow = i , | ||
relOffset = \balanceRowOffset , | ||
} | ||
\\ | ||
\end{array}\right. | ||
\] | ||
\saNote{} | ||
In other words we require that $\locValue + \locMaxFee \cdot \locGasLimit \leq \txInitialBalance_{i}$. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
\item[\underline{\underline{Row n$°(i + \detectingEmptyCallDataRowOffset)$: detecting empty call data:}}] | ||
\[ | ||
\smallCallToIszero { | ||
anchorRow = i , | ||
relOffset = \detectingEmptyCallDataRowOffset , | ||
argOneLo = \locDataSize , | ||
} | ||
% {i}{\detectingEmptyCallDataRowOffset} | ||
% {\locDataSize} | ||
\] | ||
we further set | ||
\[ | ||
\locNonzeroDataSize \define 1 - \res_{i + \detectingEmptyCallDataRowOffset} | ||
\] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
\item[\underline{\underline{Row n$°(i + \effectiveGasPriceRowOffset)$: computing the effective gas price:}}] | ||
we impose that | ||
\[ | ||
\smallCallToLeq { | ||
anchorRow = i , | ||
relOffset = \effectiveGasPriceRowOffset , | ||
argOneLo = \locMaxPriorityFee + \txBasefee , | ||
argTwoLo = \locMaxFee , | ||
} | ||
% {i}{\effectiveGasPriceRowOffset} | ||
% {\locMaxPriorityFee + \txBasefee} | ||
% {\locMaxFee } | ||
\] | ||
and we define the following shorthand | ||
\[ | ||
\locGetFullTip \define \res_{i + \effectiveGasPriceRowOffset} | ||
\] | ||
\saNote{} | ||
By construction | ||
\[ | ||
\locGetFullTip = 1 \iff \locMaxPriorityFee + \txBasefee \leq \locMaxFee | ||
\] |
25 changes: 25 additions & 0 deletions
25
txn_data/computations/eip_1559_max_fee_vs_max_priority_fee.tex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
\item[\underline{\underline{Row n$°(i + \maxFeeVsMaxPriorityFee)$: comparing \locMaxFee{} and \locMaxPriorityFee{}:}}] | ||
we impose that | ||
\[ | ||
\left\{ \begin{array}{l} | ||
\smallCallToLeq { | ||
anchorRow = i , | ||
relOffset = \maxFeeVsMaxPriorityFee , | ||
argOneLo = \locMaxPriorityFee , | ||
argTwoLo = \locMaxFee , | ||
} | ||
% {i}{\maxFeeVsMaxPriorityFee} | ||
% {\locMaxPriorityFee} | ||
% {\locMaxFee} | ||
\vspace{2mm} | ||
\\ | ||
\resultMustBeTrue { | ||
anchorRow = i , | ||
relOffset = \maxFeeVsMaxPriorityFee , | ||
} | ||
\\ | ||
\end{array} \right. | ||
\] | ||
\saNote{} | ||
The above thus enforces that | ||
$\locMaxPriorityFee \leq \locMaxFee$. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure these are correct