Consumed data gas receipt fix (#5018)

* adding test for nonblob blob transaction
* Do not add consumed data gas to gas used in the transaction receipt

Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Jiri Peinlich <jiri.peinlich@gmail.com>
pull/5022/head
Fabio Di Fabio 2 years ago committed by GitHub
parent fd427d4f90
commit b13583ada6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java
  2. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java
  3. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java

@ -342,16 +342,14 @@ public class BlockTransactionSelector {
transaction.isGoQuorumPrivateTransaction(
transactionProcessor.getTransactionValidator().getGoQuorumCompatibilityMode());
final long dataGasUsed = gasCalculator.dataGasCost(transaction.getBlobCount());
final long gasUsedByTransaction =
isGoQuorumPrivateTransaction
? 0
: transaction.getGasLimit() + dataGasUsed - result.getGasRemaining();
isGoQuorumPrivateTransaction ? 0 : transaction.getGasLimit() - result.getGasRemaining();
final long cumulativeGasUsed =
transactionSelectionResult.getCumulativeGasUsed() + gasUsedByTransaction;
final long dataGasUsed = gasCalculator.dataGasCost(transaction.getBlobCount());
transactionSelectionResult.update(
transaction,
transactionReceiptFactory.create(

@ -95,6 +95,9 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {
final PrivateMetadataUpdater privateMetadataUpdater) {
final List<TransactionReceipt> receipts = new ArrayList<>();
long currentGasUsed = 0;
final ProtocolSpec protocolSpec = protocolSchedule.getByBlockHeader(blockHeader);
for (final Transaction transaction : transactions) {
if (!hasAvailableBlockBudget(blockHeader, transaction, currentGasUsed)) {
return new BlockProcessingResult(Optional.empty(), "provided gas insufficient");
@ -132,7 +135,10 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {
}
worldStateUpdater.commit();
currentGasUsed += transaction.getGasLimit() - result.getGasRemaining();
final long dataGasUsed =
protocolSpec.getGasCalculator().dataGasCost(transaction.getBlobCount());
currentGasUsed += transaction.getGasLimit() - result.getGasRemaining() - dataGasUsed;
final TransactionReceipt transactionReceipt =
transactionReceiptFactory.create(
transaction.getType(), result, worldState, currentGasUsed);
@ -140,7 +146,7 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {
}
final Optional<WithdrawalsProcessor> maybeWithdrawalsProcessor =
protocolSchedule.getByBlockHeader(blockHeader).getWithdrawalsProcessor();
protocolSpec.getWithdrawalsProcessor();
if (maybeWithdrawalsProcessor.isPresent() && maybeWithdrawals.isPresent()) {
maybeWithdrawalsProcessor
.get()

@ -658,7 +658,7 @@ public abstract class MainnetProtocolSpecs {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
// extra vaiables need to support flipping the warm coinbase flag.
// extra variables need to support flipping the warm coinbase flag.
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
final long londonForkBlockNumber = genesisConfigOptions.getLondonBlockNumber().orElse(0L);
final BaseFeeMarket londonFeeMarket =

Loading…
Cancel
Save