From 14287ed810ab8af3f0421e200c5904a6c87b11cb Mon Sep 17 00:00:00 2001 From: bengtlofgren Date: Tue, 5 Mar 2024 16:40:45 +0000 Subject: [PATCH 01/20] added clone to transaction structs --- crates/light_sdk/src/transaction/account.rs | 1 + crates/light_sdk/src/transaction/bridge.rs | 1 + crates/light_sdk/src/transaction/governance.rs | 1 + crates/light_sdk/src/transaction/ibc.rs | 1 + crates/light_sdk/src/transaction/mod.rs | 1 + crates/light_sdk/src/transaction/pgf.rs | 1 + crates/light_sdk/src/transaction/pos.rs | 1 + crates/light_sdk/src/transaction/transfer.rs | 1 + 8 files changed, 8 insertions(+) diff --git a/crates/light_sdk/src/transaction/account.rs b/crates/light_sdk/src/transaction/account.rs index b037238a2e..eec6ebd683 100644 --- a/crates/light_sdk/src/transaction/account.rs +++ b/crates/light_sdk/src/transaction/account.rs @@ -14,6 +14,7 @@ const TX_REVEAL_PK_WASM: &str = "tx_reveal_pk.wasm"; const TX_UPDATE_ACCOUNT_WASM: &str = "tx_update_account.wasm"; /// Transaction to initialize an established account +#[derive(Debug, Clone)] pub struct InitAccount(Tx); impl InitAccount { diff --git a/crates/light_sdk/src/transaction/bridge.rs b/crates/light_sdk/src/transaction/bridge.rs index a8fb35c2ab..a7085a85d6 100644 --- a/crates/light_sdk/src/transaction/bridge.rs +++ b/crates/light_sdk/src/transaction/bridge.rs @@ -13,6 +13,7 @@ use crate::transaction; const TX_BRIDGE_POOL_WASM: &str = "tx_bridge_pool.wasm"; /// A transfer over the Ethereum bridge +#[derive(Debug, Clone)] pub struct BridgeTransfer(Tx); impl BridgeTransfer { diff --git a/crates/light_sdk/src/transaction/governance.rs b/crates/light_sdk/src/transaction/governance.rs index ae97e0d4c9..230e423551 100644 --- a/crates/light_sdk/src/transaction/governance.rs +++ b/crates/light_sdk/src/transaction/governance.rs @@ -14,6 +14,7 @@ const TX_INIT_PROPOSAL_WASM: &str = "tx_init_proposal.wasm"; const TX_VOTE_PROPOSAL: &str = "tx_vote_proposal.wasm"; /// Transaction to initialize a governance proposal +#[derive(Debug, Clone)] pub struct InitProposal(Tx); impl InitProposal { diff --git a/crates/light_sdk/src/transaction/ibc.rs b/crates/light_sdk/src/transaction/ibc.rs index 32afdb4c30..9bd143c593 100644 --- a/crates/light_sdk/src/transaction/ibc.rs +++ b/crates/light_sdk/src/transaction/ibc.rs @@ -17,6 +17,7 @@ use crate::transaction; const TX_IBC_WASM: &str = "tx_ibc.wasm"; /// An IBC transfer +#[derive(Debug, Clone)] pub struct IbcTransfer(Tx); impl IbcTransfer { diff --git a/crates/light_sdk/src/transaction/mod.rs b/crates/light_sdk/src/transaction/mod.rs index 6f8aebd5da..ab043d211b 100644 --- a/crates/light_sdk/src/transaction/mod.rs +++ b/crates/light_sdk/src/transaction/mod.rs @@ -21,6 +21,7 @@ pub mod pos; pub mod transfer; /// Generic arguments required to construct a transaction +#[derive(Debug, Clone)] pub struct GlobalArgs { pub expiration: Option, pub code_hash: Hash, diff --git a/crates/light_sdk/src/transaction/pgf.rs b/crates/light_sdk/src/transaction/pgf.rs index 1a492b331b..02ce44141f 100644 --- a/crates/light_sdk/src/transaction/pgf.rs +++ b/crates/light_sdk/src/transaction/pgf.rs @@ -15,6 +15,7 @@ const TX_RESIGN_STEWARD: &str = "tx_resign_steward.wasm"; const TX_UPDATE_STEWARD_COMMISSION: &str = "tx_update_steward_commission.wasm"; /// A transaction to resign from stewarding pgf +#[derive(Debug, Clone)] pub struct ResignSteward(Tx); impl ResignSteward { diff --git a/crates/light_sdk/src/transaction/pos.rs b/crates/light_sdk/src/transaction/pos.rs index 25b7a19f37..746005754c 100644 --- a/crates/light_sdk/src/transaction/pos.rs +++ b/crates/light_sdk/src/transaction/pos.rs @@ -26,6 +26,7 @@ const TX_CHANGE_COMMISSION_WASM: &str = "tx_change_validator_commission.wasm"; const TX_WITHDRAW_WASM: &str = "tx_withdraw.wasm"; /// A bond transaction +#[derive(Debug, Clone)] pub struct Bond(Tx); impl Bond { diff --git a/crates/light_sdk/src/transaction/transfer.rs b/crates/light_sdk/src/transaction/transfer.rs index 3a5d188a21..9a8152ce69 100644 --- a/crates/light_sdk/src/transaction/transfer.rs +++ b/crates/light_sdk/src/transaction/transfer.rs @@ -13,6 +13,7 @@ use crate::transaction; const TX_TRANSFER_WASM: &str = "tx_transfer.wasm"; /// A transfer transaction +#[derive(Debug, Clone)] pub struct Transfer(Tx); impl Transfer { From f3765ee559c4ba97d5e4e09fbcd52e5c756fb49a Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Mon, 29 Apr 2024 15:05:19 +0200 Subject: [PATCH 02/20] Changelog #2817 --- .changelog/unreleased/bug-fixes/2817-light-sdk-clone.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/bug-fixes/2817-light-sdk-clone.md diff --git a/.changelog/unreleased/bug-fixes/2817-light-sdk-clone.md b/.changelog/unreleased/bug-fixes/2817-light-sdk-clone.md new file mode 100644 index 0000000000..ce2e70b9f2 --- /dev/null +++ b/.changelog/unreleased/bug-fixes/2817-light-sdk-clone.md @@ -0,0 +1,2 @@ +- Light SDK objects must be clone-able. + ([\#2817](https://github.com/anoma/namada/pull/2817)) \ No newline at end of file From 47123bca67b07f80da3a153f4f699bcb25cfbd2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 9 May 2024 15:13:59 +0200 Subject: [PATCH 03/20] deliberatly empty From 4a55777f246803e70ed6c74fdc419f42b18a2b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 10 May 2024 08:57:41 +0200 Subject: [PATCH 04/20] changelog: add #3216 --- .changelog/unreleased/miscellaneous/3216-update-tower-abci.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/miscellaneous/3216-update-tower-abci.md diff --git a/.changelog/unreleased/miscellaneous/3216-update-tower-abci.md b/.changelog/unreleased/miscellaneous/3216-update-tower-abci.md new file mode 100644 index 0000000000..f8ae248b2e --- /dev/null +++ b/.changelog/unreleased/miscellaneous/3216-update-tower-abci.md @@ -0,0 +1,2 @@ +- Update tower-abci to fix windows build. + ([\#3216](https://github.com/anoma/namada/pull/3216)) \ No newline at end of file From cde6070ce07c4b72980a3393c91aca3d9906a43b Mon Sep 17 00:00:00 2001 From: brentstone Date: Tue, 14 May 2024 08:57:25 -0600 Subject: [PATCH 05/20] empty commit From 253676e731c95a0166df61a5467a6e3b7ec96ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 14 May 2024 20:17:35 +0200 Subject: [PATCH 06/20] fixup! Merge branch 'tomas/more-checked-arith' (#3214) --- crates/apps/src/lib/node/ledger/mod.rs | 11 +++++++---- .../src/lib/node/ledger/shell/prepare_proposal.rs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/apps/src/lib/node/ledger/mod.rs b/crates/apps/src/lib/node/ledger/mod.rs index 020e4c9464..8e4a384d16 100644 --- a/crates/apps/src/lib/node/ledger/mod.rs +++ b/crates/apps/src/lib/node/ledger/mod.rs @@ -151,10 +151,13 @@ pub fn migrating_state() -> Option { fn emit_warning_on_non_64bit_cpu() { if std::mem::size_of::() != 8 { tracing::warn!(""); - tracing::warn!( - "Your machine has a {}-bit CPU...", - 8 * std::mem::size_of::() - ); + #[allow(clippy::arithmetic_side_effects)] + { + tracing::warn!( + "Your machine has a {}-bit CPU...", + 8 * std::mem::size_of::() + ); + } tracing::warn!(""); tracing::warn!("A majority of nodes will run on 64-bit hardware!"); tracing::warn!(""); diff --git a/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs b/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs index 015538bf09..a26c91a933 100644 --- a/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs +++ b/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs @@ -356,7 +356,7 @@ where fn compute_min_gas_price( fee_token: &Address, proposer_local_config: Option<&ValidatorLocalConfig>, - temp_state: &TempWlState, + temp_state: &TempWlState<'_, D, H>, ) -> Result where D: DB + for<'iter> DBIter<'iter> + Sync + 'static, From 4cafd2c626f27b0c16290686717b972bdbf3fcb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 14 May 2024 21:21:13 +0200 Subject: [PATCH 07/20] fixup! Merge branch 'tiago/max-proposal-bytes-validation' (#3220) --- crates/apps/src/lib/node/ledger/tendermint_node.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/apps/src/lib/node/ledger/tendermint_node.rs b/crates/apps/src/lib/node/ledger/tendermint_node.rs index c617d6efe3..b5a01fa9a7 100644 --- a/crates/apps/src/lib/node/ledger/tendermint_node.rs +++ b/crates/apps/src/lib/node/ledger/tendermint_node.rs @@ -417,8 +417,12 @@ async fn update_tendermint_config( // during some round's start config.mempool.max_tx_bytes = 1024 * 1024; - // Hold 50x the max amount of txs in a block - config.mempool.max_txs_bytes = 50 * ProposalBytes::MAX.get(); + // Hold 50x the max amount of txs in a block. + #[allow(clippy::arithmetic_side_effects)] + { + // Multiply with consts - cannot overflow + config.mempool.max_txs_bytes = 50 * ProposalBytes::MAX.get(); + } // Hold up to 4k txs in the mempool config.mempool.size = 4000; @@ -477,7 +481,9 @@ async fn write_tm_genesis( // maximum size of a serialized Tendermint block. // on Namada, we have a hard-cap of 16 MiB (6 MiB max // txs in a block + 10 MiB reserved for evidence data, - // block headers and protobuf serialization overhead) + // block headers and protobuf serialization overhead). + // Addition with consts - cannot overflow. + #[allow(clippy::arithmetic_side_effects)] max_bytes: EVIDENCE_AND_PROTOBUF_OVERHEAD + ProposalBytes::MAX.get(), // gas is metered app-side, so we disable it // at the Tendermint level From 00008b7c3b71ab7bf1cd4cbc3529e455adfc29fa Mon Sep 17 00:00:00 2001 From: brentstone Date: Wed, 15 May 2024 12:57:23 -0700 Subject: [PATCH 08/20] fixup! Merge branch 'bat/fix/issue-1796' (#3226) --- crates/apps/src/lib/cli/utils.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/apps/src/lib/cli/utils.rs b/crates/apps/src/lib/cli/utils.rs index 0ad1197fc6..23dcb65f0e 100644 --- a/crates/apps/src/lib/cli/utils.rs +++ b/crates/apps/src/lib/cli/utils.rs @@ -157,9 +157,10 @@ pub const fn arg_multi(name: &'static str) -> ArgMulti { #[macro_export] macro_rules! wrap { ($text:literal) => { - textwrap_macros::fill!($text, 60) + textwrap_macros::fill!($text, 80) }; } + impl Arg { pub const fn opt(self) -> ArgOpt { ArgOpt { From 30bb889ae96429ca891244052e01758e16b155d4 Mon Sep 17 00:00:00 2001 From: brentstone Date: Thu, 16 May 2024 12:58:43 -0700 Subject: [PATCH 09/20] fixup! Merge branch 'grarco/tx-batch' (#3103) --- crates/apps/src/lib/bench_utils.rs | 2 +- .../lib/node/ledger/shell/finalize_block.rs | 100 ++++++++++-------- crates/namada/src/ledger/governance/mod.rs | 7 +- crates/namada/src/ledger/mod.rs | 1 + .../ethereum_bridge/bridge_pool_vp.rs | 2 +- .../ledger/native_vp/ethereum_bridge/nut.rs | 2 +- .../ledger/native_vp/ethereum_bridge/vp.rs | 2 +- crates/namada/src/ledger/native_vp/ibc/mod.rs | 2 +- crates/namada/src/ledger/native_vp/masp.rs | 2 +- crates/namada/src/ledger/native_vp/mod.rs | 2 +- .../namada/src/ledger/native_vp/multitoken.rs | 7 +- .../namada/src/ledger/native_vp/parameters.rs | 2 +- crates/namada/src/ledger/pgf/mod.rs | 4 +- crates/namada/src/ledger/pos/vp.rs | 2 +- crates/namada/src/ledger/protocol/mod.rs | 6 +- crates/namada/src/ledger/vp_host_fns.rs | 5 +- crates/namada/src/vm/host_env.rs | 2 +- crates/namada/src/vm/wasm/memory.rs | 2 +- crates/namada/src/vm/wasm/run.rs | 9 +- crates/sdk/src/rpc.rs | 2 +- crates/state/src/write_log.rs | 22 +++- crates/tx/src/data/mod.rs | 4 +- crates/tx/src/data/wrapper.rs | 2 +- crates/tx/src/types.rs | 18 +++- crates/vp_env/src/lib.rs | 4 +- crates/vp_prelude/src/lib.rs | 2 +- 26 files changed, 131 insertions(+), 84 deletions(-) diff --git a/crates/apps/src/lib/bench_utils.rs b/crates/apps/src/lib/bench_utils.rs index 029fc44537..e1d0f15d53 100644 --- a/crates/apps/src/lib/bench_utils.rs +++ b/crates/apps/src/lib/bench_utils.rs @@ -404,7 +404,7 @@ impl BenchShell { /// Execute the tx and return a set of verifiers inserted by the tx. pub fn execute_tx( &mut self, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, ) -> BTreeSet
{ let gas_meter = RefCell::new(TxGasMeter::new_from_sub_limit(u64::MAX.into())); diff --git a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs index 115eaaafd2..6072379a91 100644 --- a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -214,29 +214,27 @@ where continue; } - let (mut tx_event, tx_gas_meter, mut wrapper_args) = - match &tx_header.tx_type { - TxType::Wrapper(wrapper) => { - stats.increment_wrapper_txs(); - let tx_event = new_tx_event(&tx, height.0); - let gas_limit = match Gas::try_from(wrapper.gas_limit) { - Ok(value) => value, - Err(_) => { - response.events.emit( - new_tx_event(&tx, height.0) - .with(Code(ResultCode::InvalidTx)) - .with(Info( - "The wrapper gas limit overflowed \ - gas representation" - .to_owned(), - )) - .with(GasUsed(0.into())), - ); - continue; - } - }; - let gas_meter = TxGasMeter::new(gas_limit); - for cmt in tx.commitments() { + let (tx_gas_meter, mut wrapper_args) = match &tx_header.tx_type { + TxType::Wrapper(wrapper) => { + stats.increment_wrapper_txs(); + let gas_limit = match Gas::try_from(wrapper.gas_limit) { + Ok(value) => value, + Err(_) => { + response.events.emit( + new_tx_event(&tx, height.0) + .with(Code(ResultCode::InvalidTx)) + .with(Info( + "The wrapper gas limit overflowed gas \ + representation" + .to_owned(), + )) + .with(GasUsed(0.into())), + ); + continue; + } + }; + let gas_meter = TxGasMeter::new(gas_limit); + for cmt in tx.commitments() { if let Some(code_sec) = tx .get_section(cmt.code_sechash()) .and_then(|x| Section::code_sec(x.as_ref())) @@ -245,8 +243,8 @@ where code_sec.code.hash().to_string(), ); } - } } + ( gas_meter, Some(WrapperArgs { @@ -544,8 +542,8 @@ where namada::tx::data::TxResult, DispatchError, >, - tx_data: TxData, - mut tx_logs: TxLogs, + tx_data: TxData<'_>, + mut tx_logs: TxLogs<'_>, ) { // Check the commitment of the fee unshielding regardless of the // result, it could be committed even in case of errors @@ -628,8 +626,8 @@ where &mut self, response: &mut shim::response::FinalizeBlock, tx_result: namada::tx::data::TxResult, - tx_data: TxData, - tx_logs: &mut TxLogs, + tx_data: TxData<'_>, + tx_logs: &mut TxLogs<'_>, ) { let mut temp_log = TempTxLogs::new_from_tx_logs(tx_logs); @@ -646,8 +644,13 @@ where if tx_data.is_atomic_batch && is_any_tx_invalid { // Atomic batches need custom handling when even a single tx fails, // since we need to drop everything - let unrun_txs = tx_data.commitments_len - - tx_result.batch_results.0.len() as u64; + let unrun_txs = tx_data + .commitments_len + .checked_sub( + u64::try_from(tx_result.batch_results.0.len()) + .expect("Should be able to convert to u64"), + ) + .expect("Shouldn't underflow"); temp_log.stats.set_failing_atomic_batch(unrun_txs); temp_log.commit_stats_only(tx_logs); self.state.write_log_mut().drop_batch(); @@ -687,8 +690,8 @@ where response: &mut shim::response::FinalizeBlock, msg: &Error, tx_result: namada::tx::data::TxResult, - tx_data: TxData, - tx_logs: &mut TxLogs, + tx_data: TxData<'_>, + tx_logs: &mut TxLogs<'_>, ) { let mut temp_log = TempTxLogs::new_from_tx_logs(tx_logs); @@ -702,8 +705,13 @@ where tx_data.height, ); - let unrun_txs = - tx_data.commitments_len - tx_result.batch_results.0.len() as u64; + let unrun_txs = tx_data + .commitments_len + .checked_sub( + u64::try_from(tx_result.batch_results.0.len()) + .expect("Should be able to convert to u64"), + ) + .expect("Shouldn't underflow"); if tx_data.is_atomic_batch { tx_logs.stats.set_failing_atomic_batch(unrun_txs); @@ -735,7 +743,7 @@ where .extend(Batch(&tx_result.to_result_string())); } - fn handle_batch_error_reprot(&mut self, err: &Error, tx_data: TxData) { + fn handle_batch_error_reprot(&mut self, err: &Error, tx_data: TxData<'_>) { // If user transaction didn't fail because of out of gas nor // invalid section commitment, commit its hash to prevent // replays @@ -801,7 +809,7 @@ struct TempTxLogs { } impl TempTxLogs { - fn new_from_tx_logs(tx_logs: &TxLogs) -> Self { + fn new_from_tx_logs(tx_logs: &TxLogs<'_>) -> Self { Self { tx_event: Event::new( tx_logs.tx_event.kind().to_owned(), @@ -3095,7 +3103,7 @@ mod test_finalize_block { assert_eq!(*event[0].kind(), APPLIED_TX); let code = event[0].read_attribute::().expect("Test failed"); assert_eq!(code, ResultCode::Ok); - let inner_tx_result = event[0].read_attribute::().unwrap(); + let inner_tx_result = event[0].read_attribute::>().unwrap(); let first_tx_result = inner_tx_result .batch_results .0 @@ -3246,7 +3254,7 @@ mod test_finalize_block { assert_eq!(*event[1].kind(), APPLIED_TX); let code = event[1].read_attribute::().expect("Test failed"); assert_eq!(code, ResultCode::Ok); - let inner_tx_result = event[1].read_attribute::().unwrap(); + let inner_tx_result = event[1].read_attribute::>().unwrap(); let inner_result = inner_tx_result .batch_results .0 @@ -3256,7 +3264,7 @@ mod test_finalize_block { assert_eq!(*event[2].kind(), APPLIED_TX); let code = event[2].read_attribute::().expect("Test failed"); assert_eq!(code, ResultCode::Ok); - let inner_tx_result = event[2].read_attribute::().unwrap(); + let inner_tx_result = event[2].read_attribute::>().unwrap(); let inner_result = inner_tx_result .batch_results .0 @@ -3271,7 +3279,7 @@ mod test_finalize_block { assert_eq!(*event[3].kind(), APPLIED_TX); let code = event[3].read_attribute::().expect("Test failed"); assert_eq!(code, ResultCode::Ok); - let inner_tx_result = event[3].read_attribute::().unwrap(); + let inner_tx_result = event[3].read_attribute::>().unwrap(); let inner_result = inner_tx_result .batch_results .0 @@ -3476,7 +3484,7 @@ mod test_finalize_block { assert_eq!(*event.kind(), APPLIED_TX); let code = event.read_attribute::().expect("Test failed"); assert_eq!(code, ResultCode::Ok); - let inner_tx_result = event.read_attribute::().unwrap(); + let inner_tx_result = event.read_attribute::>().unwrap(); let inner_result = inner_tx_result .batch_results .0 @@ -5399,7 +5407,7 @@ mod test_finalize_block { let code = event[0].read_attribute::().unwrap(); assert_eq!(code, ResultCode::Ok); - let inner_tx_result = event[0].read_attribute::().unwrap(); + let inner_tx_result = event[0].read_attribute::>().unwrap(); let inner_results = inner_tx_result.batch_results.0; for cmt in batch.commitments() { @@ -5444,7 +5452,7 @@ mod test_finalize_block { let code = event[0].read_attribute::().unwrap(); assert_eq!(code, ResultCode::WasmRuntimeError); - let inner_tx_result = event[0].read_attribute::().unwrap(); + let inner_tx_result = event[0].read_attribute::>().unwrap(); let inner_results = inner_tx_result.batch_results.0; assert!( @@ -5494,7 +5502,7 @@ mod test_finalize_block { let code = event[0].read_attribute::().unwrap(); assert_eq!(code, ResultCode::Ok); - let inner_tx_result = event[0].read_attribute::().unwrap(); + let inner_tx_result = event[0].read_attribute::>().unwrap(); let inner_results = inner_tx_result.batch_results.0; assert!( @@ -5562,7 +5570,7 @@ mod test_finalize_block { let code = event[0].read_attribute::().unwrap(); assert_eq!(code, ResultCode::WasmRuntimeError); - let inner_tx_result = event[0].read_attribute::().unwrap(); + let inner_tx_result = event[0].read_attribute::>().unwrap(); let inner_results = inner_tx_result.batch_results.0; assert!( @@ -5611,7 +5619,7 @@ mod test_finalize_block { let code = event[0].read_attribute::().unwrap(); assert_eq!(code, ResultCode::WasmRuntimeError); - let inner_tx_result = event[0].read_attribute::().unwrap(); + let inner_tx_result = event[0].read_attribute::>().unwrap(); let inner_results = inner_tx_result.batch_results.0; assert!( diff --git a/crates/namada/src/ledger/governance/mod.rs b/crates/namada/src/ledger/governance/mod.rs index 563be01e72..5840f1a488 100644 --- a/crates/namada/src/ledger/governance/mod.rs +++ b/crates/namada/src/ledger/governance/mod.rs @@ -69,7 +69,7 @@ where fn validate_tx( &self, - tx_data: &BatchedTxRef, + tx_data: &BatchedTxRef<'_>, keys_changed: &BTreeSet, verifiers: &BTreeSet
, ) -> Result<()> { @@ -1119,7 +1119,10 @@ where } /// Validate a governance parameter - pub fn is_valid_parameter(&self, batched_tx: &BatchedTxRef) -> Result<()> { + pub fn is_valid_parameter( + &self, + batched_tx: &BatchedTxRef<'_>, + ) -> Result<()> { let BatchedTxRef { tx, cmt } = batched_tx; tx.data(cmt).map_or_else( || { diff --git a/crates/namada/src/ledger/mod.rs b/crates/namada/src/ledger/mod.rs index e412fb1d53..4556007637 100644 --- a/crates/namada/src/ledger/mod.rs +++ b/crates/namada/src/ledger/mod.rs @@ -23,6 +23,7 @@ pub use { mod dry_run_tx { use std::cell::RefCell; + use namada_gas::Gas; use namada_sdk::queries::{EncodedResponseQuery, RequestCtx, RequestQuery}; use namada_state::{DBIter, ResultExt, StorageHasher, DB}; use namada_tx::data::{GasLimit, TxResult}; diff --git a/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs b/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs index 86f1767291..897c096ea7 100644 --- a/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs +++ b/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs @@ -543,7 +543,7 @@ where fn validate_tx( &self, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, keys_changed: &BTreeSet, _verifiers: &BTreeSet
, ) -> Result<(), Error> { diff --git a/crates/namada/src/ledger/native_vp/ethereum_bridge/nut.rs b/crates/namada/src/ledger/native_vp/ethereum_bridge/nut.rs index a09fee2d50..e97a7cd92c 100644 --- a/crates/namada/src/ledger/native_vp/ethereum_bridge/nut.rs +++ b/crates/namada/src/ledger/native_vp/ethereum_bridge/nut.rs @@ -41,7 +41,7 @@ where fn validate_tx( &self, - _: &BatchedTxRef, + _: &BatchedTxRef<'_>, keys_changed: &BTreeSet, verifiers: &BTreeSet
, ) -> Result<(), Self::Error> { diff --git a/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs b/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs index 060422d3da..e9d9592331 100644 --- a/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs +++ b/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs @@ -93,7 +93,7 @@ where /// no wasm transactions should be able to modify those keys. fn validate_tx( &self, - _: &BatchedTxRef, + _: &BatchedTxRef<'_>, keys_changed: &BTreeSet, verifiers: &BTreeSet
, ) -> Result<(), Self::Error> { diff --git a/crates/namada/src/ledger/native_vp/ibc/mod.rs b/crates/namada/src/ledger/native_vp/ibc/mod.rs index 6e0547feeb..a0e1f41bbd 100644 --- a/crates/namada/src/ledger/native_vp/ibc/mod.rs +++ b/crates/namada/src/ledger/native_vp/ibc/mod.rs @@ -79,7 +79,7 @@ where fn validate_tx( &self, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, keys_changed: &BTreeSet, _verifiers: &BTreeSet
, ) -> VpResult<()> { diff --git a/crates/namada/src/ledger/native_vp/masp.rs b/crates/namada/src/ledger/native_vp/masp.rs index 4d24b6f8c8..0cd8d16304 100644 --- a/crates/namada/src/ledger/native_vp/masp.rs +++ b/crates/namada/src/ledger/native_vp/masp.rs @@ -387,7 +387,7 @@ where fn validate_tx( &self, - tx_data: &BatchedTxRef, + tx_data: &BatchedTxRef<'_>, keys_changed: &BTreeSet, _verifiers: &BTreeSet
, ) -> Result<()> { diff --git a/crates/namada/src/ledger/native_vp/mod.rs b/crates/namada/src/ledger/native_vp/mod.rs index 9257ef8b74..e03f187de9 100644 --- a/crates/namada/src/ledger/native_vp/mod.rs +++ b/crates/namada/src/ledger/native_vp/mod.rs @@ -43,7 +43,7 @@ pub trait NativeVp { /// Run the validity predicate fn validate_tx( &self, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, keys_changed: &BTreeSet, verifiers: &BTreeSet
, ) -> std::result::Result<(), Self::Error>; diff --git a/crates/namada/src/ledger/native_vp/multitoken.rs b/crates/namada/src/ledger/native_vp/multitoken.rs index fc08affb15..e8f130d437 100644 --- a/crates/namada/src/ledger/native_vp/multitoken.rs +++ b/crates/namada/src/ledger/native_vp/multitoken.rs @@ -51,7 +51,7 @@ where fn validate_tx( &self, - tx_data: &BatchedTxRef, + tx_data: &BatchedTxRef<'_>, keys_changed: &BTreeSet, verifiers: &BTreeSet
, ) -> Result<()> { @@ -280,7 +280,10 @@ where } /// Return if the parameter change was done via a governance proposal - pub fn is_valid_parameter(&self, batched_tx: &BatchedTxRef) -> Result<()> { + pub fn is_valid_parameter( + &self, + batched_tx: &BatchedTxRef<'_>, + ) -> Result<()> { batched_tx.tx.data(batched_tx.cmt).map_or_else( || { Err(native_vp::Error::new_const( diff --git a/crates/namada/src/ledger/native_vp/parameters.rs b/crates/namada/src/ledger/native_vp/parameters.rs index 4747f4e236..1529e7ca3f 100644 --- a/crates/namada/src/ledger/native_vp/parameters.rs +++ b/crates/namada/src/ledger/native_vp/parameters.rs @@ -41,7 +41,7 @@ where fn validate_tx( &self, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, keys_changed: &BTreeSet, _verifiers: &BTreeSet
, ) -> Result<()> { diff --git a/crates/namada/src/ledger/pgf/mod.rs b/crates/namada/src/ledger/pgf/mod.rs index 9b268f0a2f..4c29c13b3b 100644 --- a/crates/namada/src/ledger/pgf/mod.rs +++ b/crates/namada/src/ledger/pgf/mod.rs @@ -52,7 +52,7 @@ where fn validate_tx( &self, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, keys_changed: &BTreeSet, verifiers: &BTreeSet
, ) -> Result<()> { @@ -202,7 +202,7 @@ where /// Validate a governance parameter pub fn is_valid_parameter_change( &self, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, ) -> Result<()> { batched_tx.tx.data(batched_tx.cmt).map_or_else( || { diff --git a/crates/namada/src/ledger/pos/vp.rs b/crates/namada/src/ledger/pos/vp.rs index a088676370..5090636058 100644 --- a/crates/namada/src/ledger/pos/vp.rs +++ b/crates/namada/src/ledger/pos/vp.rs @@ -55,7 +55,7 @@ where fn validate_tx( &self, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, keys_changed: &BTreeSet, verifiers: &BTreeSet
, ) -> Result<()> { diff --git a/crates/namada/src/ledger/protocol/mod.rs b/crates/namada/src/ledger/protocol/mod.rs index 8f300f6dc1..0fd4ede9f7 100644 --- a/crates/namada/src/ledger/protocol/mod.rs +++ b/crates/namada/src/ledger/protocol/mod.rs @@ -817,7 +817,7 @@ where /// Apply a transaction going via the wasm environment. Gas will be metered and /// validity predicates will be triggered in the normal way. pub fn apply_wasm_tx<'a, S, D, H, CA>( - batched_tx: BatchedTxRef, + batched_tx: BatchedTxRef<'_>, tx_index: &TxIndex, shell_params: ShellParams<'a, S, D, H, CA>, ) -> Result @@ -939,7 +939,7 @@ where /// Execute a transaction code. Returns verifiers requested by the transaction. #[allow(clippy::too_many_arguments)] fn execute_tx( - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, tx_index: &TxIndex, state: &mut S, tx_gas_meter: &RefCell, @@ -1024,7 +1024,7 @@ where fn execute_vps( verifiers: BTreeSet
, keys_changed: BTreeSet, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, tx_index: &TxIndex, state: &S, tx_gas_meter: &TxGasMeter, diff --git a/crates/namada/src/ledger/vp_host_fns.rs b/crates/namada/src/ledger/vp_host_fns.rs index a207309d21..37c2e3c05c 100644 --- a/crates/namada/src/ledger/vp_host_fns.rs +++ b/crates/namada/src/ledger/vp_host_fns.rs @@ -261,7 +261,7 @@ where /// current transaction is being applied. pub fn get_tx_code_hash( gas_meter: &RefCell, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, ) -> EnvResult> { add_gas( gas_meter, @@ -269,7 +269,8 @@ pub fn get_tx_code_hash( .checked_mul(MEMORY_ACCESS_GAS_PER_BYTE) .expect("Consts mul that cannot overflow"), )?; - let hash = batched_tx.tx + let hash = batched_tx + .tx .get_section(batched_tx.cmt.code_sechash()) .and_then(|x| Section::code_sec(x.as_ref())) .map(|x| x.code.hash()); diff --git a/crates/namada/src/vm/host_env.rs b/crates/namada/src/vm/host_env.rs index 5dc5c2c679..c0cda09388 100644 --- a/crates/namada/src/vm/host_env.rs +++ b/crates/namada/src/vm/host_env.rs @@ -389,7 +389,7 @@ pub trait VpEvaluator { &self, ctx: VpCtx<'static, Self::Db, Self::H, Self::Eval, Self::CA>, vp_code_hash: Hash, - input_data: BatchedTxRef, + input_data: BatchedTxRef<'_>, ) -> HostEnvResult; } diff --git a/crates/namada/src/vm/wasm/memory.rs b/crates/namada/src/vm/wasm/memory.rs index 9359c8d7c1..451301ec9b 100644 --- a/crates/namada/src/vm/wasm/memory.rs +++ b/crates/namada/src/vm/wasm/memory.rs @@ -90,7 +90,7 @@ pub struct TxCallInput { /// Write transaction inputs into wasm memory pub fn write_tx_inputs( memory: &wasmer::Memory, - tx_data: &BatchedTxRef, + tx_data: &BatchedTxRef<'_>, ) -> Result { let tx_data_ptr = 0; let tx_data_bytes = tx_data.serialize_to_vec(); diff --git a/crates/namada/src/vm/wasm/run.rs b/crates/namada/src/vm/wasm/run.rs index a80ac954b6..168529a5b3 100644 --- a/crates/namada/src/vm/wasm/run.rs +++ b/crates/namada/src/vm/wasm/run.rs @@ -107,7 +107,10 @@ pub type Result = std::result::Result; /// Returns [`Error::DisallowedTx`] when the given tx is a user tx and its code /// `Hash` is not included in the `tx_allowlist` parameter. -pub fn check_tx_allowed(batched_tx: &BatchedTxRef, storage: &S) -> Result<()> +pub fn check_tx_allowed( + batched_tx: &BatchedTxRef<'_>, + storage: &S, +) -> Result<()> where S: StorageRead, { @@ -282,7 +285,7 @@ where #[allow(clippy::too_many_arguments)] pub fn vp( vp_code_hash: Hash, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, tx_index: &TxIndex, address: &Address, state: &S, @@ -353,7 +356,7 @@ fn run_vp( module: wasmer::Module, vp_imports: wasmer::ImportObject, vp_code_hash: &Hash, - input_data: &BatchedTxRef, + input_data: &BatchedTxRef<'_>, address: &Address, keys_changed: &BTreeSet, verifiers: &BTreeSet
, diff --git a/crates/sdk/src/rpc.rs b/crates/sdk/src/rpc.rs index e63fad1c19..736374ee48 100644 --- a/crates/sdk/src/rpc.rs +++ b/crates/sdk/src/rpc.rs @@ -620,7 +620,7 @@ impl TryFrom for TxResponse { type Error = String; fn try_from(event: Event) -> Result { - let batch = event.read_attribute::().ok(); + let batch = event.read_attribute::>().ok(); let hash = event .read_attribute::() .map_err(|err| err.to_string())?; diff --git a/crates/state/src/write_log.rs b/crates/state/src/write_log.rs index e6af3696f1..82929e02f4 100644 --- a/crates/state/src/write_log.rs +++ b/crates/state/src/write_log.rs @@ -238,7 +238,8 @@ impl WriteLog { pub fn read_pre( &self, key: &storage::Key, - ) -> std::result::Result<((Option<&StorageModification>, u64), arith::Error> { + ) -> std::result::Result<(Option<&StorageModification>, u64), arith::Error> + { for bucket in self .batch_write_log .iter() @@ -256,7 +257,10 @@ impl WriteLog { checked!(key.len() + vp_code_hash.len())? } } as u64; - return Ok((Some(v), checked!(gas * MEMORY_ACCESS_GAS_PER_BYTE)?)); + return Ok(( + Some(v), + checked!(gas * MEMORY_ACCESS_GAS_PER_BYTE)?, + )); } } let gas = key.len() as u64; @@ -295,7 +299,6 @@ impl WriteLog { value: Vec, ) -> Result<(u64, i64)> { let len = value.len(); - let gas = key.len() + len; if self.tx_write_log.tx_temp_log.contains_key(key) { return Err(Error::UpdateTemporaryValue); } @@ -512,9 +515,17 @@ impl WriteLog { if gas_cost.as_ref().is_some() { let event_type = event.kind().to_string(); if !self.tx_write_log.events.tree.contains_key(&event_type) { - self.tx_write_log.events.tree.insert(&event_type, HashSet::new()); + self.tx_write_log + .events + .tree + .insert(&event_type, HashSet::new()); } - self.tx_write_log.events.tree.get_mut(&event_type).unwrap().insert(event); + self.tx_write_log + .events + .tree + .get_mut(&event_type) + .unwrap() + .insert(event); } gas_cost } @@ -681,6 +692,7 @@ impl WriteLog { self.batch_write_log = Default::default(); } + /// Commit the tx write log to the block write log. pub fn commit_tx(&mut self) { // First precommit everything self.precommit_tx(); diff --git a/crates/tx/src/data/mod.rs b/crates/tx/src/data/mod.rs index 939f08381b..0525ccf0db 100644 --- a/crates/tx/src/data/mod.rs +++ b/crates/tx/src/data/mod.rs @@ -163,6 +163,7 @@ pub fn hash_tx(tx_bytes: &[u8]) -> Hash { Hash(*digest.as_ref()) } +/// The set of inner tx results indexed by the inner tx hash // The generic is only used to return typed errors in protocol for error // management with regards to replay protection, whereas for logging we use // strings @@ -207,7 +208,7 @@ where { type Value = BatchResults; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("BatchResult") } @@ -263,6 +264,7 @@ impl Default for TxResult { } impl TxResult { + /// Convert the batched result to a string pub fn to_result_string(self) -> TxResult { let mut batch_results: BTreeMap> = BTreeMap::new(); diff --git a/crates/tx/src/data/wrapper.rs b/crates/tx/src/data/wrapper.rs index 700728e2df..97d7a24566 100644 --- a/crates/tx/src/data/wrapper.rs +++ b/crates/tx/src/data/wrapper.rs @@ -146,7 +146,7 @@ impl TryFrom for Gas { BorshSchema, Serialize, Deserialize, - PartialEq + PartialEq, )] pub struct WrapperTx { /// The fee to be paid for including the tx diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index 28f20e4e3c..e559c90a30 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -935,6 +935,7 @@ impl TxCommitments { &self.memo_hash } + /// Hash the commitments to the transaction's sections pub fn hash<'a>(&self, hasher: &'a mut Sha256) -> &'a mut Sha256 { hasher.update(self.serialize_to_vec()); hasher @@ -1691,26 +1692,31 @@ impl Tx { self } + /// Get the references to the inner transactions pub fn commitments(&self) -> &HashSet { &self.header.batch } + /// Get the reference to the first inner transaction pub fn first_commitments(&self) -> Option<&TxCommitments> { self.header.batch.first() } + /// Creates a batched tx from one or more inner transactions pub fn batch_tx(self, cmt: TxCommitments) -> BatchedTx { BatchedTx { tx: self, cmt } } + /// Creates a batched tx along with the reference to the first inner tx #[cfg(any(test, feature = "testing"))] - pub fn batch_ref_first_tx(&self) -> BatchedTxRef { + pub fn batch_ref_first_tx(&self) -> BatchedTxRef<'_> { BatchedTxRef { tx: self, cmt: self.first_commitments().unwrap(), } } + /// Creates a batched tx along with a copy of the first inner tx #[cfg(any(test, feature = "testing"))] pub fn batch_first_tx(self) -> BatchedTx { let cmt = self.first_commitments().unwrap().to_owned(); @@ -1719,6 +1725,7 @@ impl Tx { } impl<'tx> Tx { + /// Creates a batched tx along with the reference to one or more inner txs pub fn batch_ref_tx( &'tx self, cmt: &'tx TxCommitments, @@ -1742,7 +1749,9 @@ impl<'tx> Tx { Hash, )] pub enum IndexedTxType { + /// Wrapper (outer) tx Wrapper, + /// Inner tx with commitment Inner(TxCommitments), } @@ -1784,7 +1793,9 @@ impl Default for IndexedTx { /// transaction of the batch #[derive(Debug, BorshSerialize)] pub struct BatchedTxRef<'tx> { + /// The transaction pub tx: &'tx Tx, + /// The reference to the inner transaction pub cmt: &'tx TxCommitments, } @@ -1794,12 +1805,15 @@ pub struct BatchedTxRef<'tx> { Debug, Clone, Serialize, Deserialize, BorshSerialize, BorshDeserialize, )] pub struct BatchedTx { + /// The transaction pub tx: Tx, + /// The reference to the inner transaction pub cmt: TxCommitments, } impl BatchedTx { - pub fn to_ref(&self) -> BatchedTxRef { + /// Convert owned version to a referenced one + pub fn to_ref(&self) -> BatchedTxRef<'_> { BatchedTxRef { tx: &self.tx, cmt: &self.cmt, diff --git a/crates/vp_env/src/lib.rs b/crates/vp_env/src/lib.rs index 9b1e87147c..b3115443dc 100644 --- a/crates/vp_env/src/lib.rs +++ b/crates/vp_env/src/lib.rs @@ -117,7 +117,7 @@ where fn eval( &self, vp_code: Hash, - input_data: BatchedTxRef, + input_data: BatchedTxRef<'_>, ) -> Result<(), namada_storage::Error>; /// Get a tx hash @@ -126,7 +126,7 @@ where /// Get the masp tx part of the shielded action fn get_shielded_action( &self, - batched_tx: &BatchedTxRef, + batched_tx: &BatchedTxRef<'_>, ) -> Result { let data = batched_tx .tx diff --git a/crates/vp_prelude/src/lib.rs b/crates/vp_prelude/src/lib.rs index c75b792a23..80dada3f19 100644 --- a/crates/vp_prelude/src/lib.rs +++ b/crates/vp_prelude/src/lib.rs @@ -367,7 +367,7 @@ impl<'view> VpEnv<'view> for Ctx { fn eval( &self, vp_code_hash: Hash, - input_data: BatchedTxRef, + input_data: BatchedTxRef<'_>, ) -> Result<(), StorageError> { let input_data_bytes = input_data.serialize_to_vec(); From 1dfa217f823d3959a56b9108f2fc15a3a76d7514 Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Fri, 17 May 2024 11:47:30 +0200 Subject: [PATCH 10/20] fixup! Merge branch 'grarco/tx-batch' (#3103) --- crates/sdk/src/rpc.rs | 3 ++- crates/tx/src/data/mod.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/sdk/src/rpc.rs b/crates/sdk/src/rpc.rs index 736374ee48..a03ec02ba9 100644 --- a/crates/sdk/src/rpc.rs +++ b/crates/sdk/src/rpc.rs @@ -606,7 +606,8 @@ pub struct TxResponse { pub gas_used: Gas, } -/// Determines a result of an inner tx from [`TxResponse::inner_tx_result`]. +/// Determines a result of an inner tx from +/// [`namada_tx::data::BatchedTxResult`]. pub enum InnerTxResult<'a> { /// Tx is applied and accepted by all VPs Success(&'a BatchedTxResult), diff --git a/crates/tx/src/data/mod.rs b/crates/tx/src/data/mod.rs index 0525ccf0db..22dae316cc 100644 --- a/crates/tx/src/data/mod.rs +++ b/crates/tx/src/data/mod.rs @@ -249,7 +249,7 @@ pub struct TxResult { /// Storage keys touched by the wrapper transaction pub wrapper_changed_keys: BTreeSet, /// The results of the batch, indexed by the hash of the specific - /// [`Commitments`] + /// [`crate::types::TxCommitments`] pub batch_results: BatchResults, } From b0321a51246b6558450d670c07e9315275a76ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 20 May 2024 16:30:51 +0200 Subject: [PATCH 11/20] fixup! Merge branch 'grarco/masp-fees' (#3217) --- .github/workflows/scripts/hermes.txt | 2 +- crates/tests/src/e2e/ibc_tests.rs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts/hermes.txt b/.github/workflows/scripts/hermes.txt index 03726c5ea5..7588db229e 100644 --- a/.github/workflows/scripts/hermes.txt +++ b/.github/workflows/scripts/hermes.txt @@ -1 +1 @@ -1.7.4-namada-beta9-rc2 +1.8.2-namada-beta10-rc diff --git a/crates/tests/src/e2e/ibc_tests.rs b/crates/tests/src/e2e/ibc_tests.rs index eef22981e2..0346366a68 100644 --- a/crates/tests/src/e2e/ibc_tests.rs +++ b/crates/tests/src/e2e/ibc_tests.rs @@ -747,7 +747,9 @@ fn ibc_rate_limit() -> Result<()> { &channel_id_a, None, // expect an error of the throughput limit - Some("Transaction was rejected by VPs"), + Some( + "Transfer exceeding the per-epoch throughput limit is not allowed", + ), false, )?; @@ -1017,10 +1019,15 @@ fn wait_for_packet_relay( // Check no pending packet if hermes .exp_string( - "\"dst\":{\"unreceived_acks\":[],\"unreceived_packets\":[]},\"\ - src\":{\"unreceived_acks\":[],\"unreceived_packets\":[]}", + "\"dst\":{\"unreceived_acks\":[],\"unreceived_packets\":[]},", ) .is_ok() + && hermes + .exp_string( + "\"src\":{\"unreceived_acks\":[],\"unreceived_packets\":\ + []}", + ) + .is_ok() { return Ok(()); } From 7eb526d1b9a703a34e12bf0216133e928e8dc0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 16 May 2024 14:05:42 +0200 Subject: [PATCH 12/20] apps_lib: add a new crate for apps lib crate --- Cargo.toml | 1 + Makefile | 1 + crates/apps_lib/Cargo.toml | 135 +++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 crates/apps_lib/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index 492d2b68a6..c4044ab281 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ resolver = "2" members = [ "crates/account", "crates/apps", + "crates/apps_lib", "crates/benches", "crates/controller", "crates/core", diff --git a/Makefile b/Makefile index 6deb843a3b..9df1a9d282 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,7 @@ audit-ignores += RUSTSEC-2021-0076 crates := namada crates += namada_account crates += namada_apps +crates += namada_apps_lib crates += namada_benchmarks crates += namada_core crates += namada_encoding_spec diff --git a/crates/apps_lib/Cargo.toml b/crates/apps_lib/Cargo.toml new file mode 100644 index 0000000000..244158eb86 --- /dev/null +++ b/crates/apps_lib/Cargo.toml @@ -0,0 +1,135 @@ +[package] +name = "namada_apps_lib" +description = "Namada CLI apps library code" +resolver = "2" +authors.workspace = true +edition.workspace = true +documentation.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +version.workspace = true + +[features] +default = ["migrations"] +mainnet = [ + "namada/mainnet", +] +# for integration tests and test utilities +testing = ["namada_test_utils"] +benches = ["namada_test_utils"] +integration = [] +jemalloc = ["rocksdb/jemalloc"] +migrations = [ + "namada_migrations", + "namada_sdk/migrations", + "namada/migrations", + "linkme", +] +namada-eth-bridge = [ + "namada/namada-eth-bridge", + "namada_sdk/namada-eth-bridge", +] + +[dependencies] +namada = {path = "../namada", features = ["multicore", "http-client", "tendermint-rpc", "std"]} +namada_macros = {path = "../macros"} +namada_migrations = {path = "../migrations", optional = true} +namada_sdk = {path = "../sdk", default-features = false, features = ["wasm-runtime", "download-params", "std", "rand"]} +namada_test_utils = {path = "../test_utils", optional = true} + +ark-serialize.workspace = true +ark-std.workspace = true +arse-merkle-tree = { workspace = true, features = ["blake2b"] } +assert_matches.workspace = true +async-trait.workspace = true +base64.workspace = true +bech32.workspace = true +bimap.workspace = true +blake2b-rs.workspace = true +borsh.workspace = true +borsh-ext.workspace = true +byte-unit.workspace = true +byteorder.workspace = true +clap.workspace = true +color-eyre.workspace = true +config.workspace = true +data-encoding.workspace = true +derivative.workspace = true +directories.workspace = true +drain_filter_polyfill.workspace = true +ed25519-consensus = { workspace = true, features = ["std"] } +ethabi.workspace = true +ethbridge-bridge-events.workspace = true +ethbridge-events.workspace = true +eyre.workspace = true +fd-lock.workspace = true +flate2.workspace = true +futures.workspace = true +itertools.workspace = true +lazy_static.workspace= true +ledger-namada-rs.workspace = true +ledger-transport-hid.workspace = true +libc.workspace = true +libloading.workspace = true +linkme = { workspace = true, optional = true } +masp_primitives = { workspace = true, features = ["transparent-inputs"] } +masp_proofs = { workspace = true, features = ["bundled-prover", "download-params"] } +num_cpus.workspace = true +num256.workspace = true +num-rational.workspace = true +num-traits.workspace = true +once_cell.workspace = true +orion.workspace = true +pretty_assertions.workspace = true +prost-types.workspace = true +prost.workspace = true +rand_core = { workspace = true, features = ["std"] } +rand = { workspace = true, features = ["std"] } +rayon.workspace = true +regex.workspace = true +reqwest.workspace = true +ripemd.workspace = true +rlimit.workspace = true +rocksdb.workspace = true +rpassword.workspace = true +serde_bytes.workspace = true +serde_json = {workspace = true, features = ["raw_value"]} +serde.workspace = true +sha2.workspace = true +signal-hook.workspace = true +smooth-operator.workspace = true +sysinfo.workspace = true +tar.workspace = true +tempfile.workspace = true +tendermint-config.workspace = true +tendermint-rpc.workspace = true +textwrap-macros = "0.3.0" +thiserror.workspace = true +tokio = {workspace = true, features = ["full"]} +toml.workspace = true +tonic.workspace = true +tower-abci.workspace = true +tower.workspace = true +tracing-appender.workspace = true +tracing-log.workspace = true +tracing-subscriber = { workspace = true, features = ["std", "json", "ansi", "tracing-log"]} +tracing.workspace = true +winapi.workspace = true +zeroize.workspace = true +warp = "0.3.2" +bytes = "1.1.0" + +[dev-dependencies] +assert_matches = "1.5.0" +namada = {path = "../namada", default-features = false, features = ["testing", "wasm-runtime"]} +namada_test_utils = {path = "../test_utils"} +bit-set.workspace = true +proptest.workspace = true +test-log.workspace = true +tokio-test.workspace = true + +[build-dependencies] +git2.workspace = true From 36957713eb6ccd33b578d454fc94eec79c27fbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 16 May 2024 14:07:22 +0200 Subject: [PATCH 13/20] `mv crates/apps/src/lib crates/apps_lib/src` --- crates/{apps/src/lib => apps_lib/src}/bench_utils.rs | 0 crates/{apps/src/lib => apps_lib/src}/cli.rs | 0 crates/{apps/src/lib => apps_lib/src}/cli/api.rs | 0 crates/{apps/src/lib => apps_lib/src}/cli/client.rs | 0 crates/{apps/src/lib => apps_lib/src}/cli/context.rs | 0 crates/{apps/src/lib => apps_lib/src}/cli/relayer.rs | 0 crates/{apps/src/lib => apps_lib/src}/cli/utils.rs | 0 crates/{apps/src/lib => apps_lib/src}/cli/wallet.rs | 0 crates/{apps/src/lib => apps_lib/src}/client/masp.rs | 0 crates/{apps/src/lib => apps_lib/src}/client/mod.rs | 0 crates/{apps/src/lib => apps_lib/src}/client/rpc.rs | 0 crates/{apps/src/lib => apps_lib/src}/client/tx.rs | 0 crates/{apps/src/lib => apps_lib/src}/client/utils.rs | 0 .../src/lib => apps_lib/src}/config/ethereum_bridge/ledger.rs | 0 .../{apps/src/lib => apps_lib/src}/config/ethereum_bridge/mod.rs | 0 crates/{apps/src/lib => apps_lib/src}/config/genesis.rs | 0 crates/{apps/src/lib => apps_lib/src}/config/genesis/chain.rs | 0 crates/{apps/src/lib => apps_lib/src}/config/genesis/templates.rs | 0 .../{apps/src/lib => apps_lib/src}/config/genesis/transactions.rs | 0 crates/{apps/src/lib => apps_lib/src}/config/genesis/utils.rs | 0 crates/{apps/src/lib => apps_lib/src}/config/global.rs | 0 crates/{apps/src/lib => apps_lib/src}/config/mod.rs | 0 crates/{apps/src/lib => apps_lib/src}/config/utils.rs | 0 crates/{apps/src/lib => apps_lib/src}/logging.rs | 0 crates/{apps/src/lib => apps_lib/src}/mod.rs | 0 crates/{apps/src/lib => apps_lib/src}/node/ledger/abortable.rs | 0 crates/{apps/src/lib => apps_lib/src}/node/ledger/broadcaster.rs | 0 .../lib => apps_lib/src}/node/ledger/ethereum_oracle/control.rs | 0 .../lib => apps_lib/src}/node/ledger/ethereum_oracle/events.rs | 0 .../src/lib => apps_lib/src}/node/ledger/ethereum_oracle/mod.rs | 0 .../node/ledger/ethereum_oracle/test_tools/events_endpoint.rs | 0 .../src}/node/ledger/ethereum_oracle/test_tools/mod.rs | 0 crates/{apps/src/lib => apps_lib/src}/node/ledger/mod.rs | 0 .../src/lib => apps_lib/src}/node/ledger/shell/block_alloc.rs | 0 .../lib => apps_lib/src}/node/ledger/shell/block_alloc/states.rs | 0 .../src}/node/ledger/shell/block_alloc/states/normal_txs.rs | 0 .../src}/node/ledger/shell/block_alloc/states/protocol_txs.rs | 0 .../src/lib => apps_lib/src}/node/ledger/shell/finalize_block.rs | 0 .../src/lib => apps_lib/src}/node/ledger/shell/governance.rs | 0 .../src/lib => apps_lib/src}/node/ledger/shell/init_chain.rs | 0 crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/mod.rs | 0 .../lib => apps_lib/src}/node/ledger/shell/prepare_proposal.rs | 0 .../lib => apps_lib/src}/node/ledger/shell/process_proposal.rs | 0 .../{apps/src/lib => apps_lib/src}/node/ledger/shell/queries.rs | 0 crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/stats.rs | 0 .../src/lib => apps_lib/src}/node/ledger/shell/testing/client.rs | 0 .../src/lib => apps_lib/src}/node/ledger/shell/testing/mod.rs | 0 .../src/lib => apps_lib/src}/node/ledger/shell/testing/node.rs | 0 .../src/lib => apps_lib/src}/node/ledger/shell/testing/utils.rs | 0 crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/utils.rs | 0 .../src/lib => apps_lib/src}/node/ledger/shell/vote_extensions.rs | 0 .../src}/node/ledger/shell/vote_extensions/bridge_pool_vext.rs | 0 .../src}/node/ledger/shell/vote_extensions/eth_events.rs | 0 .../src}/node/ledger/shell/vote_extensions/val_set_update.rs | 0 .../src/lib => apps_lib/src}/node/ledger/shims/abcipp_shim.rs | 0 .../lib => apps_lib/src}/node/ledger/shims/abcipp_shim_types.rs | 0 crates/{apps/src/lib => apps_lib/src}/node/ledger/shims/mod.rs | 0 crates/{apps/src/lib => apps_lib/src}/node/ledger/storage/mod.rs | 0 .../{apps/src/lib => apps_lib/src}/node/ledger/storage/rocksdb.rs | 0 .../{apps/src/lib => apps_lib/src}/node/ledger/tendermint_node.rs | 0 crates/{apps/src/lib => apps_lib/src}/node/mod.rs | 0 crates/{apps/src/lib => apps_lib/src}/wallet/defaults.rs | 0 crates/{apps/src/lib => apps_lib/src}/wallet/mod.rs | 0 crates/{apps/src/lib => apps_lib/src}/wallet/pre_genesis.rs | 0 crates/{apps/src/lib => apps_lib/src}/wallet/store.rs | 0 crates/{apps/src/lib => apps_lib/src}/wasm_loader/mod.rs | 0 66 files changed, 0 insertions(+), 0 deletions(-) rename crates/{apps/src/lib => apps_lib/src}/bench_utils.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/cli.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/cli/api.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/cli/client.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/cli/context.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/cli/relayer.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/cli/utils.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/cli/wallet.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/client/masp.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/client/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/client/rpc.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/client/tx.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/client/utils.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/config/ethereum_bridge/ledger.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/config/ethereum_bridge/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/config/genesis.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/config/genesis/chain.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/config/genesis/templates.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/config/genesis/transactions.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/config/genesis/utils.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/config/global.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/config/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/config/utils.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/logging.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/abortable.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/broadcaster.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/ethereum_oracle/control.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/ethereum_oracle/events.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/ethereum_oracle/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/ethereum_oracle/test_tools/events_endpoint.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/ethereum_oracle/test_tools/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/block_alloc.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/block_alloc/states.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/block_alloc/states/normal_txs.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/block_alloc/states/protocol_txs.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/finalize_block.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/governance.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/init_chain.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/prepare_proposal.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/process_proposal.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/queries.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/stats.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/testing/client.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/testing/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/testing/node.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/testing/utils.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/utils.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/vote_extensions.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/vote_extensions/bridge_pool_vext.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/vote_extensions/eth_events.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shell/vote_extensions/val_set_update.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shims/abcipp_shim.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shims/abcipp_shim_types.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/shims/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/storage/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/storage/rocksdb.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/ledger/tendermint_node.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/node/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/wallet/defaults.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/wallet/mod.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/wallet/pre_genesis.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/wallet/store.rs (100%) rename crates/{apps/src/lib => apps_lib/src}/wasm_loader/mod.rs (100%) diff --git a/crates/apps/src/lib/bench_utils.rs b/crates/apps_lib/src/bench_utils.rs similarity index 100% rename from crates/apps/src/lib/bench_utils.rs rename to crates/apps_lib/src/bench_utils.rs diff --git a/crates/apps/src/lib/cli.rs b/crates/apps_lib/src/cli.rs similarity index 100% rename from crates/apps/src/lib/cli.rs rename to crates/apps_lib/src/cli.rs diff --git a/crates/apps/src/lib/cli/api.rs b/crates/apps_lib/src/cli/api.rs similarity index 100% rename from crates/apps/src/lib/cli/api.rs rename to crates/apps_lib/src/cli/api.rs diff --git a/crates/apps/src/lib/cli/client.rs b/crates/apps_lib/src/cli/client.rs similarity index 100% rename from crates/apps/src/lib/cli/client.rs rename to crates/apps_lib/src/cli/client.rs diff --git a/crates/apps/src/lib/cli/context.rs b/crates/apps_lib/src/cli/context.rs similarity index 100% rename from crates/apps/src/lib/cli/context.rs rename to crates/apps_lib/src/cli/context.rs diff --git a/crates/apps/src/lib/cli/relayer.rs b/crates/apps_lib/src/cli/relayer.rs similarity index 100% rename from crates/apps/src/lib/cli/relayer.rs rename to crates/apps_lib/src/cli/relayer.rs diff --git a/crates/apps/src/lib/cli/utils.rs b/crates/apps_lib/src/cli/utils.rs similarity index 100% rename from crates/apps/src/lib/cli/utils.rs rename to crates/apps_lib/src/cli/utils.rs diff --git a/crates/apps/src/lib/cli/wallet.rs b/crates/apps_lib/src/cli/wallet.rs similarity index 100% rename from crates/apps/src/lib/cli/wallet.rs rename to crates/apps_lib/src/cli/wallet.rs diff --git a/crates/apps/src/lib/client/masp.rs b/crates/apps_lib/src/client/masp.rs similarity index 100% rename from crates/apps/src/lib/client/masp.rs rename to crates/apps_lib/src/client/masp.rs diff --git a/crates/apps/src/lib/client/mod.rs b/crates/apps_lib/src/client/mod.rs similarity index 100% rename from crates/apps/src/lib/client/mod.rs rename to crates/apps_lib/src/client/mod.rs diff --git a/crates/apps/src/lib/client/rpc.rs b/crates/apps_lib/src/client/rpc.rs similarity index 100% rename from crates/apps/src/lib/client/rpc.rs rename to crates/apps_lib/src/client/rpc.rs diff --git a/crates/apps/src/lib/client/tx.rs b/crates/apps_lib/src/client/tx.rs similarity index 100% rename from crates/apps/src/lib/client/tx.rs rename to crates/apps_lib/src/client/tx.rs diff --git a/crates/apps/src/lib/client/utils.rs b/crates/apps_lib/src/client/utils.rs similarity index 100% rename from crates/apps/src/lib/client/utils.rs rename to crates/apps_lib/src/client/utils.rs diff --git a/crates/apps/src/lib/config/ethereum_bridge/ledger.rs b/crates/apps_lib/src/config/ethereum_bridge/ledger.rs similarity index 100% rename from crates/apps/src/lib/config/ethereum_bridge/ledger.rs rename to crates/apps_lib/src/config/ethereum_bridge/ledger.rs diff --git a/crates/apps/src/lib/config/ethereum_bridge/mod.rs b/crates/apps_lib/src/config/ethereum_bridge/mod.rs similarity index 100% rename from crates/apps/src/lib/config/ethereum_bridge/mod.rs rename to crates/apps_lib/src/config/ethereum_bridge/mod.rs diff --git a/crates/apps/src/lib/config/genesis.rs b/crates/apps_lib/src/config/genesis.rs similarity index 100% rename from crates/apps/src/lib/config/genesis.rs rename to crates/apps_lib/src/config/genesis.rs diff --git a/crates/apps/src/lib/config/genesis/chain.rs b/crates/apps_lib/src/config/genesis/chain.rs similarity index 100% rename from crates/apps/src/lib/config/genesis/chain.rs rename to crates/apps_lib/src/config/genesis/chain.rs diff --git a/crates/apps/src/lib/config/genesis/templates.rs b/crates/apps_lib/src/config/genesis/templates.rs similarity index 100% rename from crates/apps/src/lib/config/genesis/templates.rs rename to crates/apps_lib/src/config/genesis/templates.rs diff --git a/crates/apps/src/lib/config/genesis/transactions.rs b/crates/apps_lib/src/config/genesis/transactions.rs similarity index 100% rename from crates/apps/src/lib/config/genesis/transactions.rs rename to crates/apps_lib/src/config/genesis/transactions.rs diff --git a/crates/apps/src/lib/config/genesis/utils.rs b/crates/apps_lib/src/config/genesis/utils.rs similarity index 100% rename from crates/apps/src/lib/config/genesis/utils.rs rename to crates/apps_lib/src/config/genesis/utils.rs diff --git a/crates/apps/src/lib/config/global.rs b/crates/apps_lib/src/config/global.rs similarity index 100% rename from crates/apps/src/lib/config/global.rs rename to crates/apps_lib/src/config/global.rs diff --git a/crates/apps/src/lib/config/mod.rs b/crates/apps_lib/src/config/mod.rs similarity index 100% rename from crates/apps/src/lib/config/mod.rs rename to crates/apps_lib/src/config/mod.rs diff --git a/crates/apps/src/lib/config/utils.rs b/crates/apps_lib/src/config/utils.rs similarity index 100% rename from crates/apps/src/lib/config/utils.rs rename to crates/apps_lib/src/config/utils.rs diff --git a/crates/apps/src/lib/logging.rs b/crates/apps_lib/src/logging.rs similarity index 100% rename from crates/apps/src/lib/logging.rs rename to crates/apps_lib/src/logging.rs diff --git a/crates/apps/src/lib/mod.rs b/crates/apps_lib/src/mod.rs similarity index 100% rename from crates/apps/src/lib/mod.rs rename to crates/apps_lib/src/mod.rs diff --git a/crates/apps/src/lib/node/ledger/abortable.rs b/crates/apps_lib/src/node/ledger/abortable.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/abortable.rs rename to crates/apps_lib/src/node/ledger/abortable.rs diff --git a/crates/apps/src/lib/node/ledger/broadcaster.rs b/crates/apps_lib/src/node/ledger/broadcaster.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/broadcaster.rs rename to crates/apps_lib/src/node/ledger/broadcaster.rs diff --git a/crates/apps/src/lib/node/ledger/ethereum_oracle/control.rs b/crates/apps_lib/src/node/ledger/ethereum_oracle/control.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/ethereum_oracle/control.rs rename to crates/apps_lib/src/node/ledger/ethereum_oracle/control.rs diff --git a/crates/apps/src/lib/node/ledger/ethereum_oracle/events.rs b/crates/apps_lib/src/node/ledger/ethereum_oracle/events.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/ethereum_oracle/events.rs rename to crates/apps_lib/src/node/ledger/ethereum_oracle/events.rs diff --git a/crates/apps/src/lib/node/ledger/ethereum_oracle/mod.rs b/crates/apps_lib/src/node/ledger/ethereum_oracle/mod.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/ethereum_oracle/mod.rs rename to crates/apps_lib/src/node/ledger/ethereum_oracle/mod.rs diff --git a/crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/events_endpoint.rs b/crates/apps_lib/src/node/ledger/ethereum_oracle/test_tools/events_endpoint.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/events_endpoint.rs rename to crates/apps_lib/src/node/ledger/ethereum_oracle/test_tools/events_endpoint.rs diff --git a/crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/mod.rs b/crates/apps_lib/src/node/ledger/ethereum_oracle/test_tools/mod.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/ethereum_oracle/test_tools/mod.rs rename to crates/apps_lib/src/node/ledger/ethereum_oracle/test_tools/mod.rs diff --git a/crates/apps/src/lib/node/ledger/mod.rs b/crates/apps_lib/src/node/ledger/mod.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/mod.rs rename to crates/apps_lib/src/node/ledger/mod.rs diff --git a/crates/apps/src/lib/node/ledger/shell/block_alloc.rs b/crates/apps_lib/src/node/ledger/shell/block_alloc.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/block_alloc.rs rename to crates/apps_lib/src/node/ledger/shell/block_alloc.rs diff --git a/crates/apps/src/lib/node/ledger/shell/block_alloc/states.rs b/crates/apps_lib/src/node/ledger/shell/block_alloc/states.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/block_alloc/states.rs rename to crates/apps_lib/src/node/ledger/shell/block_alloc/states.rs diff --git a/crates/apps/src/lib/node/ledger/shell/block_alloc/states/normal_txs.rs b/crates/apps_lib/src/node/ledger/shell/block_alloc/states/normal_txs.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/block_alloc/states/normal_txs.rs rename to crates/apps_lib/src/node/ledger/shell/block_alloc/states/normal_txs.rs diff --git a/crates/apps/src/lib/node/ledger/shell/block_alloc/states/protocol_txs.rs b/crates/apps_lib/src/node/ledger/shell/block_alloc/states/protocol_txs.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/block_alloc/states/protocol_txs.rs rename to crates/apps_lib/src/node/ledger/shell/block_alloc/states/protocol_txs.rs diff --git a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs b/crates/apps_lib/src/node/ledger/shell/finalize_block.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/finalize_block.rs rename to crates/apps_lib/src/node/ledger/shell/finalize_block.rs diff --git a/crates/apps/src/lib/node/ledger/shell/governance.rs b/crates/apps_lib/src/node/ledger/shell/governance.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/governance.rs rename to crates/apps_lib/src/node/ledger/shell/governance.rs diff --git a/crates/apps/src/lib/node/ledger/shell/init_chain.rs b/crates/apps_lib/src/node/ledger/shell/init_chain.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/init_chain.rs rename to crates/apps_lib/src/node/ledger/shell/init_chain.rs diff --git a/crates/apps/src/lib/node/ledger/shell/mod.rs b/crates/apps_lib/src/node/ledger/shell/mod.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/mod.rs rename to crates/apps_lib/src/node/ledger/shell/mod.rs diff --git a/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs b/crates/apps_lib/src/node/ledger/shell/prepare_proposal.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs rename to crates/apps_lib/src/node/ledger/shell/prepare_proposal.rs diff --git a/crates/apps/src/lib/node/ledger/shell/process_proposal.rs b/crates/apps_lib/src/node/ledger/shell/process_proposal.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/process_proposal.rs rename to crates/apps_lib/src/node/ledger/shell/process_proposal.rs diff --git a/crates/apps/src/lib/node/ledger/shell/queries.rs b/crates/apps_lib/src/node/ledger/shell/queries.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/queries.rs rename to crates/apps_lib/src/node/ledger/shell/queries.rs diff --git a/crates/apps/src/lib/node/ledger/shell/stats.rs b/crates/apps_lib/src/node/ledger/shell/stats.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/stats.rs rename to crates/apps_lib/src/node/ledger/shell/stats.rs diff --git a/crates/apps/src/lib/node/ledger/shell/testing/client.rs b/crates/apps_lib/src/node/ledger/shell/testing/client.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/testing/client.rs rename to crates/apps_lib/src/node/ledger/shell/testing/client.rs diff --git a/crates/apps/src/lib/node/ledger/shell/testing/mod.rs b/crates/apps_lib/src/node/ledger/shell/testing/mod.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/testing/mod.rs rename to crates/apps_lib/src/node/ledger/shell/testing/mod.rs diff --git a/crates/apps/src/lib/node/ledger/shell/testing/node.rs b/crates/apps_lib/src/node/ledger/shell/testing/node.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/testing/node.rs rename to crates/apps_lib/src/node/ledger/shell/testing/node.rs diff --git a/crates/apps/src/lib/node/ledger/shell/testing/utils.rs b/crates/apps_lib/src/node/ledger/shell/testing/utils.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/testing/utils.rs rename to crates/apps_lib/src/node/ledger/shell/testing/utils.rs diff --git a/crates/apps/src/lib/node/ledger/shell/utils.rs b/crates/apps_lib/src/node/ledger/shell/utils.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/utils.rs rename to crates/apps_lib/src/node/ledger/shell/utils.rs diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions.rs b/crates/apps_lib/src/node/ledger/shell/vote_extensions.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/vote_extensions.rs rename to crates/apps_lib/src/node/ledger/shell/vote_extensions.rs diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs b/crates/apps_lib/src/node/ledger/shell/vote_extensions/bridge_pool_vext.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs rename to crates/apps_lib/src/node/ledger/shell/vote_extensions/bridge_pool_vext.rs diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs b/crates/apps_lib/src/node/ledger/shell/vote_extensions/eth_events.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs rename to crates/apps_lib/src/node/ledger/shell/vote_extensions/eth_events.rs diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs b/crates/apps_lib/src/node/ledger/shell/vote_extensions/val_set_update.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs rename to crates/apps_lib/src/node/ledger/shell/vote_extensions/val_set_update.rs diff --git a/crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs b/crates/apps_lib/src/node/ledger/shims/abcipp_shim.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs rename to crates/apps_lib/src/node/ledger/shims/abcipp_shim.rs diff --git a/crates/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs b/crates/apps_lib/src/node/ledger/shims/abcipp_shim_types.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs rename to crates/apps_lib/src/node/ledger/shims/abcipp_shim_types.rs diff --git a/crates/apps/src/lib/node/ledger/shims/mod.rs b/crates/apps_lib/src/node/ledger/shims/mod.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/shims/mod.rs rename to crates/apps_lib/src/node/ledger/shims/mod.rs diff --git a/crates/apps/src/lib/node/ledger/storage/mod.rs b/crates/apps_lib/src/node/ledger/storage/mod.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/storage/mod.rs rename to crates/apps_lib/src/node/ledger/storage/mod.rs diff --git a/crates/apps/src/lib/node/ledger/storage/rocksdb.rs b/crates/apps_lib/src/node/ledger/storage/rocksdb.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/storage/rocksdb.rs rename to crates/apps_lib/src/node/ledger/storage/rocksdb.rs diff --git a/crates/apps/src/lib/node/ledger/tendermint_node.rs b/crates/apps_lib/src/node/ledger/tendermint_node.rs similarity index 100% rename from crates/apps/src/lib/node/ledger/tendermint_node.rs rename to crates/apps_lib/src/node/ledger/tendermint_node.rs diff --git a/crates/apps/src/lib/node/mod.rs b/crates/apps_lib/src/node/mod.rs similarity index 100% rename from crates/apps/src/lib/node/mod.rs rename to crates/apps_lib/src/node/mod.rs diff --git a/crates/apps/src/lib/wallet/defaults.rs b/crates/apps_lib/src/wallet/defaults.rs similarity index 100% rename from crates/apps/src/lib/wallet/defaults.rs rename to crates/apps_lib/src/wallet/defaults.rs diff --git a/crates/apps/src/lib/wallet/mod.rs b/crates/apps_lib/src/wallet/mod.rs similarity index 100% rename from crates/apps/src/lib/wallet/mod.rs rename to crates/apps_lib/src/wallet/mod.rs diff --git a/crates/apps/src/lib/wallet/pre_genesis.rs b/crates/apps_lib/src/wallet/pre_genesis.rs similarity index 100% rename from crates/apps/src/lib/wallet/pre_genesis.rs rename to crates/apps_lib/src/wallet/pre_genesis.rs diff --git a/crates/apps/src/lib/wallet/store.rs b/crates/apps_lib/src/wallet/store.rs similarity index 100% rename from crates/apps/src/lib/wallet/store.rs rename to crates/apps_lib/src/wallet/store.rs diff --git a/crates/apps/src/lib/wasm_loader/mod.rs b/crates/apps_lib/src/wasm_loader/mod.rs similarity index 100% rename from crates/apps/src/lib/wasm_loader/mod.rs rename to crates/apps_lib/src/wasm_loader/mod.rs From 439af18ed7fa5adf96a562854a085ae461ad3cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 16 May 2024 14:09:42 +0200 Subject: [PATCH 14/20] `mv crates/apps_lib/src/lib/mod.rs crates/apps_lib/src/lib.rs` --- crates/apps_lib/src/{mod.rs => lib.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename crates/apps_lib/src/{mod.rs => lib.rs} (100%) diff --git a/crates/apps_lib/src/mod.rs b/crates/apps_lib/src/lib.rs similarity index 100% rename from crates/apps_lib/src/mod.rs rename to crates/apps_lib/src/lib.rs From 27be40294f163594e35227d74dbd5dd5d6723347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 16 May 2024 14:36:16 +0200 Subject: [PATCH 15/20] `mv crates/apps/build.rs crates/apps_lib/` --- crates/{apps => apps_lib}/build.rs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename crates/{apps => apps_lib}/build.rs (100%) diff --git a/crates/apps/build.rs b/crates/apps_lib/build.rs similarity index 100% rename from crates/apps/build.rs rename to crates/apps_lib/build.rs From 5c72b0113ab372e03361d71d10e5edfd2cdeac44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 16 May 2024 14:36:42 +0200 Subject: [PATCH 16/20] symlink proto from `apps_lib` --- crates/apps/proto | 1 - crates/apps_lib/proto | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 120000 crates/apps/proto create mode 120000 crates/apps_lib/proto diff --git a/crates/apps/proto b/crates/apps/proto deleted file mode 120000 index 5c8d352537..0000000000 --- a/crates/apps/proto +++ /dev/null @@ -1 +0,0 @@ -../proto \ No newline at end of file diff --git a/crates/apps_lib/proto b/crates/apps_lib/proto new file mode 120000 index 0000000000..b943f93991 --- /dev/null +++ b/crates/apps_lib/proto @@ -0,0 +1 @@ +../../proto \ No newline at end of file From 1d61b3523f95e16c1cd647cf8719aa7f579bf1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 16 May 2024 14:37:21 +0200 Subject: [PATCH 17/20] git: ignore the new generated version.rs path --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 251e29aa33..faac72b4ca 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,8 @@ target/ wasm/*.wasm # app version string file +/crates/apps_lib/version.rs +# app version string file (previously at this path, left for transition) /crates/apps/version.rs # Hidden to stop from re-appearing. Moved to `tx/src/proto/generated/types.rs`. From 1d788cbf8164451d0279f4695e78945262fd6807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 16 May 2024 15:16:49 +0200 Subject: [PATCH 18/20] fix paths for split up namada_apps_lib --- Cargo.lock | 31 ++++- crates/apps/Cargo.toml | 115 ++---------------- crates/apps/src/bin/namada-client/main.rs | 6 +- crates/apps/src/bin/namada-node/cli.rs | 6 +- crates/apps/src/bin/namada-node/main.rs | 2 +- crates/apps/src/bin/namada-relayer/main.rs | 4 +- crates/apps/src/bin/namada-wallet/main.rs | 4 +- crates/apps/src/bin/namada/cli.rs | 2 +- crates/apps/src/bin/namada/main.rs | 2 +- crates/apps_lib/Cargo.toml | 4 +- crates/apps_lib/src/cli.rs | 2 +- crates/benches/Cargo.toml | 4 +- crates/benches/host_env.rs | 6 +- crates/benches/native_vps.rs | 4 +- crates/benches/process_wrapper.rs | 6 +- crates/benches/txs.rs | 4 +- crates/tests/Cargo.toml | 6 +- crates/tests/src/e2e/eth_bridge_tests.rs | 2 +- .../tests/src/e2e/eth_bridge_tests/helpers.rs | 2 +- crates/tests/src/e2e/helpers.rs | 10 +- crates/tests/src/e2e/ibc_tests.rs | 22 ++-- crates/tests/src/e2e/ledger_tests.rs | 20 +-- crates/tests/src/e2e/setup.rs | 22 ++-- crates/tests/src/integration/helpers.rs | 8 +- crates/tests/src/integration/ledger_tests.rs | 8 +- crates/tests/src/integration/masp.rs | 12 +- crates/tests/src/integration/setup.rs | 46 +++---- crates/tests/src/native_vp/eth_bridge_pool.rs | 4 +- examples/Cargo.toml | 2 +- examples/make-db-migration.rs | 2 +- 30 files changed, 154 insertions(+), 214 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7e48bd0d4c..880b93aa71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4465,6 +4465,31 @@ dependencies = [ [[package]] name = "namada_apps" version = "0.35.1" +dependencies = [ + "assert_matches", + "bit-set", + "bytes", + "color-eyre", + "eyre", + "git2", + "namada", + "namada_apps_lib", + "namada_test_utils", + "proptest", + "test-log", + "tokio", + "tokio-test", + "toml 0.5.11", + "tracing", + "tracing-subscriber", + "warp", + "winapi", + "zeroize", +] + +[[package]] +name = "namada_apps_lib" +version = "0.35.1" dependencies = [ "ark-serialize", "ark-std", @@ -4567,7 +4592,7 @@ dependencies = [ "lazy_static", "masp_primitives", "namada", - "namada_apps", + "namada_apps_lib", "prost 0.12.3", "rand 0.8.5", "rand_core 0.6.4", @@ -4708,7 +4733,7 @@ dependencies = [ "borsh 1.2.1", "data-encoding", "masp_proofs", - "namada_apps", + "namada_apps_lib", "namada_macros", "namada_migrations", "namada_parameters", @@ -5079,7 +5104,7 @@ dependencies = [ "itertools 0.12.1", "lazy_static", "namada", - "namada_apps", + "namada_apps_lib", "namada_core", "namada_sdk", "namada_test_utils", diff --git a/crates/apps/Cargo.toml b/crates/apps/Cargo.toml index 238766006f..a41350d198 100644 --- a/crates/apps/Cargo.toml +++ b/crates/apps/Cargo.toml @@ -13,12 +13,6 @@ readme.workspace = true repository.workspace = true version.workspace = true -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -name = "namada_apps" -path = "src/lib/mod.rs" - # Namada CLI that aggregates some common commands for the node and the client [[bin]] doc = false @@ -50,123 +44,38 @@ name = "namadar" path = "src/bin/namada-relayer/main.rs" [features] -default = ["migrations"] -mainnet = [ - "namada/mainnet", -] -# for integration tests and test utilities -testing = ["namada_test_utils"] -benches = ["namada_test_utils"] -integration = [] -jemalloc = ["rocksdb/jemalloc"] -migrations = [ - "namada_migrations", - "namada_sdk/migrations", - "namada/migrations", - "linkme", -] -namada-eth-bridge = [ - "namada/namada-eth-bridge", - "namada_sdk/namada-eth-bridge", -] +default = ["namada/mainnet", "migrations"] +mainnet = ["namada_apps_lib/mainnet"] +jemalloc = ["namada_apps_lib/jemalloc"] +migrations = ["namada/migrations", "namada_apps_lib/migrations"] +namada-eth-bridge = ["namada_apps_lib/namada-eth-bridge"] [dependencies] -namada = {path = "../namada", features = ["multicore", "http-client", "tendermint-rpc", "std"]} -namada_macros = {path = "../macros"} -namada_migrations = {path = "../migrations", optional = true} -namada_sdk = {path = "../sdk", default-features = false, features = ["download-params", "std", "rand"]} -namada_test_utils = {path = "../test_utils", optional = true} +namada = {path = "../namada"} +namada_apps_lib = {path = "../apps_lib"} - -ark-serialize.workspace = true -ark-std.workspace = true -arse-merkle-tree = { workspace = true, features = ["blake2b"] } -async-trait.workspace = true -base64.workspace = true -bech32.workspace = true -bimap.workspace = true -blake2b-rs.workspace = true -borsh.workspace = true -borsh-ext.workspace = true -byte-unit.workspace = true -byteorder.workspace = true -clap.workspace = true color-eyre.workspace = true -config.workspace = true -data-encoding.workspace = true -derivative.workspace = true -directories.workspace = true -drain_filter_polyfill.workspace = true -ed25519-consensus = { workspace = true, features = ["std"] } -ethabi.workspace = true -ethbridge-bridge-events.workspace = true -ethbridge-events.workspace = true eyre.workspace = true -fd-lock.workspace = true -flate2.workspace = true -futures.workspace = true -itertools.workspace = true -lazy_static.workspace= true -ledger-namada-rs.workspace = true -ledger-transport-hid.workspace = true -libc.workspace = true -libloading.workspace = true -linkme = { workspace = true, optional = true } -masp_primitives = { workspace = true, features = ["transparent-inputs"] } -masp_proofs = { workspace = true, features = ["bundled-prover", "download-params"] } -num_cpus.workspace = true -num256.workspace = true -num-rational.workspace = true -num-traits.workspace = true -once_cell.workspace = true -orion.workspace = true -prost-types.workspace = true -prost.workspace = true -rand_core = { workspace = true, features = ["std"] } -rand = { workspace = true, features = ["std"] } -rayon.workspace = true -regex.workspace = true -reqwest.workspace = true -ripemd.workspace = true -rlimit.workspace = true -rocksdb.workspace = true -rpassword.workspace = true -serde_bytes.workspace = true -serde_json = {workspace = true, features = ["raw_value"]} -serde.workspace = true -sha2.workspace = true -smooth-operator.workspace = true -sysinfo.workspace = true -tar.workspace = true -tempfile.workspace = true -tendermint-config.workspace = true -tendermint-rpc.workspace = true -textwrap-macros = "0.3.0" -thiserror.workspace = true tokio = {workspace = true, features = ["full"]} toml.workspace = true -tower-abci.workspace = true -tower.workspace = true -tracing-appender.workspace = true -tracing-log.workspace = true tracing-subscriber = { workspace = true, features = ["std", "json", "ansi", "tracing-log"]} tracing.workspace = true zeroize.workspace = true warp = "0.3.2" bytes = "1.1.0" +[target.'cfg(windows)'.dependencies] +winapi.workspace = true + [dev-dependencies] namada = {path = "../namada", default-features = false, features = ["testing", "wasm-runtime"]} namada_test_utils = {path = "../test_utils"} -assert_matches.workspace = true + +assert_matches = "1.5.0" bit-set.workspace = true -pretty_assertions.workspace = true proptest.workspace = true test-log.workspace = true tokio-test.workspace = true [build-dependencies] git2.workspace = true - -[target.'cfg(windows)'.dependencies] -winapi.workspace = true diff --git a/crates/apps/src/bin/namada-client/main.rs b/crates/apps/src/bin/namada-client/main.rs index 9fdea9c51d..666f7d39b5 100644 --- a/crates/apps/src/bin/namada-client/main.rs +++ b/crates/apps/src/bin/namada-client/main.rs @@ -1,7 +1,7 @@ use color_eyre::eyre::Result; -use namada_apps::cli::api::{CliApi, CliIo}; -use namada_apps::facade::tendermint_rpc::HttpClient; -use namada_apps::{cli, logging}; +use namada_apps_lib::cli::api::{CliApi, CliIo}; +use namada_apps_lib::facade::tendermint_rpc::HttpClient; +use namada_apps_lib::{cli, logging}; use tracing_subscriber::filter::LevelFilter; #[tokio::main] diff --git a/crates/apps/src/bin/namada-node/cli.rs b/crates/apps/src/bin/namada-node/cli.rs index 70eac446ae..c9fab41d7c 100644 --- a/crates/apps/src/bin/namada-node/cli.rs +++ b/crates/apps/src/bin/namada-node/cli.rs @@ -2,9 +2,9 @@ use eyre::{Context, Result}; use namada::core::time::{DateTimeUtc, Utc}; -use namada_apps::cli::{self, cmds}; -use namada_apps::config::{Action, ActionAtHeight, ValidatorLocalConfig}; -use namada_apps::node::ledger; +use namada_apps_lib::cli::{self, cmds}; +use namada_apps_lib::config::{Action, ActionAtHeight, ValidatorLocalConfig}; +use namada_apps_lib::node::ledger; #[cfg(not(feature = "migrations"))] use namada_sdk::display_line; diff --git a/crates/apps/src/bin/namada-node/main.rs b/crates/apps/src/bin/namada-node/main.rs index a5f187c160..4a54cca748 100644 --- a/crates/apps/src/bin/namada-node/main.rs +++ b/crates/apps/src/bin/namada-node/main.rs @@ -1,7 +1,7 @@ mod cli; use color_eyre::eyre::Result; -use namada_apps::logging; +use namada_apps_lib::logging; use tracing_subscriber::filter::LevelFilter; fn main() -> Result<()> { diff --git a/crates/apps/src/bin/namada-relayer/main.rs b/crates/apps/src/bin/namada-relayer/main.rs index 1eb2679e28..115b63296d 100644 --- a/crates/apps/src/bin/namada-relayer/main.rs +++ b/crates/apps/src/bin/namada-relayer/main.rs @@ -1,7 +1,7 @@ use color_eyre::eyre::Result; use namada::tendermint_rpc::HttpClient; -use namada_apps::cli::api::{CliApi, CliIo}; -use namada_apps::{cli, logging}; +use namada_apps_lib::cli::api::{CliApi, CliIo}; +use namada_apps_lib::{cli, logging}; use tracing_subscriber::filter::LevelFilter; #[tokio::main] diff --git a/crates/apps/src/bin/namada-wallet/main.rs b/crates/apps/src/bin/namada-wallet/main.rs index 6ee0bc0bd7..218cb534ed 100644 --- a/crates/apps/src/bin/namada-wallet/main.rs +++ b/crates/apps/src/bin/namada-wallet/main.rs @@ -1,6 +1,6 @@ use color_eyre::eyre::Result; -use namada_apps::cli; -use namada_apps::cli::api::{CliApi, CliIo}; +use namada_apps_lib::cli; +use namada_apps_lib::cli::api::{CliApi, CliIo}; #[tokio::main] pub async fn main() -> Result<()> { diff --git a/crates/apps/src/bin/namada/cli.rs b/crates/apps/src/bin/namada/cli.rs index c7694117aa..9b97f2e761 100644 --- a/crates/apps/src/bin/namada/cli.rs +++ b/crates/apps/src/bin/namada/cli.rs @@ -9,7 +9,7 @@ use std::env; use std::process::Command; use eyre::Result; -use namada_apps::cli; +use namada_apps_lib::cli; pub fn main() -> Result<()> { let (cmd, raw_sub_cmd) = cli::namada_cli(); diff --git a/crates/apps/src/bin/namada/main.rs b/crates/apps/src/bin/namada/main.rs index 488164ca0d..428c2a55bb 100644 --- a/crates/apps/src/bin/namada/main.rs +++ b/crates/apps/src/bin/namada/main.rs @@ -1,7 +1,7 @@ mod cli; use color_eyre::eyre::Result; -use namada_apps::logging; +use namada_apps_lib::logging; use tracing_subscriber::filter::LevelFilter; fn main() -> Result<()> { diff --git a/crates/apps_lib/Cargo.toml b/crates/apps_lib/Cargo.toml index 244158eb86..31a720fdf5 100644 --- a/crates/apps_lib/Cargo.toml +++ b/crates/apps_lib/Cargo.toml @@ -37,7 +37,7 @@ namada-eth-bridge = [ namada = {path = "../namada", features = ["multicore", "http-client", "tendermint-rpc", "std"]} namada_macros = {path = "../macros"} namada_migrations = {path = "../migrations", optional = true} -namada_sdk = {path = "../sdk", default-features = false, features = ["wasm-runtime", "download-params", "std", "rand"]} +namada_sdk = {path = "../sdk", default-features = false, features = ["download-params", "std", "rand"]} namada_test_utils = {path = "../test_utils", optional = true} ark-serialize.workspace = true @@ -99,7 +99,6 @@ serde_bytes.workspace = true serde_json = {workspace = true, features = ["raw_value"]} serde.workspace = true sha2.workspace = true -signal-hook.workspace = true smooth-operator.workspace = true sysinfo.workspace = true tar.workspace = true @@ -110,7 +109,6 @@ textwrap-macros = "0.3.0" thiserror.workspace = true tokio = {workspace = true, features = ["full"]} toml.workspace = true -tonic.workspace = true tower-abci.workspace = true tower.workspace = true tracing-appender.workspace = true diff --git a/crates/apps_lib/src/cli.rs b/crates/apps_lib/src/cli.rs index 4898693db8..ea1a13dd2a 100644 --- a/crates/apps_lib/src/cli.rs +++ b/crates/apps_lib/src/cli.rs @@ -22,7 +22,7 @@ pub use utils::{safe_exit, Cmd}; pub use self::context::Context; use crate::cli::api::CliIo; -include!("../../version.rs"); +include!("../version.rs"); const APP_NAME: &str = "Namada"; diff --git a/crates/benches/Cargo.toml b/crates/benches/Cargo.toml index 6fff64480d..ae5daaa92b 100644 --- a/crates/benches/Cargo.toml +++ b/crates/benches/Cargo.toml @@ -40,7 +40,7 @@ path = "wasm_opcodes.rs" [features] namada-eth-bridge = [ "namada/namada-eth-bridge", - "namada_apps/namada-eth-bridge", + "namada_apps_lib/namada-eth-bridge", ] [dependencies] @@ -48,7 +48,7 @@ namada-eth-bridge = [ # NOTE: this crate MUST NOT import any dependency with testing features to prevent benchmarking non-production code [dev-dependencies] namada = { path = "../namada", features = ["rand", "benches"] } -namada_apps = { path = "../apps", features = ["benches"] } +namada_apps_lib = { path = "../apps_lib", features = ["benches"] } masp_primitives.workspace = true borsh.workspace = true borsh-ext.workspace = true diff --git a/crates/benches/host_env.rs b/crates/benches/host_env.rs index 5149b6e2ac..9b2870e962 100644 --- a/crates/benches/host_env.rs +++ b/crates/benches/host_env.rs @@ -6,12 +6,12 @@ use namada::ledger::storage::DB; use namada::token::{Amount, Transfer}; use namada::tx::Authorization; use namada::vm::wasm::TxCache; -use namada_apps::bench_utils::{ +use namada_apps_lib::bench_utils::{ BenchShell, TX_INIT_PROPOSAL_WASM, TX_REVEAL_PK_WASM, TX_TRANSFER_WASM, TX_UPDATE_ACCOUNT_WASM, VP_USER_WASM, WASM_DIR, }; -use namada_apps::wallet::defaults; -use namada_apps::wasm_loader; +use namada_apps_lib::wallet::defaults; +use namada_apps_lib::wasm_loader; // Benchmarks the validation of a single signature on a single `Section` of a // transaction diff --git a/crates/benches/native_vps.rs b/crates/benches/native_vps.rs index bf7a30f2bd..0287065d1c 100644 --- a/crates/benches/native_vps.rs +++ b/crates/benches/native_vps.rs @@ -56,13 +56,13 @@ use namada::sdk::masp_proofs::sapling::SaplingVerificationContext; use namada::state::{Epoch, StorageRead, StorageWrite, TxIndex}; use namada::token::{Amount, Transfer}; use namada::tx::{BatchedTx, Code, Section, Tx}; -use namada_apps::bench_utils::{ +use namada_apps_lib::bench_utils::{ generate_foreign_key_tx, BenchShell, BenchShieldedCtx, ALBERT_PAYMENT_ADDRESS, ALBERT_SPENDING_KEY, BERTHA_PAYMENT_ADDRESS, TX_BRIDGE_POOL_WASM, TX_IBC_WASM, TX_INIT_PROPOSAL_WASM, TX_RESIGN_STEWARD, TX_TRANSFER_WASM, TX_UPDATE_STEWARD_COMMISSION, TX_VOTE_PROPOSAL_WASM, }; -use namada_apps::wallet::defaults; +use namada_apps_lib::wallet::defaults; fn governance(c: &mut Criterion) { let mut group = c.benchmark_group("vp_governance"); diff --git a/crates/benches/process_wrapper.rs b/crates/benches/process_wrapper.rs index 9db1ef4794..bc79a0d6dc 100644 --- a/crates/benches/process_wrapper.rs +++ b/crates/benches/process_wrapper.rs @@ -6,9 +6,9 @@ use namada::core::time::DateTimeUtc; use namada::token::{Amount, DenominatedAmount, Transfer}; use namada::tx::data::{Fee, WrapperTx}; use namada::tx::Authorization; -use namada_apps::bench_utils::{BenchShell, TX_TRANSFER_WASM}; -use namada_apps::node::ledger::shell::process_proposal::ValidationMeta; -use namada_apps::wallet::defaults; +use namada_apps_lib::bench_utils::{BenchShell, TX_TRANSFER_WASM}; +use namada_apps_lib::node::ledger::shell::process_proposal::ValidationMeta; +use namada_apps_lib::wallet::defaults; fn process_tx(c: &mut Criterion) { let mut shell = BenchShell::default(); diff --git a/crates/benches/txs.rs b/crates/benches/txs.rs index a260a9af5e..be963966a4 100644 --- a/crates/benches/txs.rs +++ b/crates/benches/txs.rs @@ -16,10 +16,10 @@ use namada::ibc::core::host::types::identifiers::{ use namada::ibc::primitives::ToProto; use namada::proof_of_stake::KeySeg; use namada::token::Amount; -use namada_apps::bench_utils::{ +use namada_apps_lib::bench_utils::{ BenchShieldedCtx, ALBERT_PAYMENT_ADDRESS, ALBERT_SPENDING_KEY, TX_IBC_WASM, }; -use namada_apps::wallet::defaults; +use namada_apps_lib::wallet::defaults; fn ibc(c: &mut Criterion) { let mut group = c.benchmark_group("tx_ibc"); diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index 1a5c89b002..470268934d 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -18,7 +18,7 @@ mainnet = [ "namada/mainnet", ] wasm-runtime = ["namada/wasm-runtime"] -integration = ["namada_apps/integration"] +integration = ["namada_apps_lib/integration"] migrations = [ "namada/migrations", "namada_sdk/migrations", @@ -27,7 +27,7 @@ migrations = [ namada-eth-bridge = [ "namada/namada-eth-bridge", "namada_sdk/namada-eth-bridge", - "namada_apps/namada-eth-bridge", + "namada_apps_lib/namada-eth-bridge", ] [dependencies] @@ -60,7 +60,7 @@ tracing-subscriber.workspace = true tracing.workspace = true [dev-dependencies] -namada_apps = {path = "../apps", features = ["testing"]} +namada_apps_lib = {path = "../apps_lib", features = ["testing"]} namada_vm_env = {path = "../vm_env"} assert_cmd.workspace = true assert_matches.workspace = true diff --git a/crates/tests/src/e2e/eth_bridge_tests.rs b/crates/tests/src/e2e/eth_bridge_tests.rs index 9c77ab85b3..582a2ca094 100644 --- a/crates/tests/src/e2e/eth_bridge_tests.rs +++ b/crates/tests/src/e2e/eth_bridge_tests.rs @@ -19,7 +19,7 @@ use namada::ledger::eth_bridge::{ ContractVersion, Contracts, EthereumBridgeParams, MinimumConfirmations, UpgradeableContract, }; -use namada_apps::config::ethereum_bridge; +use namada_apps_lib::config::ethereum_bridge; use namada_core::address::Address; use namada_core::ethereum_events::{ EthereumEvent, TransferToEthereum, TransferToNamada, diff --git a/crates/tests/src/e2e/eth_bridge_tests/helpers.rs b/crates/tests/src/e2e/eth_bridge_tests/helpers.rs index 813cad5e99..40f9b68bf9 100644 --- a/crates/tests/src/e2e/eth_bridge_tests/helpers.rs +++ b/crates/tests/src/e2e/eth_bridge_tests/helpers.rs @@ -16,7 +16,7 @@ use namada::ledger::eth_bridge::{ MinimumConfirmations, UpgradeableContract, }; use namada::token; -use namada_apps::config::ethereum_bridge; +use namada_apps_lib::config::ethereum_bridge; use crate::e2e::helpers::{ get_actor_rpc, rpc_client_do, strip_trailing_newline, diff --git a/crates/tests/src/e2e/helpers.rs b/crates/tests/src/e2e/helpers.rs index 210917a875..e5723d580a 100644 --- a/crates/tests/src/e2e/helpers.rs +++ b/crates/tests/src/e2e/helpers.rs @@ -21,11 +21,11 @@ use namada::core::storage::Epoch; use namada::ledger::queries::{Rpc, RPC}; use namada::tendermint_rpc::HttpClient; use namada::token; -use namada_apps::cli::context::ENV_VAR_CHAIN_ID; -use namada_apps::config::genesis::chain::DeriveEstablishedAddress; -use namada_apps::config::genesis::templates; -use namada_apps::config::utils::convert_tm_addr_to_socket_addr; -use namada_apps::config::{Config, TendermintMode}; +use namada_apps_lib::cli::context::ENV_VAR_CHAIN_ID; +use namada_apps_lib::config::genesis::chain::DeriveEstablishedAddress; +use namada_apps_lib::config::genesis::templates; +use namada_apps_lib::config::utils::convert_tm_addr_to_socket_addr; +use namada_apps_lib::config::{Config, TendermintMode}; use namada_core::token::NATIVE_MAX_DECIMAL_PLACES; use namada_sdk::wallet::fs::FsWalletUtils; use namada_sdk::wallet::Wallet; diff --git a/crates/tests/src/e2e/ibc_tests.rs b/crates/tests/src/e2e/ibc_tests.rs index 0346366a68..0533374315 100644 --- a/crates/tests/src/e2e/ibc_tests.rs +++ b/crates/tests/src/e2e/ibc_tests.rs @@ -68,17 +68,17 @@ use namada::sdk::events::extend::ReadFromEventAttributes; use namada::state::Sha256Hasher; use namada::tendermint::abci::Event as AbciEvent; use namada::tendermint::block::Height as TmHeight; -use namada_apps::cli::context::ENV_VAR_CHAIN_ID; -use namada_apps::client::rpc::{ +use namada_apps_lib::cli::context::ENV_VAR_CHAIN_ID; +use namada_apps_lib::client::rpc::{ query_pos_parameters, query_storage_value, query_storage_value_bytes, }; -use namada_apps::client::utils::id_from_pk; -use namada_apps::config::genesis::{chain, templates}; -use namada_apps::config::utils::set_port; -use namada_apps::config::{ethereum_bridge, TendermintMode}; -use namada_apps::facade::tendermint::block::Header as TmHeader; -use namada_apps::facade::tendermint::merkle::proof::ProofOps as TmProof; -use namada_apps::facade::tendermint_rpc::{Client, HttpClient, Url}; +use namada_apps_lib::client::utils::id_from_pk; +use namada_apps_lib::config::genesis::{chain, templates}; +use namada_apps_lib::config::utils::set_port; +use namada_apps_lib::config::{ethereum_bridge, TendermintMode}; +use namada_apps_lib::facade::tendermint::block::Header as TmHeader; +use namada_apps_lib::facade::tendermint::merkle::proof::ProofOps as TmProof; +use namada_apps_lib::facade::tendermint_rpc::{Client, HttpClient, Url}; use namada_core::string_encoding::StringEncoded; use namada_sdk::masp::fs::FsShieldedUtils; use namada_test_utils::TestWasms; @@ -877,7 +877,7 @@ fn setup_two_single_node_nets( let genesis_b_dir = test_b .test_dir .path() - .join(namada_apps::client::utils::NET_ACCOUNTS_DIR) + .join(namada_apps_lib::client::utils::NET_ACCOUNTS_DIR) .join("validator-0"); let mut genesis_b = chain::Finalized::read_toml_files( &genesis_b_dir.join(test_b.net.chain_id.as_str()), @@ -917,7 +917,7 @@ fn setup_two_single_node_nets( .write_toml_files(&genesis_b_dir.join(test_b.net.chain_id.as_str())) .map_err(|_| eyre!("Could not write genesis toml files for test_b"))?; // modify chain b to use different ports for cometbft - let mut config = namada_apps::config::Config::load( + let mut config = namada_apps_lib::config::Config::load( &genesis_b_dir, &test_b.net.chain_id, Some(TendermintMode::Validator), diff --git a/crates/tests/src/e2e/ledger_tests.rs b/crates/tests/src/e2e/ledger_tests.rs index afc8f9cec3..199c2c293b 100644 --- a/crates/tests/src/e2e/ledger_tests.rs +++ b/crates/tests/src/e2e/ledger_tests.rs @@ -22,10 +22,10 @@ use color_eyre::owo_colors::OwoColorize; use namada::core::address::Address; use namada::core::storage::Epoch; use namada::token; -use namada_apps::cli::context::ENV_VAR_CHAIN_ID; -use namada_apps::config::ethereum_bridge; -use namada_apps::config::utils::convert_tm_addr_to_socket_addr; -use namada_apps::facade::tendermint_config::net::Address as TendermintAddress; +use namada_apps_lib::cli::context::ENV_VAR_CHAIN_ID; +use namada_apps_lib::config::ethereum_bridge; +use namada_apps_lib::config::utils::convert_tm_addr_to_socket_addr; +use namada_apps_lib::facade::tendermint_config::net::Address as TendermintAddress; use namada_core::chain::ChainId; use namada_core::token::NATIVE_MAX_DECIMAL_PLACES; use namada_test_utils::TestWasms; @@ -1067,8 +1067,8 @@ fn double_signing_gets_slashed() -> Result<()> { use std::str::FromStr; use namada::core::key::{self, ed25519, SigScheme}; - use namada_apps::client; - use namada_apps::config::Config; + use namada_apps_lib::client; + use namada_apps_lib::config::Config; let mut pipeline_len = 0; let mut unbonding_len = 0; @@ -1136,7 +1136,7 @@ fn double_signing_gets_slashed() -> Result<()> { .join(test.net.chain_id.as_str()) .join(client::utils::NET_ACCOUNTS_DIR) .join("validator-0-copy") - .join(namada_apps::config::DEFAULT_BASE_DIR); + .join(namada_apps_lib::config::DEFAULT_BASE_DIR); fs_extra::dir::copy( validator_0_base_dir, &validator_0_base_dir_copy, @@ -1867,7 +1867,7 @@ fn change_consensus_key() -> Result<()> { "Setting up the new validator consensus key in CometBFT...".blue() ); let chain_dir = test.get_chain_dir(Who::Validator(0)); - let mut wallet = namada_apps::wallet::load(&chain_dir).unwrap(); + let mut wallet = namada_apps_lib::wallet::load(&chain_dir).unwrap(); // ========================================================================= // 4. Configure validator-0 node with the new key @@ -1877,7 +1877,7 @@ fn change_consensus_key() -> Result<()> { let new_sk = wallet.find_secret_key(new_key_alias, None).unwrap(); // Write the key to CometBFT dir let cometbft_dir = test.get_cometbft_home(Who::Validator(0)); - namada_apps::node::ledger::tendermint_node::write_validator_key( + namada_apps_lib::node::ledger::tendermint_node::write_validator_key( cometbft_dir, &new_sk, ) @@ -2164,7 +2164,7 @@ fn test_sync_chain() -> Result<()> { } // Add seed nodes if any given if let Ok(seed_nodes) = std::env::var(ENV_VAR_NAMADA_SEED_NODES) { - let mut config = namada_apps::config::Config::load( + let mut config = namada_apps_lib::config::Config::load( base_dir, &test.net.chain_id, None, diff --git a/crates/tests/src/e2e/setup.rs b/crates/tests/src/e2e/setup.rs index d84db45ed1..287ff9fa8d 100644 --- a/crates/tests/src/e2e/setup.rs +++ b/crates/tests/src/e2e/setup.rs @@ -19,14 +19,16 @@ use expectrl::{ControlCode, Eof, WaitStatus}; use eyre::eyre; use itertools::{Either, Itertools}; use namada::core::chain::ChainId; -use namada_apps::cli::context::ENV_VAR_CHAIN_ID; -use namada_apps::client::utils::{ +use namada_apps_lib::cli::context::ENV_VAR_CHAIN_ID; +use namada_apps_lib::client::utils::{ self, validator_pre_genesis_dir, validator_pre_genesis_txs_file, }; -use namada_apps::config::genesis::utils::read_toml; -use namada_apps::config::genesis::{templates, transactions, GenesisAddress}; -use namada_apps::config::{ethereum_bridge, genesis, Config}; -use namada_apps::{config, wallet}; +use namada_apps_lib::config::genesis::utils::read_toml; +use namada_apps_lib::config::genesis::{ + templates, transactions, GenesisAddress, +}; +use namada_apps_lib::config::{ethereum_bridge, genesis, Config}; +use namada_apps_lib::{config, wallet}; use namada_core::address::Address; use namada_core::collections::HashMap; use namada_core::key::{RefTo, SchemeType}; @@ -48,7 +50,7 @@ use crate::e2e::helpers::{ /// process pub static INIT: Once = Once::new(); -pub const APPS_PACKAGE: &str = "namada_apps"; +pub const APPS_PACKAGE: &str = "namada_apps_lib"; /// Env. var for running E2E tests in debug mode pub const ENV_VAR_DEBUG: &str = "NAMADA_E2E_DEBUG"; @@ -179,7 +181,7 @@ where }); println!("alias: {}, pk: {}", alias, sk.ref_to()); let validator_address = { - use namada_apps::config::genesis::chain::DeriveEstablishedAddress; + use namada_apps_lib::config::genesis::chain::DeriveEstablishedAddress; let pre_genesis_tx = transactions::EstablishedAccountTx { vp: "vp_user".to_string(), threshold: 1, @@ -453,7 +455,7 @@ pub fn network( // Set the network archive dir to make it available for `join-network` // commands std::env::set_var( - namada_apps::client::utils::ENV_VAR_NETWORK_CONFIGS_DIR, + namada_apps_lib::client::utils::ENV_VAR_NETWORK_CONFIGS_DIR, archive_dir, ); @@ -777,7 +779,7 @@ impl Test { pub fn get_cometbft_home(&self, who: Who) -> PathBuf { self.get_chain_dir(who) - .join(namada_apps::config::COMETBFT_DIR) + .join(namada_apps_lib::config::COMETBFT_DIR) } /// Get an async runtime. diff --git a/crates/tests/src/integration/helpers.rs b/crates/tests/src/integration/helpers.rs index b8268858e7..26ba4fcb4c 100644 --- a/crates/tests/src/integration/helpers.rs +++ b/crates/tests/src/integration/helpers.rs @@ -2,9 +2,11 @@ use std::path::PathBuf; use std::str::FromStr; use eyre::eyre; -use namada_apps::node::ledger::shell::testing::client::run; -use namada_apps::node::ledger::shell::testing::node::MockNode; -use namada_apps::node::ledger::shell::testing::utils::{Bin, CapturedOutput}; +use namada_apps_lib::node::ledger::shell::testing::client::run; +use namada_apps_lib::node::ledger::shell::testing::node::MockNode; +use namada_apps_lib::node::ledger::shell::testing::utils::{ + Bin, CapturedOutput, +}; use namada_core::address::Address; /// Query the wallet to get an address from a given alias. diff --git a/crates/tests/src/integration/ledger_tests.rs b/crates/tests/src/integration/ledger_tests.rs index 7d178ca61c..feee8217a2 100644 --- a/crates/tests/src/integration/ledger_tests.rs +++ b/crates/tests/src/integration/ledger_tests.rs @@ -7,9 +7,11 @@ use color_eyre::eyre::Result; use data_encoding::HEXLOWER; use namada::core::collections::HashMap; use namada::token; -use namada_apps::node::ledger::shell::testing::client::run; -use namada_apps::node::ledger::shell::testing::utils::{Bin, CapturedOutput}; -use namada_apps::wallet::defaults; +use namada_apps_lib::node::ledger::shell::testing::client::run; +use namada_apps_lib::node::ledger::shell::testing::utils::{ + Bin, CapturedOutput, +}; +use namada_apps_lib::wallet::defaults; use namada_core::dec::Dec; use namada_core::storage::Epoch; use namada_core::token::NATIVE_MAX_DECIMAL_PLACES; diff --git a/crates/tests/src/integration/masp.rs b/crates/tests/src/integration/masp.rs index 0b4367f7d9..d8d59a0f86 100644 --- a/crates/tests/src/integration/masp.rs +++ b/crates/tests/src/integration/masp.rs @@ -6,10 +6,12 @@ use color_eyre::owo_colors::OwoColorize; use namada::state::{StorageRead, StorageWrite}; use namada::token::storage_key::masp_token_map_key; use namada::token::{self, DenominatedAmount}; -use namada_apps::node::ledger::shell::testing::client::run; -use namada_apps::node::ledger::shell::testing::node::NodeResults; -use namada_apps::node::ledger::shell::testing::utils::{Bin, CapturedOutput}; -use namada_apps::wallet::defaults::christel_keypair; +use namada_apps_lib::node::ledger::shell::testing::client::run; +use namada_apps_lib::node::ledger::shell::testing::node::NodeResults; +use namada_apps_lib::node::ledger::shell::testing::utils::{ + Bin, CapturedOutput, +}; +use namada_apps_lib::wallet::defaults::christel_keypair; use namada_core::dec::Dec; use namada_core::masp::TokenMap; use namada_sdk::masp::fs::FsShieldedUtils; @@ -939,7 +941,7 @@ fn spend_unconverted_asset_type() -> Result<()> { #[test] fn masp_txs_and_queries() -> Result<()> { // Uncomment for better debugging - // let _log_guard = namada_apps::logging::init_from_env_or( + // let _log_guard = namada_apps_lib::logging::init_from_env_or( // tracing::level_filters::LevelFilter::INFO, // )?; // This address doesn't matter for tests. But an argument is required. diff --git a/crates/tests/src/integration/setup.rs b/crates/tests/src/integration/setup.rs index 8ebf834616..0b52661c74 100644 --- a/crates/tests/src/integration/setup.rs +++ b/crates/tests/src/integration/setup.rs @@ -7,22 +7,22 @@ use std::sync::{Arc, Mutex}; use color_eyre::eyre::{eyre, Result}; use namada::core::dec::Dec; use namada::token; -use namada_apps::cli::args; -use namada_apps::client::utils::PRE_GENESIS_DIR; -use namada_apps::config; -use namada_apps::config::genesis::chain::Finalized; -use namada_apps::config::genesis::templates; -use namada_apps::config::genesis::templates::load_and_validate; -use namada_apps::config::TendermintMode; -use namada_apps::facade::tendermint::Timeout; -use namada_apps::facade::tendermint_proto::google::protobuf::Timestamp; -use namada_apps::node::ledger::shell::testing::node::{ +use namada_apps_lib::cli::args; +use namada_apps_lib::client::utils::PRE_GENESIS_DIR; +use namada_apps_lib::config; +use namada_apps_lib::config::genesis::chain::Finalized; +use namada_apps_lib::config::genesis::templates; +use namada_apps_lib::config::genesis::templates::load_and_validate; +use namada_apps_lib::config::TendermintMode; +use namada_apps_lib::facade::tendermint::Timeout; +use namada_apps_lib::facade::tendermint_proto::google::protobuf::Timestamp; +use namada_apps_lib::node::ledger::shell::testing::node::{ mock_services, MockNode, MockServicesCfg, MockServicesController, MockServicesPackage, }; -use namada_apps::node::ledger::shell::testing::utils::TestDir; -use namada_apps::node::ledger::shell::Shell; -use namada_apps::wallet::pre_genesis; +use namada_apps_lib::node::ledger::shell::testing::utils::TestDir; +use namada_apps_lib::node::ledger::shell::Shell; +use namada_apps_lib::wallet::pre_genesis; use namada_core::chain::ChainIdPrefix; use namada_core::collections::HashMap; use namada_sdk::wallet::alias::Alias; @@ -95,7 +95,7 @@ pub fn initialize_genesis( // Create genesis chain release archive let release_archive_path = - namada_apps::client::utils::init_network(args::InitNetwork { + namada_apps_lib::client::utils::init_network(args::InitNetwork { templates_path: genesis_path, wasm_checksums_path, chain_id_prefix, @@ -161,7 +161,7 @@ fn finalize_wallet( }); // Try to load pre-genesis wallet - let pre_genesis_wallet = namada_apps::wallet::load(&pre_genesis_path); + let pre_genesis_wallet = namada_apps_lib::wallet::load(&pre_genesis_path); let chain_dir = global_args .base_dir .join(global_args.chain_id.as_ref().unwrap().as_str()); @@ -171,7 +171,7 @@ fn finalize_wallet( pre_genesis_wallet, validator_alias_and_pre_genesis_wallet, ); - namada_apps::wallet::save(&wallet).unwrap(); + namada_apps_lib::wallet::save(&wallet).unwrap(); } /// Create a mock ledger node. @@ -222,7 +222,7 @@ fn create_node( auto_drive_services, }; let init_req = - namada_apps::facade::tendermint::v0_37::abci::request::InitChain { + namada_apps_lib::facade::tendermint::v0_37::abci::request::InitChain { time: Timestamp { seconds: 0, nanos: 0, @@ -230,23 +230,23 @@ fn create_node( .try_into().unwrap(), chain_id: chain_id.to_string(), consensus_params: - namada_apps::facade::tendermint::consensus::params::Params { - block: namada_apps::facade::tendermint::block::Size { + namada_apps_lib::facade::tendermint::consensus::params::Params { + block: namada_apps_lib::facade::tendermint::block::Size { max_bytes: 0, max_gas: 0, time_iota_ms: 0, }, evidence: - namada_apps::facade::tendermint::evidence::Params { + namada_apps_lib::facade::tendermint::evidence::Params { max_age_num_blocks: 0, - max_age_duration: namada_apps::facade::tendermint::evidence::Duration(core::time::Duration::MAX), + max_age_duration: namada_apps_lib::facade::tendermint::evidence::Duration(core::time::Duration::MAX), max_bytes: 0, }, - validator: namada_apps::facade::tendermint::consensus::params::ValidatorParams { + validator: namada_apps_lib::facade::tendermint::consensus::params::ValidatorParams { pub_key_types: vec![] }, version: None, - abci: namada_apps::facade::tendermint::consensus::params::AbciParams { + abci: namada_apps_lib::facade::tendermint::consensus::params::AbciParams { vote_extensions_enable_height: None, }, }, diff --git a/crates/tests/src/native_vp/eth_bridge_pool.rs b/crates/tests/src/native_vp/eth_bridge_pool.rs index b670778146..aefc436f16 100644 --- a/crates/tests/src/native_vp/eth_bridge_pool.rs +++ b/crates/tests/src/native_vp/eth_bridge_pool.rs @@ -17,8 +17,8 @@ mod test_bridge_pool_vp { use namada::gas::VpGasMeter; use namada::ledger::native_vp::ethereum_bridge::bridge_pool_vp::BridgePoolVp; use namada::tx::Tx; - use namada_apps::wallet::defaults::{albert_address, bertha_address}; - use namada_apps::wasm_loader; + use namada_apps_lib::wallet::defaults::{albert_address, bertha_address}; + use namada_apps_lib::wasm_loader; use namada_sdk::eth_bridge::{ wrapped_erc20s, Contracts, Erc20WhitelistEntry, EthereumBridgeParams, UpgradeableContract, diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 0c81607abd..a95700f17a 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -29,7 +29,7 @@ namada-eth-bridge = ["namada_sdk/namada-eth-bridge"] [dev-dependencies] masp_proofs = { workspace = true, default-features = false, features = ["local-prover", "download-params"] } -namada_apps = {path = "../crates/apps", features = ["migrations"]} +namada_apps_lib = {path = "../crates/apps_lib", features = ["migrations"]} namada_macros = {path = "../crates/macros"} namada_migrations = {path = "../crates/migrations"} namada_parameters = { path = "../crates/parameters"} diff --git a/examples/make-db-migration.rs b/examples/make-db-migration.rs index 5428f6741b..f695ebe06a 100644 --- a/examples/make-db-migration.rs +++ b/examples/make-db-migration.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use borsh::{BorshDeserialize, BorshSerialize}; use data_encoding::{HEXLOWER, HEXUPPER}; -use namada_apps::wasm_loader::read_wasm; +use namada_apps_lib::wasm_loader::read_wasm; use namada_macros::BorshDeserializer; use namada_parameters::storage; use namada_sdk::address::Address; From 15f7da26f0560689844efd49aac6a5f4ebf9ea41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 16 May 2024 18:33:40 +0200 Subject: [PATCH 19/20] test/apps_lib: fix the top-level dir check --- crates/apps_lib/src/node/ledger/shell/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/apps_lib/src/node/ledger/shell/mod.rs b/crates/apps_lib/src/node/ledger/shell/mod.rs index 84b464cce3..d27b2e1ed6 100644 --- a/crates/apps_lib/src/node/ledger/shell/mod.rs +++ b/crates/apps_lib/src/node/ledger/shell/mod.rs @@ -1374,7 +1374,7 @@ mod test_utils { .expect("Current directory should exist") .canonicalize() .expect("Current directory should exist"); - while current_path.file_name().unwrap() != "apps" { + while current_path.file_name().unwrap() != "apps_lib" { current_path.pop(); } // Two-dirs up to root From b132a3a30da1b60d61d1ed981408b363cb06244b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 17 May 2024 13:02:48 +0200 Subject: [PATCH 20/20] changelog: add #3259 --- .changelog/unreleased/improvements/3259-split-up-apps.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/improvements/3259-split-up-apps.md diff --git a/.changelog/unreleased/improvements/3259-split-up-apps.md b/.changelog/unreleased/improvements/3259-split-up-apps.md new file mode 100644 index 0000000000..b47c9c7c34 --- /dev/null +++ b/.changelog/unreleased/improvements/3259-split-up-apps.md @@ -0,0 +1,2 @@ +- Separated the apps library code from binaries code into a new crate + `namada_apps_lib`. ([\#3259](https://github.com/anoma/namada/pull/3259)) \ No newline at end of file