From 14b80a02208676814e8b76306ef4f93eff7df35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 16 Jan 2024 11:44:39 +0000 Subject: [PATCH] fixup! Merge branch 'tomas+tiago/modularization' (#2312) --- Cargo.lock | 35 ++-- apps/src/lib/client/rpc.rs | 2 +- apps/src/lib/client/tx.rs | 3 +- .../lib/node/ledger/shell/finalize_block.rs | 21 +- apps/src/lib/node/ledger/shell/init_chain.rs | 10 +- .../lib/node/ledger/shell/vote_extensions.rs | 3 +- .../shell/vote_extensions/bridge_pool_vext.rs | 8 +- benches/host_env.rs | 2 +- benches/native_vps.rs | 12 +- benches/process_wrapper.rs | 3 +- benches/txs.rs | 6 +- benches/vps.rs | 6 +- .../transactions/ethereum_events/mod.rs | 2 +- .../protocol/validation/bridge_pool_roots.rs | 11 +- .../protocol/validation/ethereum_events.rs | 15 +- .../validation/validator_set_update.rs | 9 +- governance/Cargo.toml | 2 +- governance/src/cli/onchain.rs | 20 -- governance/src/lib.rs | 2 +- governance/src/parameters.rs | 4 +- governance/src/pgf/inflation.rs | 19 +- governance/src/pgf/parameters.rs | 4 +- governance/src/pgf/storage/keys.rs | 2 +- governance/src/pgf/storage/mod.rs | 19 +- governance/src/storage/mod.rs | 31 ++- governance/src/storage/proposal.rs | 29 +-- ibc/Cargo.toml | 3 + ibc/src/actions.rs | 190 ++++++++++++++++++ ibc/src/lib.rs | 2 + proof_of_stake/src/storage.rs | 6 +- proof_of_stake/src/tests/state_machine.rs | 1 + proof_of_stake/src/tests/state_machine_v2.rs | 1 + sdk/src/masp.rs | 9 +- sdk/src/queries/vp/pos.rs | 2 +- sdk/src/rpc.rs | 2 + sdk/src/signing.rs | 2 +- shared/src/ledger/native_vp/masp.rs | 34 ++-- shielded_token/src/conversion.rs | 10 +- shielded_token/src/storage_key.rs | 60 ++++-- shielded_token/src/utils.rs | 5 +- state/src/lib.rs | 4 +- state/src/wl_storage.rs | 1 + tests/src/e2e/ibc_tests.rs | 6 +- tx/src/types.rs | 8 +- vp_prelude/src/key.rs | 12 -- vp_prelude/src/token.rs | 69 ------- wasm/Cargo.lock | 37 ++-- wasm/wasm_source/src/tx_transfer.rs | 6 +- wasm_for_tests/wasm_source/Cargo.lock | 37 ++-- 49 files changed, 458 insertions(+), 329 deletions(-) create mode 100644 ibc/src/actions.rs delete mode 100644 vp_prelude/src/key.rs delete mode 100644 vp_prelude/src/token.rs diff --git a/Cargo.lock b/Cargo.lock index d7b589c935..18ccd64992 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4204,7 +4204,7 @@ dependencies = [ [[package]] name = "namada_account" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", @@ -4426,7 +4426,7 @@ dependencies = [ [[package]] name = "namada_gas" -version = "0.29.0" +version = "0.30.0" dependencies = [ "assert_matches", "borsh", @@ -4438,13 +4438,13 @@ dependencies = [ [[package]] name = "namada_governance" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", "namada_macros", "namada_parameters", - "namada_storage", + "namada_state", "namada_trans_token", "proptest", "serde 1.0.193", @@ -4455,15 +4455,18 @@ dependencies = [ [[package]] name = "namada_ibc" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "ibc", "ibc-derive", "ibc-testkit", "ics23", + "masp_primitives", "namada_core", + "namada_governance", "namada_parameters", + "namada_state", "namada_storage", "namada_trans_token", "primitive-types", @@ -4499,7 +4502,7 @@ dependencies = [ [[package]] name = "namada_merkle_tree" -version = "0.29.0" +version = "0.30.0" dependencies = [ "assert_matches", "borsh", @@ -4515,7 +4518,7 @@ dependencies = [ [[package]] name = "namada_parameters" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", @@ -4616,7 +4619,7 @@ dependencies = [ [[package]] name = "namada_shielded_token" -version = "0.29.0" +version = "0.30.0" dependencies = [ "masp_primitives", "namada_core", @@ -4632,7 +4635,7 @@ dependencies = [ [[package]] name = "namada_state" -version = "0.29.0" +version = "0.30.0" dependencies = [ "assert_matches", "borsh", @@ -4658,7 +4661,7 @@ dependencies = [ [[package]] name = "namada_storage" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "itertools 0.10.5", @@ -4732,7 +4735,7 @@ dependencies = [ [[package]] name = "namada_token" -version = "0.29.0" +version = "0.30.0" dependencies = [ "namada_core", "namada_shielded_token", @@ -4742,7 +4745,7 @@ dependencies = [ [[package]] name = "namada_trans_token" -version = "0.29.0" +version = "0.30.0" dependencies = [ "namada_core", "namada_storage", @@ -4750,7 +4753,7 @@ dependencies = [ [[package]] name = "namada_tx" -version = "0.29.0" +version = "0.30.0" dependencies = [ "ark-bls12-381", "assert_matches", @@ -4774,7 +4777,7 @@ dependencies = [ [[package]] name = "namada_tx_env" -version = "0.29.0" +version = "0.30.0" dependencies = [ "namada_core", "namada_storage", @@ -4813,7 +4816,7 @@ dependencies = [ [[package]] name = "namada_vote_ext" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "data-encoding", @@ -4824,7 +4827,7 @@ dependencies = [ [[package]] name = "namada_vp_env" -version = "0.29.0" +version = "0.30.0" dependencies = [ "derivative", "masp_primitives", diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index 6af0abaec9..23a9a84e37 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -38,7 +38,6 @@ use namada::ledger::pos::types::{CommissionPair, Slash}; use namada::ledger::pos::PosParams; use namada::ledger::queries::RPC; use namada::proof_of_stake::types::{ValidatorState, WeightedValidator}; -use namada::token; use namada::types::address::{Address, InternalAddress, MASP}; use namada::types::hash::Hash; use namada::types::ibc::{is_ibc_denom, IbcTokenHash}; @@ -49,6 +48,7 @@ use namada::types::storage::{ BlockHeight, BlockResults, Epoch, IndexedTx, Key, KeySeg, }; use namada::types::token::{Change, MaspDenom}; +use namada::{state as storage, token}; use namada_sdk::error::{ is_pinned_error, Error, PinnedBalanceError, QueryError, }; diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index c94c6aa838..8666e27bf7 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -11,8 +11,9 @@ use namada::governance::cli::offline::{ OfflineProposal, OfflineSignedProposal, OfflineVote, }; use namada::governance::cli::onchain::{ - DefaultProposal, PgfFundingProposal, PgfStewardProposal, ProposalVote, + DefaultProposal, PgfFundingProposal, PgfStewardProposal, }; +use namada::governance::ProposalVote; use namada::ibc::apps::transfer::types::Memo; use namada::state::EPOCH_SWITCH_BLOCKS_DELAY; use namada::tx::data::pos::{BecomeValidator, ConsensusKeyChange}; diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index c3d47b9b20..9707ee7811 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -3,12 +3,11 @@ use data_encoding::HEXUPPER; use masp_primitives::merkle_tree::CommitmentTree; use masp_primitives::sapling::Node; -use masp_proofs::bls12_381; use namada::governance::pgf::inflation as pgf_inflation; use namada::ledger::events::EventType; use namada::ledger::gas::{GasMetering, TxGasMeter}; use namada::ledger::pos::namada_proof_of_stake; -use namada::ledger::protocol; +use namada::ledger::protocol::{self, WrapperArgs}; use namada::proof_of_stake::storage::{ find_validator_by_raw_hash, read_last_block_proposer_address, write_last_block_proposer_address, @@ -21,7 +20,7 @@ use namada::state::{ use namada::token::conversion::update_allowed_conversions; use namada::tx::data::protocol::ProtocolTxType; use namada::types::key::tm_raw_hash_to_string; -use namada::types::storage::{BlockHash, BlockResults, Epoch, Header, KeySeg}; +use namada::types::storage::{BlockHash, BlockResults, Epoch, Header}; use namada::vote_ext::ethereum_events::MultiSignedEthEvent; use namada::vote_ext::ethereum_tx_data_variants; @@ -598,16 +597,15 @@ where tracing::info!("{}", stats.format_tx_executed()); // Update the MASP commitment tree anchor if the tree was updated - let tree_key = namada::core::types::token::masp_commitment_tree_key(); + let tree_key = token::storage_key::masp_commitment_tree_key(); if let Some(StorageModification::Write { value }) = self.wl_storage.write_log.read(&tree_key).0 { let updated_tree = CommitmentTree::::try_from_slice(value) .into_storage_result()?; - let anchor_key = - namada::core::types::token::masp_commitment_anchor_key( - updated_tree.root(), - ); + let anchor_key = token::storage_key::masp_commitment_anchor_key( + updated_tree.root(), + ); self.wl_storage.write(&anchor_key, ())?; } @@ -711,7 +709,10 @@ where )?; // Pgf inflation - pgf_inflation::apply_inflation(&mut self.wl_storage)?; + pgf_inflation::apply_inflation( + &mut self.wl_storage, + namada::ibc::transfer_over_ibc, + )?; for ibc_event in self.wl_storage.write_log_mut().take_ibc_events() { let mut event = Event::from(ibc_event.clone()); // Add the height for IBC event query @@ -859,7 +860,6 @@ mod test_finalize_block { use namada::ethereum_bridge::storage::wrapped_erc20s; use namada::governance::storage::keys::get_proposal_execution_key; use namada::governance::storage::proposal::ProposalType; - use namada::governance::storage::vote::VoteType; use namada::governance::{InitProposalData, VoteProposalData}; use namada::ledger::gas::VpGasMeter; use namada::ledger::native_vp::parameters::ParametersVp; @@ -894,6 +894,7 @@ mod test_finalize_block { use namada::types::uint::Uint; use namada::vote_ext::{ethereum_events, EthereumTxData}; use namada_sdk::eth_bridge::MinimumConfirmations; + use namada_sdk::governance::ProposalVote; use namada_sdk::proof_of_stake::storage::{ liveness_missed_votes_handle, liveness_sum_missed_votes_handle, read_consensus_validator_set_addresses, diff --git a/apps/src/lib/node/ledger/shell/init_chain.rs b/apps/src/lib/node/ledger/shell/init_chain.rs index aedb8dae43..74e3d671ce 100644 --- a/apps/src/lib/node/ledger/shell/init_chain.rs +++ b/apps/src/lib/node/ledger/shell/init_chain.rs @@ -11,9 +11,8 @@ use namada::ledger::{ibc, pos}; use namada::proof_of_stake::BecomeValidator; use namada::state::{DBIter, StorageHasher, StorageWrite, DB}; use namada::token::{credit_tokens, write_denom}; -use namada::types::address::{Address, MASP}; +use namada::types::address::Address; use namada::types::hash::Hash as CodeHash; -use namada::types::storage::KeySeg; use namada::types::time::{DateTimeUtc, TimeZone, Utc}; use namada::vm::validate_untrusted_wasm; use namada_sdk::eth_bridge::EthBridgeStatus; @@ -140,19 +139,18 @@ where CommitmentTree::empty(); let anchor = empty_commitment_tree.root(); let note_commitment_tree_key = - namada::core::types::token::masp_commitment_tree_key(); + token::storage_key::masp_commitment_tree_key(); self.wl_storage .write(¬e_commitment_tree_key, empty_commitment_tree) .unwrap(); let commitment_tree_anchor_key = - namada::core::types::token::masp_commitment_anchor_key(anchor); + token::storage_key::masp_commitment_anchor_key(anchor); self.wl_storage .write(&commitment_tree_anchor_key, ()) .unwrap(); // Init masp convert anchor - let convert_anchor_key = - namada::core::types::token::masp_convert_anchor_key(); + let convert_anchor_key = token::storage_key::masp_convert_anchor_key(); self.wl_storage.write( &convert_anchor_key, namada::types::hash::Hash( diff --git a/apps/src/lib/node/ledger/shell/vote_extensions.rs b/apps/src/lib/node/ledger/shell/vote_extensions.rs index fe5c9c3459..2f0454bbb4 100644 --- a/apps/src/lib/node/ledger/shell/vote_extensions.rs +++ b/apps/src/lib/node/ledger/shell/vote_extensions.rs @@ -9,7 +9,6 @@ use namada::ethereum_bridge::protocol::transactions::ethereum_events::sign_ether use namada::ethereum_bridge::protocol::transactions::validator_set_update::sign_validator_set_update; pub use namada::ethereum_bridge::protocol::validation::VoteExtensionError; use namada::tx::Signed; -use namada::types::keccak::keccak_hash; use namada::vote_ext::{ bridge_pool_roots, ethereum_events, validator_set_update, EthereumTxData, VoteExtension, @@ -70,6 +69,7 @@ where protocol_key, ethereum_events, ) + .map(|ethereum_events::SignedVext(ext)| ext) } /// Extend PreCommit votes with [`bridge_pool_roots::Vext`] instances. @@ -94,6 +94,7 @@ where eth_hot_key, protocol_key, ) + .map(|bridge_pool_roots::SignedVext(ext)| ext) } /// Extend PreCommit votes with [`validator_set_update::Vext`] diff --git a/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs b/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs index 5e0fe9e55e..f6f9f10308 100644 --- a/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs +++ b/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs @@ -281,7 +281,7 @@ mod test_bp_vote_extensions { validate_bp_roots_vext( &shell.wl_storage, &bp_root.0, - shell.wl_storage.pos_queries().get_current_decision_height(), + shell.get_current_decision_height(), ) .is_err() ) @@ -470,7 +470,7 @@ mod test_bp_vote_extensions { validate_bp_roots_vext( &shell.wl_storage, &bp_root.0, - shell.wl_storage.pos_queries().get_current_decision_height() + shell.get_current_decision_height() ) .is_ok() ); @@ -490,7 +490,7 @@ mod test_bp_vote_extensions { validate_bp_roots_vext( &shell.wl_storage, &bp_root.0, - shell.wl_storage.pos_queries().get_current_decision_height() + shell.get_current_decision_height() ) .is_ok() ); @@ -545,7 +545,7 @@ mod test_bp_vote_extensions { validate_bp_roots_vext( &shell.wl_storage, &bp_root.0, - shell.wl_storage.pos_queries().get_current_decision_height() + shell.get_current_decision_height() ) .is_err() ); diff --git a/benches/host_env.rs b/benches/host_env.rs index 3dfbda3738..ca38170977 100644 --- a/benches/host_env.rs +++ b/benches/host_env.rs @@ -3,8 +3,8 @@ use std::collections::{HashMap, HashSet}; use criterion::{criterion_group, criterion_main, Criterion}; use namada::core::types::account::AccountPublicKeysMap; use namada::core::types::address; -use namada::core::types::token::{Amount, Transfer}; use namada::ledger::storage::DB; +use namada::token::{Amount, Transfer}; use namada::tx::Signature; use namada::vm::wasm::TxCache; use namada_apps::bench_utils::{ diff --git a/benches/native_vps.rs b/benches/native_vps.rs index b3f6a39a9f..b1be552bc1 100644 --- a/benches/native_vps.rs +++ b/benches/native_vps.rs @@ -6,13 +6,10 @@ use std::str::FromStr; use criterion::{criterion_group, criterion_main, Criterion}; use masp_primitives::sapling::Node; use namada::core::types::address::{self, Address}; -use namada::core::types::token::{Amount, Transfer}; use namada::eth_bridge::storage::whitelist; use namada::governance::pgf::storage::steward::StewardDetail; use namada::governance::storage::proposal::ProposalType; -use namada::governance::storage::vote::{ - ProposalVote, StorageProposalVote, VoteType, -}; +use namada::governance::storage::vote::ProposalVote; use namada::governance::{InitProposalData, VoteProposalData}; use namada::ibc::core::channel::types::channel::Order; use namada::ibc::core::channel::types::msgs::MsgChannelOpenInit; @@ -44,7 +41,8 @@ use namada::proof_of_stake::KeySeg; use namada::sdk::masp::verify_shielded_tx; use namada::sdk::masp_primitives::merkle_tree::CommitmentTree; use namada::sdk::masp_primitives::transaction::Transaction; -use namada::state::{StorageRead, StorageWrite}; +use namada::state::{Epoch, StorageRead, StorageWrite, TxIndex}; +use namada::token::{Amount, Transfer}; use namada::tx::{Code, Section, Tx}; use namada::types::address::InternalAddress; use namada::types::eth_bridge_pool::{GasFee, PendingTransfer}; @@ -504,14 +502,14 @@ fn setup_storage_for_masp_verification( shielded_ctx.shell.wl_storage.commit_tx(); // Update the anchor in storage - let tree_key = namada::core::types::token::masp_commitment_tree_key(); + let tree_key = namada::token::storage_key::masp_commitment_tree_key(); let updated_tree: CommitmentTree = shielded_ctx .shell .wl_storage .read(&tree_key) .unwrap() .unwrap(); - let anchor_key = namada::core::types::token::masp_commitment_anchor_key( + let anchor_key = namada::token::storage_key::masp_commitment_anchor_key( updated_tree.root(), ); shielded_ctx diff --git a/benches/process_wrapper.rs b/benches/process_wrapper.rs index 110e59c118..4a12b34836 100644 --- a/benches/process_wrapper.rs +++ b/benches/process_wrapper.rs @@ -1,8 +1,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use namada::core::types::address; -use namada::core::types::token::{Amount, Transfer}; use namada::ledger::storage::TempWlStorage; -use namada::token::DenominatedAmount; +use namada::token::{Amount, DenominatedAmount, Transfer}; use namada::tx::data::{Fee, WrapperTx}; use namada::tx::Signature; use namada::types::key::RefTo; diff --git a/benches/txs.rs b/benches/txs.rs index a69585bb5c..1409c67a83 100644 --- a/benches/txs.rs +++ b/benches/txs.rs @@ -6,12 +6,9 @@ use namada::account::{InitAccount, UpdateAccount}; use namada::core::types::key::{ common, SecretKey as SecretKeyInterface, SigScheme, }; -use namada::core::types::token::Amount; use namada::governance::pgf::storage::steward::StewardDetail; use namada::governance::storage::proposal::ProposalType; -use namada::governance::storage::vote::{ - ProposalVote, StorageProposalVote, VoteType, -}; +use namada::governance::storage::vote::ProposalVote; use namada::governance::{InitProposalData, VoteProposalData}; use namada::ibc::core::channel::types::channel::Order; use namada::ibc::core::channel::types::msgs::MsgChannelOpenInit; @@ -28,6 +25,7 @@ use namada::proof_of_stake::storage::read_pos_params; use namada::proof_of_stake::types::SlashType; use namada::proof_of_stake::{self, KeySeg}; use namada::state::{StorageRead, StorageWrite}; +use namada::token::Amount; use namada::tx::data::pos::{ BecomeValidator, Bond, CommissionChange, ConsensusKeyChange, MetaDataChange, Redelegation, Withdraw, diff --git a/benches/vps.rs b/benches/vps.rs index 3c7f17a40b..cec7814bb7 100644 --- a/benches/vps.rs +++ b/benches/vps.rs @@ -6,12 +6,10 @@ use namada::core::types::address::{self, Address}; use namada::core::types::key::{ common, SecretKey as SecretKeyInterface, SigScheme, }; -use namada::core::types::token::{Amount, Transfer}; -use namada::governance::storage::vote::{ - ProposalVote, StorageProposalVote, VoteType, -}; +use namada::governance::storage::vote::ProposalVote; use namada::governance::VoteProposalData; use namada::ledger::gas::{TxGasMeter, VpGasMeter}; +use namada::token::{Amount, Transfer}; use namada::tx::data::pos::{Bond, CommissionChange}; use namada::tx::{Code, Section}; use namada::types::hash::Hash; diff --git a/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs b/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs index 97453b8da2..b9b2fe2731 100644 --- a/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs +++ b/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs @@ -70,7 +70,7 @@ where tracing::debug!("New Ethereum events - {:#?}", ext.ethereum_events); } - Some(ext.sign(protocol_key)) + Some(ext.sign(protocol_key).into()) } /// Applies derived state changes to storage, based on Ethereum `events` which diff --git a/ethereum_bridge/src/protocol/validation/bridge_pool_roots.rs b/ethereum_bridge/src/protocol/validation/bridge_pool_roots.rs index de23245a80..e178a1fa98 100644 --- a/ethereum_bridge/src/protocol/validation/bridge_pool_roots.rs +++ b/ethereum_bridge/src/protocol/validation/bridge_pool_roots.rs @@ -1,12 +1,11 @@ //! Bridge pool roots validation. -use namada_core::ledger::storage; -use namada_core::ledger::storage::WlStorage; -use namada_core::proto::{SignableEthMessage, Signed}; use namada_core::types::keccak::keccak_hash; use namada_core::types::storage::BlockHeight; -use namada_core::types::vote_extensions::bridge_pool_roots; use namada_proof_of_stake::pos_queries::PosQueries; +use namada_state::{DBIter, StorageHasher, WlStorage, DB}; +use namada_tx::{SignableEthMessage, Signed}; +use namada_vote_ext::bridge_pool_roots; use super::VoteExtensionError; use crate::storage::eth_bridge_queries::EthBridgeQueries; @@ -27,8 +26,8 @@ pub fn validate_bp_roots_vext( last_height: BlockHeight, ) -> Result<(), VoteExtensionError> where - D: 'static + storage::DB + for<'iter> storage::DBIter<'iter>, - H: 'static + storage::StorageHasher, + D: 'static + DB + for<'iter> DBIter<'iter>, + H: 'static + StorageHasher, { // NOTE: for ABCI++, we should pass // `last_height` here, instead of `ext.data.block_height` diff --git a/ethereum_bridge/src/protocol/validation/ethereum_events.rs b/ethereum_bridge/src/protocol/validation/ethereum_events.rs index c49968d1ee..a71d743c35 100644 --- a/ethereum_bridge/src/protocol/validation/ethereum_events.rs +++ b/ethereum_bridge/src/protocol/validation/ethereum_events.rs @@ -1,11 +1,10 @@ //! Ethereum events validation. -use namada_core::ledger::storage; -use namada_core::ledger::storage::WlStorage; -use namada_core::proto::Signed; use namada_core::types::storage::BlockHeight; -use namada_core::types::vote_extensions::ethereum_events; use namada_proof_of_stake::pos_queries::PosQueries; +use namada_state::{DBIter, StorageHasher, WlStorage, DB}; +use namada_tx::Signed; +use namada_vote_ext::ethereum_events; use super::VoteExtensionError; use crate::storage::eth_bridge_queries::EthBridgeQueries; @@ -25,8 +24,8 @@ pub fn validate_eth_events_vext( last_height: BlockHeight, ) -> Result<(), VoteExtensionError> where - D: 'static + storage::DB + for<'iter> storage::DBIter<'iter>, - H: 'static + storage::StorageHasher, + D: 'static + DB + for<'iter> DBIter<'iter>, + H: 'static + StorageHasher, { // NOTE: for ABCI++, we should pass // `last_height` here, instead of `ext.data.block_height` @@ -107,8 +106,8 @@ fn validate_eth_events( ext: ðereum_events::Vext, ) -> Result<(), VoteExtensionError> where - D: 'static + storage::DB + for<'iter> storage::DBIter<'iter>, - H: 'static + storage::StorageHasher, + D: 'static + DB + for<'iter> DBIter<'iter>, + H: 'static + StorageHasher, { // verify if we have any duplicate Ethereum events, // and if these are sorted in ascending order diff --git a/ethereum_bridge/src/protocol/validation/validator_set_update.rs b/ethereum_bridge/src/protocol/validation/validator_set_update.rs index 3b0163f536..ec22576393 100644 --- a/ethereum_bridge/src/protocol/validation/validator_set_update.rs +++ b/ethereum_bridge/src/protocol/validation/validator_set_update.rs @@ -1,10 +1,9 @@ //! Validator set update validation. -use namada_core::ledger::storage; -use namada_core::ledger::storage::WlStorage; use namada_core::types::storage::Epoch; -use namada_core::types::vote_extensions::validator_set_update; use namada_proof_of_stake::pos_queries::PosQueries; +use namada_state::{DBIter, StorageHasher, WlStorage, DB}; +use namada_vote_ext::validator_set_update; use super::VoteExtensionError; use crate::storage::eth_bridge_queries::EthBridgeQueries; @@ -33,8 +32,8 @@ pub fn validate_valset_upd_vext( last_epoch: Epoch, ) -> Result<(), VoteExtensionError> where - D: 'static + storage::DB + for<'iter> storage::DBIter<'iter>, - H: 'static + storage::StorageHasher, + D: 'static + DB + for<'iter> DBIter<'iter>, + H: 'static + StorageHasher, { if wl_storage.storage.last_block.is_none() { tracing::debug!( diff --git a/governance/Cargo.toml b/governance/Cargo.toml index de47365d44..cdc5265873 100644 --- a/governance/Cargo.toml +++ b/governance/Cargo.toml @@ -19,7 +19,7 @@ testing = ["proptest"] namada_core = { path = "../core" } namada_macros = {path = "../macros"} namada_parameters = {path = "../parameters"} -namada_storage = {path = "../storage"} +namada_state = {path = "../state"} namada_trans_token = {path = "../trans_token"} borsh.workspace = true diff --git a/governance/src/cli/onchain.rs b/governance/src/cli/onchain.rs index 227c2dfa09..160df5b8e8 100644 --- a/governance/src/cli/onchain.rs +++ b/governance/src/cli/onchain.rs @@ -254,26 +254,6 @@ pub struct PgfSteward { pub address: Address, } -/// The target of a PGF payment -#[derive( - Debug, - Clone, - PartialEq, - BorshSerialize, - BorshDeserialize, - Serialize, - Deserialize, - Ord, - Eq, - PartialOrd, -)] -pub struct PGFTarget { - /// The target address - pub target: Address, - /// The amount of token to fund the target address - pub amount: token::Amount, -} - /// Pgf action #[derive( Debug, Clone, BorshSerialize, BorshDeserialize, Serialize, Deserialize, diff --git a/governance/src/lib.rs b/governance/src/lib.rs index f30dffe5fd..6a20b5f591 100644 --- a/governance/src/lib.rs +++ b/governance/src/lib.rs @@ -13,7 +13,7 @@ pub mod storage; pub mod utils; pub use storage::proposal::{InitProposalData, ProposalType, VoteProposalData}; -pub use storage::vote::{StorageProposalVote, VoteType}; +pub use storage::vote::{ProposalVote, VoteType}; pub use storage::{init_proposal, is_proposal_accepted, vote_proposal}; /// The governance internal address diff --git a/governance/src/parameters.rs b/governance/src/parameters.rs index ee8686854c..a93eefad43 100644 --- a/governance/src/parameters.rs +++ b/governance/src/parameters.rs @@ -1,6 +1,6 @@ use namada_core::borsh::{BorshDeserialize, BorshSerialize}; use namada_core::types::token; -use namada_storage::{Result, StorageRead, StorageWrite}; +use namada_state::{StorageRead, StorageResult, StorageWrite}; use super::storage::keys as goverance_storage; @@ -46,7 +46,7 @@ impl Default for GovernanceParameters { impl GovernanceParameters { /// Initialize governance parameters into storage - pub fn init_storage(&self, storage: &mut S) -> Result<()> + pub fn init_storage(&self, storage: &mut S) -> StorageResult<()> where S: StorageRead + StorageWrite, { diff --git a/governance/src/pgf/inflation.rs b/governance/src/pgf/inflation.rs index 37e5198a25..7fcc0b5c09 100644 --- a/governance/src/pgf/inflation.rs +++ b/governance/src/pgf/inflation.rs @@ -1,23 +1,32 @@ //! PGF lib code. +use namada_core::types::address::Address; use namada_core::types::dec::Dec; use namada_core::types::token; -use namada_ibc::transfer_over_ibc; use namada_parameters::storage as params_storage; -use namada_storage::{StorageRead, StorageWrite}; +use namada_state::{ + DBIter, StorageHasher, StorageRead, StorageResult, WlStorage, DB, +}; use namada_trans_token::credit_tokens; use namada_trans_token::storage_key::minted_balance_key; use crate::pgf::storage::{get_parameters, get_payments, get_stewards}; -use crate::storage::proposal::PGFTarget; +use crate::storage::proposal::{PGFIbcTarget, PGFTarget}; /// Apply the PGF inflation. -pub fn apply_inflation( +pub fn apply_inflation( storage: &mut WlStorage, -) -> namada_storage::Result<()> + transfer_over_ibc: F, +) -> StorageResult<()> where D: DB + for<'iter> DBIter<'iter> + Sync + 'static, H: StorageHasher + Sync + 'static, + F: Fn( + &mut WlStorage, + &Address, + &Address, + &PGFIbcTarget, + ) -> StorageResult<()>, { let pgf_parameters = get_parameters(storage)?; let staking_token = storage.get_native_token()?; diff --git a/governance/src/pgf/parameters.rs b/governance/src/pgf/parameters.rs index 7ca973dbbf..416cbcb931 100644 --- a/governance/src/pgf/parameters.rs +++ b/governance/src/pgf/parameters.rs @@ -3,7 +3,7 @@ use std::collections::BTreeSet; use namada_core::borsh::{BorshDeserialize, BorshSerialize}; use namada_core::types::address::Address; use namada_core::types::dec::Dec; -use namada_storage::{Result, StorageRead, StorageWrite}; +use namada_state::{StorageRead, StorageResult, StorageWrite}; use serde::{Deserialize, Serialize}; use super::storage::keys as pgf_storage; @@ -44,7 +44,7 @@ impl Default for PgfParameters { impl PgfParameters { /// Initialize governance parameters into storage - pub fn init_storage(&self, storage: &mut S) -> Result<()> + pub fn init_storage(&self, storage: &mut S) -> StorageResult<()> where S: StorageRead + StorageWrite, { diff --git a/governance/src/pgf/storage/keys.rs b/governance/src/pgf/storage/keys.rs index 7ae8884eef..5d581d27a7 100644 --- a/governance/src/pgf/storage/keys.rs +++ b/governance/src/pgf/storage/keys.rs @@ -1,7 +1,7 @@ use namada_core::types::address::Address; use namada_core::types::storage::{DbKeySeg, Key, KeySeg}; use namada_macros::StorageKeys; -use namada_storage::collections::{lazy_map, LazyCollection, LazyMap}; +use namada_state::collections::{lazy_map, LazyCollection, LazyMap}; use crate::pgf::storage::steward::StewardDetail; use crate::pgf::ADDRESS; diff --git a/governance/src/pgf/storage/mod.rs b/governance/src/pgf/storage/mod.rs index 63ea00b3a7..f965da157d 100644 --- a/governance/src/pgf/storage/mod.rs +++ b/governance/src/pgf/storage/mod.rs @@ -9,7 +9,7 @@ use std::collections::HashMap; use namada_core::types::address::Address; use namada_core::types::dec::Dec; -use namada_storage::{Result, StorageRead, StorageWrite}; +use namada_state::{StorageRead, StorageResult, StorageWrite}; use crate::pgf::parameters::PgfParameters; use crate::pgf::storage::keys as pgf_keys; @@ -17,7 +17,7 @@ use crate::pgf::storage::steward::StewardDetail; use crate::storage::proposal::StoragePgfFunding; /// Query the current pgf steward set -pub fn get_stewards(storage: &S) -> Result> +pub fn get_stewards(storage: &S) -> StorageResult> where S: StorageRead, { @@ -36,7 +36,7 @@ where pub fn get_steward( storage: &S, address: &Address, -) -> Result> +) -> StorageResult> where S: StorageRead, { @@ -44,7 +44,7 @@ where } /// Check if an address is a steward -pub fn is_steward(storage: &S, address: &Address) -> Result +pub fn is_steward(storage: &S, address: &Address) -> StorageResult where S: StorageRead, { @@ -52,7 +52,10 @@ where } /// Remove a steward -pub fn remove_steward(storage: &mut S, address: &Address) -> Result<()> +pub fn remove_steward( + storage: &mut S, + address: &Address, +) -> StorageResult<()> where S: StorageRead + StorageWrite, { @@ -62,7 +65,7 @@ where } /// Query the current pgf continous payments -pub fn get_payments(storage: &S) -> Result> +pub fn get_payments(storage: &S) -> StorageResult> where S: StorageRead, { @@ -78,7 +81,7 @@ where } /// Query the pgf parameters -pub fn get_parameters(storage: &S) -> Result +pub fn get_parameters(storage: &S) -> StorageResult where S: StorageRead, { @@ -105,7 +108,7 @@ pub fn update_commission( storage: &mut S, address: Address, reward_distribution: HashMap, -) -> Result<()> +) -> StorageResult<()> where S: StorageRead + StorageWrite, { diff --git a/governance/src/storage/mod.rs b/governance/src/storage/mod.rs index d3bceba994..84b844ece0 100644 --- a/governance/src/storage/mod.rs +++ b/governance/src/storage/mod.rs @@ -12,7 +12,9 @@ use std::collections::BTreeMap; use namada_core::borsh::BorshDeserialize; use namada_core::types::address::Address; use namada_core::types::storage::Epoch; -use namada_storage::{iter_prefix, Error, Result, StorageRead, StorageWrite}; +use namada_state::{ + iter_prefix, StorageError, StorageRead, StorageResult, StorageWrite, +}; use namada_trans_token as token; use crate::parameters::GovernanceParameters; @@ -30,7 +32,7 @@ pub fn init_proposal( data: InitProposalData, content: Vec, code: Option>, -) -> Result<()> +) -> StorageResult<()> where S: StorageRead + StorageWrite, { @@ -55,7 +57,7 @@ where governance_keys::get_proposal_code_key(proposal_id); let proposal_code = code .clone() - .ok_or(Error::new_const("Missing proposal code"))?; + .ok_or(StorageError::new_const("Missing proposal code"))?; storage.write_bytes(&proposal_code_key, proposal_code)? } _ => storage.write(&proposal_type_key, data.r#type.clone())?, @@ -76,7 +78,7 @@ where let proposal_code_key = governance_keys::get_proposal_code_key(proposal_id); let proposal_code = - code.ok_or(Error::new_const("Missing proposal code"))?; + code.ok_or(StorageError::new_const("Missing proposal code"))?; storage.write_bytes(&proposal_code_key, proposal_code)?; } @@ -107,7 +109,10 @@ where } /// A proposal vote transaction. -pub fn vote_proposal(storage: &mut S, data: VoteProposalData) -> Result<()> +pub fn vote_proposal( + storage: &mut S, + data: VoteProposalData, +) -> StorageResult<()> where S: StorageRead + StorageWrite, { @@ -126,7 +131,7 @@ where pub fn get_proposal_by_id( storage: &S, id: u64, -) -> Result> +) -> StorageResult> where S: StorageRead, { @@ -159,7 +164,10 @@ where } /// Query all the votes for a proposal_id -pub fn get_proposal_votes(storage: &S, proposal_id: u64) -> Result> +pub fn get_proposal_votes( + storage: &S, + proposal_id: u64, +) -> StorageResult> where S: StorageRead, { @@ -194,7 +202,10 @@ where } /// Check if an accepted proposal is being executed -pub fn is_proposal_accepted(storage: &S, tx_data: &[u8]) -> Result +pub fn is_proposal_accepted( + storage: &S, + tx_data: &[u8], +) -> StorageResult where S: StorageRead, { @@ -210,7 +221,7 @@ where } /// Get governance parameters -pub fn get_parameters(storage: &S) -> Result +pub fn get_parameters(storage: &S) -> StorageResult where S: StorageRead, { @@ -247,7 +258,7 @@ where } /// Get governance "max_proposal_period" parameter -pub fn get_max_proposal_period(storage: &S) -> Result +pub fn get_max_proposal_period(storage: &S) -> StorageResult where S: StorageRead, { diff --git a/governance/src/storage/proposal.rs b/governance/src/storage/proposal.rs index 5062a11dc4..ef680228be 100644 --- a/governance/src/storage/proposal.rs +++ b/governance/src/storage/proposal.rs @@ -6,13 +6,14 @@ use namada_core::ibc::core::host::types::identifiers::{ChannelId, PortId}; use namada_core::types::address::Address; use namada_core::types::hash::Hash; use namada_core::types::storage::Epoch; +use namada_trans_token::Amount; use serde::{Deserialize, Serialize}; use thiserror::Error; -use super::vote::StorageProposalVote; +use super::vote::ProposalVote; use crate::cli::onchain::{ - DefaultProposal, PGFTarget, PgfAction, PgfContinous, PgfFundingProposal, - PgfRetro, PgfSteward, PgfStewardProposal, StewardsUpdate, + DefaultProposal, PgfAction, PgfContinous, PgfFundingProposal, PgfRetro, + PgfSteward, PgfStewardProposal, StewardsUpdate, }; use crate::utils::{ProposalStatus, TallyType}; @@ -35,7 +36,7 @@ pub enum ProposalError { )] pub struct InitProposalData { /// The proposal id - pub id: Option, + pub id: u64, /// The proposal content pub content: Hash, /// The proposal author address @@ -74,7 +75,7 @@ pub struct VoteProposalData { /// The proposal id pub id: u64, /// The proposal vote - pub vote: StorageProposalVote, + pub vote: ProposalVote, /// The proposal author address pub voter: Address, /// Delegator addreses @@ -125,12 +126,8 @@ impl TryFrom for InitProposalData { .continuous .iter() .cloned() - .map(|funding| { - let target = PGFTarget { - target: funding.address, - amount: funding.amount, - }; - if funding.amount.is_zero() { + .map(|target| { + if target.amount().is_zero() { PGFAction::Continuous(AddRemove::Remove(target)) } else { PGFAction::Continuous(AddRemove::Add(target)) @@ -143,13 +140,7 @@ impl TryFrom for InitProposalData { .retro .iter() .cloned() - .map(|funding| { - let target = PGFTarget { - target: funding.address, - amount: funding.amount, - }; - PGFAction::Retro(target) - }) + .map(PGFAction::Retro) .collect::>(); let extra_data = [continous_fundings, retro_fundings].concat(); @@ -636,7 +627,7 @@ pub mod testing { prop_compose! { /// Generate a proposal initialization pub fn arb_init_proposal()( - id: Option, + id: u64, content in arb_hash(), author in arb_non_internal_address(), r#type in arb_proposal_type(), diff --git a/ibc/Cargo.toml b/ibc/Cargo.toml index 1246ff11cb..27a4065e5b 100644 --- a/ibc/Cargo.toml +++ b/ibc/Cargo.toml @@ -18,7 +18,9 @@ testing = ["namada_core/testing", "ibc-testkit", "proptest"] [dependencies] namada_core = { path = "../core" } +namada_governance = { path = "../governance" } namada_parameters = { path = "../parameters" } +namada_state = { path = "../state" } namada_storage = { path = "../storage" } namada_trans_token = { path = "../trans_token" } @@ -27,6 +29,7 @@ ibc.workspace = true ibc-derive.workspace = true ibc-testkit = {workspace = true, optional = true} ics23.workspace = true +masp_primitives.workspace = true primitive-types.workspace = true proptest = { workspace = true, optional = true } prost.workspace = true diff --git a/ibc/src/actions.rs b/ibc/src/actions.rs new file mode 100644 index 0000000000..f56192802b --- /dev/null +++ b/ibc/src/actions.rs @@ -0,0 +1,190 @@ +//! Implementation of `IbcActions` with the protocol storage + +use std::cell::RefCell; +use std::rc::Rc; + +use namada_core::ibc::apps::transfer::types::msgs::transfer::MsgTransfer; +use namada_core::ibc::apps::transfer::types::packet::PacketData; +use namada_core::ibc::apps::transfer::types::PrefixedCoin; +use namada_core::ibc::core::channel::types::timeout::TimeoutHeight; +use namada_core::ibc::primitives::Msg; +use namada_core::tendermint::Time as TmTime; +use namada_core::types::address::{Address, InternalAddress}; +use namada_core::types::hash::Hash; +use namada_core::types::ibc::IbcEvent; +use namada_core::types::storage::Epochs; +use namada_core::types::time::DateTimeUtc; +use namada_core::types::token::DenominatedAmount; +use namada_governance::storage::proposal::PGFIbcTarget; +use namada_parameters::read_epoch_duration_parameter; +use namada_state::wl_storage::{PrefixIter, WriteLogAndStorage}; +use namada_state::write_log::{self, WriteLog}; +use namada_state::{ + self as storage, iter_prefix_post, DBIter, ResultExt, State, StorageError, + StorageHasher, StorageResult, StorageWrite, WlStorage, DB, +}; +use namada_storage::StorageRead; +use namada_trans_token as token; + +use crate::{IbcActions, IbcCommonContext, IbcStorageContext}; + +/// IBC protocol context +#[derive(Debug)] +pub struct IbcProtocolContext<'a, D, H> +where + D: DB + for<'iter> DBIter<'iter>, + H: StorageHasher, +{ + wl_storage: &'a mut WlStorage, +} + +impl WriteLogAndStorage for IbcProtocolContext<'_, D, H> +where + D: DB + for<'iter> DBIter<'iter>, + H: StorageHasher, +{ + type D = D; + type H = H; + + fn write_log(&self) -> &WriteLog { + self.wl_storage.write_log() + } + + fn write_log_mut(&mut self) -> &mut WriteLog { + self.wl_storage.write_log_mut() + } + + fn storage(&self) -> &State { + self.wl_storage.storage() + } + + fn split_borrow(&mut self) -> (&mut WriteLog, &State) { + self.wl_storage.split_borrow() + } + + fn write_tx_hash(&mut self, hash: Hash) -> write_log::Result<()> { + self.wl_storage.write_tx_hash(hash) + } +} +namada_state::impl_storage_traits!(IbcProtocolContext<'_, D, H>); + +impl IbcStorageContext for IbcProtocolContext<'_, D, H> +where + D: DB + for<'iter> DBIter<'iter> + 'static, + H: StorageHasher + 'static, +{ + fn emit_ibc_event(&mut self, event: IbcEvent) -> Result<(), StorageError> { + self.wl_storage.write_log.emit_ibc_event(event); + Ok(()) + } + + /// Get IBC events + fn get_ibc_events( + &self, + event_type: impl AsRef, + ) -> Result, StorageError> { + Ok(self + .wl_storage + .write_log + .get_ibc_events() + .iter() + .filter(|event| event.event_type == event_type.as_ref()) + .cloned() + .collect()) + } + + /// Transfer token + fn transfer_token( + &mut self, + src: &Address, + dest: &Address, + token: &Address, + amount: DenominatedAmount, + ) -> Result<(), StorageError> { + token::transfer(self, token, src, dest, amount.amount()) + } + + /// Handle masp tx + fn handle_masp_tx( + &mut self, + _shielded: &masp_primitives::transaction::Transaction, + _pin_key: Option<&str>, + ) -> Result<(), StorageError> { + unimplemented!("No MASP transfer in an IBC protocol transaction") + } + + /// Mint token + fn mint_token( + &mut self, + target: &Address, + token: &Address, + amount: DenominatedAmount, + ) -> Result<(), StorageError> { + token::credit_tokens(self.wl_storage, token, target, amount.amount())?; + let minter_key = token::storage_key::minter_key(token); + self.wl_storage + .write(&minter_key, Address::Internal(InternalAddress::Ibc)) + } + + /// Burn token + fn burn_token( + &mut self, + target: &Address, + token: &Address, + amount: DenominatedAmount, + ) -> Result<(), StorageError> { + token::burn(self.wl_storage, token, target, amount.amount()) + } + + fn log_string(&self, message: String) { + tracing::trace!(message); + } +} + +impl IbcCommonContext for IbcProtocolContext<'_, D, H> +where + D: DB + for<'iter> DBIter<'iter> + 'static, + H: StorageHasher + 'static, +{ +} + +/// Transfer tokens over IBC +pub fn transfer_over_ibc( + wl_storage: &mut WlStorage, + token: &Address, + source: &Address, + target: &PGFIbcTarget, +) -> StorageResult<()> +where + D: DB + for<'iter> DBIter<'iter> + 'static, + H: StorageHasher + 'static, +{ + let token = PrefixedCoin { + denom: token.to_string().parse().expect("invalid token"), + amount: target.amount.into(), + }; + let packet_data = PacketData { + token, + sender: source.to_string().into(), + receiver: target.target.clone().into(), + memo: String::default().into(), + }; + let timeout_timestamp = DateTimeUtc::now() + + read_epoch_duration_parameter(wl_storage)?.min_duration; + let timeout_timestamp = + TmTime::try_from(timeout_timestamp).into_storage_result()?; + let ibc_message = MsgTransfer { + port_id_on_a: target.port_id.clone(), + chan_id_on_a: target.channel_id.clone(), + packet_data, + timeout_height_on_b: TimeoutHeight::Never, + timeout_timestamp_on_b: timeout_timestamp.into(), + }; + let any_msg = ibc_message.to_any(); + let mut data = vec![]; + prost::Message::encode(&any_msg, &mut data).into_storage_result()?; + + let ctx = IbcProtocolContext { wl_storage }; + let mut actions = IbcActions::new(Rc::new(RefCell::new(ctx))); + actions.execute(&data).into_storage_result() +} diff --git a/ibc/src/lib.rs b/ibc/src/lib.rs index 535d051423..0d566a39a1 100644 --- a/ibc/src/lib.rs +++ b/ibc/src/lib.rs @@ -1,5 +1,6 @@ //! IBC library code +mod actions; pub mod context; pub mod storage; @@ -8,6 +9,7 @@ use std::fmt::Debug; use std::rc::Rc; use std::str::FromStr; +pub use actions::transfer_over_ibc; use borsh::BorshDeserialize; pub use context::common::IbcCommonContext; use context::router::IbcRouter; diff --git a/proof_of_stake/src/storage.rs b/proof_of_stake/src/storage.rs index 8de0e8d068..36c0af84ac 100644 --- a/proof_of_stake/src/storage.rs +++ b/proof_of_stake/src/storage.rs @@ -755,7 +755,7 @@ where pub fn read_validator_avatar( storage: &S, validator: &Address, -) -> storage_api::Result> +) -> namada_storage::Result> where S: StorageRead, { @@ -768,7 +768,7 @@ pub fn write_validator_avatar( storage: &mut S, validator: &Address, avatar: &String, -) -> storage_api::Result<()> +) -> namada_storage::Result<()> where S: StorageRead + StorageWrite, { @@ -882,7 +882,7 @@ pub fn get_consensus_key( storage: &S, addr: &Address, epoch: Epoch, -) -> storage_api::Result> +) -> namada_storage::Result> where S: StorageRead, { diff --git a/proof_of_stake/src/tests/state_machine.rs b/proof_of_stake/src/tests/state_machine.rs index c3bbb559bb..3dc34c36fa 100644 --- a/proof_of_stake/src/tests/state_machine.rs +++ b/proof_of_stake/src/tests/state_machine.rs @@ -12,6 +12,7 @@ use namada_core::types::key; use namada_core::types::key::common::PublicKey; use namada_core::types::storage::Epoch; use namada_core::types::token::Change; +use namada_governance::parameters::GovernanceParameters; use namada_state::testing::TestWlStorage; use namada_storage::collections::lazy_map::{ Collectable, NestedSubKey, SubKey, diff --git a/proof_of_stake/src/tests/state_machine_v2.rs b/proof_of_stake/src/tests/state_machine_v2.rs index c324771415..872625f9d5 100644 --- a/proof_of_stake/src/tests/state_machine_v2.rs +++ b/proof_of_stake/src/tests/state_machine_v2.rs @@ -13,6 +13,7 @@ use namada_core::types::key; use namada_core::types::key::common::PublicKey; use namada_core::types::storage::Epoch; use namada_core::types::token::Change; +use namada_governance::parameters::GovernanceParameters; use namada_state::testing::TestWlStorage; use namada_storage::collections::lazy_map::{NestedSubKey, SubKey}; use namada_storage::StorageRead; diff --git a/sdk/src/masp.rs b/sdk/src/masp.rs index ffc852e592..4ad15b808d 100644 --- a/sdk/src/masp.rs +++ b/sdk/src/masp.rs @@ -51,7 +51,6 @@ use masp_proofs::bellman::groth16::PreparedVerifyingKey; use masp_proofs::bls12_381::Bls12; use masp_proofs::prover::LocalTxProver; use masp_proofs::sapling::SaplingVerificationContext; -use namada_core::ledger::ibc::IbcMessage; use namada_core::types::address::{Address, MASP}; use namada_core::types::ibc::IbcShieldedTransfer; use namada_core::types::masp::{ @@ -60,8 +59,8 @@ use namada_core::types::masp::{ }; use namada_core::types::storage::{BlockHeight, Epoch, IndexedTx, TxIndex}; use namada_core::types::time::{DateTimeUtc, DurationSecs}; -use namada_core::types::token; -use namada_token::{Change, MaspDenom, Transfer}; +use namada_ibc::IbcMessage; +use namada_token::{self as token, MaspDenom, Transfer}; use namada_tx::data::{TxResult, WrapperTx}; use namada_tx::Tx; use rand_core::{CryptoRng, OsRng, RngCore}; @@ -1404,7 +1403,7 @@ impl ShieldedContext { } } // Construct the key for where the transaction ID would be stored - let pin_key = namada_core::types::token::masp_pin_tx_key(&owner.hash()); + let pin_key = namada_token::storage_key::masp_pin_tx_key(&owner.hash()); // Obtain the transaction pointer at the key // If we don't discard the error message then a test fails, // however the error underlying this will go undetected @@ -2287,7 +2286,7 @@ async fn extract_payload_from_shielded_action<'args, C: Client + Sync>( tx_data: &[u8], args: ExtractShieldedActionArg<'args, C>, ) -> Result { - let message = namada_core::ledger::ibc::decode_message(tx_data) + let message = namada_ibc::decode_message(tx_data) .map_err(|e| Error::Other(e.to_string()))?; let shielded_transfer = match message { diff --git a/sdk/src/queries/vp/pos.rs b/sdk/src/queries/vp/pos.rs index 67a2012afc..02b395f269 100644 --- a/sdk/src/queries/vp/pos.rs +++ b/sdk/src/queries/vp/pos.rs @@ -199,7 +199,7 @@ where fn consensus_key( ctx: RequestCtx<'_, D, H, V, T>, addr: Address, -) -> storage_api::Result> +) -> namada_storage::Result> where D: 'static + DB + for<'iter> DBIter<'iter> + Sync, H: 'static + StorageHasher + Sync, diff --git a/sdk/src/rpc.rs b/sdk/src/rpc.rs index 8e8af1bcfb..0a28f98d80 100644 --- a/sdk/src/rpc.rs +++ b/sdk/src/rpc.rs @@ -9,6 +9,8 @@ use borsh::BorshDeserialize; use masp_primitives::asset_type::AssetType; use masp_primitives::merkle_tree::MerklePath; use masp_primitives::sapling::Node; +use namada_account::Account; +use namada_core::types::address::{Address, InternalAddress}; use namada_core::types::hash::Hash; use namada_core::types::key::common; use namada_core::types::storage::{ diff --git a/sdk/src/signing.rs b/sdk/src/signing.rs index fee12bf639..494ddb9b60 100644 --- a/sdk/src/signing.rs +++ b/sdk/src/signing.rs @@ -27,7 +27,7 @@ use namada_core::types::token::{Amount, DenominatedAmount, MaspDenom}; use namada_governance::storage::proposal::{ InitProposalData, ProposalType, VoteProposalData, }; -use namada_governance::storage::vote::{ProposalVote, VoteType}; +use namada_governance::storage::vote::ProposalVote; use namada_parameters::storage as parameter_storage; use namada_token::storage_key::balance_key; use namada_tx::data::pgf::UpdateStewardCommission; diff --git a/shared/src/ledger/native_vp/masp.rs b/shared/src/ledger/native_vp/masp.rs index 771df721b5..3621bebb68 100644 --- a/shared/src/ledger/native_vp/masp.rs +++ b/shared/src/ledger/native_vp/masp.rs @@ -9,26 +9,28 @@ use masp_primitives::merkle_tree::CommitmentTree; use masp_primitives::sapling::Node; use masp_primitives::transaction::components::I128Sum; use masp_primitives::transaction::Transaction; +use namada_core::types::address::Address; use namada_core::types::address::InternalAddress::Masp; -use namada_core::types::address::{Address, MASP}; -use namada_core::types::storage::{BlockHeight, Epoch, Key, KeySeg, TxIndex}; +use namada_core::types::masp::encode_asset_type; +use namada_core::types::storage::{IndexedTx, Key}; use namada_gas::MASP_VERIFY_SHIELDED_TX_GAS; use namada_sdk::masp::verify_shielded_tx; -use namada_state::OptionExt; +use namada_state::{OptionExt, ResultExt}; use namada_tx::Tx; use namada_vp_env::VpEnv; use ripemd::Digest as RipemdDigest; use sha2::Digest as Sha2Digest; use thiserror::Error; +use token::storage_key::{ + is_masp_allowed_key, is_masp_key, is_masp_nullifier_key, + masp_commitment_anchor_key, masp_commitment_tree_key, + masp_convert_anchor_key, masp_nullifier_key, masp_pin_tx_key, +}; +use token::MaspDenom; use crate::ledger::native_vp; use crate::ledger::native_vp::{Ctx, NativeVp}; -use crate::token::storage_key::{ - is_masp_allowed_key, is_masp_key, is_masp_nullifier_key, -}; -use crate::token::{self as token, Transfer}; -use crate::types::masp::encode_asset_type; -use crate::types::token::MaspDenom; +use crate::token; use crate::vm::WasmCacheAccess; #[allow(missing_docs)] @@ -79,9 +81,7 @@ where }; for description in shielded_spends { - let nullifier_key = namada_core::types::token::masp_nullifier_key( - &description.nullifier, - ); + let nullifier_key = masp_nullifier_key(&description.nullifier); if self.ctx.has_key_pre(&nullifier_key)? || revealed_nullifiers.contains(&nullifier_key) { @@ -128,7 +128,7 @@ where ) -> Result { // Check that the merkle tree in storage has been correctly updated with // the output descriptions cmu - let tree_key = namada_core::types::token::masp_commitment_tree_key(); + let tree_key = masp_commitment_tree_key(); let mut previous_tree: CommitmentTree = self.ctx.read_pre(&tree_key)?.ok_or(Error::NativeVpError( native_vp::Error::SimpleMessage("Cannot read storage"), @@ -182,10 +182,7 @@ where }; for description in shielded_spends { - let anchor_key = - namada_core::types::token::masp_commitment_anchor_key( - description.anchor, - ); + let anchor_key = masp_commitment_anchor_key(description.anchor); // Check if the provided anchor was published before if !self.ctx.has_key_pre(&anchor_key)? { @@ -206,8 +203,7 @@ where ) -> Result { if let Some(bundle) = transaction.sapling_bundle() { if !bundle.shielded_converts.is_empty() { - let anchor_key = - namada_core::types::token::masp_convert_anchor_key(); + let anchor_key = masp_convert_anchor_key(); let expected_anchor = self .ctx .read_pre::(&anchor_key)? diff --git a/shielded_token/src/conversion.rs b/shielded_token/src/conversion.rs index 64176c0221..48945e13d9 100644 --- a/shielded_token/src/conversion.rs +++ b/shielded_token/src/conversion.rs @@ -1,17 +1,14 @@ //! MASP rewards conversions -use masp_primitives::asset_type::AssetType; -use namada_core::borsh::BorshSerializeExt; use namada_core::ledger::inflation::{RewardsController, ValsToUpdate}; use namada_core::types::address::{Address, MASP}; use namada_core::types::dec::Dec; -use namada_core::types::storage::Epoch; use namada_core::types::uint::Uint; use namada_parameters as parameters; use namada_state::{DBIter, StorageHasher, WlStorage, DB}; use namada_storage::{StorageRead, StorageWrite}; use namada_trans_token::storage_key::{balance_key, minted_balance_key}; -use namada_trans_token::{read_denom, Amount, DenominatedAmount, MaspDenom}; +use namada_trans_token::{read_denom, Amount, DenominatedAmount}; use crate::storage_key::{ masp_kd_gain_key, masp_kp_gain_key, masp_last_inflation_key, @@ -193,8 +190,9 @@ where use masp_primitives::sapling::Node; use masp_primitives::transaction::components::I128Sum as MaspAmount; use namada_core::types::masp::encode_asset_type; - use namada_core::types::storage::{Key, KeySeg}; + use namada_core::types::storage::Epoch; use namada_storage::ResultExt; + use namada_trans_token::MaspDenom; use rayon::iter::{ IndexedParallelIterator, IntoParallelIterator, ParallelIterator, }; @@ -324,7 +322,7 @@ where total_reward += native_reward .0 .checked_add(native_reward.1) - .unwrap_or(token::Amount::max()) + .unwrap_or(Amount::max()) .checked_sub(addr_bal) .unwrap_or_default(); // Save the new normed inflation diff --git a/shielded_token/src/storage_key.rs b/shielded_token/src/storage_key.rs index aa00fa74d4..a9eef6fb83 100644 --- a/shielded_token/src/storage_key.rs +++ b/shielded_token/src/storage_key.rs @@ -1,13 +1,12 @@ //! Shielded token storage keys +use masp_primitives::bls12_381::Scalar; +use masp_primitives::sapling::Nullifier; use namada_core::types::address::{self, Address}; -use namada_core::types::storage::{self, DbKeySeg}; +use namada_core::types::hash::Hash; +use namada_core::types::storage::{self, DbKeySeg, KeySeg}; use namada_trans_token::storage_key::key_of_token; -/// Key segment for head shielded transaction pointer keys -pub const HEAD_TX_KEY: &str = "head-tx"; -/// Key segment prefix for shielded transaction key -pub const TX_KEY_PREFIX: &str = "tx-"; /// Key segment prefix for pinned shielded transactions pub const PIN_KEY_PREFIX: &str = "pin-"; /// Key segment prefix for the nullifiers @@ -67,9 +66,7 @@ pub fn is_masp_allowed_key(key: &storage::Key) -> bool { match &key.segments[..] { [DbKeySeg::AddressSeg(addr), DbKeySeg::StringSeg(key)] if *addr == address::MASP - && (key == HEAD_TX_KEY - || key.starts_with(TX_KEY_PREFIX) - || key.starts_with(PIN_KEY_PREFIX) + && (key.starts_with(PIN_KEY_PREFIX) || key == MASP_NOTE_COMMITMENT_TREE_KEY) => { true @@ -84,14 +81,6 @@ pub fn is_masp_allowed_key(key: &storage::Key) -> bool { } } -/// Check if the given storage key is a masp tx prefix key -pub fn is_masp_tx_prefix_key(key: &storage::Key) -> bool { - matches!(&key.segments[..], - [DbKeySeg::AddressSeg(addr), - DbKeySeg::StringSeg(prefix), - ] if *addr == address::MASP && prefix.starts_with(TX_KEY_PREFIX)) -} - /// Check if the given storage key is a masp tx pin key pub fn is_masp_tx_pin_key(key: &storage::Key) -> bool { matches!(&key.segments[..], @@ -126,3 +115,42 @@ pub fn masp_last_inflation_key(token_address: &Address) -> storage::Key { "cannot obtain storage key for the last inflation rate", ) } + +/// Get a key for a masp pin +pub fn masp_pin_tx_key(key: &str) -> storage::Key { + storage::Key::from(address::MASP.to_db_key()) + .push(&(PIN_KEY_PREFIX.to_owned() + key)) + .expect("Cannot obtain a storage key") +} + +/// Get a key for a masp nullifier +pub fn masp_nullifier_key(nullifier: &Nullifier) -> storage::Key { + storage::Key::from(address::MASP.to_db_key()) + .push(&MASP_NULLIFIERS_KEY.to_owned()) + .expect("Cannot obtain a storage key") + .push(&Hash(nullifier.0)) + .expect("Cannot obtain a storage key") +} + +/// Get the key for the masp commitment tree +pub fn masp_commitment_tree_key() -> storage::Key { + storage::Key::from(address::MASP.to_db_key()) + .push(&MASP_NOTE_COMMITMENT_TREE_KEY.to_owned()) + .expect("Cannot obtain a storage key") +} + +/// Get a key for a masp commitment tree anchor +pub fn masp_commitment_anchor_key(anchor: impl Into) -> storage::Key { + storage::Key::from(address::MASP.to_db_key()) + .push(&MASP_NOTE_COMMITMENT_ANCHOR_PREFIX.to_owned()) + .expect("Cannot obtain a storage key") + .push(&Hash(anchor.into().to_bytes())) + .expect("Cannot obtain a storage key") +} + +/// Get the key for the masp convert tree anchor +pub fn masp_convert_anchor_key() -> storage::Key { + storage::Key::from(address::MASP.to_db_key()) + .push(&MASP_CONVERT_ANCHOR_KEY.to_owned()) + .expect("Cannot obtain a storage key") +} diff --git a/shielded_token/src/utils.rs b/shielded_token/src/utils.rs index d2c55f8151..4dfbaa9e89 100644 --- a/shielded_token/src/utils.rs +++ b/shielded_token/src/utils.rs @@ -3,10 +3,7 @@ use masp_primitives::merkle_tree::CommitmentTree; use masp_primitives::sapling::Node; use masp_primitives::transaction::Transaction; -use namada_core::types::address::MASP; -use namada_core::types::hash::Hash; -use namada_core::types::storage::{BlockHeight, Epoch, Key, KeySeg, TxIndex}; -use namada_core::types::token::Transfer; +use namada_core::types::storage::IndexedTx; use namada_storage::{Error, Result, StorageRead, StorageWrite}; use crate::storage_key::{ diff --git a/state/src/lib.rs b/state/src/lib.rs index 2281023230..b4ff046d4a 100644 --- a/state/src/lib.rs +++ b/state/src/lib.rs @@ -16,7 +16,7 @@ use namada_core::types::chain::{ChainId, CHAIN_ID_LENGTH}; use namada_core::types::eth_bridge_pool::is_pending_transfer_key; use namada_core::types::hash::{Error as HashError, Hash}; pub use namada_core::types::hash::{Sha256Hasher, StorageHasher}; -use namada_core::types::storage::{ +pub use namada_core::types::storage::{ BlockHash, BlockHeight, BlockResults, Epoch, Epochs, EthEventsQueue, Header, Key, KeySeg, TxIndex, BLOCK_HASH_LENGTH, BLOCK_HEIGHT_LENGTH, EPOCH_TYPE_LENGTH, @@ -1067,7 +1067,7 @@ pub mod testing { /// Storage with a mock DB for testing. /// /// Prefer to use [`TestWlStorage`], which implements - /// `storage_api::StorageRead + StorageWrite` with properly working + /// `namada_storageStorageRead + StorageWrite` with properly working /// `prefix_iter`. pub type TestStorage = State; diff --git a/state/src/wl_storage.rs b/state/src/wl_storage.rs index 16d77b207e..5c1d17a091 100644 --- a/state/src/wl_storage.rs +++ b/state/src/wl_storage.rs @@ -429,6 +429,7 @@ where } } +#[macro_export] macro_rules! impl_storage_traits { ($($type:ty)*) => { impl StorageRead for $($type)* diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 511252bf6b..43e82f5f8d 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -17,10 +17,8 @@ use std::path::{Path, PathBuf}; use color_eyre::eyre::Result; use eyre::eyre; -use namada::core::ledger::governance::cli::onchain::PgfFunding; -use namada::core::ledger::governance::storage::proposal::{ - PGFIbcTarget, PGFTarget, -}; +use namada::governance::cli::onchain::PgfFunding; +use namada::governance::storage::proposal::{PGFIbcTarget, PGFTarget}; use namada::ibc::apps::transfer::types::VERSION as ICS20_VERSION; use namada::ibc::clients::tendermint::client_state::ClientState as TmClientState; use namada::ibc::clients::tendermint::consensus_state::ConsensusState as TmConsensusState; diff --git a/tx/src/types.rs b/tx/src/types.rs index 1d2686cb23..eea4852e93 100644 --- a/tx/src/types.rs +++ b/tx/src/types.rs @@ -1072,18 +1072,18 @@ impl Tx { } /// Set the transaction memo hash stored in the header - pub fn set_memo_sechash(&mut self, hash: crate::types::hash::Hash) { + pub fn set_memo_sechash(&mut self, hash: namada_core::types::hash::Hash) { self.header.memo_hash = hash; } /// Get the hash of this transaction's memo from the heeader - pub fn memo_sechash(&self) -> &crate::types::hash::Hash { + pub fn memo_sechash(&self) -> &namada_core::types::hash::Hash { &self.header.memo_hash } /// Get the memo designated by the memo hash in the header pub fn memo(&self) -> Option> { - if self.memo_sechash() == &crate::types::hash::Hash::default() { + if self.memo_sechash() == &namada_core::types::hash::Hash::default() { return None; } match self @@ -1415,7 +1415,7 @@ impl Tx { pub fn add_memo( &mut self, memo: &[u8], - ) -> (&mut Self, crate::types::hash::Hash) { + ) -> (&mut Self, namada_core::types::hash::Hash) { let sechash = self .add_section(Section::ExtraData(Code::new(memo.to_vec(), None))) .get_hash(); diff --git a/vp_prelude/src/key.rs b/vp_prelude/src/key.rs deleted file mode 100644 index 95946ff268..0000000000 --- a/vp_prelude/src/key.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! Cryptographic signature keys - -use namada_core::types::address::Address; -pub use namada_core::types::key::*; - -use super::*; - -/// Get the public key associated with the given address from the state prior to -/// tx execution. Returns `Ok(None)` if not found. -pub fn get(ctx: &Ctx, owner: &Address) -> EnvResult> { - storage_api::key::get(&ctx.pre(), owner) -} diff --git a/vp_prelude/src/token.rs b/vp_prelude/src/token.rs deleted file mode 100644 index 1e302204a7..0000000000 --- a/vp_prelude/src/token.rs +++ /dev/null @@ -1,69 +0,0 @@ -//! A fungible token validity predicate. - -use std::collections::BTreeSet; - -use namada_core::types::address::{self, Address, InternalAddress}; -use namada_core::types::storage::Key; -/// Vp imports and functions. -use namada_core::types::storage::KeySeg; -use namada_core::types::token; -pub use namada_core::types::token::*; - -use super::*; - -/// A token validity predicate. -pub fn vp( - ctx: &Ctx, - token: &Address, - keys_changed: &BTreeSet, - verifiers: &BTreeSet
, -) -> VpResult { - let mut change: Change = Change::default(); - for key in keys_changed.iter() { - let owner: Option<&Address> = - match token::is_multitoken_balance_key(token, key) { - Some((_, o)) => Some(o), - None => token::is_balance_key(token, key), - }; - match owner { - None => { - // Unknown changes to this address space are disallowed, but - // unknown changes anywhere else are permitted - if key.segments.get(0) == Some(&token.to_db_key()) { - return reject(); - } - } - Some(owner) => { - // accumulate the change - let pre: Amount = match owner { - Address::Internal(InternalAddress::IbcMint) => { - Amount::max_signed() - } - Address::Internal(InternalAddress::IbcBurn) => { - Amount::default() - } - _ => ctx.read_pre(key)?.unwrap_or_default(), - }; - let post: Amount = match owner { - Address::Internal(InternalAddress::IbcMint) => { - ctx.read_temp(key)?.unwrap_or_else(Amount::max_signed) - } - Address::Internal(InternalAddress::IbcBurn) => { - ctx.read_temp(key)?.unwrap_or_default() - } - _ => ctx.read_post(key)?.unwrap_or_default(), - }; - let this_change = post.change() - pre.change(); - change += this_change; - // make sure that the spender approved the transaction - if !(this_change.non_negative() - || verifiers.contains(owner) - || *owner == address::masp()) - { - return reject(); - } - } - } - } - Ok(change.is_zero()) -} diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 9f36e834c5..776c3f72e6 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "namada_account" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", @@ -3474,7 +3474,7 @@ dependencies = [ [[package]] name = "namada_gas" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", @@ -3484,13 +3484,13 @@ dependencies = [ [[package]] name = "namada_governance" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", "namada_macros", "namada_parameters", - "namada_storage", + "namada_state", "namada_trans_token", "proptest", "serde", @@ -3501,15 +3501,18 @@ dependencies = [ [[package]] name = "namada_ibc" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "ibc", "ibc-derive", "ibc-testkit", "ics23", + "masp_primitives", "namada_core", + "namada_governance", "namada_parameters", + "namada_state", "namada_storage", "namada_trans_token", "primitive-types", @@ -3531,7 +3534,7 @@ dependencies = [ [[package]] name = "namada_merkle_tree" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "eyre", @@ -3544,7 +3547,7 @@ dependencies = [ [[package]] name = "namada_parameters" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", @@ -3566,6 +3569,7 @@ dependencies = [ "namada_parameters", "namada_storage", "namada_trans_token", + "num-traits", "once_cell", "proptest", "serde", @@ -3604,6 +3608,7 @@ dependencies = [ "namada_token", "namada_tx", "namada_vote_ext", + "num-traits", "num256", "orion", "owo-colors", @@ -3631,7 +3636,7 @@ dependencies = [ [[package]] name = "namada_shielded_token" -version = "0.29.0" +version = "0.30.0" dependencies = [ "masp_primitives", "namada_core", @@ -3644,7 +3649,7 @@ dependencies = [ [[package]] name = "namada_state" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "ics23", @@ -3666,7 +3671,7 @@ dependencies = [ [[package]] name = "namada_storage" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "itertools 0.10.5", @@ -3723,7 +3728,7 @@ dependencies = [ [[package]] name = "namada_token" -version = "0.29.0" +version = "0.30.0" dependencies = [ "namada_core", "namada_shielded_token", @@ -3733,7 +3738,7 @@ dependencies = [ [[package]] name = "namada_trans_token" -version = "0.29.0" +version = "0.30.0" dependencies = [ "namada_core", "namada_storage", @@ -3741,7 +3746,7 @@ dependencies = [ [[package]] name = "namada_tx" -version = "0.29.0" +version = "0.30.0" dependencies = [ "ark-bls12-381", "borsh", @@ -3763,7 +3768,7 @@ dependencies = [ [[package]] name = "namada_tx_env" -version = "0.29.0" +version = "0.30.0" dependencies = [ "namada_core", "namada_storage", @@ -3802,7 +3807,7 @@ dependencies = [ [[package]] name = "namada_vote_ext" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", @@ -3812,7 +3817,7 @@ dependencies = [ [[package]] name = "namada_vp_env" -version = "0.29.0" +version = "0.30.0" dependencies = [ "derivative", "masp_primitives", diff --git a/wasm/wasm_source/src/tx_transfer.rs b/wasm/wasm_source/src/tx_transfer.rs index 34c3045dd9..aa8a86d53b 100644 --- a/wasm/wasm_source/src/tx_transfer.rs +++ b/wasm/wasm_source/src/tx_transfer.rs @@ -38,11 +38,7 @@ fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { }) .transpose()?; if let Some(shielded) = shielded { - token::masp_utils::handle_masp_tx( - ctx, - &shielded, - transfer.key.as_deref(), - )?; + token::utils::handle_masp_tx(ctx, &shielded, transfer.key.as_deref())?; update_masp_note_commitment_tree(&shielded)?; } Ok(()) diff --git a/wasm_for_tests/wasm_source/Cargo.lock b/wasm_for_tests/wasm_source/Cargo.lock index c735eb407f..2d730eafd8 100644 --- a/wasm_for_tests/wasm_source/Cargo.lock +++ b/wasm_for_tests/wasm_source/Cargo.lock @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "namada_account" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", @@ -3474,7 +3474,7 @@ dependencies = [ [[package]] name = "namada_gas" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", @@ -3484,13 +3484,13 @@ dependencies = [ [[package]] name = "namada_governance" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", "namada_macros", "namada_parameters", - "namada_storage", + "namada_state", "namada_trans_token", "proptest", "serde", @@ -3501,15 +3501,18 @@ dependencies = [ [[package]] name = "namada_ibc" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "ibc", "ibc-derive", "ibc-testkit", "ics23", + "masp_primitives", "namada_core", + "namada_governance", "namada_parameters", + "namada_state", "namada_storage", "namada_trans_token", "primitive-types", @@ -3531,7 +3534,7 @@ dependencies = [ [[package]] name = "namada_merkle_tree" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "eyre", @@ -3544,7 +3547,7 @@ dependencies = [ [[package]] name = "namada_parameters" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", @@ -3566,6 +3569,7 @@ dependencies = [ "namada_parameters", "namada_storage", "namada_trans_token", + "num-traits", "once_cell", "proptest", "serde", @@ -3604,6 +3608,7 @@ dependencies = [ "namada_token", "namada_tx", "namada_vote_ext", + "num-traits", "num256", "orion", "owo-colors", @@ -3631,7 +3636,7 @@ dependencies = [ [[package]] name = "namada_shielded_token" -version = "0.29.0" +version = "0.30.0" dependencies = [ "masp_primitives", "namada_core", @@ -3644,7 +3649,7 @@ dependencies = [ [[package]] name = "namada_state" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "ics23", @@ -3666,7 +3671,7 @@ dependencies = [ [[package]] name = "namada_storage" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "itertools 0.10.5", @@ -3723,7 +3728,7 @@ dependencies = [ [[package]] name = "namada_token" -version = "0.29.0" +version = "0.30.0" dependencies = [ "namada_core", "namada_shielded_token", @@ -3733,7 +3738,7 @@ dependencies = [ [[package]] name = "namada_trans_token" -version = "0.29.0" +version = "0.30.0" dependencies = [ "namada_core", "namada_storage", @@ -3741,7 +3746,7 @@ dependencies = [ [[package]] name = "namada_tx" -version = "0.29.0" +version = "0.30.0" dependencies = [ "ark-bls12-381", "borsh", @@ -3763,7 +3768,7 @@ dependencies = [ [[package]] name = "namada_tx_env" -version = "0.29.0" +version = "0.30.0" dependencies = [ "namada_core", "namada_storage", @@ -3802,7 +3807,7 @@ dependencies = [ [[package]] name = "namada_vote_ext" -version = "0.29.0" +version = "0.30.0" dependencies = [ "borsh", "namada_core", @@ -3812,7 +3817,7 @@ dependencies = [ [[package]] name = "namada_vp_env" -version = "0.29.0" +version = "0.30.0" dependencies = [ "derivative", "masp_primitives",