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

Make the the backing integer type for amounts 256 bit #1282

Closed
wants to merge 106 commits into from
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
932156c
Drafting
batconjurer Mar 29, 2023
3aa2856
Fixed errors in core
batconjurer Mar 29, 2023
d2d3665
temp
batconjurer Apr 1, 2023
faedfed
Some more fixes for amount types in the client code
batconjurer Apr 3, 2023
0082f2b
core/token: add `fn zero`
tzemanovic Apr 4, 2023
a468d49
core/token: add `write_denom`
tzemanovic Apr 4, 2023
6bb685d
core/transaction/wrapper: add a todo for later
tzemanovic Apr 4, 2023
f17e75e
app/shell: use token::Amount::native_whole for min fee conversion
tzemanovic Apr 4, 2023
8a64466
core/token: make conv from Amount to u128 falliable
tzemanovic Apr 4, 2023
de17218
WIP: shared/pos: update token to TM voting power conv
tzemanovic Apr 4, 2023
819f319
Fixed most of the masp compile issues. May not be logically correct yet
batconjurer Apr 6, 2023
92976fd
[feat]: First compiling refactor. Now for testing
batconjurer Apr 11, 2023
b651787
[feat]: Fixed unit tests
batconjurer Apr 12, 2023
2356c5d
[chore]: Formatting
batconjurer Apr 12, 2023
b244e1b
[chore]: Added test coverage for new token types and fixed the bugs t…
batconjurer Apr 13, 2023
b58d49b
[fix]: Fixed some conversions to amounts in tests. Fixed PoS state ma…
batconjurer Apr 13, 2023
8efcc32
[fix]: Fixed the router tests
batconjurer Apr 13, 2023
70702a1
[fix]: Cleanup up the wasms
batconjurer Apr 13, 2023
86698a9
[feat]: Added sub-prefixs to denom storage read/writes
batconjurer Apr 17, 2023
5d10c6c
[fix]: Fixed wasm tests
batconjurer Apr 17, 2023
bed746d
[chore] Merging in main
batconjurer Apr 19, 2023
8c977cc
[chore]: Merging in main
batconjurer Apr 19, 2023
a8d9b72
[feat]: Added multitoken support to MASP
batconjurer Apr 21, 2023
33b2bf0
[fix]: Fixed makefile recipes for abcipp
batconjurer Apr 21, 2023
9d20a96
[feat]: Replaced u128 in governance with u256
batconjurer Apr 24, 2023
adaf3a1
[fix]: Incorporating in review suggestions
batconjurer Apr 25, 2023
acc79d2
[fix]: Refactored gen_sheilded_transfer to only denominate amounts at…
batconjurer Apr 25, 2023
1e3e77d
Update query_sheilded_balance to handle the multiple denominations
mariari Apr 25, 2023
e71cd44
Update query_sheilded_balance to handle the multiple denominations
mariari Apr 25, 2023
88b6ae1
Merge branch 'bat/feature/uint256_amount' of github.com:anoma/namada …
batconjurer Apr 25, 2023
8de6a44
Starting replacing rust_decimal crate in PoS
batconjurer Apr 25, 2023
8920d0a
WIP continue replacing rust_decimal crate in PoS
brentstone Apr 25, 2023
b0419f5
[fix]: Added tests for Dec, fixed division bug, cleaned up from_str m…
batconjurer Apr 26, 2023
bb93c85
[chore]: Added more tests and fixes
batconjurer Apr 26, 2023
1968660
WIP more `Dec` integration and testing (compiling!)
brentstone Apr 26, 2023
7fbd9c6
WIP fixing pos unit tests
brentstone Apr 26, 2023
32b69e9
Fix pos unit tests, change `Dec` precision to 12 places
brentstone Apr 28, 2023
95419c3
Merge branch 'main' into bat/feature/uint256_amount
batconjurer May 1, 2023
62cc6ec
[fix]: Fixed proptest in PoS, removed rust_decimal from core and pos …
batconjurer May 1, 2023
c2c66cc
[chore]: Removed rust_decimal and rust_decimal_macro deps from project
batconjurer May 1, 2023
c97a9e9
Fix Key from always parsing
mariari May 10, 2023
26413ec
Fixing Masp Amounts to convert on the edges
mariari May 1, 2023
e218999
Remove all references to Masp::Amount out of RPC
mariari May 4, 2023
f6d0f62
Gensis Parsing config issue solved
mariari May 5, 2023
997ff52
Improve dec display method
mariari May 5, 2023
8f7270a
Fix u64 going to Dec from overflowing
mariari May 5, 2023
85a82b4
Temporary remove check for chain id verification
mariari May 9, 2023
bfb81af
Remove signed conversion errors
mariari May 9, 2023
79133e4
Fix underflow issue in commisions
mariari May 10, 2023
b1f4063
Merge branch 'mariari/key-parsing-fix' into bat/feature/uint256_amount
mariari May 10, 2023
ecb135c
Add a new destination for ibc rpc endpoint
mariari May 10, 2023
c09dd7e
Removed denominated from being called from user contracts
mariari May 10, 2023
34e5be7
WIP fix `pos_bonds`
brentstone May 11, 2023
fcaa11a
refactor `Dec` to allow negative values
brentstone May 12, 2023
2584aa2
Merge remote-tracking branch 'origin/base' into HEAD
mariari May 20, 2023
f855fd1
fixup! Merge remote-tracking branch 'origin/base' into HEAD
juped May 21, 2023
bcfcd32
fixup! Merge remote-tracking branch 'origin/base' into HEAD
juped May 21, 2023
d9d2654
fixup! Merge remote-tracking branch 'origin/base' into HEAD
juped May 22, 2023
eb81893
fixup! Merge remote-tracking branch 'origin/base' into HEAD
juped May 22, 2023
d481cfa
compiles
juped May 22, 2023
42de040
some test fixes
juped May 22, 2023
5801ef5
minor stuff again
juped May 22, 2023
48a27dc
dubious e2e fixes
juped May 23, 2023
aebb5f5
we don't take separators anymore whoops
juped May 24, 2023
f09312e
disambiguate token denom and ibc denom
juped May 24, 2023
55591d5
force 0 ibc denoms
juped May 24, 2023
9be7ef8
stupid test fix: add six zeroes
juped May 24, 2023
f558899
fix IBC stuff, IBC e2e test still failed
yito88 May 25, 2023
43ce2af
fix ledger e2e tests
juped May 25, 2023
ae4eb81
set NATIVE_MAX_DECIMAL_PLACES if denom isn't stored
yito88 May 25, 2023
41b6267
unsorted wips on e2e
juped May 29, 2023
6e5782b
WIP fixing masp amounts
batconjurer May 30, 2023
5053330
WIP fixing masp incentives
batconjurer Jun 1, 2023
cdde306
WIP fixed bug in collecting unspent notes
batconjurer Jun 1, 2023
16b17cc
WIP
batconjurer Jun 2, 2023
087341d
WIP fixing masp incentives
batconjurer Jun 1, 2023
ffd72ec
WIP fixed bug in collecting unspent notes
batconjurer Jun 1, 2023
b4f616b
WIP
batconjurer Jun 2, 2023
5dba8ab
Undo aggregate_conversions and related changes
juped Jun 2, 2023
d2a07ed
WIP small bug fixes and a debugger can be attached
batconjurer Jun 2, 2023
5d5772d
WIP fixed unspent note calcs
batconjurer Jun 5, 2023
057b4d3
WIP masp incentives passes. But I did something reckless to get there.
batconjurer Jun 7, 2023
1899e65
WIP fixed masp incentives
batconjurer Jun 7, 2023
b380c20
Masp e2e tests now passing
batconjurer Jun 9, 2023
61e9bd6
[fix]: Fixed serialization bug with amounts. Fixed remaining masp e2e…
batconjurer Jun 11, 2023
38e514c
[chore] Fixed clippy and formatting
batconjurer Jun 11, 2023
2cf1e76
Merge remote-tracking branch 'origin/mariari/amount-WIP' into bat/fea…
mariari Jun 13, 2023
1b39e98
[fix]: Merged in ibc fixes
batconjurer Jun 14, 2023
51c5423
[chore]: merged in v17
batconjurer Jun 14, 2023
5eea244
[fix]: Fixed unit tests other than flaky pos test
batconjurer Jun 15, 2023
cb5a547
[fix]: Cleanup imports
batconjurer Jun 15, 2023
637e2f8
WIP merging in v0.17.2
batconjurer Jun 16, 2023
85b36fd
[fix]: Removed problematic dep so that wasms load correctly
batconjurer Jun 18, 2023
869798f
[fix]: Fixed test wasm code for e2e tests
batconjurer Jun 20, 2023
3ec182e
[fix]: Finalize block no longer marks undecryptable txs as valid
batconjurer Jun 20, 2023
b1af386
fix IBC prefixed balance
yito88 Jun 20, 2023
5636c66
[chore]: Formatting
batconjurer Jun 21, 2023
6bc3dcb
Merge branch 'bat/feature/uint256_amount' of github.com:anoma/namada …
batconjurer Jun 21, 2023
3d2e91c
fix `pos_state_machine_test`
brentstone Jun 21, 2023
4531c26
[NOTE] Building wasm with wasm-opt ^112 fixes wasm bugs
batconjurer Jun 26, 2023
f4c9079
[fix]: Fixed masp tx deserialization issue
batconjurer Jun 26, 2023
72d8e9d
[fix]: Fixed masp e2e test that tests transfers and queries
batconjurer Jun 26, 2023
2f398b7
Improve consistentcy on pinned tx read
mariari Jun 27, 2023
e998bce
[fix]: Merge of 17.2 complete. Tests passing
batconjurer Jun 28, 2023
621b8d1
[feat]: Merge in main
batconjurer Jun 28, 2023
ec845c2
[ci] wasm checksums update
github-actions[bot] Jun 29, 2023
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
279 changes: 268 additions & 11 deletions Cargo.lock

