diff --git a/.changelog/unreleased/improvements/1882-minimum-gas-price.md b/.changelog/unreleased/improvements/1882-minimum-gas-price.md new file mode 100644 index 0000000000..ca05277eb6 --- /dev/null +++ b/.changelog/unreleased/improvements/1882-minimum-gas-price.md @@ -0,0 +1,2 @@ +- Renamed `gas_cost` to `minimum_gas_price` in the genesis file. + ([\#1882](https://github.com/anoma/namada/pull/1882)) \ No newline at end of file diff --git a/apps/src/lib/config/genesis.rs b/apps/src/lib/config/genesis.rs index ac3738a9bc..b7281fd4ce 100644 --- a/apps/src/lib/config/genesis.rs +++ b/apps/src/lib/config/genesis.rs @@ -277,7 +277,7 @@ pub mod genesis_config { pub fee_unshielding_descriptions_limit: u64, /// Map of the cost per gas unit for every token allowed for fee /// payment - pub gas_cost: BTreeMap, + pub minimum_gas_price: BTreeMap, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -616,7 +616,7 @@ pub mod genesis_config { pos_gain_d: parameters.pos_gain_d, staked_ratio: Dec::zero(), pos_inflation_amount: token::Amount::zero(), - gas_cost: parameters.gas_cost, + minimum_gas_price: parameters.minimum_gas_price, fee_unshielding_gas_limit: parameters.fee_unshielding_gas_limit, fee_unshielding_descriptions_limit: parameters .fee_unshielding_descriptions_limit, @@ -885,7 +885,7 @@ pub struct Parameters { /// Fee unshielding descriptions limit pub fee_unshielding_descriptions_limit: u64, /// Map of the cost per gas unit for every token allowed for fee payment - pub gas_cost: BTreeMap, + pub minimum_gas_price: BTreeMap, } #[cfg(not(any(test, feature = "dev")))] @@ -1007,7 +1007,9 @@ pub fn genesis(num_validators: u64) -> Genesis { pos_gain_d: Dec::new(1, 1).expect("This can't fail"), staked_ratio: Dec::zero(), pos_inflation_amount: token::Amount::zero(), - gas_cost: [(nam(), token::Amount::from(1))].into_iter().collect(), + minimum_gas_price: [(nam(), token::Amount::from(1))] + .into_iter() + .collect(), fee_unshielding_gas_limit: 20_000, fee_unshielding_descriptions_limit: 15, }; diff --git a/apps/src/lib/node/ledger/shell/init_chain.rs b/apps/src/lib/node/ledger/shell/init_chain.rs index 174830d87c..d6b2efe4dd 100644 --- a/apps/src/lib/node/ledger/shell/init_chain.rs +++ b/apps/src/lib/node/ledger/shell/init_chain.rs @@ -94,7 +94,7 @@ where pos_gain_d, staked_ratio, pos_inflation_amount, - gas_cost, + minimum_gas_price, fee_unshielding_gas_limit, fee_unshielding_descriptions_limit, } = genesis.parameters; @@ -181,7 +181,7 @@ where pos_gain_d, staked_ratio, pos_inflation_amount, - gas_cost, + minimum_gas_price, fee_unshielding_gas_limit, fee_unshielding_descriptions_limit, }; diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index 778ceffd01..5044b55c9d 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -1358,7 +1358,7 @@ where CA: 'static + WasmCacheAccess + Sync, { // Check that fee token is an allowed one - let gas_cost = namada::ledger::parameters::read_gas_cost( + let minimum_gas_price = namada::ledger::parameters::read_gas_cost( &self.wl_storage, &wrapper.fee.token, ) @@ -1368,12 +1368,14 @@ where wrapper.fee.token ))))?; - if wrapper.fee.amount_per_gas_unit < gas_cost { + if wrapper.fee.amount_per_gas_unit < minimum_gas_price { // The fees do not match the minimum required return Err(Error::TxApply(protocol::Error::FeeError(format!( "Fee amount {:?} do not match the minimum required amount \ {:?} for token {}", - wrapper.fee.amount_per_gas_unit, gas_cost, wrapper.fee.token + wrapper.fee.amount_per_gas_unit, + minimum_gas_price, + wrapper.fee.token )))); } diff --git a/core/src/ledger/parameters/mod.rs b/core/src/ledger/parameters/mod.rs index 31801cf7c5..0ad6d5a918 100644 --- a/core/src/ledger/parameters/mod.rs +++ b/core/src/ledger/parameters/mod.rs @@ -66,7 +66,7 @@ pub struct Parameters { /// Fee unshielding descriptions limit pub fee_unshielding_descriptions_limit: u64, /// Map of the cost per gas unit for every token allowed for fee payment - pub gas_cost: BTreeMap, + pub minimum_gas_price: BTreeMap, } /// Epoch duration. A new epoch begins as soon as both the `min_num_of_blocks` @@ -130,7 +130,7 @@ impl Parameters { pos_gain_d, staked_ratio, pos_inflation_amount, - gas_cost, + minimum_gas_price, fee_unshielding_gas_limit, fee_unshielding_descriptions_limit, } = self; @@ -214,7 +214,7 @@ impl Parameters { storage.write(&pos_inflation_key, pos_inflation_amount)?; let gas_cost_key = storage::get_gas_cost_key(); - storage.write(&gas_cost_key, gas_cost)?; + storage.write(&gas_cost_key, minimum_gas_price)?; Ok(()) } @@ -538,7 +538,7 @@ where // read gas cost let gas_cost_key = storage::get_gas_cost_key(); let value = storage.read(&gas_cost_key)?; - let gas_cost: BTreeMap = value + let minimum_gas_price: BTreeMap = value .ok_or(ReadError::ParametersMissing) .into_storage_result()?; @@ -556,7 +556,7 @@ where pos_gain_d, staked_ratio, pos_inflation_amount, - gas_cost, + minimum_gas_price, fee_unshielding_gas_limit, fee_unshielding_descriptions_limit, }) diff --git a/core/src/ledger/parameters/storage.rs b/core/src/ledger/parameters/storage.rs index 4b4b85822f..31fac1abd4 100644 --- a/core/src/ledger/parameters/storage.rs +++ b/core/src/ledger/parameters/storage.rs @@ -41,7 +41,7 @@ struct Keys { vp_whitelist: &'static str, max_proposal_bytes: &'static str, max_block_gas: &'static str, - gas_cost: &'static str, + minimum_gas_price: &'static str, fee_unshielding_gas_limit: &'static str, fee_unshielding_descriptions_limit: &'static str, max_signatures_per_transaction: &'static str, @@ -192,7 +192,7 @@ pub fn get_max_block_gas_key() -> Key { /// Storage key used for the gas cost table pub fn get_gas_cost_key() -> Key { - get_gas_cost_key_at_addr(ADDRESS) + get_minimum_gas_price_key_at_addr(ADDRESS) } /// Storage key used for the max signatures per transaction key diff --git a/core/src/ledger/storage/mod.rs b/core/src/ledger/storage/mod.rs index 327e8525fa..81be7e48a6 100644 --- a/core/src/ledger/storage/mod.rs +++ b/core/src/ledger/storage/mod.rs @@ -1294,7 +1294,7 @@ mod tests { pos_inflation_amount: token::Amount::zero(), fee_unshielding_gas_limit: 20_000, fee_unshielding_descriptions_limit: 15, - gas_cost: BTreeMap::default(), + minimum_gas_price: BTreeMap::default(), }; parameters.init_storage(&mut wl_storage).unwrap(); diff --git a/genesis/dev.toml b/genesis/dev.toml index 105bdbda19..dded8358d9 100644 --- a/genesis/dev.toml +++ b/genesis/dev.toml @@ -187,7 +187,7 @@ pos_gain_d = "0.1" # The maximum number of signatures allowed per transaction max_signatures_per_transaction = 15 -[parameters.gas_cost] +[parameters.minimum_gas_price] "atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5" = "0.000001" # Proof of stake parameters. diff --git a/genesis/e2e-tests-single-node.toml b/genesis/e2e-tests-single-node.toml index dbf8c1ea76..4a3c02b805 100644 --- a/genesis/e2e-tests-single-node.toml +++ b/genesis/e2e-tests-single-node.toml @@ -165,7 +165,7 @@ pos_gain_d = "0.1" # The maximum number of signatures allowed per transaction max_signatures_per_transaction = 15 -[parameters.gas_cost] +[parameters.minimum_gas_price] "atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5" = "0.000001" # Proof of stake parameters.