Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/2046-ibc-token-addr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Replace strings with a specialized IBC token hash type in addresses
([\#2046](https://github.com/anoma/namada/pull/2046))
3 changes: 3 additions & 0 deletions .changelog/unreleased/improvements/2060-new-addresses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Switch to a more compact representation in Namada's transparent
addresses, and change all bech32m HRPs to their mainnet equivalent
([\#2060](https://github.com/anoma/namada/pull/2060))
30 changes: 26 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use namada::ledger::storage::ConversionState;
use namada::proof_of_stake::types::{ValidatorState, WeightedValidator};
use namada::types::address::{masp, Address, InternalAddress};
use namada::types::hash::Hash;
use namada::types::ibc::is_ibc_denom;
use namada::types::ibc::{is_ibc_denom, IbcTokenHash};
use namada::types::io::Io;
use namada::types::key::*;
use namada::types::masp::{BalanceOwner, ExtendedViewingKey, PaymentAddress};
Expand Down Expand Up @@ -635,7 +635,8 @@ async fn lookup_token_alias<'a>(
owner: &Address,
) -> String {
if let Address::Internal(InternalAddress::IbcToken(trace_hash)) = token {
let ibc_denom_key = ibc_denom_key(owner.to_string(), trace_hash);
let ibc_denom_key =
ibc_denom_key(owner.to_string(), trace_hash.to_string());
match query_storage_value::<_, String>(context.client(), &ibc_denom_key)
.await
{
Expand Down Expand Up @@ -687,6 +688,9 @@ async fn query_tokens<'a>(
if let Some((_, hash)) = is_ibc_denom_key(&key) {
let ibc_denom_alias =
get_ibc_denom_alias(context, ibc_denom).await;
let hash: IbcTokenHash = hash.parse().expect(
"Parsing an IBC token hash from storage shouldn't fail",
);
let ibc_token =
Address::Internal(InternalAddress::IbcToken(hash));
tokens.insert(ibc_denom_alias, ibc_token);
Expand Down
29 changes: 15 additions & 14 deletions apps/src/lib/node/ledger/ethereum_oracle/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,11 @@ pub mod eth_events {
10, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 84, 97, 116, 101, 115, 116, 49, 118, 52, 101, 104,
103, 119, 51, 54, 120, 117, 117, 110, 119, 100, 54, 57, 56, 57,
112, 114, 119, 100, 102, 107, 120, 113, 109, 110, 118, 115,
102, 106, 120, 115, 54, 110, 118, 118, 54, 120, 120, 117, 99,
114, 115, 51, 102, 51, 120, 99, 109, 110, 115, 51, 102, 99,
120, 100, 122, 114, 118, 118, 122, 57, 120, 118, 101, 114, 122,
118, 122, 114, 53, 54, 108, 101, 56, 102, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 45, 116, 110, 97, 109, 49, 113, 57, 117, 104, 48, 54,
100, 104, 50, 99, 114, 107, 53, 102, 122, 107, 56, 97, 99, 103,
117, 57, 110, 99, 97, 113, 55, 107, 112, 99, 101, 112, 112,
115, 115, 112, 117, 121, 97, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
];

let raw: TransferToChainFilter = TRANSFER_TO_CHAIN_CODEC
Expand All @@ -379,8 +376,11 @@ pub mod eth_events {
raw.transfers,
vec![ethereum_structs::ChainTransfer {
amount: 100u64.into(),
from: ethabi::Address::from_str("0x5FbDB2315678afecb367f032d93F642f64180aa3").unwrap(),
to: "atest1v4ehgw36xuunwd6989prwdfkxqmnvsfjxs6nvv6xxucrs3f3xcmns3fcxdzrvvz9xverzvzr56le8f".into(),
from: ethabi::Address::from_str(
"0x5FbDB2315678afecb367f032d93F642f64180aa3"
)
.unwrap(),
to: "tnam1q9uh06dh2crk5fzk8acgu9ncaq7kpceppsspuya2".into(),
}]
)
}
Expand Down Expand Up @@ -423,8 +423,10 @@ pub mod eth_events {
#[test]
fn test_decoding_roundtrips() {
let erc = EthAddress([1; 20]);
let address = Address::from_str("atest1v4ehgw36gep5ysecxq6nyv3jg3zygv3e89qn2vp48pryxsf4xpznvve5gvmy23fs89pryvf5a6ht90")
.expect("Test failed");
let address = Address::from_str(
"tnam1q87teqzjytwa9xd9qk8u558xxnrwuzdjzs7zvhzr",
)
.expect("Test failed");
let amount = Amount::from(42u64);
let confs = 50u32;
let uint = Uint::from(42u64);
Expand Down Expand Up @@ -468,8 +470,7 @@ pub mod eth_events {
#[test]
fn test_complex_round_trips() {
let address: String =
"atest1v4ehgw36gep5ysecxq6nyv3jg3zygv3e89qn2vp48pryxsf4xpznvve5gvmy23fs89pryvf5a6ht90"
.into();
"tnam1q87teqzjytwa9xd9qk8u558xxnrwuzdjzs7zvhzr".into();
let nam_transfers = TransferToChainFilter {
transfers: vec![
ethereum_structs::ChainTransfer {
Expand Down
14 changes: 9 additions & 5 deletions apps/src/lib/wallet/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,25 @@ mod dev {

/// An established user address for testing & development
pub fn albert_address() -> Address {
Address::decode("atest1v4ehgw368ycryv2z8qcnxv3cxgmrgvjpxs6yg333gym5vv2zxepnj334g4rryvj9xucrgve4x3xvr4").expect("The token address decoding shouldn't fail")
Address::decode("tnam1qxgzrwqn9qny9fzd7xnlrdkf7hhj9ecyx5mv3sgw")
.expect("The token address decoding shouldn't fail")
}

/// An established user address for testing & development
pub fn bertha_address() -> Address {
Address::decode("atest1v4ehgw36xvcyyvejgvenxs34g3zygv3jxqunjd6rxyeyys3sxy6rwvfkx4qnj33hg9qnvse4lsfctw").expect("The token address decoding shouldn't fail")
Address::decode("tnam1qyctxtpnkhwaygye0sftkq28zedf774xc5a2m7st")
.expect("The token address decoding shouldn't fail")
}

/// An established user address for testing & development
pub fn christel_address() -> Address {
Address::decode("atest1v4ehgw36x3qng3jzggu5yvpsxgcngv2xgguy2dpkgvu5x33kx3pr2w2zgep5xwfkxscrxs2pj8075p").expect("The token address decoding shouldn't fail")
Address::decode("tnam1q99ylwumqqs5r7uwgmyu7e94n07vjeqr4g970na0")
.expect("The token address decoding shouldn't fail")
}

/// An implicit user address for testing & development
pub fn daewon_address() -> Address {
// "atest1d9khqw36xprrzdpk89rrws69g4z5vd6pgv65gvjrgeqnv3pcg4zns335xymry335gcerqs3etd0xfa"
// "tnam1qq83g60hemh00tza9naxmrhg7stz7neqhytnj6l0"
(&daewon_keypair().ref_to()).into()
}

Expand All @@ -131,7 +134,8 @@ mod dev {

/// An established validator address for testing & development
pub fn validator_address() -> Address {
Address::decode("atest1v4ehgw36ggcnsdee8qerswph8y6ry3p5xgunvve3xaqngd3kxc6nqwz9gseyydzzg5unys3ht2n48q").expect("The token address decoding shouldn't fail")
Address::decode("tnam1qxcc0xpgs72z6s5kx9ayvejs3mftf05jkutgz2cc")
.expect("The token address decoding shouldn't fail")
}

/// N.B. this is the corresponding value from
Expand Down
10 changes: 6 additions & 4 deletions apps/src/lib/wallet/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ mod test_wallet {
let validator_keys =
gen_validator_keys(None, None, SchemeType::Ed25519);
store.add_validator_data(
Address::decode("atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5").unwrap(),
validator_keys
Address::decode("tnam1q99c37u38grkdcc2qze0hz4zjjd8zr3yucd3mzgz")
.unwrap(),
validator_keys,
);
let data = store.encode();
let _ = Store::decode(data).expect("Test failed");
Expand All @@ -86,8 +87,9 @@ mod test_wallet {
let validator_keys =
gen_validator_keys(None, None, SchemeType::Secp256k1);
store.add_validator_data(
Address::decode("atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5").unwrap(),
validator_keys
Address::decode("tnam1q99c37u38grkdcc2qze0hz4zjjd8zr3yucd3mzgz")
.unwrap(),
validator_keys,
);
let data = store.encode();
let _ = Store::decode(data).expect("Test failed");
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ itertools.workspace = true
k256.workspace = true
masp_primitives.workspace = true
num256.workspace = true
num_enum = "0.7.0"
num-integer = "0.1.45"
num-rational.workspace = true
num-traits.workspace = true
Expand Down
Loading