Large diffs are not rendered by default.

35 changes: 20 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ wasms_for_tests := wasm_for_tests/wasm_source
# Paths for all the wasm templates
wasm_templates := wasm/tx_template wasm/vp_template

ifdef JOBS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

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

build-test:
$(cargo) +$(nightly) build --tests -Z unstable-options
$(cargo) +$(nightly) build --tests $(jobs) -Z unstable-options

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 @@ -56,7 +62,7 @@ check-mainnet:
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 @@ -126,38 +132,35 @@ test-e2e:
-Z unstable-options --report-time

test-unit-abcipp:
$(cargo) test \
$(cargo) +$(nightly) test \
--manifest-path ./apps/Cargo.toml \
$(jobs) \
--no-default-features \
--features "testing std abcipp" \
-Z unstable-options \
$(TEST_FILTER) -- \
-Z unstable-options --report-time && \
$(cargo) test \
$(cargo) +$(nightly) test \
--manifest-path \
./proof_of_stake/Cargo.toml \
$(jobs) \
--features "testing" \
-Z unstable-options \
$(TEST_FILTER) -- \
-Z unstable-options --report-time && \
$(cargo) test \
$(cargo) +$(nightly) test \
--manifest-path ./shared/Cargo.toml \
$(jobs) \
--no-default-features \
--features "testing wasm-runtime abcipp ibc-mocks-abcipp" \
-Z unstable-options \
$(TEST_FILTER) -- \
-Z unstable-options --report-time && \
$(cargo) test \
--manifest-path ./vm_env/Cargo.toml \
--no-default-features \
--features "abcipp" \
--features "testing wasm-runtime abcipp ibc-mocks-abcipp ferveo-tpke" \
-Z unstable-options \
$(TEST_FILTER) -- \
-Z unstable-options --report-time

