Skip to content

Commit

Permalink
Merge branch 'tomas/refactor-testing-addrs' (#2507)
Browse files Browse the repository at this point in the history
* tomas/refactor-testing-addrs:
  changelog: add #2507
  core: prevent from using addresses for testing in non-test code
  changelog: add #2506
  gov: replace namada_state dep with namada_storage
  changelog: add #2503
  update all core types usages
  core: flatten types mod
  update replay_protection usage
  core: factor out the ledger::replay_protection mod into a new crate
  core: refactor out ledger::eth_bridge mod
  changelog: add #2493
  benches: fix the shell to update conversions on new epochs
  move shielded params from core into shielded_token
  move inflation from core to trans_token
  replace namada_state usage with namada_storage in token crates
  changelog: add #2482
  refactor finalize_block PoS updates
  refactor finalize_block governance updates
  refactor finalize_block token updates
  • Loading branch information
tzemanovic committed Feb 6, 2024
2 parents 724c0bc + ced19df commit c7c971f
Show file tree
Hide file tree
Showing 333 changed files with 2,839 additions and 2,794 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Refactored sub-systems integration in the ABCI FinalizeBlock request handler.
([\#2482](https://github.com/anoma/namada/pull/2482))
1 change: 1 addition & 0 deletions .changelog/unreleased/improvements/2493-refactor-token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Refactored token crates. ([\#2493](https://github.com/anoma/namada/pull/2493))
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/2503-refactor-core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Refactored core crate to flatten the modules structure.
([\#2503](https://github.com/anoma/namada/pull/2503))
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/2506-refactor-gov.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Refactored governance crate dependencies.
([\#2506](https://github.com/anoma/namada/pull/2506))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Hid addresses used for testing from public API.
([\#2507](https://github.com/anoma/namada/pull/2507))
17 changes: 13 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
"crates/merkle_tree",
"crates/parameters",
"crates/proof_of_stake",
"crates/replay_protection",
"crates/sdk",
"crates/namada",
"crates/shielded_token",
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ crates += namada_macros
crates += namada_merkle_tree
crates += namada_parameters
crates += namada_proof_of_stake
crates += namada_replay_protection
crates += namada_sdk
crates += namada_shielded_token
crates += namada_state
Expand Down
6 changes: 3 additions & 3 deletions crates/account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ mod storage_key;
mod types;

use borsh::{BorshDeserialize, BorshSerialize};
pub use namada_core::types::account::AccountPublicKeysMap;
use namada_core::types::address::Address;
use namada_core::types::key::common;
pub use namada_core::account::AccountPublicKeysMap;
use namada_core::address::Address;
use namada_core::key::common;
use serde::{Deserialize, Serialize};
pub use storage::*;
pub use storage_key::*;
Expand Down
6 changes: 3 additions & 3 deletions crates/account/src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Cryptographic signature keys storage API
use namada_core::types::address::Address;
use namada_core::types::key::common;
use namada_core::types::storage;
use namada_core::address::Address;
use namada_core::key::common;
use namada_core::storage;
use namada_storage::{Result, StorageRead, StorageWrite};

use super::*;
Expand Down
6 changes: 3 additions & 3 deletions crates/account/src/storage_key.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use namada_core::types::address::Address;
use namada_core::types::key::common;
use namada_core::types::storage::{self, DbKeySeg};
use namada_core::address::Address;
use namada_core::key::common;
use namada_core::storage::{self, DbKeySeg};
use namada_macros::StorageKeys;
use namada_storage::collections::lazy_map::LazyMap;
use namada_storage::collections::{lazy_map, LazyCollection};
Expand Down
12 changes: 6 additions & 6 deletions crates/account/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use namada_core::address::Address;
use namada_core::borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use namada_core::types::address::Address;
use namada_core::types::hash::Hash;
use namada_core::types::key::common;
use namada_core::hash::Hash;
use namada_core::key::common;
use serde::{Deserialize, Serialize};

/// A tx data type to initialize a new established account
Expand Down Expand Up @@ -53,9 +53,9 @@ pub struct UpdateAccount {
#[cfg(any(test, feature = "testing"))]
/// Tests and strategies for accounts
pub mod tests {
use namada_core::types::address::testing::arb_non_internal_address;
use namada_core::types::hash::testing::arb_hash;
use namada_core::types::key::testing::arb_common_pk;
use namada_core::address::testing::arb_non_internal_address;
use namada_core::hash::testing::arb_hash;
use namada_core::key::testing::arb_common_pk;
use proptest::prelude::Just;
use proptest::{collection, option, prop_compose};

Expand Down
2 changes: 1 addition & 1 deletion crates/apps/src/bin/namada-node/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Namada node CLI.
use eyre::{Context, Result};
use namada::types::time::{DateTimeUtc, Utc};
use namada::core::time::{DateTimeUtc, Utc};
use namada_apps::cli::{self, cmds};
use namada_apps::config::ValidatorLocalConfig;
use namada_apps::node::ledger;
Expand Down
41 changes: 21 additions & 20 deletions crates/apps/src/lib/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ use borsh_ext::BorshSerializeExt;
use masp_primitives::transaction::Transaction;
use masp_primitives::zip32::ExtendedFullViewingKey;
use masp_proofs::prover::LocalTxProver;
use namada::core::address::{self, Address, InternalAddress};
use namada::core::chain::ChainId;
use namada::core::hash::Hash;
use namada::core::key::common::SecretKey;
use namada::core::masp::{
ExtendedViewingKey, PaymentAddress, TransferSource, TransferTarget,
};
use namada::core::storage::{BlockHeight, Epoch, Key, KeySeg, TxIndex};
use namada::core::time::DateTimeUtc;
use namada::core::token::{Amount, DenominatedAmount, Transfer};
use namada::governance::storage::proposal::ProposalType;
use namada::governance::InitProposalData;
use namada::ibc::apps::transfer::types::msgs::transfer::MsgTransfer;
Expand Down Expand Up @@ -50,6 +60,7 @@ use namada::ibc::core::host::types::path::{
use namada::ibc::primitives::proto::{Any, Protobuf};
use namada::ibc::primitives::{Msg, Timestamp as IbcTimestamp};
use namada::ibc::storage::port_key;
use namada::io::StdIo;
use namada::ledger::dry_run_tx;
use namada::ledger::gas::TxGasMeter;
use namada::ledger::ibc::storage::{channel_key, connection_key};
Expand All @@ -62,17 +73,6 @@ use namada::tendermint_rpc::{self};
use namada::tx::data::pos::Bond;
use namada::tx::data::{TxResult, VpsResult};
use namada::tx::{Code, Data, Section, Signature, Tx};
use namada::types::address::{self, Address, InternalAddress};
use namada::types::chain::ChainId;
use namada::types::hash::Hash;
use namada::types::io::StdIo;
use namada::types::key::common::SecretKey;
use namada::types::masp::{
ExtendedViewingKey, PaymentAddress, TransferSource, TransferTarget,
};
use namada::types::storage::{BlockHeight, Epoch, Key, KeySeg, TxIndex};
use namada::types::time::DateTimeUtc;
use namada::types::token::{Amount, DenominatedAmount, Transfer};
use namada::vm::wasm::run;
use namada::{proof_of_stake, tendermint};
use namada_sdk::masp::{
Expand Down Expand Up @@ -350,7 +350,7 @@ impl BenchShell {

pub fn generate_ibc_transfer_tx(&self) -> Tx {
let token = PrefixedCoin {
denom: address::nam().to_string().parse().unwrap(),
denom: address::testing::nam().to_string().parse().unwrap(),
amount: Amount::native_whole(1000)
.to_string_native()
.split('.')
Expand Down Expand Up @@ -414,6 +414,11 @@ impl BenchShell {
current_epoch + params.pipeline_len,
)
.unwrap();

namada::token::conversion::update_allowed_conversions(
&mut self.wl_storage,
)
.unwrap();
}

pub fn init_ibc_client_state(&mut self, addr_key: Key) -> ClientId {
Expand Down Expand Up @@ -887,7 +892,7 @@ impl Client for BenchShell {

impl Default for BenchShieldedCtx {
fn default() -> Self {
let mut shell = BenchShell::default();
let shell = BenchShell::default();
let base_dir = shell.tempdir.as_ref().canonicalize().unwrap();

// Create a global config and an empty wallet in the chain dir - this is
Expand Down Expand Up @@ -957,10 +962,6 @@ impl Default for BenchShieldedCtx {
}

crate::wallet::save(&chain_ctx.wallet).unwrap();
namada::token::conversion::update_allowed_conversions(
&mut shell.wl_storage,
)
.unwrap();

Self {
shielded: ShieldedContext::default(),
Expand Down Expand Up @@ -1004,7 +1005,7 @@ impl BenchShieldedCtx {
&namada,
&source,
&target,
&address::nam(),
&address::testing::nam(),
denominated_amount,
),
)
Expand All @@ -1020,7 +1021,7 @@ impl BenchShieldedCtx {

let mut hasher = Sha256::new();
let shielded_section_hash = shielded.clone().map(|transaction| {
namada::types::hash::Hash(
namada::core::hash::Hash(
Section::MaspTx(transaction)
.hash(&mut hasher)
.finalize_reset()
Expand All @@ -1033,7 +1034,7 @@ impl BenchShieldedCtx {
Transfer {
source: source.effective_address(),
target: target.effective_address(),
token: address::nam(),
token: address::testing::nam(),
amount: DenominatedAmount::native(amount),
key: None,
shielded: shielded_section_hash,
Expand Down
24 changes: 12 additions & 12 deletions crates/apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod wallet;

use clap::{ArgGroup, ArgMatches, ColorChoice};
use color_eyre::eyre::Result;
use namada::types::io::StdIo;
use namada::io::StdIo;
use utils::*;
pub use utils::{safe_exit, Cmd};

Expand Down Expand Up @@ -2849,19 +2849,19 @@ pub mod args {
use std::path::PathBuf;
use std::str::FromStr;

use namada::core::address::{Address, EstablishedAddress};
use namada::core::chain::{ChainId, ChainIdPrefix};
use namada::core::dec::Dec;
use namada::core::ethereum_events::EthAddress;
use namada::core::keccak::KeccakHash;
use namada::core::key::*;
use namada::core::masp::PaymentAddress;
use namada::core::storage::{self, BlockHeight, Epoch};
use namada::core::time::DateTimeUtc;
use namada::core::token;
use namada::core::token::NATIVE_MAX_DECIMAL_PLACES;
use namada::ibc::core::host::types::identifiers::{ChannelId, PortId};
use namada::tx::data::GasLimit;
use namada::types::address::{Address, EstablishedAddress};
use namada::types::chain::{ChainId, ChainIdPrefix};
use namada::types::dec::Dec;
use namada::types::ethereum_events::EthAddress;
use namada::types::keccak::KeccakHash;
use namada::types::key::*;
use namada::types::masp::PaymentAddress;
use namada::types::storage::{self, BlockHeight, Epoch};
use namada::types::time::DateTimeUtc;
use namada::types::token;
use namada::types::token::NATIVE_MAX_DECIMAL_PLACES;
pub use namada_sdk::args::*;
pub use namada_sdk::tx::{
TX_BECOME_VALIDATOR_WASM, TX_BOND_WASM, TX_BRIDGE_POOL_WASM,
Expand Down
2 changes: 1 addition & 1 deletion crates/apps/src/lib/cli/api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use namada::io::Io;
use namada::tendermint_rpc::HttpClient;
use namada::types::io::Io;
use namada_sdk::error::Error;
use namada_sdk::queries::Client;
use namada_sdk::rpc::wait_until_node_is_synched;
Expand Down
2 changes: 1 addition & 1 deletion crates/apps/src/lib/cli/client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use color_eyre::eyre::Result;
use namada::types::io::Io;
use namada::io::Io;
use namada_sdk::{Namada, NamadaImpl};

use crate::cli;
Expand Down
14 changes: 7 additions & 7 deletions crates/apps/src/lib/cli/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;

use color_eyre::eyre::Result;
use namada::core::address::{Address, InternalAddress};
use namada::core::chain::ChainId;
use namada::core::ethereum_events::EthAddress;
use namada::core::ibc::is_ibc_denom;
use namada::core::key::*;
use namada::core::masp::*;
use namada::io::Io;
use namada::ledger::ibc::storage::ibc_token;
use namada::types::address::{Address, InternalAddress};
use namada::types::chain::ChainId;
use namada::types::ethereum_events::EthAddress;
use namada::types::ibc::is_ibc_denom;
use namada::types::io::Io;
use namada::types::key::*;
use namada::types::masp::*;
use namada_sdk::masp::fs::FsShieldedUtils;
use namada_sdk::masp::ShieldedContext;
use namada_sdk::wallet::Wallet;
Expand Down
2 changes: 1 addition & 1 deletion crates/apps/src/lib/cli/relayer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use color_eyre::eyre::Result;
use namada::types::io::Io;
use namada::io::Io;
use namada_sdk::eth_bridge::{bridge_pool, validator_set};

use crate::cli;
Expand Down
8 changes: 4 additions & 4 deletions crates/apps/src/lib/cli/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use ledger_namada_rs::{BIP44Path, NamadaApp};
use ledger_transport_hid::hidapi::HidApi;
use ledger_transport_hid::TransportNativeHID;
use masp_primitives::zip32::ExtendedFullViewingKey;
use namada::types::address::{Address, DecodeError};
use namada::types::io::Io;
use namada::types::key::*;
use namada::types::masp::{ExtendedSpendingKey, MaspValue, PaymentAddress};
use namada::core::address::{Address, DecodeError};
use namada::core::key::*;
use namada::core::masp::{ExtendedSpendingKey, MaspValue, PaymentAddress};
use namada::io::Io;
use namada_sdk::masp::find_valid_diversifier;
use namada_sdk::wallet::{
DecryptionError, DerivationPath, DerivationPathError, FindKeyError, Wallet,
Expand Down
Loading

0 comments on commit c7c971f

Please sign in to comment.