Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: enable default ibc #12

Closed
wants to merge 3 commits into from
Closed
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
278 changes: 187 additions & 91 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 4 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ members = [
"staking_party",
"shielding_party",
"shielding_reward_party",
]

default-members = [
"block_party",
"staking_party",
"shielding_party",
"shielding_reward_party",
"enable_ibc"
]

[workspace.package]
Expand All @@ -22,8 +16,9 @@ license = "GPL-3.0"
version = "0.1.0"

[workspace.dependencies]
namada_tx_prelude = { git = "https://github.com/anoma/namada", tag = "v0.41.0" }
namada_proof_of_stake = { git = "https://github.com/anoma/namada", tag = "v0.41.0" }
namada_tx_prelude = { git = "https://github.com/anoma/namada", tag = "v0.43.0" }
namada_proof_of_stake = { git = "https://github.com/anoma/namada", tag = "v0.43.0" }
namada_ibc = { git = "https://github.com/anoma/namada", tag = "v0.43.0" }
rlsf = "0.2.1"
getrandom = { version = "0.2", features = ["custom"] }
lazy_static = "1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ source:
COPY --keep-ts Cargo.toml Cargo.lock ./
COPY --keep-ts --chmod 755 docker/run-wasmopt.sh ./run-wasmopt.sh
COPY --keep-ts --chmod 755 docker/download-wasmopt.sh ./download-wasmopt.sh
COPY --keep-ts --dir block_party shielding_party staking_party shielding_reward_party ./
COPY --keep-ts --dir block_party shielding_party staking_party shielding_reward_party enable_ibc ./

# lint runs cargo clippy on the source code
lint:
Expand Down
2 changes: 1 addition & 1 deletion block_party/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use namada_proof_of_stake::storage::{read_pos_params, write_pos_params};
#[transaction]
fn apply_tx(ctx: &mut Ctx, _tx_data: BatchedTx) -> TxResult {
// PoS inflation
let mut pos_params = read_pos_params(ctx)?.owned;
let mut pos_params = read_pos_params::<_, governance::Store<_>>(ctx)?.owned;
pos_params.max_inflation_rate = Dec::from_str("0.1").unwrap();
pos_params.target_staked_ratio = Dec::from_str("0.666667").unwrap();
pos_params.rewards_gain_p = Dec::from_str("2.5").unwrap();
Expand Down
18 changes: 18 additions & 0 deletions enable_ibc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "enable_ibc"
description = "WASM transaction to enable IBC on any IBC tokens."
authors.workspace = true
edition.workspace = true
license.workspace = true
version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
namada_tx_prelude.workspace = true
namada_ibc.workspace = true
rlsf.workspace = true
getrandom.workspace = true

[lib]
crate-type = ["cdylib"]
15 changes: 15 additions & 0 deletions enable_ibc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use namada_ibc::parameters::IbcParameters;
use namada_tx_prelude::*;

#[transaction]
fn apply_tx(ctx: &mut Ctx, _tx_data: BatchedTx) -> TxResult {
let ibc_parameters = IbcParameters {
default_mint_limit: token::Amount::native_whole(10000000),
default_per_epoch_throughput_limit: token::Amount::native_whole(10000000),
};

let ibc_parameters_key = namada_ibc::storage::params_key();
ctx.write(&ibc_parameters_key, ibc_parameters)?;

Ok(())
}
15 changes: 3 additions & 12 deletions shielding_party/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,13 @@ fn apply_tx(ctx: &mut Ctx, _tx_data: BatchedTx) -> TxResult {
&shielded_native_token_last_locked_amount_key,
token::Amount::zero(),
)?;
ctx.write(
&shielded_native_token_max_rewards_key,
Dec::zero(),
)?;
ctx.write(&shielded_native_token_max_rewards_key, Dec::zero())?;
ctx.write(
&shielded_native_token_target_locked_amount_key,
token::Amount::from_uint(0, 6).unwrap(),
)?;
ctx.write(
&shielded_native_token_kp_gain_key,
Dec::zero(),
)?;
ctx.write(
&shielded_native_token_kd_gain_key,
Dec::zero(),
)?;
ctx.write(&shielded_native_token_kp_gain_key, Dec::zero())?;
ctx.write(&shielded_native_token_kd_gain_key, Dec::zero())?;

// Enable shielded set rewards for ibc tokens
for (denomination, channel_id, base_token, max_reward, target_locked_amount, kp, kd) in
Expand Down
2 changes: 1 addition & 1 deletion shielding_reward_party/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub const KD_GAIN: &str = "120000";
#[transaction]
fn apply_tx(ctx: &mut Ctx, _tx_data: BatchedTx) -> TxResult {
let nam_address = ctx.get_native_token()?;

// Enable NAM transfers
let native_token_transferable_key = parameters_storage::get_native_token_transferable_key();
ctx.write(&native_token_transferable_key, true)?;
Expand Down