Skip to content

EIP-7623: Increase calldata cost #75

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
1 of 3 tasks
OlivierBBB opened this issue Jan 22, 2025 · 0 comments · May be fixed by #133
Open
1 of 3 tasks

EIP-7623: Increase calldata cost #75

OlivierBBB opened this issue Jan 22, 2025 · 0 comments · May be fixed by #133
Labels
hardfork prague EIP's for the Pectra hardfork London to Prague London to Pectra will implement For those EIP's that will be implemented on Linea
Milestone

Comments

@OlivierBBB
Copy link
Collaborator

OlivierBBB commented Jan 22, 2025

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;
  }
@OlivierBBB OlivierBBB added London to Prague London to Pectra hardfork prague EIP's for the Pectra hardfork will implement For those EIP's that will be implemented on Linea labels Jan 22, 2025
@OlivierBBB OlivierBBB added this to the London to Pectra milestone Mar 22, 2025
@OlivierBBB OlivierBBB linked a pull request Mar 25, 2025 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hardfork prague EIP's for the Pectra hardfork London to Prague London to Pectra will implement For those EIP's that will be implemented on Linea
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant