diff --git a/Cargo.lock b/Cargo.lock index e02760d..79c7c04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4316,6 +4316,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "update-gas-costs" +version = "1.0.0" +dependencies = [ + "getrandom 0.2.16", + "namada_tx_prelude", + "rlsf", +] + [[package]] name = "update-params" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 24c4c6c..765465f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ members = [ "proposals/mainnet_phases/phase5a", "proposals/mainnet_phases/phase5b", "proposals/mainnet/update-staking-inflation-parameters", - "proposals/testnet/add-uusdc-gas-token", + "proposals/testnet/add-uusdc-gas-token", "proposals/mainnet/update-gas-costs", ] [workspace.package] @@ -22,9 +22,7 @@ version = "1.0.0" [workspace.dependencies] namada_tx_prelude_01502 = { package = "namada_tx_prelude", git = "https://github.com/anoma/namada", tag = "libs-v0.150.2" } -namada_tx_prelude_02512 = { package = "namada_tx_prelude", git = "https://github.com/anoma/namada", tag = "libs-v0.251.2" } namada_proof_of_stake_01502 = { package = "namada_proof_of_stake", git = "https://github.com/anoma/namada", tag = "libs-v0.150.2" } -namada_proof_of_stake_02512 = { package = "namada_proof_of_stake", git = "https://github.com/anoma/namada", tag = "libs-v0.251.2" } rlsf = "0.2.1" getrandom = { version = "0.2", features = ["custom"] } diff --git a/proposals/mainnet/update-gas-costs/Cargo.toml b/proposals/mainnet/update-gas-costs/Cargo.toml new file mode 100644 index 0000000..32141ce --- /dev/null +++ b/proposals/mainnet/update-gas-costs/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "update-gas-costs" +description = "WASM transaction to write minimum gas costs for desired tokens." +authors.workspace = true +edition.workspace = true +license.workspace = true +version.workspace = true + +[dependencies] +namada_tx_prelude_01502.workspace = true +rlsf.workspace = true +getrandom.workspace = true + +[lib] +crate-type = ["cdylib"] \ No newline at end of file diff --git a/proposals/mainnet/update-gas-costs/data.json b/proposals/mainnet/update-gas-costs/data.json new file mode 100644 index 0000000..28b9958 --- /dev/null +++ b/proposals/mainnet/update-gas-costs/data.json @@ -0,0 +1,15 @@ +{ + "rust-version": "1.85.1", + "proposal": { + "title": "Insert title.", + "authors": "Bob The Builer ", + "discussions-to": "www.bob-the-builder.forum.rock", + "abstract": "OPTIONAL: You can put an abstract here if you'd like.", + "motivation": "OPTIONAL: You can put a motivation here if you'd like.", + "details": "Put proposal details here.", + "author": "tnam1qxfj3sf6a0meahdu9t6znp05g8zx4dkjtgyn9gfu", + "voting_start_epoch": 6, + "voting_end_epoch": 12, + "activation_epoch": 18 + } +} \ No newline at end of file diff --git a/proposals/mainnet/update-gas-costs/src/lib.rs b/proposals/mainnet/update-gas-costs/src/lib.rs new file mode 100644 index 0000000..7be6273 --- /dev/null +++ b/proposals/mainnet/update-gas-costs/src/lib.rs @@ -0,0 +1,64 @@ +use std::collections::BTreeMap; + +use namada_tx_prelude::*; +use namada_tx_prelude_01502::{self as namada_tx_prelude, parameters_storage::get_gas_cost_key}; + +pub type ChannelId = &'static str; +pub type BaseToken = &'static str; + +pub type Gas = token::Amount; + +const IBC_TOKENS: [(ChannelId, BaseToken, Gas); 6] = [ + ( + "channel-0", + "stuosmo", + Gas::from_u64(3), // 3 stuosmo / gas unit + ), + ( + "channel-1", + "uosmo", + Gas::from_u64(3), // 3 uosmo / gas unit + ), + ( + "channel-4", + "upenumbra", + Gas::from_u64(3), // 3 upenumbra / gas unit; + ), + ( + "channel-5", + "uusdc", + Gas::from_u64(1), // 1 uusdc / gas unit; + ), + ( + "channel-6", + "unym", + Gas::from_u64(15), // 15 unym / gas unit; + ), + ( + "channel-7", + "untrn", + Gas::from_u64(7), // 7 untrn / gas unit; + ), +]; + +#[transaction] +fn apply_tx(ctx: &mut Ctx, _tx_data: BatchedTx) -> TxResult { + // Read the current gas cost map + let gas_cost_key = get_gas_cost_key(); + let mut minimum_gas_price: BTreeMap = + ctx.read(&gas_cost_key)?.unwrap_or_default(); + + // Enable IBC deposit/withdraws limits + for (channel_id, base_token, gas) in IBC_TOKENS { + let ibc_denom = format!("transfer/{channel_id}/{base_token}"); + let token_address = ibc::ibc_token(&ibc_denom).clone(); + + // Check if this ibc token should can also be used to pay for gas + minimum_gas_price.insert(token_address.clone(), gas); + } + + // Write the gas cost map back to storage + ctx.write(&gas_cost_key, minimum_gas_price)?; + + Ok(()) +}