diff --git a/Cargo.lock b/Cargo.lock index 84cbd6f48e..1c0d1cb6d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "0.2.0" -source = "git+https://github.com/anoma/masp?rev=50acc5028fbcd52a05970fe7991c7850ab04358e#50acc5028fbcd52a05970fe7991c7850ab04358e" +source = "git+https://github.com/anoma/masp?rev=1345b463e8fa3b3a6fa13e4a43fb1c410690ad62#1345b463e8fa3b3a6fa13e4a43fb1c410690ad62" dependencies = [ "borsh 0.9.4", "chacha20 0.9.1", @@ -3761,7 +3761,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "0.9.0" -source = "git+https://github.com/anoma/masp?rev=50acc5028fbcd52a05970fe7991c7850ab04358e#50acc5028fbcd52a05970fe7991c7850ab04358e" +source = "git+https://github.com/anoma/masp?rev=1345b463e8fa3b3a6fa13e4a43fb1c410690ad62#1345b463e8fa3b3a6fa13e4a43fb1c410690ad62" dependencies = [ "aes 0.7.5", "bip0039", @@ -3792,7 +3792,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "0.9.0" -source = "git+https://github.com/anoma/masp?rev=50acc5028fbcd52a05970fe7991c7850ab04358e#50acc5028fbcd52a05970fe7991c7850ab04358e" +source = "git+https://github.com/anoma/masp?rev=1345b463e8fa3b3a6fa13e4a43fb1c410690ad62#1345b463e8fa3b3a6fa13e4a43fb1c410690ad62" dependencies = [ "bellman", "blake2b_simd", diff --git a/Cargo.toml b/Cargo.toml index 9c731f0fdf..db71e92989 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,8 +90,8 @@ libc = "0.2.97" libloading = "0.7.2" libsecp256k1 = {git = "https://github.com/heliaxdev/libsecp256k1", rev = "bbb3bd44a49db361f21d9db80f9a087c194c0ae9", default-features = false, features = ["std", "static-context"]} # branch = "murisi/namada-integration" -masp_primitives = { git = "https://github.com/anoma/masp", rev = "50acc5028fbcd52a05970fe7991c7850ab04358e" } -masp_proofs = { git = "https://github.com/anoma/masp", rev = "50acc5028fbcd52a05970fe7991c7850ab04358e", default-features = false, features = ["local-prover"] } +masp_primitives = { git = "https://github.com/anoma/masp", rev = "1345b463e8fa3b3a6fa13e4a43fb1c410690ad62" } +masp_proofs = { git = "https://github.com/anoma/masp", rev = "1345b463e8fa3b3a6fa13e4a43fb1c410690ad62", default-features = false, features = ["local-prover"] } num256 = "0.3.5" num_cpus = "1.13.0" num-derive = "0.3.3" diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index d750ccc759..1645009011 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -2126,7 +2126,7 @@ pub async fn query_conversions< // Track whether any non-sentinel conversions are found let mut conversions_found = false; for ((addr, _), epoch, conv, _) in conv_state.assets.values() { - let amt: masp_primitives::transaction::components::I32Sum = + let amt: masp_primitives::transaction::components::I128Sum = conv.clone().into(); // If the user has specified any targets, then meet them // If we have a sentinel conversion, then skip printing @@ -2181,7 +2181,7 @@ pub async fn query_conversion( Address, MaspDenom, Epoch, - masp_primitives::transaction::components::I32Sum, + masp_primitives::transaction::components::I128Sum, MerklePath, )> { namada::sdk::rpc::query_conversion(client, asset_type).await diff --git a/apps/src/lib/config/genesis.rs b/apps/src/lib/config/genesis.rs index eac5f5bdca..3331a30c03 100644 --- a/apps/src/lib/config/genesis.rs +++ b/apps/src/lib/config/genesis.rs @@ -1012,8 +1012,8 @@ pub fn genesis(num_validators: u64) -> Genesis { implicit_vp_code_path: vp_implicit_path.into(), implicit_vp_sha256: Default::default(), max_signatures_per_transaction: 15, - epochs_per_year: 525_600, /* seconds in yr (60*60*24*365) div seconds - * per epoch (60 = min_duration) */ + epochs_per_year: 365, /* seconds in yr (60*60*24*365) div seconds + * per epoch (60 = min_duration) */ pos_gain_p: Dec::new(1, 1).expect("This can't fail"), pos_gain_d: Dec::new(1, 1).expect("This can't fail"), staked_ratio: Dec::zero(), diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index 346a3f916b..525ed86ec4 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -618,10 +618,8 @@ where /// with respect to the previous epoch. fn apply_inflation(&mut self, current_epoch: Epoch) -> Result<()> { let last_epoch = current_epoch.prev(); - // Get input values needed for the PD controller for PoS and MASP. + // Get input values needed for the PD controller for PoS. // Run the PD controllers to calculate new rates. - // - // MASP is included below just for some completeness. let params = read_pos_params(&self.wl_storage)?; @@ -653,15 +651,6 @@ where let pos_locked_ratio_target = params.target_staked_ratio; let pos_max_inflation_rate = params.max_inflation_rate; - // TODO: properly fetch these values (arbitrary for now) - let masp_locked_supply: Amount = Amount::default(); - let masp_locked_ratio_target = Dec::new(5, 1).expect("Cannot fail"); - let masp_locked_ratio_last = Dec::new(5, 1).expect("Cannot fail"); - let masp_max_inflation_rate = Dec::new(2, 1).expect("Cannot fail"); - let masp_last_inflation_rate = Dec::new(12, 2).expect("Cannot fail"); - let masp_p_gain = Dec::new(1, 1).expect("Cannot fail"); - let masp_d_gain = Dec::new(1, 1).expect("Cannot fail"); - // Run rewards PD controller let pos_controller = inflation::RewardsController { locked_tokens: pos_locked_supply, @@ -675,27 +664,12 @@ where d_gain_nom: pos_d_gain_nom, epochs_per_year, }; - let _masp_controller = inflation::RewardsController { - locked_tokens: masp_locked_supply, - total_tokens, - total_native_tokens: total_tokens, - locked_ratio_target: masp_locked_ratio_target, - locked_ratio_last: masp_locked_ratio_last, - max_reward_rate: masp_max_inflation_rate, - last_inflation_amount: token::Amount::from( - masp_last_inflation_rate, - ), - p_gain_nom: masp_p_gain, - d_gain_nom: masp_d_gain, - epochs_per_year, - }; // Run the rewards controllers let inflation::ValsToUpdate { locked_ratio, inflation, } = pos_controller.run(); - // let new_masp_vals = _masp_controller.run(); // Get the number of blocks in the last epoch let first_block_of_last_epoch = self diff --git a/apps/src/lib/node/ledger/shell/init_chain.rs b/apps/src/lib/node/ledger/shell/init_chain.rs index 46d4222983..abe231e9af 100644 --- a/apps/src/lib/node/ledger/shell/init_chain.rs +++ b/apps/src/lib/node/ledger/shell/init_chain.rs @@ -338,11 +338,14 @@ where // Init token parameters and last inflation and caching rates parameters.init_storage(&address, &mut self.wl_storage); self.wl_storage - .write(&token::masp_last_inflation(&address), last_inflation) + .write( + &token::masp_last_inflation_key(&address), + last_inflation, + ) .unwrap(); self.wl_storage .write( - &token::masp_last_locked_ratio(&address), + &token::masp_last_locked_ratio_key(&address), last_locked_ratio, ) .unwrap(); diff --git a/core/src/ledger/storage/masp_conversions.rs b/core/src/ledger/storage/masp_conversions.rs index 5b195dd29d..d9b13526fe 100644 --- a/core/src/ledger/storage/masp_conversions.rs +++ b/core/src/ledger/storage/masp_conversions.rs @@ -10,6 +10,7 @@ use masp_primitives::sapling::Node; use crate::ledger::inflation::{RewardsController, ValsToUpdate}; use crate::ledger::parameters; +use crate::ledger::storage_api::token::read_denom; use crate::ledger::storage_api::{StorageRead, StorageWrite}; use crate::types::address::Address; use crate::types::dec::Dec; @@ -17,18 +18,11 @@ use crate::types::storage::Epoch; use crate::types::token::MaspDenom; use crate::types::{address, token}; -/// Inflation is implicitly denominated by this value. The lower this figure, -/// the less precise inflation computations are. The higher this figure, the -/// larger the fixed-width types that are required to carry out inflation -/// computations. This value should be fixed constant for each asset type - here -/// we have simplified it and made it constant across asset types. -const PRECISION: u64 = 100; - /// A representation of the conversion state #[derive(Debug, Default, BorshSerialize, BorshDeserialize)] pub struct ConversionState { /// The last amount of the native token distributed - pub normed_inflation: Option, + pub normed_inflation: Option, /// The tree currently containing all the conversions pub tree: FrozenCommitmentTree, /// Map assets to their latest conversion and position in Merkle tree @@ -44,11 +38,20 @@ pub struct ConversionState { pub fn calculate_masp_rewards( wl_storage: &mut super::WlStorage, addr: &Address, -) -> crate::ledger::storage_api::Result<(u32, u32)> +) -> crate::ledger::storage_api::Result<(u128, u128)> where D: 'static + super::DB + for<'iter> super::DBIter<'iter>, H: 'static + super::StorageHasher, { + let denomination = read_denom(wl_storage, addr).unwrap().unwrap(); + // Inflation is implicitly denominated by this value. The lower this + // figure, the less precise inflation computations are. This is especially + // problematic when inflation is coming from a token with much higher + // denomination than the native token. The higher this figure, the higher + // the threshold of holdings required in order to receive non-zero rewards. + // This value should be fixed constant for each asset type. + let precision = 10u128.pow(std::cmp::max(u32::from(denomination.0), 3) - 3); + let masp_addr = address::masp(); // Query the storage for information @@ -69,38 +72,33 @@ where let epochs_per_year: u64 = wl_storage .read(¶meters::storage::get_epochs_per_year_key())? - .expect(""); + .expect("epochs per year should properly decode"); //// Values from the last epoch let last_inflation: token::Amount = wl_storage - .read(&token::masp_last_inflation(addr)) - .expect("failure to read last inflation") - .expect(""); + .read(&token::masp_last_inflation_key(addr))? + .expect("failure to read last inflation"); let last_locked_ratio: Dec = wl_storage - .read(&token::masp_last_locked_ratio(addr)) - .expect("failure to read last inflation") - .expect(""); + .read(&token::masp_last_locked_ratio_key(addr))? + .expect("failure to read last inflation"); //// Parameters for each token let max_reward_rate: Dec = wl_storage - .read(&token::masp_max_reward_rate(addr)) - .expect("max reward should properly decode") - .expect(""); + .read(&token::masp_max_reward_rate_key(addr))? + .expect("max reward should properly decode"); let kp_gain_nom: Dec = wl_storage - .read(&token::masp_kp_gain(addr)) - .expect("kp_gain_nom reward should properly decode") - .expect(""); + .read(&token::masp_kp_gain_key(addr))? + .expect("kp_gain_nom reward should properly decode"); let kd_gain_nom: Dec = wl_storage - .read(&token::masp_kd_gain(addr)) - .expect("kd_gain_nom reward should properly decode") - .expect(""); + .read(&token::masp_kd_gain_key(addr))? + .expect("kd_gain_nom reward should properly decode"); let locked_target_ratio: Dec = wl_storage - .read(&token::masp_locked_ratio_target(addr))? - .expect(""); + .read(&token::masp_locked_ratio_target_key(addr))? + .expect("locked ratio target should properly decode"); // Creating the PD controller for handing out tokens let controller = RewardsController { @@ -126,10 +124,11 @@ where // Since we must put the notes in a compatible format with the // note format, we must make the inflation amount discrete. let noterized_inflation = if total_token_in_masp.is_zero() { - 0u32 + 0u128 } else { crate::types::uint::Uint::try_into( - (inflation.raw_amount() * PRECISION) + (inflation.raw_amount() + * crate::types::uint::Uint::from(precision)) / total_token_in_masp.raw_amount(), ) .unwrap() @@ -163,24 +162,21 @@ where // otherwise we will have an inaccurate view of inflation wl_storage .write( - &token::masp_last_inflation(addr), - (total_token_in_masp / PRECISION) * u64::from(noterized_inflation), + &token::masp_last_inflation_key(addr), + token::Amount::from_uint( + (total_token_in_masp.raw_amount() / precision) + * crate::types::uint::Uint::from(noterized_inflation), + 0, + ) + .unwrap(), ) .expect("unable to encode new inflation rate (Decimal)"); wl_storage - .write(&token::masp_last_locked_ratio(addr), locked_ratio) + .write(&token::masp_last_locked_ratio_key(addr), locked_ratio) .expect("unable to encode new locked ratio (Decimal)"); - // to make it conform with the expected output, we need to - // move it to a ratio of x/100 to match the masp_rewards - // function This may be unneeded, as we could describe it as a - // ratio of x/1 - - Ok(( - noterized_inflation, - PRECISION.try_into().expect("inflation precision too large"), - )) + Ok((noterized_inflation, precision)) } // This is only enabled when "wasm-runtime" is on, because we're using rayon @@ -196,7 +192,7 @@ where use std::cmp::Ordering; use masp_primitives::ff::PrimeField; - use masp_primitives::transaction::components::I32Sum as MaspAmount; + use masp_primitives::transaction::components::I128Sum as MaspAmount; use rayon::iter::{ IndexedParallelIterator, IntoParallelIterator, ParallelIterator, }; @@ -288,12 +284,12 @@ where (addr.clone(), denom), (MaspAmount::from_pair( old_asset, - -(*normed_inflation as i32), + -(*normed_inflation as i128), ) .unwrap() + MaspAmount::from_pair( new_asset, - new_normed_inflation as i32, + new_normed_inflation as i128, ) .unwrap()) .into(), @@ -320,13 +316,13 @@ where // intermediate tokens cancel/ telescope out current_convs.insert( (addr.clone(), denom), - (MaspAmount::from_pair(old_asset, -(reward.1 as i32)) + (MaspAmount::from_pair(old_asset, -(reward.1 as i128)) .unwrap() - + MaspAmount::from_pair(new_asset, reward.1 as i32) + + MaspAmount::from_pair(new_asset, reward.1 as i128) .unwrap() + MaspAmount::from_pair( reward_assets[denom as usize], - real_reward as i32, + real_reward as i128, ) .unwrap()) .into(), diff --git a/core/src/types/address.rs b/core/src/types/address.rs index 416b3f059e..b0b709d69f 100644 --- a/core/src/types/address.rs +++ b/core/src/types/address.rs @@ -681,23 +681,6 @@ pub fn tokens() -> HashMap { .collect() } -/// Temporary helper for testing, a hash map of tokens addresses with their -/// MASP XAN incentive schedules. If the reward is (a, b) then a rewarded tokens -/// are dispensed for every b possessed tokens. -pub fn masp_rewards() -> HashMap { - vec![ - (nam(), (0, 100)), - (btc(), (1, 100)), - (eth(), (2, 100)), - (dot(), (3, 100)), - (schnitzel(), (4, 100)), - (apfel(), (5, 100)), - (kartoffel(), (6, 100)), - ] - .into_iter() - .collect() -} - #[cfg(test)] pub mod tests { use proptest::prelude::*; diff --git a/core/src/types/token.rs b/core/src/types/token.rs index c6fefea9c6..ffc21f817d 100644 --- a/core/src/types/token.rs +++ b/core/src/types/token.rs @@ -596,6 +596,20 @@ impl Mul for Amount { } } +/// A combination of Euclidean division and fractions: +/// x*(a,b) = (a*(x//b), x%b). +impl Mul<(u128, u128)> for Amount { + type Output = (Amount, Amount); + + fn mul(mut self, rhs: (u128, u128)) -> Self::Output { + let amt = Amount { + raw: (self.raw / rhs.1) * Uint::from(rhs.0), + }; + self.raw %= rhs.1; + (amt, self) + } +} + /// A combination of Euclidean division and fractions: /// x*(a,b) = (a*(x//b), x%b). impl Mul<(u64, u64)> for Amount { @@ -816,18 +830,18 @@ pub const CONVERSION_KEY_PREFIX: &str = "conv"; /// Key segment prefix for pinned shielded transactions pub const PIN_KEY_PREFIX: &str = "pin-"; /// Last calculated inflation value handed out -pub const MASP_LAST_INFLATION: &str = "last_inflation"; +pub const MASP_LAST_INFLATION_KEY: &str = "last_inflation"; /// The last locked ratio -pub const MASP_LAST_LOCKED_RATIO: &str = "last_locked_ratio"; +pub const MASP_LAST_LOCKED_RATIO_KEY: &str = "last_locked_ratio"; /// The key for the nominal proportional gain of a shielded pool for a given /// asset -pub const MASP_KP_GAIN_KEY: &str = "proptional_gain"; +pub const MASP_KP_GAIN_KEY: &str = "proportional_gain"; /// The key for the nominal derivative gain of a shielded pool for a given asset pub const MASP_KD_GAIN_KEY: &str = "derivative_gain"; /// The key for the locked ratio target for a given asset pub const MASP_LOCKED_RATIO_TARGET_KEY: &str = "locked_ratio_target"; /// The key for the max reward rate for a given asset -pub const MASP_MAX_REWARD_RATE: &str = "max_reward_rate"; +pub const MASP_MAX_REWARD_RATE_KEY: &str = "max_reward_rate"; /// Gets the key for the given token address, error with the given /// message to expect if the key is not in the address @@ -874,22 +888,22 @@ pub fn minted_balance_key(token_addr: &Address) -> Key { } /// Obtain the nominal proportional key for the given token -pub fn masp_kp_gain(token_addr: &Address) -> Key { +pub fn masp_kp_gain_key(token_addr: &Address) -> Key { key_of_token(token_addr, MASP_KP_GAIN_KEY, "nominal proproitonal gains") } /// Obtain the nominal derivative key for the given token -pub fn masp_kd_gain(token_addr: &Address) -> Key { +pub fn masp_kd_gain_key(token_addr: &Address) -> Key { key_of_token(token_addr, MASP_KD_GAIN_KEY, "nominal proproitonal gains") } /// The max reward rate key for the given token -pub fn masp_max_reward_rate(token_addr: &Address) -> Key { - key_of_token(token_addr, MASP_MAX_REWARD_RATE, "max reward rate") +pub fn masp_max_reward_rate_key(token_addr: &Address) -> Key { + key_of_token(token_addr, MASP_MAX_REWARD_RATE_KEY, "max reward rate") } /// Obtain the locked target ratio key for the given token -pub fn masp_locked_ratio_target(token_addr: &Address) -> Key { +pub fn masp_locked_ratio_target_key(token_addr: &Address) -> Key { key_of_token( token_addr, MASP_LOCKED_RATIO_TARGET_KEY, @@ -920,7 +934,7 @@ pub struct Parameters { /// Shielded Pool nominal proportional gain for the given token pub kp_gain_nom: Dec, /// Locked ratio for the given token - pub locked_ratio_target_key: Dec, + pub locked_ratio_target: Dec, } impl Parameters { @@ -937,19 +951,19 @@ impl Parameters { max_reward_rate: max_rate, kd_gain_nom, kp_gain_nom, - locked_ratio_target_key: locked_target, + locked_ratio_target: locked_target, } = self; wl_storage - .write(&masp_max_reward_rate(address), max_rate) + .write(&masp_max_reward_rate_key(address), max_rate) .expect("max reward rate for the given asset must be initialized"); wl_storage - .write(&masp_locked_ratio_target(address), locked_target) + .write(&masp_locked_ratio_target_key(address), locked_target) .expect("locked ratio must be initialized"); wl_storage - .write(&masp_kp_gain(address), kp_gain_nom) + .write(&masp_kp_gain_key(address), kp_gain_nom) .expect("The nominal proportional gain must be initialized"); wl_storage - .write(&masp_kd_gain(address), kd_gain_nom) + .write(&masp_kd_gain_key(address), kd_gain_nom) .expect("The nominal derivative gain must be initialized"); } } @@ -960,7 +974,7 @@ impl Default for Parameters { max_reward_rate: Dec::from_str("0.1").unwrap(), kp_gain_nom: Dec::from_str("0.1").unwrap(), kd_gain_nom: Dec::from_str("0.1").unwrap(), - locked_ratio_target_key: Dec::from_str("0.1").unwrap(), + locked_ratio_target: Dec::from_str("0.1").unwrap(), } } } @@ -1032,20 +1046,20 @@ pub fn is_masp_key(key: &Key) -> bool { || key.starts_with(PIN_KEY_PREFIX))) } -/// The last locked ratio of a token -pub fn masp_last_locked_ratio(token_address: &Address) -> Key { +/// Obtain the storage key for the last locked ratio of a token +pub fn masp_last_locked_ratio_key(token_address: &Address) -> Key { key_of_token( token_address, - MASP_LAST_LOCKED_RATIO, + MASP_LAST_LOCKED_RATIO_KEY, "cannot obtain storage key for the last locked ratio", ) } -/// The last inflation of a token -pub fn masp_last_inflation(token_address: &Address) -> Key { +/// Obtain the storage key for the last inflation of a token +pub fn masp_last_inflation_key(token_address: &Address) -> Key { key_of_token( token_address, - MASP_LAST_INFLATION, + MASP_LAST_INFLATION_KEY, "cannot obtain storage key for the last inflation rate", ) } @@ -1336,10 +1350,10 @@ pub mod testing { H: 'static + ledger_storage::StorageHasher, { use crate::ledger::parameters::storage::get_epochs_per_year_key; - use crate::types::address::masp_rewards; + use crate::types::address::tokens; - let masp_rewards = masp_rewards(); - let masp_reward_keys: Vec<_> = masp_rewards.keys().collect(); + let tokens = tokens(); + let masp_reward_keys: Vec<_> = tokens.keys().collect(); wl_storage .write(&get_epochs_per_year_key(), epochs_per_year) @@ -1348,7 +1362,7 @@ pub mod testing { max_reward_rate: Dec::from_str("0.1").unwrap(), kd_gain_nom: Dec::from_str("0.1").unwrap(), kp_gain_nom: Dec::from_str("0.1").unwrap(), - locked_ratio_target_key: Dec::zero(), + locked_ratio_target: Dec::zero(), }; for address in masp_reward_keys { @@ -1360,10 +1374,10 @@ pub mod testing { ) .unwrap(); wl_storage - .write(&masp_last_inflation(address), Amount::zero()) + .write(&masp_last_inflation_key(address), Amount::zero()) .expect("inflation ought to be written"); wl_storage - .write(&masp_last_locked_ratio(address), Dec::zero()) + .write(&masp_last_locked_ratio_key(address), Dec::zero()) .expect("last locked set default"); } } diff --git a/genesis/e2e-tests-single-node.toml b/genesis/e2e-tests-single-node.toml index 0020dd995a..1096be0d28 100644 --- a/genesis/e2e-tests-single-node.toml +++ b/genesis/e2e-tests-single-node.toml @@ -40,7 +40,7 @@ Ester = "1000000" max_reward_rate = "0.1" kd_gain_nom = "0.1" kp_gain_nom = "0.1" -locked_ratio_target_key = "0.6667" +locked_ratio_target = "0.6667" [token.BTC] address = "atest1v4ehgw36xdzryve5gsc52veeg5cnsv2yx5eygvp38qcrvd29xy6rys6p8yc5xvp4xfpy2v694wgwcp" @@ -55,7 +55,7 @@ Ester = "1000000" max_reward_rate = "0.1" kd_gain_nom = "0.1" kp_gain_nom = "0.1" -locked_ratio_target_key = "0.6667" +locked_ratio_target = "0.6667" [token.ETH] address = "atest1v4ehgw36xqmr2d3nx3ryvd2xxgmrq33j8qcns33sxezrgv6zxdzrydjrxveygd2yxumrsdpsf9jc2p" @@ -70,7 +70,7 @@ Ester = "1000000" max_reward_rate = "0.1" kd_gain_nom = "0.1" kp_gain_nom = "0.1" -locked_ratio_target_key = "0.6667" +locked_ratio_target = "0.6667" [token.DOT] address = "atest1v4ehgw36gg6nvs2zgfpyxsfjgc65yv6pxy6nwwfsxgungdzrggeyzv35gveyxsjyxymyz335hur2jn" @@ -85,7 +85,7 @@ Ester = "1000000" max_reward_rate = "0.1" kd_gain_nom = "0.1" kp_gain_nom = "0.1" -locked_ratio_target_key = "0.6667" +locked_ratio_target = "0.6667" [token.Schnitzel] address = "atest1v4ehgw36xue5xvf5xvuyzvpjx5un2v3k8qeyvd3cxdqns32p89rrxd6xx9zngvpegccnzs699rdnnt" @@ -100,7 +100,7 @@ Ester = "1000000" max_reward_rate = "0.1" kd_gain_nom = "0.1" kp_gain_nom = "0.1" -locked_ratio_target_key = "0.6667" +locked_ratio_target = "0.6667" [token.Apfel] address = "atest1v4ehgw36gfryydj9g3p5zv3kg9znyd358ycnzsfcggc5gvecgc6ygs2rxv6ry3zpg4zrwdfeumqcz9" @@ -115,7 +115,7 @@ Ester = "1000000" max_reward_rate = "0.1" kd_gain_nom = "0.1" kp_gain_nom = "0.1" -locked_ratio_target_key = "0.6667" +locked_ratio_target = "0.6667" [token.Kartoffel] address = "atest1v4ehgw36gep5ysecxq6nyv3jg3zygv3e89qn2vp48pryxsf4xpznvve5gvmy23fs89pryvf5a6ht90" @@ -131,7 +131,7 @@ Ester = "1000000" max_reward_rate = "0.1" kd_gain_nom = "0.1" kp_gain_nom = "0.1" -locked_ratio_target_key = "0.6667" +locked_ratio_target = "0.6667" [established.Albert] vp = "vp_user" diff --git a/shared/src/ledger/queries/shell.rs b/shared/src/ledger/queries/shell.rs index a766846916..520c702608 100644 --- a/shared/src/ledger/queries/shell.rs +++ b/shared/src/ledger/queries/shell.rs @@ -30,7 +30,7 @@ type Conversion = ( Address, MaspDenom, Epoch, - masp_primitives::transaction::components::I32Sum, + masp_primitives::transaction::components::I128Sum, MerklePath, ); @@ -254,7 +254,7 @@ where addr.clone(), *denom, *epoch, - Into::::into( + Into::::into( conv.clone(), ), ctx.wl_storage.storage.conversion_state.tree.path(*pos), diff --git a/shared/src/sdk/masp.rs b/shared/src/sdk/masp.rs index 739f941b9a..f9459f6cab 100644 --- a/shared/src/sdk/masp.rs +++ b/shared/src/sdk/masp.rs @@ -34,8 +34,8 @@ use masp_primitives::transaction::builder::{self, *}; use masp_primitives::transaction::components::sapling::builder::SaplingMetadata; use masp_primitives::transaction::components::transparent::builder::TransparentBuilder; use masp_primitives::transaction::components::{ - ConvertDescription, I128Sum, I32Sum, OutputDescription, SpendDescription, - TxOut, U64Sum, + ConvertDescription, I128Sum, OutputDescription, SpendDescription, TxOut, + U64Sum, }; use masp_primitives::transaction::fees::fixed::FeeRule; use masp_primitives::transaction::sighash::{signature_hash, SignableInput}; @@ -989,7 +989,7 @@ impl ShieldedContext { Address, MaspDenom, _, - I32Sum, + I128Sum, MerklePath, ) = rpc::query_conversion(client, asset_type).await?; self.asset_types diff --git a/shared/src/sdk/rpc.rs b/shared/src/sdk/rpc.rs index 58609bed42..cb881e88a2 100644 --- a/shared/src/sdk/rpc.rs +++ b/shared/src/sdk/rpc.rs @@ -228,7 +228,7 @@ pub async fn query_conversion( Address, MaspDenom, Epoch, - masp_primitives::transaction::components::I32Sum, + masp_primitives::transaction::components::I128Sum, MerklePath, )> { Some(unwrap_client_response::( diff --git a/shared/src/sdk/tx.rs b/shared/src/sdk/tx.rs index 9d7fe0cfe4..0381e6f6aa 100644 --- a/shared/src/sdk/tx.rs +++ b/shared/src/sdk/tx.rs @@ -15,7 +15,7 @@ use masp_primitives::transaction::components::sapling::fees::{ use masp_primitives::transaction::components::transparent::fees::{ InputView as TransparentInputView, OutputView as TransparentOutputView, }; -use masp_primitives::transaction::components::I32Sum; +use masp_primitives::transaction::components::I128Sum; use namada_core::ledger::governance::cli::onchain::{ DefaultProposal, OnChainProposal, PgfFundingProposal, PgfStewardProposal, ProposalVote, @@ -1643,7 +1643,7 @@ async fn used_asset_types< // Collect all the asset types used in the Sapling converts for output in builder.sapling_converts() { for (asset_type, _) in - I32Sum::from(output.conversion().clone()).components() + I128Sum::from(output.conversion().clone()).components() { add_asset_type(&mut asset_types, shielded, client, *asset_type) .await; diff --git a/test_fixtures/masp_proofs/1362F1CF9B836CF8B05D8189EA9CB1712CCA85B0E96A3330A63BE7CD9E5ECD22.bin b/test_fixtures/masp_proofs/1362F1CF9B836CF8B05D8189EA9CB1712CCA85B0E96A3330A63BE7CD9E5ECD22.bin index 20634c1de5..741f4d5106 100644 Binary files a/test_fixtures/masp_proofs/1362F1CF9B836CF8B05D8189EA9CB1712CCA85B0E96A3330A63BE7CD9E5ECD22.bin and b/test_fixtures/masp_proofs/1362F1CF9B836CF8B05D8189EA9CB1712CCA85B0E96A3330A63BE7CD9E5ECD22.bin differ diff --git a/test_fixtures/masp_proofs/29AC8DE3B07495BEABEAF50FE8FF8BF07596031CD460FEBFAEA4F75AF65D5402.bin b/test_fixtures/masp_proofs/29AC8DE3B07495BEABEAF50FE8FF8BF07596031CD460FEBFAEA4F75AF65D5402.bin new file mode 100644 index 0000000000..b748454de8 Binary files /dev/null and b/test_fixtures/masp_proofs/29AC8DE3B07495BEABEAF50FE8FF8BF07596031CD460FEBFAEA4F75AF65D5402.bin differ diff --git a/test_fixtures/masp_proofs/37332141CB34FC30FF51F4BEE8D76149D3088F539CF8372D404609B89B095EF7.bin b/test_fixtures/masp_proofs/37332141CB34FC30FF51F4BEE8D76149D3088F539CF8372D404609B89B095EF7.bin index 1fbae64602..18f83d0543 100644 Binary files a/test_fixtures/masp_proofs/37332141CB34FC30FF51F4BEE8D76149D3088F539CF8372D404609B89B095EF7.bin and b/test_fixtures/masp_proofs/37332141CB34FC30FF51F4BEE8D76149D3088F539CF8372D404609B89B095EF7.bin differ diff --git a/test_fixtures/masp_proofs/52984E26D4A044A259B441C1DAEB66F886B3A3B6C71D33F456B859D01DA47ADD.bin b/test_fixtures/masp_proofs/52984E26D4A044A259B441C1DAEB66F886B3A3B6C71D33F456B859D01DA47ADD.bin new file mode 100644 index 0000000000..c51b5ed0d9 Binary files /dev/null and b/test_fixtures/masp_proofs/52984E26D4A044A259B441C1DAEB66F886B3A3B6C71D33F456B859D01DA47ADD.bin differ diff --git a/test_fixtures/masp_proofs/8B29BC2E1A96DF331C7C3A2B227C98D1E5AAAA9988F26B1A47090ACCE693572F.bin b/test_fixtures/masp_proofs/8B29BC2E1A96DF331C7C3A2B227C98D1E5AAAA9988F26B1A47090ACCE693572F.bin index fc528241a1..afcad7c654 100644 Binary files a/test_fixtures/masp_proofs/8B29BC2E1A96DF331C7C3A2B227C98D1E5AAAA9988F26B1A47090ACCE693572F.bin and b/test_fixtures/masp_proofs/8B29BC2E1A96DF331C7C3A2B227C98D1E5AAAA9988F26B1A47090ACCE693572F.bin differ diff --git a/test_fixtures/masp_proofs/917B7AD5FD4F2F0CB33924511A59181FA326C06FCA9A49B5A5C394C75942820E.bin b/test_fixtures/masp_proofs/917B7AD5FD4F2F0CB33924511A59181FA326C06FCA9A49B5A5C394C75942820E.bin deleted file mode 100644 index 4dde0ccf5f..0000000000 Binary files a/test_fixtures/masp_proofs/917B7AD5FD4F2F0CB33924511A59181FA326C06FCA9A49B5A5C394C75942820E.bin and /dev/null differ diff --git a/test_fixtures/masp_proofs/9883C2EF7971504BB1CF651BAFFC3DA2C57E4FD8FF0811D9CB129887F0F9F706.bin b/test_fixtures/masp_proofs/9883C2EF7971504BB1CF651BAFFC3DA2C57E4FD8FF0811D9CB129887F0F9F706.bin new file mode 100644 index 0000000000..094103100a Binary files /dev/null and b/test_fixtures/masp_proofs/9883C2EF7971504BB1CF651BAFFC3DA2C57E4FD8FF0811D9CB129887F0F9F706.bin differ diff --git a/test_fixtures/masp_proofs/99393E3AC8046F86ABA05519568B6780B6F18A312AE3909BEA19D16FCFE837DC.bin b/test_fixtures/masp_proofs/99393E3AC8046F86ABA05519568B6780B6F18A312AE3909BEA19D16FCFE837DC.bin new file mode 100644 index 0000000000..f456d94d7d Binary files /dev/null and b/test_fixtures/masp_proofs/99393E3AC8046F86ABA05519568B6780B6F18A312AE3909BEA19D16FCFE837DC.bin differ diff --git a/test_fixtures/masp_proofs/A08264B610C5903A47D48E90ABA700BB49387329F8FD049D5F66C95B11B55ADE.bin b/test_fixtures/masp_proofs/A08264B610C5903A47D48E90ABA700BB49387329F8FD049D5F66C95B11B55ADE.bin deleted file mode 100644 index 4d88ddcc5d..0000000000 Binary files a/test_fixtures/masp_proofs/A08264B610C5903A47D48E90ABA700BB49387329F8FD049D5F66C95B11B55ADE.bin and /dev/null differ diff --git a/test_fixtures/masp_proofs/A9D6D90370C747C254D4DD4A2D4B1C762CEA0436B0ECA42C52A830A0FD66BC00.bin b/test_fixtures/masp_proofs/A9D6D90370C747C254D4DD4A2D4B1C762CEA0436B0ECA42C52A830A0FD66BC00.bin deleted file mode 100644 index d67642b43e..0000000000 Binary files a/test_fixtures/masp_proofs/A9D6D90370C747C254D4DD4A2D4B1C762CEA0436B0ECA42C52A830A0FD66BC00.bin and /dev/null differ diff --git a/test_fixtures/masp_proofs/BA4FED83467B6FEE522748C6F7E72A01F0B169F946835583DC2C71B550315603.bin b/test_fixtures/masp_proofs/BA4FED83467B6FEE522748C6F7E72A01F0B169F946835583DC2C71B550315603.bin new file mode 100644 index 0000000000..565d189c0c Binary files /dev/null and b/test_fixtures/masp_proofs/BA4FED83467B6FEE522748C6F7E72A01F0B169F946835583DC2C71B550315603.bin differ diff --git a/test_fixtures/masp_proofs/C7ECE8C02C2E764EFD5B6A0756CFE8EEC08E2D8512695A667D294AE1A4A8D4E6.bin b/test_fixtures/masp_proofs/C7ECE8C02C2E764EFD5B6A0756CFE8EEC08E2D8512695A667D294AE1A4A8D4E6.bin new file mode 100644 index 0000000000..d7fe00a74f Binary files /dev/null and b/test_fixtures/masp_proofs/C7ECE8C02C2E764EFD5B6A0756CFE8EEC08E2D8512695A667D294AE1A4A8D4E6.bin differ diff --git a/test_fixtures/masp_proofs/EE7C912B7E21F07494D58AA6668DC6BBB31619C7E93A1A5A2E64B694DBE1BD6E.bin b/test_fixtures/masp_proofs/EE7C912B7E21F07494D58AA6668DC6BBB31619C7E93A1A5A2E64B694DBE1BD6E.bin new file mode 100644 index 0000000000..fee4361a2b Binary files /dev/null and b/test_fixtures/masp_proofs/EE7C912B7E21F07494D58AA6668DC6BBB31619C7E93A1A5A2E64B694DBE1BD6E.bin differ diff --git a/test_fixtures/masp_proofs/EEB91EB873807EC77BBCA95D4CFA3F379DB351AB4AE081207ABFDFC429C9FA48.bin b/test_fixtures/masp_proofs/EEB91EB873807EC77BBCA95D4CFA3F379DB351AB4AE081207ABFDFC429C9FA48.bin new file mode 100644 index 0000000000..5064fd5593 Binary files /dev/null and b/test_fixtures/masp_proofs/EEB91EB873807EC77BBCA95D4CFA3F379DB351AB4AE081207ABFDFC429C9FA48.bin differ diff --git a/test_fixtures/masp_proofs/F068FDF05B8F25DD923E667215344FFFAA6CA273027CD480AEA68DDED57D88CA.bin b/test_fixtures/masp_proofs/F068FDF05B8F25DD923E667215344FFFAA6CA273027CD480AEA68DDED57D88CA.bin index 9d76ce43f2..3b05c546b0 100644 Binary files a/test_fixtures/masp_proofs/F068FDF05B8F25DD923E667215344FFFAA6CA273027CD480AEA68DDED57D88CA.bin and b/test_fixtures/masp_proofs/F068FDF05B8F25DD923E667215344FFFAA6CA273027CD480AEA68DDED57D88CA.bin differ diff --git a/test_fixtures/masp_proofs/F36A8353F15FD6D8158DBC67DDB827EEEDA858AB983D16024AAA415579A68953.bin b/test_fixtures/masp_proofs/F36A8353F15FD6D8158DBC67DDB827EEEDA858AB983D16024AAA415579A68953.bin new file mode 100644 index 0000000000..755c32011e Binary files /dev/null and b/test_fixtures/masp_proofs/F36A8353F15FD6D8158DBC67DDB827EEEDA858AB983D16024AAA415579A68953.bin differ diff --git a/test_fixtures/masp_proofs/F3FE67606FCCCE54C3BCF643F0C7F5019CA3DF4CB89D10CB4E38DA9CDE3A9A0A.bin b/test_fixtures/masp_proofs/F3FE67606FCCCE54C3BCF643F0C7F5019CA3DF4CB89D10CB4E38DA9CDE3A9A0A.bin deleted file mode 100644 index b10162bc6b..0000000000 Binary files a/test_fixtures/masp_proofs/F3FE67606FCCCE54C3BCF643F0C7F5019CA3DF4CB89D10CB4E38DA9CDE3A9A0A.bin and /dev/null differ diff --git a/tests/src/integration/masp.rs b/tests/src/integration/masp.rs index ecd1b34465..592130e574 100644 --- a/tests/src/integration/masp.rs +++ b/tests/src/integration/masp.rs @@ -6,9 +6,6 @@ use namada::types::io::DefaultIo; use namada_apps::client::tx::CLIShieldedUtils; use namada_apps::node::ledger::shell::testing::client::run; use namada_apps::node::ledger::shell::testing::utils::{Bin, CapturedOutput}; -use namada_core::types::address::{btc, eth, masp_rewards}; -use namada_core::types::token; -use namada_core::types::token::{DenominatedAmount, NATIVE_MAX_DECIMAL_PLACES}; use test_log::test; use super::setup; @@ -22,10 +19,6 @@ use crate::e2e::setup::constants::{ /// for leaving their assets in the pool for varying periods of time. #[test] fn masp_incentives() -> Result<()> { - // The number of decimal places used by BTC amounts. - const BTC_DENOMINATION: u8 = 8; - // The number of decimal places used by ETH amounts. - const ETH_DENOMINATION: u8 = 18; // This address doesn't matter for tests. But an argument is required. let validator_one_rpc = "127.0.0.1:26567"; // Download the shielded pool parameters before starting node @@ -35,7 +28,7 @@ fn masp_incentives() -> Result<()> { // not invalidated. let mut node = setup::setup()?; // Wait till epoch boundary - let ep0 = node.next_epoch(); + node.next_epoch(); // Send 20 BTC from Albert to PA run( &node, @@ -94,10 +87,8 @@ fn masp_incentives() -> Result<()> { assert!(captured.result.is_ok()); assert!(captured.contains("No shielded nam balance found")); - let masp_rewards = masp_rewards(); - // Wait till epoch boundary - let ep1 = node.next_epoch(); + node.next_epoch(); // Assert BTC balance at VK(A) is 20 let captured = CapturedOutput::of(|| { @@ -118,9 +109,6 @@ fn masp_incentives() -> Result<()> { assert!(captured.result.is_ok()); assert!(captured.contains("btc: 20")); - let amt20 = token::Amount::from_uint(20, BTC_DENOMINATION).unwrap(); - let amt10 = token::Amount::from_uint(10, ETH_DENOMINATION).unwrap(); - // Assert NAM balance at VK(A) is 20*BTC_reward*(epoch_1-epoch_0) let captured = CapturedOutput::of(|| { run( @@ -138,13 +126,8 @@ fn masp_incentives() -> Result<()> { ) }); - let amt = (amt20 * masp_rewards[&btc()]).0 * (ep1.0 - ep0.0); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated))); + assert!(captured.contains("nam: 22.74")); // Assert NAM balance at MASP pool is 20*BTC_reward*(epoch_1-epoch_0) let captured = CapturedOutput::of(|| { @@ -162,16 +145,11 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = (amt20 * masp_rewards[&btc()]).0 * (ep1.0 - ep0.0); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated))); + assert!(captured.contains("nam: 22.74")); // Wait till epoch boundary - let ep2 = node.next_epoch(); + node.next_epoch(); // Assert BTC balance at VK(A) is 20 let captured = CapturedOutput::of(|| { @@ -208,13 +186,8 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = (amt20 * masp_rewards[&btc()]).0 * (ep2.0 - ep0.0); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated))); + assert!(captured.contains("nam: 90.96")); // Assert NAM balance at MASP pool is 20*BTC_reward*(epoch_2-epoch_0) let captured = CapturedOutput::of(|| { @@ -232,16 +205,11 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = (amt20 * masp_rewards[&btc()]).0 * (ep2.0 - ep0.0); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated))); + assert!(captured.contains("nam: 90.96")); // Wait till epoch boundary - let ep3 = node.next_epoch(); + node.next_epoch(); // Send 10 ETH from Albert to PA(B) run( @@ -302,7 +270,7 @@ fn masp_incentives() -> Result<()> { assert!(captured.contains("No shielded nam balance found")); // Wait till epoch boundary - let ep4 = node.next_epoch(); + node.next_epoch(); // Assert ETH balance at VK(B) is 10 let captured = CapturedOutput::of(|| { @@ -339,13 +307,8 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = (amt10 * masp_rewards[ð()]).0 * (ep4.0 - ep3.0); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated))); + assert!(captured.contains("nam: 22.71432")); // Assert NAM balance at MASP pool is // 20*BTC_reward*(epoch_4-epoch_0)+10*ETH_reward*(epoch_4-epoch_3) @@ -364,17 +327,11 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = ((amt20 * masp_rewards[&btc()]).0 * (ep4.0 - ep0.0)) - + ((amt10 * masp_rewards[ð()]).0 * (ep4.0 - ep3.0)); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated))); + assert!(captured.contains("nam: 386.46336")); // Wait till epoch boundary - let ep5 = node.next_epoch(); + node.next_epoch(); // Send 10 ETH from SK(B) to Christel run( @@ -417,7 +374,7 @@ fn masp_incentives() -> Result<()> { assert!(captured.result.is_ok()); assert!(captured.contains("No shielded eth balance found")); - let _ep = node.next_epoch(); + node.next_epoch(); // Assert NAM balance at VK(B) is 10*ETH_reward*(ep-epoch_3) let captured = CapturedOutput::of(|| { @@ -435,15 +392,10 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = (amt10 * masp_rewards[ð()]).0 * (ep5.0 - ep3.0); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated))); + assert!(captured.contains("nam: 86.60024")); - let ep = node.next_epoch(); + node.next_epoch(); // Assert NAM balance at MASP pool is // 20*BTC_reward*(epoch_5-epoch_0)+10*ETH_reward*(epoch_5-epoch_3) let captured = CapturedOutput::of(|| { @@ -461,17 +413,11 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = ((amt20 * masp_rewards[&btc()]).0 * (ep.0 - ep0.0)) - + ((amt10 * masp_rewards[ð()]).0 * (ep5.0 - ep3.0)); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated))); + assert!(captured.contains("nam: 1180.41525")); // Wait till epoch boundary - let ep6 = node.next_epoch(); + node.next_epoch(); // Send 20 BTC from SK(A) to Christel run( @@ -530,13 +476,8 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = (amt20 * masp_rewards[&btc()]).0 * (ep6.0 - ep0.0); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated,))); + assert!(captured.contains("nam: 1407.16324")); // Assert NAM balance at MASP pool is // 20*BTC_reward*(epoch_6-epoch_0)+20*ETH_reward*(epoch_5-epoch_3) @@ -555,17 +496,11 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = ((amt20 * masp_rewards[&btc()]).0 * (ep6.0 - ep0.0)) - + ((amt10 * masp_rewards[ð()]).0 * (ep5.0 - ep3.0)); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated,))); + assert!(captured.contains("nam: 1520.37191")); // Wait till epoch boundary - let _ep7 = node.next_epoch(); + node.next_epoch(); // Assert NAM balance at VK(A) is 20*BTC_reward*(epoch_6-epoch_0) let captured = CapturedOutput::of(|| { @@ -583,13 +518,8 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = (amt20 * masp_rewards[&btc()]).0 * (ep6.0 - ep0.0); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated))); + assert!(captured.contains("nam: 1573.18")); // Assert NAM balance at VK(B) is 10*ETH_reward*(epoch_5-epoch_3) let captured = CapturedOutput::of(|| { @@ -607,13 +537,8 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = (amt10 * masp_rewards[ð()]).0 * (ep5.0 - ep3.0); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated,))); + assert!(captured.contains("nam: 126.565")); // Assert NAM balance at MASP pool is // 20*BTC_reward*(epoch_6-epoch_0)+10*ETH_reward*(epoch_5-epoch_3) @@ -632,18 +557,12 @@ fn masp_incentives() -> Result<()> { ], ) }); - let amt = ((amt20 * masp_rewards[&btc()]).0 * (ep6.0 - ep0.0)) - + ((amt10 * masp_rewards[ð()]).0 * (ep5.0 - ep3.0)); - let denominated = DenominatedAmount { - amount: amt, - denom: NATIVE_MAX_DECIMAL_PLACES.into(), - }; assert!(captured.result.is_ok()); - assert!(captured.contains(&format!("nam: {}", denominated,))); + assert!(captured.contains("nam: 1699.745")); // Wait till epoch boundary to prevent conversion expiry during transaction // construction - let _ep8 = node.next_epoch(); + node.next_epoch(); // Send 10*ETH_reward*(epoch_5-epoch_3) NAM from SK(B) to Christel run( @@ -658,8 +577,7 @@ fn masp_incentives() -> Result<()> { "--token", NAM, "--amount", - &((amt10 * masp_rewards[ð()]).0 * (ep5.0 - ep3.0)) - .to_string_native(), + "141.49967", "--signing-keys", BERTHA, "--node", @@ -669,7 +587,7 @@ fn masp_incentives() -> Result<()> { node.assert_success(); // Wait till epoch boundary - let _ep9 = node.next_epoch(); + node.next_epoch(); // Send 20*BTC_reward*(epoch_6-epoch_0) NAM from SK(A) to Bertha run( @@ -684,8 +602,7 @@ fn masp_incentives() -> Result<()> { "--token", NAM, "--amount", - &((amt20 * masp_rewards[&btc()]).0 * (ep6.0 - ep0.0)) - .to_string_native(), + "1980.356", "--signing-keys", ALBERT, "--node", diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 5dbe91c1e4..439d62e184 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -3101,7 +3101,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "0.2.0" -source = "git+https://github.com/anoma/masp?rev=50acc5028fbcd52a05970fe7991c7850ab04358e#50acc5028fbcd52a05970fe7991c7850ab04358e" +source = "git+https://github.com/anoma/masp?rev=1345b463e8fa3b3a6fa13e4a43fb1c410690ad62#1345b463e8fa3b3a6fa13e4a43fb1c410690ad62" dependencies = [ "borsh 0.9.4", "chacha20 0.9.1", @@ -3114,7 +3114,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "0.9.0" -source = "git+https://github.com/anoma/masp?rev=50acc5028fbcd52a05970fe7991c7850ab04358e#50acc5028fbcd52a05970fe7991c7850ab04358e" +source = "git+https://github.com/anoma/masp?rev=1345b463e8fa3b3a6fa13e4a43fb1c410690ad62#1345b463e8fa3b3a6fa13e4a43fb1c410690ad62" dependencies = [ "aes 0.7.5", "bip0039", @@ -3145,7 +3145,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "0.9.0" -source = "git+https://github.com/anoma/masp?rev=50acc5028fbcd52a05970fe7991c7850ab04358e#50acc5028fbcd52a05970fe7991c7850ab04358e" +source = "git+https://github.com/anoma/masp?rev=1345b463e8fa3b3a6fa13e4a43fb1c410690ad62#1345b463e8fa3b3a6fa13e4a43fb1c410690ad62" dependencies = [ "bellman", "blake2b_simd", diff --git a/wasm/wasm_source/Cargo.toml b/wasm/wasm_source/Cargo.toml index 81f07ba049..2022e64ca0 100644 --- a/wasm/wasm_source/Cargo.toml +++ b/wasm/wasm_source/Cargo.toml @@ -43,7 +43,7 @@ once_cell = {version = "1.8.0", optional = true} wee_alloc = "0.4.5" getrandom = { version = "0.2", features = ["custom"] } # branch = "murisi/namada-integration" -masp_primitives = { git = "https://github.com/anoma/masp", rev = "50acc5028fbcd52a05970fe7991c7850ab04358e", optional = true } +masp_primitives = { git = "https://github.com/anoma/masp", rev = "1345b463e8fa3b3a6fa13e4a43fb1c410690ad62", optional = true } ripemd = "0.1" [dev-dependencies] diff --git a/wasm_for_tests/wasm_source/Cargo.lock b/wasm_for_tests/wasm_source/Cargo.lock index 8e3bc2bb20..c8cafdda1c 100644 --- a/wasm_for_tests/wasm_source/Cargo.lock +++ b/wasm_for_tests/wasm_source/Cargo.lock @@ -3101,7 +3101,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "0.2.0" -source = "git+https://github.com/anoma/masp?rev=50acc5028fbcd52a05970fe7991c7850ab04358e#50acc5028fbcd52a05970fe7991c7850ab04358e" +source = "git+https://github.com/anoma/masp?rev=1345b463e8fa3b3a6fa13e4a43fb1c410690ad62#1345b463e8fa3b3a6fa13e4a43fb1c410690ad62" dependencies = [ "borsh 0.9.4", "chacha20 0.9.1", @@ -3114,7 +3114,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "0.9.0" -source = "git+https://github.com/anoma/masp?rev=50acc5028fbcd52a05970fe7991c7850ab04358e#50acc5028fbcd52a05970fe7991c7850ab04358e" +source = "git+https://github.com/anoma/masp?rev=1345b463e8fa3b3a6fa13e4a43fb1c410690ad62#1345b463e8fa3b3a6fa13e4a43fb1c410690ad62" dependencies = [ "aes 0.7.5", "bip0039", @@ -3145,7 +3145,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "0.9.0" -source = "git+https://github.com/anoma/masp?rev=50acc5028fbcd52a05970fe7991c7850ab04358e#50acc5028fbcd52a05970fe7991c7850ab04358e" +source = "git+https://github.com/anoma/masp?rev=1345b463e8fa3b3a6fa13e4a43fb1c410690ad62#1345b463e8fa3b3a6fa13e4a43fb1c410690ad62" dependencies = [ "bellman", "blake2b_simd",