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

draft #1527

Closed
wants to merge 73 commits into from
Closed

draft #1527

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
7aaf3ce
storage: add optional prefix iterator methods
juped May 23, 2023
cd966c4
apps: add namadac utils default-base-dir
juped Jun 1, 2023
b49e5f8
changelog: add #1491
juped Jun 1, 2023
cefdde2
core/types/address: rename `s/HASH_LEN/HASH_HEX_LEN`
tzemanovic Jun 6, 2023
c132c69
core/types/address: use byte array of a string in established addr
tzemanovic Jun 6, 2023
5f4e99d
wasm_for_tests: rebuild because of address breaking change
tzemanovic Jun 6, 2023
55c3f0b
[ci] wasm checksums update
github-actions[bot] Jun 6, 2023
43b25e7
channgelog: add #1510
tzemanovic Jun 6, 2023
011b443
test/wasm: update hard-coded hashes of wasm_for_tests
tzemanovic Jun 6, 2023
55499e7
core/types/address: use byte array of a string in PKH/implicit addr
tzemanovic Jun 6, 2023
bfd6371
fix: update help message
karbyshev Jun 6, 2023
93961d2
Add changelog
karbyshev Jun 6, 2023
e6b5ee3
fix: do not panic if the user skips the changes
karbyshev Jun 6, 2023
22b9066
[ci] wasm checksums update
github-actions[bot] Jun 7, 2023
a64dd84
changelog: add #1512
tzemanovic Jun 7, 2023
796afbc
fix: do not add address if it already exists
karbyshev Jun 6, 2023
85ba38b
Update changelog
karbyshev Jun 6, 2023
ba90ee1
fix calculation with `sum_post_bonds`
brentstone Jun 8, 2023
10c6bc7
client/cli: fix the msg when waiting to sync
tzemanovic Jun 8, 2023
cc50cc6
changelog: add #1522
tzemanovic Jun 8, 2023
8668fc3
Fixed local tx prover dependency regression.
Jun 8, 2023
cb864f9
Fixed the header of transactions in dry_run.
Jun 8, 2023
e00ce23
Added a changelog entry for this fix.
Jun 8, 2023
5e262fb
Merge branch 'origin/aleks/wallet-address-add-fix' (#1513)
Fraccaman Jun 9, 2023
42aa1a4
Merge branch 'origin/aleks/wallet-message-fix' (#1514)
Fraccaman Jun 9, 2023
6817ac1
Merge branch 'origin/aleks/wallet-alias-skip' (#1516)
Fraccaman Jun 9, 2023
c4068a9
Merge branch 'origin/tomas/established-addr-bytes' (#1510)
Fraccaman Jun 9, 2023
692a3fa
Merge branch 'origin/tomas/implicit-addr-bytes' (#1512)
Fraccaman Jun 9, 2023
36d0fb4
Merge branch 'origin/ray/utils-base-dir' (#1491)
Fraccaman Jun 9, 2023
90f379f
Merge branch 'origin/ray/iter-optional-prefix' (#1478)
Fraccaman Jun 9, 2023
e3162b4
Merge branch 'origin/tomas/client-fix-wait-msg' (#1522)
Fraccaman Jun 9, 2023
f1e6bc9
Merge branch 'origin/murisi/fix-dry-run-header-and-prover' (#1524)
Fraccaman Jun 12, 2023
62b345d
mute `total_slashed` for now
brentstone Jun 8, 2023
4a084c2
simplify some code to a `max` function
brentstone Jun 8, 2023
b961256
fix: use the correct storage key to parse balances
bengtlofgren Jun 9, 2023
3e87497
fmt, added changelog
Fraccaman Jun 12, 2023
4e523c7
Merge branch 'origin/bengt/balances-fix-issue-758' (#1528)
Fraccaman Jun 12, 2023
70a45ef
pos state machine: fix slashing computation
brentstone Jun 8, 2023
55d6390
changelog: #1520
brentstone Jun 12, 2023
d3b9635
shared/rpc: add bonds and unbonds details query enriched with extras
tzemanovic Jun 7, 2023
7b74871
app/client/rpc: use enriched bonds and unbonds query
tzemanovic Jun 7, 2023
ca2f53b
changelog: add #1518
tzemanovic Jun 12, 2023
8e076a1
Merge branch 'tomas/pos-bonds-query-reuse' (#1518)
tzemanovic Jun 12, 2023
9345a00
[ci] wasm checksums update
github-actions[bot] Jun 12, 2023
92ce4e2
pos/lib: fix slashing in `make_(un)bond_details`
brentstone Jun 11, 2023
eec876c
changelog: #1533
brentstone Jun 11, 2023
eb3a1b0
[ci] wasm checksums update
github-actions[bot] Jun 12, 2023
3474742
Merge branch 'brent/fix-sum-post-bonds-slashing' (#1520)
tzemanovic Jun 12, 2023
3cacdd4
Merge branch 'brent/fix-slashing-client-query' (#1533)
tzemanovic Jun 12, 2023
d36683b
update TendermintMode in Namada config for new post-genesis validator
brentstone Jun 12, 2023
fcc721b
fix: remove invalid condition around prepare-proposal
Fraccaman Jun 13, 2023
df7c22a
Merge tag 'v0.17.1' into draft-test
Fraccaman Jun 13, 2023
450531c
Merge branch 'origin/brent/fix-init-validator-tendermint-mode' (#1549)
Fraccaman Jun 13, 2023
9688ad0
Revert "Merge branch 'origin/brent/fix-init-validator-tendermint-mode…
Fraccaman Jun 13, 2023
cecb22f
update TendermintMode in Namada config for new post-genesis validator
brentstone Jun 12, 2023
7a2ebf7
fix: remove invalid condition around prepare-proposal
Fraccaman Jun 13, 2023
79ae826
core/storage: Store last committed block's hash and time with its height
tzemanovic Jun 12, 2023
9efa19c
shared/queries/shell: expose the last committed block from storage
tzemanovic Jun 12, 2023
8afdf28
core/time: impl Display for DateTimeUtc
tzemanovic Jun 12, 2023
b88ccfd
core/storage: impl Display for BlockHash
tzemanovic Jun 12, 2023
77cba8e
rpc: use the new shell last_block query to find last committed block
tzemanovic Jun 12, 2023
6e458cf
test/e2e/ledger/genesis_validators: validator wait for tx block height
tzemanovic Jun 12, 2023
93df661
test/storage: fill-in block header for commit if missing
tzemanovic Jun 12, 2023
45379a2
[ci] wasm checksums update
github-actions[bot] Jun 12, 2023
cf48f70
changelog: add #1534
tzemanovic Jun 12, 2023
a804265
Namada 0.17.1
Fraccaman Jun 12, 2023
0f17566
pos: fix is_validator to be epoch agnostic
tzemanovic Jun 13, 2023
26c2681
test/pos: check is_validator for a new validator
tzemanovic Jun 13, 2023
e957027
[ci] wasm checksums update
github-actions[bot] Jun 13, 2023
da62169
changelog: add #1553
tzemanovic Jun 13, 2023
1c1a910
test/e2e/pos_init_validator: ensure that node after init-validator works
tzemanovic Jun 13, 2023
7bacbba
changelog: add #1549
tzemanovic Jun 13, 2023
f58a6b2
Merge branch 'brent/fix-init-validator-tendermint-mode' (#1549)
Fraccaman Jun 13, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Do not add address if it already exists in the wallet.
([\#1504](https://github.com/anoma/namada/issues/1504))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- When processing slashes, bonds and unbonds that became active after
the infraction epoch must be properly accounted in order to properly
deduct stake that accounts for the precise slash amount. A bug
is fixed in the procedure that properly performs this accounting.
([#1520](https://github.com/anoma/namada/pull/1520))
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/1522-client-fix-wait-msg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix the message when a client is waiting for a node to sync on queries or
transactions. ([\#1522](https://github.com/anoma/namada/pull/1522))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- This change will enable usage of the Namada SDK to create MASP transactions
from non-CLI clients. ([\#1524](https://github.com/anoma/namada/pull/1524))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixing how token balances are displayed in case of missing --token option.
([#1528](https://github.com/anoma/namada/pull/1528))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- The slashed token amounts contained inside the bond and unbond information
returned by the PoS library fn bonds_and_unbonds are fixed and properly
computed. ([#1533](https://github.com/anoma/namada/pull/1533))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- PoS: Fixed the client to change configuration to validator
mode after a successful `init-validator` transaction.
([\#1549](https://github.com/anoma/namada/pull/1549))
3 changes: 3 additions & 0 deletions .changelog/unreleased/bug-fixes/1553-fix-is-validator-fn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- PoS: fixed a check for whether a given address belongs to a
validator account to work properly with newly created accounts.
([\#1553](https://github.com/anoma/namada/pull/1553))
4 changes: 4 additions & 0 deletions .changelog/unreleased/improvements/1491-utils-base-dir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Add a command, `namadac utils default-base-dir`, to
print the default base directory the command
line would use were one not provided by the user.
([#1491](https://github.com/anoma/namada/pull/1491))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Improve the established address in-memory representation
and use a full SHA-256 digest for their generation.
([\#1510](https://github.com/anoma/namada/pull/1510))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Improve the implicit address and PKH in-memory representation.
([\#1512](https://github.com/anoma/namada/pull/1512))
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/1514-wallet-message-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Improve help message for address add command
([\#1514](https://github.com/anoma/namada/issues/1514))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- PoS: make a re-usable bonds and unbonds details query.
([\#1518](https://github.com/anoma/namada/pull/1518))
7 changes: 5 additions & 2 deletions apps/src/bin/namada-client/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ pub async fn main() -> Result<()> {
Utils::PkToTmAddress(PkToTmAddress(args)) => {
utils::pk_to_tm_address(global_args, args)
}
Utils::DefaultBaseDir(DefaultBaseDir(args)) => {
utils::default_base_dir(global_args, args)
}
},
}
Ok(())
Expand Down Expand Up @@ -358,9 +361,9 @@ async fn wait_until_node_is_synched(ledger_address: &TendermintAddress) {
println!(
" Waiting for {} ({}/{} tries)...",
if is_at_least_height_one {
"a first block"
} else {
"node to sync"
} else {
"a first block"
},
try_count + 1,
MAX_TRIES
Expand Down
8 changes: 8 additions & 0 deletions apps/src/bin/namada-wallet/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ fn key_and_address_restore(
.unwrap_or_else(|err| {
eprintln!("{}", err);
cli::safe_exit(1)
})
.unwrap_or_else(|| {
println!("No changes are persisted. Exiting.");
cli::safe_exit(0);
});
namada_apps::wallet::save(&wallet)
.unwrap_or_else(|err| eprintln!("{}", err));
Expand Down Expand Up @@ -378,6 +382,10 @@ fn key_and_address_gen(
.unwrap_or_else(|err| {
eprintln!("{}", err);
cli::safe_exit(1);
})
.unwrap_or_else(|| {
println!("No changes are persisted. Exiting.");
cli::safe_exit(0);
});
namada_apps::wallet::save(&wallet)
.unwrap_or_else(|err| eprintln!("{}", err));
Expand Down
48 changes: 45 additions & 3 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,10 @@ pub mod cmds {
fn def() -> App {
App::new(Self::CMD)
.about(
"Restores a keypair from the given mnemonic code and \
derives the implicit address from its public key. Stores \
the keypair and the address with the given alias.",
"Restores a keypair from the given mnemonic code and HD \
derivation path and derives the implicit address from \
its public key. Stores the keypair and the address with \
the given alias.",
)
.add_args::<args::KeyAndAddressRestore>()
}
Expand Down Expand Up @@ -1588,6 +1589,7 @@ pub mod cmds {
InitNetwork(InitNetwork),
InitGenesisValidator(InitGenesisValidator),
PkToTmAddress(PkToTmAddress),
DefaultBaseDir(DefaultBaseDir),
}

impl SubCmd for Utils {
Expand All @@ -1604,11 +1606,14 @@ pub mod cmds {
SubCmd::parse(matches).map(Self::InitGenesisValidator);
let pk_to_tm_address =
SubCmd::parse(matches).map(Self::PkToTmAddress);
let default_base_dir =
SubCmd::parse(matches).map(Self::DefaultBaseDir);
join_network
.or(fetch_wasms)
.or(init_network)
.or(init_genesis)
.or(pk_to_tm_address)
.or(default_base_dir)
})
}

Expand All @@ -1620,6 +1625,7 @@ pub mod cmds {
.subcommand(InitNetwork::def())
.subcommand(InitGenesisValidator::def())
.subcommand(PkToTmAddress::def())
.subcommand(DefaultBaseDir::def())
.setting(AppSettings::SubcommandRequiredElseHelp)
}
}
Expand Down Expand Up @@ -1725,6 +1731,29 @@ pub mod cmds {
.add_args::<args::PkToTmAddress>()
}
}

#[derive(Clone, Debug)]
pub struct DefaultBaseDir(pub args::DefaultBaseDir);

impl SubCmd for DefaultBaseDir {
const CMD: &'static str = "default-base-dir";

fn parse(matches: &ArgMatches) -> Option<Self> {
matches
.subcommand_matches(Self::CMD)
.map(|matches| Self(args::DefaultBaseDir::parse(matches)))
}

fn def() -> App {
App::new(Self::CMD)
.about(
"Print the default base directory that would be used if \
--base-dir or NAMADA_BASE_DIR were not used to set the \
base directory.",
)
.add_args::<args::DefaultBaseDir>()
}
}
}

pub mod args {
Expand Down Expand Up @@ -3842,6 +3871,19 @@ pub mod args {
}
}

#[derive(Clone, Debug)]
pub struct DefaultBaseDir {}

impl Args for DefaultBaseDir {
fn parse(_matches: &ArgMatches) -> Self {
Self {}
}

fn def(app: App) -> App {
app
}
}

#[derive(Clone, Debug)]
pub struct FetchWasms {
pub chain_id: ChainId,
Expand Down
80 changes: 32 additions & 48 deletions apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ use namada::ledger::pos::{
self, BondId, BondsAndUnbondsDetail, CommissionPair, PosParams, Slash,
};
use namada::ledger::queries::RPC;
use namada::ledger::rpc::{query_epoch, TxResponse};
use namada::ledger::rpc::{
enriched_bonds_and_unbonds, query_epoch, TxResponse,
};
use namada::ledger::storage::ConversionState;
use namada::ledger::wallet::{AddressVpType, Wallet};
use namada::proof_of_stake::types::WeightedValidator;
Expand Down Expand Up @@ -314,7 +316,8 @@ pub async fn query_transparent_balance<
}
(None, Some(owner)) => {
for token in tokens {
let prefix = token.to_db_key().into();
let prefix =
token::balance_key(&token, &owner.address().unwrap());
let balances =
query_storage_prefix::<C, token::Amount>(client, &prefix)
.await;
Expand All @@ -329,7 +332,7 @@ pub async fn query_transparent_balance<
}
}
(Some(token), None) => {
let prefix = token.to_db_key().into();
let prefix = token::balance_prefix(&token);
let balances =
query_storage_prefix::<C, token::Amount>(client, &prefix).await;
if let Some(balances) = balances {
Expand Down Expand Up @@ -1263,29 +1266,18 @@ pub async fn query_bonds<C: namada::ledger::queries::Client + Sync>(
_wallet: &mut Wallet<CliWalletUtils>,
args: args::QueryBonds,
) -> std::io::Result<()> {
let _epoch = query_and_print_epoch(client).await;
let epoch = query_and_print_epoch(client).await;

let source = args.owner;
let validator = args.validator;

let stdout = io::stdout();
let mut w = stdout.lock();

let bonds_and_unbonds: pos::types::BondsAndUnbondsDetails =
unwrap_client_response::<C, pos::types::BondsAndUnbondsDetails>(
RPC.vp()
.pos()
.bonds_and_unbonds(client, &source, &validator)
.await,
);
let mut bonds_total: token::Amount = 0.into();
let mut bonds_total_slashed: token::Amount = 0.into();
let mut unbonds_total: token::Amount = 0.into();
let mut unbonds_total_slashed: token::Amount = 0.into();
let mut total_withdrawable: token::Amount = 0.into();
for (bond_id, details) in bonds_and_unbonds {
let mut total: token::Amount = 0.into();
let mut total_slashed: token::Amount = 0.into();
let bonds_and_unbonds =
enriched_bonds_and_unbonds(client, epoch, &source, &validator).await;

for (bond_id, details) in &bonds_and_unbonds.data {
let bond_type = if bond_id.source == bond_id.validator {
format!("Self-bonds from {}", bond_id.validator)
} else {
Expand All @@ -1295,74 +1287,66 @@ pub async fn query_bonds<C: namada::ledger::queries::Client + Sync>(
)
};
writeln!(w, "{}:", bond_type)?;
for bond in details.bonds {
for bond in &details.data.bonds {
writeln!(
w,
" Remaining active bond from epoch {}: Δ {}",
bond.start, bond.amount
)?;
total += bond.amount;
total_slashed += bond.slashed_amount.unwrap_or_default();
}
if total_slashed != token::Amount::default() {
if details.bonds_total_slashed != token::Amount::default() {
writeln!(
w,
"Active (slashed) bonds total: {}",
total - total_slashed
details.bonds_total_active()
)?;
}
writeln!(w, "Bonds total: {}", total)?;
writeln!(w, "Bonds total: {}", details.bonds_total)?;
writeln!(w)?;
bonds_total += total;
bonds_total_slashed += total_slashed;

let mut withdrawable = token::Amount::default();
if !details.unbonds.is_empty() {
let mut total: token::Amount = 0.into();
let mut total_slashed: token::Amount = 0.into();
if !details.data.unbonds.is_empty() {
let bond_type = if bond_id.source == bond_id.validator {
format!("Unbonded self-bonds from {}", bond_id.validator)
} else {
format!("Unbonded delegations from {}", bond_id.source)
};
writeln!(w, "{}:", bond_type)?;
for unbond in details.unbonds {
total += unbond.amount;
total_slashed += unbond.slashed_amount.unwrap_or_default();
for unbond in &details.data.unbonds {
writeln!(
w,
" Withdrawable from epoch {} (active from {}): Δ {}",
unbond.withdraw, unbond.start, unbond.amount
)?;
}
withdrawable = total - total_slashed;
writeln!(w, "Unbonded total: {}", total)?;

unbonds_total += total;
unbonds_total_slashed += total_slashed;
total_withdrawable += withdrawable;
writeln!(w, "Unbonded total: {}", details.unbonds_total)?;
}
writeln!(w, "Withdrawable total: {}", withdrawable)?;
writeln!(w, "Withdrawable total: {}", details.total_withdrawable)?;
writeln!(w)?;
}
if bonds_total != bonds_total_slashed {
if bonds_and_unbonds.bonds_total != bonds_and_unbonds.bonds_total_slashed {
writeln!(
w,
"All bonds total active: {}",
bonds_total - bonds_total_slashed
bonds_and_unbonds.bonds_total_active()
)?;
}
writeln!(w, "All bonds total: {}", bonds_total)?;
writeln!(w, "All bonds total: {}", bonds_and_unbonds.bonds_total)?;

if unbonds_total != unbonds_total_slashed {
if bonds_and_unbonds.unbonds_total
!= bonds_and_unbonds.unbonds_total_slashed
{
writeln!(
w,
"All unbonds total active: {}",
unbonds_total - unbonds_total_slashed
bonds_and_unbonds.unbonds_total_active()
)?;
}
writeln!(w, "All unbonds total: {}", unbonds_total)?;
writeln!(w, "All unbonds total withdrawable: {}", total_withdrawable)?;
writeln!(w, "All unbonds total: {}", bonds_and_unbonds.unbonds_total)?;
writeln!(
w,
"All unbonds total withdrawable: {}",
bonds_and_unbonds.total_withdrawable
)?;
Ok(())
}

Expand Down
Loading