Skip to content

Commit

Permalink
Merge branch 'mariari/fixed-amounts-history' (#1630)
Browse files Browse the repository at this point in the history
* origin/mariari/fixed-amounts-history:
  [chore] Fixed clippy and formatting
  [fix]: Fixed serialization bug with amounts. Fixed remaining masp e2e tests
  Masp e2e tests now passing
  WIP fixed masp incentives
  WIP masp incentives passes. But I did something reckless to get there.
  WIP fixed unspent note calcs
  WIP small bug fixes and a debugger can be attached
  WIP
  WIP fixed bug in collecting unspent notes
  WIP fixing masp incentives
  WIP
  WIP fixed bug in collecting unspent notes
  WIP fixing masp incentives
  WIP fixing masp amounts
  unsorted wips on e2e
  fix ledger e2e tests
  stupid test fix: add six zeroes
  force 0 ibc denoms
  disambiguate token denom and ibc denom
  we don't take separators anymore whoops
  refactor `Dec` to allow negative values
  WIP fix `pos_bonds`
  Removed denominated from being called from user contracts
  Add a new destination for ibc rpc endpoint
  Fix underflow issue in commisions
  Remove signed conversion errors
  Temporary remove check for chain id verification
  Fix u64 going to Dec from overflowing
  Improve dec display method
  Gensis Parsing config issue solved
  Remove all references to Masp::Amount out of RPC
  Fixing Masp Amounts to convert on the edges
  Fix Key from always parsing
  [chore]: Removed rust_decimal and rust_decimal_macro deps from project
  [fix]: Fixed proptest in PoS, removed rust_decimal from core and pos crates
  Fix pos unit tests, change `Dec` precision to 12 places
  WIP fixing pos unit tests
  WIP more `Dec` integration and testing (compiling!)
  [chore]: Added more tests and fixes
  [fix]: Added tests for Dec, fixed division bug, cleaned up from_str method, added tests, removed some more Decimal types
  WIP continue replacing rust_decimal crate in PoS
  Starting replacing rust_decimal crate in PoS
  Update query_sheilded_balance to handle the multiple denominations
  Update query_sheilded_balance to handle the multiple denominations
  [fix]: Refactored gen_sheilded_transfer to only denominate amounts at the masp crate boundary
  [fix]: Incorporating in review suggestions
  [feat]: Replaced u128 in governance with u256
  [fix]: Fixed makefile recipes for abcipp
  [feat]: Added multitoken support to MASP
  [fix]: Fixed wasm tests
  [feat]: Added sub-prefixs to denom storage read/writes
  [fix]: Cleanup up the wasms
  [fix]: Fixed the router tests
  [fix]: Fixed some conversions to amounts in tests. Fixed PoS state machine tests
  [chore]: Added test coverage for new token types and fixed the bugs they found
  [chore]: Formatting
  [feat]: Fixed unit tests
  [feat]: First compiling refactor. Now for testing
  Fixed most of the masp compile issues. May not be logically correct yet
  WIP: shared/pos: update token to TM voting power conv
  core/token: make conv from Amount to u128 falliable
  app/shell: use token::Amount::native_whole for min fee conversion
  core/transaction/wrapper: add a todo for later
  core/token: add `write_denom`
  core/token: add `fn zero`
  Some more fixes  for amount types in the client code
  temp
  Fixed errors in core
  Drafting
  • Loading branch information
brentstone committed Jul 3, 2023
2 parents f755fbf + 714d81c commit 51d382b
Show file tree
Hide file tree
Showing 113 changed files with 7,492 additions and 2,444 deletions.
208 changes: 100 additions & 108 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,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 = "cfea8c95d3f73077ca3e25380fd27e5b46e828fd" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "cfea8c95d3f73077ca3e25380fd27e5b46e828fd", default-features = false, features = ["local-prover"] }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "9320c6b69b5d2e97134866871e960f0a31703813" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "9320c6b69b5d2e97134866871e960f0a31703813", default-features = false, features = ["local-prover"] }
num_cpus = "1.13.0"
num-derive = "0.3.3"
num-rational = "0.4.1"
Expand Down
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ wasms_for_tests := wasm_for_tests/wasm_source
# Paths for all the wasm templates
wasm_templates := wasm/tx_template wasm/vp_template

ifdef JOBS
jobs := -j $(JOBS)
else
jobs :=
endif

# TODO upgrade libp2p
audit-ignores += RUSTSEC-2021-0076

Expand All @@ -35,13 +41,13 @@ crates += namada_vm_env
crates += namada_vp_prelude

build:
$(cargo) build
$(cargo) build $(jobs)

build-test:
$(cargo) build --tests
$(cargo) build --tests $(jobs)

build-release:
NAMADA_DEV=false $(cargo) build --release --package namada_apps --manifest-path Cargo.toml
NAMADA_DEV=false $(cargo) build $(jobs) --release --package namada_apps --manifest-path Cargo.toml

