-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
London to PragueLondon to PectraLondon to Pectrahardfork pragueEIP's for the Pectra hardforkEIP's for the Pectra hardforkwill implementFor those EIP's that will be implemented on LineaFor those EIP's that will be implemented on Linea
Milestone
Description
EIP-7623: Increase calldata cost
Progress
- spec EIP-7623: Increase calldata cost #133
- constraints
- tracer
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
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.
// 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
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()));
}
@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
Labels
London to PragueLondon to PectraLondon to Pectrahardfork pragueEIP's for the Pectra hardforkEIP's for the Pectra hardforkwill implementFor those EIP's that will be implemented on LineaFor those EIP's that will be implemented on Linea