Skip to content

Commit

Permalink
fixup! Merge branch 'tomas+tiago/modularization' (#2312)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Jan 16, 2024
1 parent a8930fc commit 14b80a0
Show file tree
Hide file tree
Showing 49 changed files with 458 additions and 329 deletions.
35 changes: 19 additions & 16 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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,
};
Expand Down
3 changes: 2 additions & 1 deletion apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
21 changes: 11 additions & 10 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand Down Expand Up @@ -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::<Node>::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, ())?;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 4 additions & 6 deletions apps/src/lib/node/ledger/shell/init_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(&note_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(
Expand Down
3 changes: 2 additions & 1 deletion apps/src/lib/node/ledger/shell/vote_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -70,6 +69,7 @@ where
protocol_key,
ethereum_events,
)
.map(|ethereum_events::SignedVext(ext)| ext)
}

/// Extend PreCommit votes with [`bridge_pool_roots::Vext`] instances.
Expand All @@ -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`]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand Down Expand Up @@ -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()
);
Expand All @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand Down
2 changes: 1 addition & 1 deletion benches/host_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
12 changes: 5 additions & 7 deletions benches/native_vps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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<Node> = 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
Expand Down
Loading

0 comments on commit 14b80a0

Please sign in to comment.