install-release:
NAMADA_DEV=false $(cargo) install --path ./apps --locked
Expand Down Expand Up @@ -69,7 +75,7 @@ check-crates:
clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets -- -D warnings

clippy:
NAMADA_DEV=false $(cargo) +$(nightly) clippy --all-targets -- -D warnings && \
NAMADA_DEV=false $(cargo) +$(nightly) clippy $(jobs) --all-targets -- -D warnings && \
make -C $(wasms) clippy && \
make -C $(wasms_for_tests) clippy && \
$(foreach wasm,$(wasm_templates),$(clippy-wasm) && ) true
Expand Down Expand Up @@ -129,18 +135,21 @@ test-e2e:
test-unit:
$(cargo) +$(nightly) test \
$(TEST_FILTER) \
$(jobs) \
-- --skip e2e \
-Z unstable-options --report-time

test-unit-mainnet:
$(cargo) +$(nightly) test \
--features "mainnet" \
$(TEST_FILTER) \
$(jobs) \
-- --skip e2e \
-Z unstable-options --report-time

test-unit-debug:
$(debug-cargo) +$(nightly) test \
$(jobs) \
$(TEST_FILTER) -- \
-- --skip e2e \
--nocapture \
Expand Down
2 changes: 0 additions & 2 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ ripemd.workspace = true
rlimit.workspace = true
rocksdb.workspace = true
rpassword.workspace = true
rust_decimal_macros.workspace = true
rust_decimal.workspace = true
serde_bytes.workspace = true
serde_json = {workspace = true, features = ["raw_value"]}
serde.workspace = true
Expand Down
64 changes: 50 additions & 14 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1772,12 +1772,13 @@ pub mod args {
pub use namada::ledger::args::*;
use namada::types::address::Address;
use namada::types::chain::{ChainId, ChainIdPrefix};
use namada::types::dec::Dec;
use namada::types::key::*;
use namada::types::masp::MaspValue;
use namada::types::storage::{self, BlockHeight, Epoch};
use namada::types::time::DateTimeUtc;
use namada::types::token;
use rust_decimal::Decimal;
use namada::types::token::NATIVE_MAX_DECIMAL_PLACES;

use super::context::*;
use super::utils::*;
Expand Down Expand Up @@ -1807,7 +1808,7 @@ pub mod args {
pub const ALIAS: Arg<String> = arg("alias");
pub const ALIAS_FORCE: ArgFlag = flag("alias-force");
pub const ALLOW_DUPLICATE_IP: ArgFlag = flag("allow-duplicate-ip");
pub const AMOUNT: Arg<token::Amount> = arg("amount");
pub const AMOUNT: Arg<token::DenominatedAmount> = arg("amount");
pub const ARCHIVE_DIR: ArgOpt<PathBuf> = arg_opt("archive-dir");
pub const BALANCE_OWNER: ArgOpt<WalletBalanceOwner> = arg_opt("owner");
pub const BASE_DIR: ArgDefault<PathBuf> = arg_default(
Expand All @@ -1826,7 +1827,7 @@ pub mod args {
pub const CHANNEL_ID: Arg<ChannelId> = arg("channel-id");
pub const CODE_PATH: Arg<PathBuf> = arg("code-path");
pub const CODE_PATH_OPT: ArgOpt<PathBuf> = CODE_PATH.opt();
pub const COMMISSION_RATE: Arg<Decimal> = arg("commission-rate");
pub const COMMISSION_RATE: Arg<Dec> = arg("commission-rate");
pub const CONSENSUS_TIMEOUT_COMMIT: ArgDefault<Timeout> = arg_default(
"consensus-timeout-commit",
DefaultFn(|| Timeout::from_str("1s").unwrap()),
Expand All @@ -1841,10 +1842,20 @@ pub mod args {
pub const EXPIRATION_OPT: ArgOpt<DateTimeUtc> = arg_opt("expiration");
pub const FORCE: ArgFlag = flag("force");
pub const DONT_PREFETCH_WASM: ArgFlag = flag("dont-prefetch-wasm");
pub const GAS_AMOUNT: ArgDefault<token::Amount> =
arg_default("gas-amount", DefaultFn(|| token::Amount::from(0)));
pub const GAS_LIMIT: ArgDefault<token::Amount> =
arg_default("gas-limit", DefaultFn(|| token::Amount::from(0)));
pub const GAS_AMOUNT: ArgDefault<token::DenominatedAmount> = arg_default(
"gas-amount",
DefaultFn(|| token::DenominatedAmount {
amount: token::Amount::default(),
denom: NATIVE_MAX_DECIMAL_PLACES.into(),
}),
);
pub const GAS_LIMIT: ArgDefault<token::DenominatedAmount> = arg_default(
"gas-limit",
DefaultFn(|| token::DenominatedAmount {
amount: token::Amount::default(),
denom: NATIVE_MAX_DECIMAL_PLACES.into(),
}),
);
pub const GAS_TOKEN: ArgDefaultFromCtx<WalletAddress> =
arg_default_from_ctx("gas-token", DefaultFn(|| "NAM".parse().unwrap()));
pub const GENESIS_PATH: Arg<PathBuf> = arg("genesis-path");
Expand All @@ -1867,7 +1878,7 @@ pub mod args {
pub const LEDGER_ADDRESS: Arg<TendermintAddress> = arg("node");
pub const LOCALHOST: ArgFlag = flag("localhost");
pub const MASP_VALUE: Arg<MaspValue> = arg("value");
pub const MAX_COMMISSION_RATE_CHANGE: Arg<Decimal> =
pub const MAX_COMMISSION_RATE_CHANGE: Arg<Dec> =
arg("max-commission-rate-change");
pub const NET_ADDRESS: Arg<SocketAddr> = arg("net-address");
pub const NAMADA_START_TIME: ArgOpt<DateTimeUtc> = arg_opt("time");
Expand Down Expand Up @@ -2170,7 +2181,7 @@ pub mod args {
let target = TRANSFER_TARGET.parse(matches);
let token = TOKEN.parse(matches);
let sub_prefix = SUB_PREFIX.parse(matches);
let amount = AMOUNT.parse(matches);
let amount = InputAmount::Unvalidated(AMOUNT.parse(matches));
let tx_code_path = PathBuf::from(TX_TRANSFER_WASM);
Self {
tx,
Expand Down Expand Up @@ -2237,7 +2248,7 @@ pub mod args {
receiver,
token,
sub_prefix,
amount,
amount: amount.amount,
port_id,
channel_id,
timeout_height,
Expand Down Expand Up @@ -2468,6 +2479,14 @@ pub mod args {
let tx = Tx::parse(matches);
let validator = VALIDATOR.parse(matches);
let amount = AMOUNT.parse(matches);
let amount = amount
.canonical()
.increase_precision(NATIVE_MAX_DECIMAL_PLACES.into())
.unwrap_or_else(|e| {
println!("Could not parse bond amount: {:?}", e);
safe_exit(1);
})
.amount;
let source = SOURCE_OPT.parse(matches);
let tx_code_path = PathBuf::from(TX_BOND_WASM);
Self {
Expand Down Expand Up @@ -2508,6 +2527,14 @@ pub mod args {
let tx = Tx::parse(matches);
let validator = VALIDATOR.parse(matches);
let amount = AMOUNT.parse(matches);
let amount = amount
.canonical()
.increase_precision(NATIVE_MAX_DECIMAL_PLACES.into())
.unwrap_or_else(|e| {
println!("Could not parse bond amount: {:?}", e);
safe_exit(1);
})
.amount;
let source = SOURCE_OPT.parse(matches);
let tx_code_path = PathBuf::from(TX_UNBOND_WASM);
Self {
Expand Down Expand Up @@ -2968,6 +2995,7 @@ pub mod args {
query: self.query.to_sdk(ctx),
owner: self.owner.map(|x| ctx.get_cached(&x)),
token: self.token.map(|x| ctx.get(&x)),
sub_prefix: self.sub_prefix,
}
}
}
Expand All @@ -2977,10 +3005,12 @@ pub mod args {
let query = Query::parse(matches);
let owner = BALANCE_OWNER.parse(matches);
let token = TOKEN_OPT.parse(matches);
let sub_prefix = SUB_PREFIX.parse(matches);
Self {
query,
owner,
token,
sub_prefix,
}
}

Expand All @@ -2992,6 +3022,11 @@ pub mod args {
.arg(TOKEN_OPT.def().help(
"The token address that queried transfers must involve.",
))
.arg(
SUB_PREFIX
.def()
.help("The token's sub prefix whose balance to query."),
)
}
}

Expand Down Expand Up @@ -3390,9 +3425,10 @@ pub mod args {
let ledger_address = LEDGER_ADDRESS_DEFAULT.parse(matches);
let initialized_account_alias = ALIAS_OPT.parse(matches);
let wallet_alias_force = WALLET_ALIAS_FORCE.parse(matches);
let fee_amount = GAS_AMOUNT.parse(matches);
let fee_amount =
InputAmount::Unvalidated(GAS_AMOUNT.parse(matches));
let fee_token = GAS_TOKEN.parse(matches);
let gas_limit = GAS_LIMIT.parse(matches).into();
let gas_limit = GAS_LIMIT.parse(matches).amount.into();
let expiration = EXPIRATION_OPT.parse(matches);
let signing_key = SIGNING_KEY_OPT.parse(matches);
let signer = SIGNER.parse(matches);
Expand Down Expand Up @@ -3971,8 +4007,8 @@ pub mod args {
#[derive(Clone, Debug)]
pub struct InitGenesisValidator {
pub alias: String,
pub commission_rate: Decimal,
pub max_commission_rate_change: Decimal,
pub commission_rate: Dec,
pub max_commission_rate_change: Dec,
pub net_address: SocketAddr,
pub unsafe_dont_encrypt: bool,
pub key_scheme: SchemeType,
Expand Down
Loading

0 comments on commit 51d382b

Please sign in to comment.