test-unit:
$(cargo) +$(nightly) test \
$(TEST_FILTER) \
$(jobs) \
-Z unstable-options \
-- --skip e2e \
-Z unstable-options --report-time
Expand All @@ -166,12 +169,14 @@ test-unit-mainnet:
$(cargo) +$(nightly) test \
--features "mainnet" \
$(TEST_FILTER) \
$(jobs)
-Z unstable-options \
-- --skip e2e \
-Z unstable-options --report-time

test-unit-debug:
$(debug-cargo) +$(nightly) test \
$(jobs)
$(TEST_FILTER) -- \
-Z unstable-options \
-- --skip e2e \
Expand Down
71 changes: 60 additions & 11 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,7 @@ pub mod args {
use namada::types::storage::{self, BlockHeight, Epoch};
use namada::types::time::DateTimeUtc;
use namada::types::token;
use namada::types::token::NATIVE_MAX_DECIMAL_PLACES;
use namada::types::transaction::GasLimit;
use rust_decimal::Decimal;

Expand All @@ -1642,7 +1643,7 @@ pub mod args {
const ALIAS_OPT: ArgOpt<String> = ALIAS.opt();
const ALIAS: Arg<String> = arg("alias");
const ALLOW_DUPLICATE_IP: ArgFlag = flag("allow-duplicate-ip");
const AMOUNT: Arg<token::Amount> = arg("amount");
const AMOUNT: Arg<token::DenominatedAmount> = arg("amount");
const ARCHIVE_DIR: ArgOpt<PathBuf> = arg_opt("archive-dir");
const BALANCE_OWNER: ArgOpt<WalletBalanceOwner> = arg_opt("owner");
const BASE_DIR: ArgDefault<PathBuf> = arg_default(
Expand Down Expand Up @@ -1676,10 +1677,20 @@ pub mod args {
const EXPIRATION_OPT: ArgOpt<DateTimeUtc> = arg_opt("expiration");
const FORCE: ArgFlag = flag("force");
const DONT_PREFETCH_WASM: ArgFlag = flag("dont-prefetch-wasm");
const GAS_AMOUNT: ArgDefault<token::Amount> =
arg_default("gas-amount", DefaultFn(|| token::Amount::from(0)));
const GAS_LIMIT: ArgDefault<token::Amount> =
arg_default("gas-limit", DefaultFn(|| token::Amount::from(0)));
const GAS_AMOUNT: ArgDefault<token::DenominatedAmount> = arg_default(
"gas-amount",
DefaultFn(|| token::DenominatedAmount {
amount: token::Amount::default(),
denom: NATIVE_MAX_DECIMAL_PLACES.into(),
}),
);
const GAS_LIMIT: ArgDefault<token::DenominatedAmount> = arg_default(
"gas-limit",
DefaultFn(|| token::DenominatedAmount {
amount: token::Amount::default(),
denom: NATIVE_MAX_DECIMAL_PLACES.into(),
}),
);
const GAS_TOKEN: ArgDefaultFromCtx<WalletAddress> =
arg_default_from_ctx("gas-token", DefaultFn(|| "NAM".into()));
const GENESIS_PATH: Arg<PathBuf> = arg("genesis-path");
Expand Down Expand Up @@ -1996,7 +2007,19 @@ pub mod args {
/// Transferred token address
pub sub_prefix: Option<String>,
/// Transferred token amount
pub amount: token::Amount,
pub amount: InputAmount,
}

/// An amount read in by the cli
#[derive(Copy, Clone, Debug)]
pub enum InputAmount {
/// An amount whose representation has been validated
/// against the allowed representation in storage
Validated(token::DenominatedAmount),
/// The parsed amount read in from the cli. It has
/// not yet been validated against the allowed
/// representation in storage.
Unvalidated(token::DenominatedAmount),
}

impl Args for TxTransfer {
Expand All @@ -2006,7 +2029,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));
Self {
tx,
source,
Expand Down Expand Up @@ -2076,7 +2099,7 @@ pub mod args {
receiver,
token,
sub_prefix,
amount,
amount: amount.amount,
port_id,
channel_id,
timeout_height,
Expand Down Expand Up @@ -2293,6 +2316,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);
Self {
tx,
Expand Down Expand Up @@ -2332,6 +2363,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);
Self {
tx,
Expand Down Expand Up @@ -2739,17 +2778,21 @@ pub mod args {
pub owner: Option<WalletBalanceOwner>,
/// Address of a token
pub token: Option<WalletAddress>,
/// sub-prefix if querying a multi-token
pub sub_prefix: Option<String>,
}

impl Args for QueryTransfers {
fn parse(matches: &ArgMatches) -> Self {
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 @@ -2761,6 +2804,11 @@ pub mod args {
.arg(TOKEN_OPT.def().about(
"The token address that queried transfers must involve.",
))
.arg(
SUB_PREFIX.def().about(
"The token's sub prefix whose balance to query.",
),
)
}
}

Expand Down Expand Up @@ -2996,7 +3044,7 @@ pub mod args {
/// save it in the wallet.
pub initialized_account_alias: Option<String>,
/// The amount being payed to include the transaction
pub fee_amount: token::Amount,
pub fee_amount: InputAmount,
/// The token in which the fee is being paid
pub fee_token: WalletAddress,
/// The max amount of gas used to process tx
Expand Down Expand Up @@ -3080,9 +3128,10 @@ pub mod args {
let broadcast_only = BROADCAST_ONLY.parse(matches);
let ledger_address = LEDGER_ADDRESS_DEFAULT.parse(matches);
let initialized_account_alias = ALIAS_OPT.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);
Expand Down
Loading