-
Notifications
You must be signed in to change notification settings - Fork 835
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
Gas accounting for EIP-4844 #4992
Conversation
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
@@ -83,6 +84,9 @@ public abstract class MainnetProtocolSpecs { | |||
public static final int SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT = 24576; | |||
public static final int SHANGHAI_INIT_CODE_SIZE_LIMIT = 2 * SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT; | |||
|
|||
private static final int CANCUN_MIN_DATA_GAS_PRICE = 1; |
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.
Maybe we can move that to CancunGasCalculator
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.
done
dataGas = 0L; | ||
} | ||
|
||
final long gasAvailable = transaction.getGasLimit() - intrinsicGas - accessListGas - dataGas; | ||
LOG.trace( | ||
"Gas available for execution {} = {} - {} (limit - intrinsic)", |
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.
can we add dataGas to the log ?
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.
sure, will add also accessListGas that is missing too
transaction.getPayload().size(), maxInitcodeSize)); | ||
} | ||
|
||
if (transaction.getType().supportsBlob()) { |
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.
if we want to push all the cost verification in the same method maybe we can also move this one ?
/** The Cancun gas calculator. */ | ||
public class CancunGasCalculator extends LondonGasCalculator { | ||
|
||
public static final int CANCUN_DATA_GAS_PER_BLOB = 131072; // 2^17 |
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.
maybe we can link the EIP in a comment for future dev
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.
done in the class doc
final long gasAvailable = transaction.getGasLimit() - intrinsicGas - accessListGas; | ||
final long dataGas; | ||
if (feeMarket.implementsDataFee()) { | ||
dataGas = gasCalculator.dataGasCost(transaction.getVersionedHashes().orElseThrow().size()); |
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.
we can use blobcount for this one or remove this one because we are already calculating this value in 306 line
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.
good catch, fixed
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
a962023
to
6c575ec
Compare
Signed-off-by: Fabio Di Fabio <[email protected]>
public static final long CANCUN_DATA_GAS_PER_BLOB = 131072; // 2^17 | ||
public static final long CANCUN_TARGET_DATA_GAS_PER_BLOCK = 262144; // 2^18 |
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.
public static final long CANCUN_DATA_GAS_PER_BLOB = 131072; // 2^17 | |
public static final long CANCUN_TARGET_DATA_GAS_PER_BLOCK = 262144; // 2^18 | |
public static final long CANCUN_DATA_GAS_PER_BLOB = 1 << 17; | |
public static final long CANCUN_TARGET_DATA_GAS_PER_BLOCK = 1 << 18; |
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.
included
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
...e/src/main/java/org/hyperledger/besu/ethereum/core/feemarket/TransactionPriceCalculator.java
Fixed
Show fixed
Hide fixed
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]>
* adding test for nonblob blob transaction * Do not add consumed data gas to gas used in the transaction receipt Signed-off-by: Jiri Peinlich <[email protected]> Signed-off-by: Fabio Di Fabio <[email protected]> Co-authored-by: Jiri Peinlich <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]> Co-authored-by: Justin Florentine <[email protected]>
This reverts commit 0719ded. Signed-off-by: Fabio Di Fabio <[email protected]>
* adding test for nonblob blob transaction * Do not add consumed data gas to gas used in the transaction receipt Signed-off-by: Jiri Peinlich <[email protected]> Signed-off-by: Fabio Di Fabio <[email protected]> Co-authored-by: Jiri Peinlich <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
...um/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java
Fixed
Show fixed
Hide fixed
Signed-off-by: Fabio Di Fabio <[email protected]>
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820) Signed-off-by: Gabriel-Trintinalia <[email protected]>
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820) Signed-off-by: Gabriel-Trintinalia <[email protected]>
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820) Signed-off-by: Gabriel-Trintinalia <[email protected]>
merge of #4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820) Signed-off-by: Gabriel-Trintinalia <[email protected]>
merge of hyperledger#4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of hyperledger#4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of hyperledger#4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of hyperledger#4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of hyperledger#4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of hyperledger#4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of hyperledger#4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of hyperledger#4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820)
merge of hyperledger#4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820) Signed-off-by: Gabriel-Trintinalia <[email protected]>
merge of hyperledger#4992 into interop feature branch Signed-off-by: Fabio Di Fabio <[email protected]> (cherry picked from commit 949e3fe) (cherry picked from commit 9734c983ce00bda161434506688f12ee07bbd820) Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Fabio Di Fabio [email protected]
PR description
This PR introduces the gas accounting for EIP-4844, specifically it introduce a data gas price and a data gas cost.
There is a new fee market named after Cancun that can calculate the data price, a new gas calculator to compute the gas
used by a blob transaction and a new gas limit calculator to track the max data gas per block.
There are changes also to the transactions selection during the block creation to take in account the data gas used and check it against the limits.
Fixed Issue(s)
fixes #4825
Documentation
doc-change-required
label to this PR ifupdates are required.
Changelog