Skip to content

Introduce gas floor#3941

Open
HDauven wants to merge 4 commits intomasterfrom
introduce-fee-floor
Open

Introduce gas floor#3941
HDauven wants to merge 4 commits intomasterfrom
introduce-fee-floor

Conversation

@HDauven
Copy link
Member

@HDauven HDauven commented Dec 11, 2025

Resolves #3940

- Add min_tx_gas field to VM config
- Reject transactions whose gas_limit is below configured min_tx_gas
- Floor receipt.gas_spent to at least min_tx_gas on successful exeuction
@HDauven HDauven force-pushed the introduce-fee-floor branch from 9d6c7fe to 114416c Compare December 11, 2025 01:02
Copy link
Member

@herr-seppia herr-seppia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to what's been commented, remember that the well-known config should be changed only during a release flow.

#[error("gas price lower than minimum {0}")]
GasPriceTooLow(u64),
#[error("gas limit lower than minimum {0}")]
#[error("gas limit lower than minimum {0} LUX")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gas limit is not expressed in LUX

let min_gas_limit = vm.min_gas_limit();
if tx.inner.gas_limit() < min_gas_limit {
return Err(TxAcceptanceError::GasLimitTooLow(min_gas_limit));
// Check global minimum gas limit and per-tx fee floor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gas limit is not fee


### Added

- Add TX floor price feature, including for well-known chain ids [#3940]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a price

.unwrap_or(false)
}

fn min_tx_gas(&self, height: u64) -> u64 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would return this as Option to be aligned with its meaning

pub generation_timeout: Option<Duration>,

/// Minimum gas charged for any transaction.
pub min_tx_gas: u64,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an option

const MAINNET_BLOB_ACTIVATION: FeatureActivation =
FeatureActivation::Height(MAINNET_AT_10_12_2025_AT_09_00_UTC);

const MAINNET_MIN_TX_GAS_ACTIVATION: FeatureActivation =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should mention a timestamp also

const TESTNET_AT_12_11_2025_AT_09_00_UTC: FeatureActivation =
FeatureActivation::Height(1_814_090);

const TESTNET_MIN_TX_GAS_ACTIVATION: FeatureActivation =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timestamp

// feature min_tx_gas is enabled
use core::cmp::min;

let floor = min(config.min_tx_gas, receipt.gas_limit);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using the gas limit of the tx? Isn't enough to check if the gas spent is lower then the minimum enforced?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using the gas limit of the tx? Isn't enough to check if the gas spent is lower then the minimum enforced?

Leftover, I can actually simplify this to the following now in that branch:

if receipt.gas_spent < config.min_tx_gas {
  receipt.gas_spent = config.min_tx_gas;
}

@HDauven HDauven requested a review from herr-seppia December 11, 2025 12:25
@HDauven HDauven changed the title Introduce fee floor Introduce gas floor Dec 11, 2025
@HDauven HDauven force-pushed the introduce-fee-floor branch from 98e9514 to ff70264 Compare December 11, 2025 22:55
Copy link
Contributor

@miloszm miloszm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one nit

// Enforce gas_limit >= min_tx_gas if min_tx_gas feature is enabled
if config.min_tx_gas > 0 && tx.gas_limit() < config.min_tx_gas {
return Err(Error::Panic(
"transaction gas_limit is below the minimum required gas".into(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change the text of the panic message to:
"transaction gas limit is below the required minimum"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rusk: Introduce protocol-level minimum gas per transaction

3 participants