Skip to content

EIP-7623: Increase calldata cost #75

@OlivierBBB

Description

@OlivierBBB

EIP-7623: Increase calldata cost

Progress

Impact

  • small change in TXN_DATA module
  • and RLP_TXN change interpretation/naming of DATA_GAS_COST column
  • the HUB, TX_INIT and TX_FINAL
  • the lookup HUB/TXN_DATA ?

Notes

  • When do we pay for the extra calldata cost ? Refund or end tax ?
  • Does it impact the coinbase_fee and sender_refund

Test vectors

  • transaction with a BALANCE
  • tests 2 CALLDATA types

Geth implementation

Transaction validation

gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
if err != nil {
	r.Error = err
	results = append(results, r)
	continue
}
r.IntrinsicGas = gas
if tx.Gas() < gas {
	r.Error = fmt.Errorf("%w: have %d, want %d", core.ErrIntrinsicGas, tx.Gas(), gas)
	results = append(results, r)
	continue
}
// For Prague txs, validate the floor data gas.
if rules.IsPrague {
	floorDataGas, err := core.FloorDataGas(tx.Data())
	if err != nil {
		r.Error = err
		results = append(results, r)
		continue
	}
	if tx.Gas() < floorDataGas {
		r.Error = fmt.Errorf("%w: have %d, want %d", core.ErrFloorDataGas, tx.Gas(), floorDataGas)
		results = append(results, r)
		continue
	}
}

Thus floorDataGas is used in transaction validation. It doesn't affect the intrinsic gas which is still computed using the old formula.

Transaction finalization

	// Compute refund counter, capped to a refund quotient.
	gasRefund := st.calcRefund()
	st.gasRemaining += gasRefund
	if rules.IsPrague {
		// After EIP-7623: Data-heavy transactions pay the floor gas.
		if st.gasUsed() < floorDataGas {
			prev := st.gasRemaining
			st.gasRemaining = st.initialGas - floorDataGas
			if t := st.evm.Config.Tracer; t != nil && t.OnGasChange != nil {
				t.OnGasChange(prev, st.gasRemaining, tracing.GasChangeTxDataFloor)
			}
		}
	}
	st.returnGas()

Besu implementation

Transaction validation

    final long baselineGas =
        clampedAdd(
            transaction.getAccessList().map(gasCalculator::accessListGasCost).orElse(0L),
            gasCalculator.delegateCodeGasCost(transaction.codeDelegationListSize()));
    final long intrinsicGasCostOrFloor =
        Math.max(
            gasCalculator.transactionIntrinsicGasCost(
                transaction.getPayload(), transaction.isContractCreation(), baselineGas),
            gasCalculator.transactionFloorCost(transaction.getPayload()));

    if (Long.compareUnsigned(intrinsicGasCostOrFloor, transaction.getGasLimit()) > 0) {
      return ValidationResult.invalid(
          TransactionInvalidReason.INTRINSIC_GAS_EXCEEDS_GAS_LIMIT,
          String.format(
              "intrinsic gas cost %s exceeds gas limit %s",
              intrinsicGasCostOrFloor, transaction.getGasLimit()));
    }

Transaction finalization

  @Override
  public long calculateGasRefund(
      final Transaction transaction,
      final MessageFrame initialFrame,
      final long codeDelegationRefund) {

    final long refundAllowance =
        calculateRefundAllowance(transaction, initialFrame, codeDelegationRefund);

    final long executionGasUsed =
        transaction.getGasLimit() - initialFrame.getRemainingGas() - refundAllowance;
    final long transactionFloorCost = transactionFloorCost(transaction.getPayload());
    final long totalGasUsed = Math.max(executionGasUsed, transactionFloorCost);
    return transaction.getGasLimit() - totalGasUsed;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    London to PragueLondon to Pectrahardfork pragueEIP's for the Pectra hardforkwill implementFor those EIP's that will be implemented on Linea

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions