Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"] }
Expand Down
15 changes: 15 additions & 0 deletions proposals/mainnet/update-gas-costs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 15 additions & 0 deletions proposals/mainnet/update-gas-costs/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"rust-version": "1.85.1",
"proposal": {
"title": "Insert title.",
"authors": "Bob The Builer <[email protected]>",
"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
}
}
64 changes: 64 additions & 0 deletions proposals/mainnet/update-gas-costs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<Address, token::Amount> =
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(())
}
Loading