diff --git a/.changelog/unreleased/improvements/2112-rm-abcipp.md b/.changelog/unreleased/improvements/2112-rm-abcipp.md new file mode 100644 index 0000000000..69e9c27be1 --- /dev/null +++ b/.changelog/unreleased/improvements/2112-rm-abcipp.md @@ -0,0 +1,2 @@ +- Removed "abcipp" and "abciplus" features and "abcipp"-only code. + ([\#2112](https://github.com/anoma/namada/pull/2112)) \ No newline at end of file diff --git a/Makefile b/Makefile index 9386f1955f..83b8f665b8 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,7 @@ check-mainnet: check-crates: $(foreach p,$(crates), echo "Checking $(p)" && cargo +$(nightly) check -Z unstable-options --tests -p $(p) && ) \ make -C $(wasms_for_tests) check && \ - cargo check --package namada --target wasm32-unknown-unknown --no-default-features --features "abciplus,namada-sdk" + cargo check --package namada --target wasm32-unknown-unknown --no-default-features --features "namada-sdk" clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets -- -D warnings diff --git a/apps/Cargo.toml b/apps/Cargo.toml index 8a783d4dc5..7b2b641cdd 100644 --- a/apps/Cargo.toml +++ b/apps/Cargo.toml @@ -50,7 +50,7 @@ name = "namadar" path = "src/bin/namada-relayer/main.rs" [features] -default = ["std", "abciplus"] +default = ["std"] mainnet = [ "namada/mainnet", ] @@ -59,14 +59,10 @@ std = ["ed25519-consensus/std", "rand/std", "rand_core/std", "namada/std", "nama testing = ["namada_test_utils"] benches = ["testing", "namada_test_utils"] integration = [] -abciplus = [ - "namada/abciplus", - "namada/tendermint-rpc", -] [dependencies] -namada = {path = "../shared", features = ["ferveo-tpke", "masp-tx-gen", "multicore", "http-client"]} +namada = {path = "../shared", features = ["ferveo-tpke", "masp-tx-gen", "multicore", "http-client", "tendermint-rpc"]} namada_sdk = {path = "../sdk", default-features = false, features = ["wasm-runtime", "masp-tx-gen"]} namada_test_utils = {path = "../test_utils", optional = true} ark-serialize.workspace = true diff --git a/apps/src/lib/mod.rs b/apps/src/lib/mod.rs index b2991870ef..a9b2039c28 100644 --- a/apps/src/lib/mod.rs +++ b/apps/src/lib/mod.rs @@ -21,19 +21,6 @@ pub mod wasm_loader; pub use std; pub mod facade { - //! Facade module to reason about `abcipp` feature flag logic. - - #[cfg(not(feature = "abcipp"))] - pub use { - namada::tendermint, namada::tendermint_proto, namada::tendermint_rpc, - tendermint_config, tower_abci, - }; - #[cfg(feature = "abcipp")] - pub use { - tendermint_abcipp as tendermint, - tendermint_config_abcipp as tendermint_config, - tendermint_proto_abcipp as tendermint_proto, - tendermint_rpc_abcipp as tendermint_rpc, - tower_abci_abcipp as tower_abci, - }; + pub use namada::{tendermint, tendermint_proto, tendermint_rpc}; + pub use {tendermint_config, tower_abci}; } diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index 243c9ab4a4..332fedba15 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -212,57 +212,6 @@ where .expect("Missing wrapper tx in queue"); } - #[cfg(not(any(feature = "abciplus", feature = "abcipp")))] - if let TxType::Wrapper(wrapper) = &tx_header.tx_type { - // Charge fee if wrapper transaction went out of gas or - // failed because of fees (also write the wrapper hash to - // storage to prevent replays that would force the fee payer - // to pay more than once) - let error_code = - ErrorCodes::from_u32(processed_tx.result.code).unwrap(); - if (error_code == ErrorCodes::TxGasLimit) - | (error_code == ErrorCodes::FeeError) - { - let masp_transaction = wrapper - .unshield_section_hash - .map(|ref hash| { - tx.get_section(hash) - .map(|section| { - if let Section::MaspTx(transaction) = - section.as_ref() - { - Some(transaction.to_owned()) - } else { - None - } - }) - .flatten() - }) - .flatten(); - if let Err(msg) = protocol::apply_wrapper_tx( - wrapper, - masp_transaction, - &processed_tx.tx, - ShellParams::new( - &mut TxGasMeter::new_from_sub_limit( - u64::MAX.into(), - ), - &mut self.wl_storage, - &mut self.vp_wasm_cache, - &mut self.tx_wasm_cache, - ), - Some(&native_block_proposer_address), - ) { - self.wl_storage.write_log.drop_tx(); - tracing::error!( - "Rejected wrapper tx {} could not pay fee: {}", - hash::Hash::sha256(tx.header_hash()), - msg - ) - } - } - } - continue; } diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index 164db32cd8..769fb38155 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -339,7 +339,6 @@ impl ShellMode { /// If this node is a validator, broadcast a tx /// to the mempool using the broadcaster subprocess - #[cfg_attr(feature = "abcipp", allow(dead_code))] pub fn broadcast(&self, data: Vec) { if let Self::Validator { broadcast_sender, .. @@ -1074,7 +1073,6 @@ where tx_bytes: &[u8], r#_type: MempoolTxType, ) -> response::CheckTx { - #[cfg(not(feature = "abcipp"))] use namada::types::transaction::protocol::{ ethereum_tx_data_variants, ProtocolTxType, }; @@ -1149,7 +1147,6 @@ where match tx_type.tx_type { TxType::Protocol(protocol_tx) => match protocol_tx.tx { - #[cfg(not(feature = "abcipp"))] ProtocolTxType::EthEventsVext => { let ext = try_vote_extension!( "Ethereum events", @@ -1171,7 +1168,6 @@ where response.log = String::from(VALID_MSG); } } - #[cfg(not(feature = "abcipp"))] ProtocolTxType::BridgePoolVext => { let ext = try_vote_extension!( "Bridge pool roots", @@ -1195,7 +1191,6 @@ where response.log = String::from(VALID_MSG); } } - #[cfg(not(feature = "abcipp"))] ProtocolTxType::ValSetUpdateVext => { let ext = try_vote_extension!( "validator set update", @@ -1884,14 +1879,6 @@ mod test_utils { } } - /// Get the only validator's voting power. - #[inline] - #[cfg(not(feature = "abcipp"))] - #[allow(dead_code)] - pub fn get_validator_bonded_stake() -> namada::types::token::Amount { - 200_000_000_000.into() - } - /// Config parameters to set up a test shell. pub struct SetupCfg { /// The last comitted block height. diff --git a/apps/src/lib/node/ledger/shell/prepare_proposal.rs b/apps/src/lib/node/ledger/shell/prepare_proposal.rs index df5f0df3f6..753240fdfd 100644 --- a/apps/src/lib/node/ledger/shell/prepare_proposal.rs +++ b/apps/src/lib/node/ledger/shell/prepare_proposal.rs @@ -2,8 +2,6 @@ use namada::core::hints; use namada::core::ledger::gas::TxGasMeter; -#[cfg(feature = "abcipp")] -use namada::ledger::eth_bridge::{EthBridgeQueries, SendValsetUpd}; use namada::ledger::pos::PosQueries; use namada::ledger::protocol::get_fee_unshielding_transaction; use namada::ledger::storage::{DBIter, StorageHasher, TempWlStorage, DB}; @@ -17,8 +15,6 @@ use namada::types::transaction::wrapper::wrapper_tx::PairingEngine; use namada::types::transaction::{ AffineCurve, DecryptedTx, EllipticCurve, TxType, }; -#[cfg(feature = "abcipp")] -use namada::types::vote_extensions::VoteExtensionDigest; use namada::vm::wasm::{TxCache, VpCache}; use namada::vm::WasmCacheAccess; @@ -28,14 +24,8 @@ use super::block_alloc::states::{ EncryptedTxBatchAllocator, NextState, TryAlloc, }; use super::block_alloc::{AllocFailure, BlockAllocator, BlockResources}; -#[cfg(feature = "abcipp")] -use crate::facade::tendermint_proto::abci::{tx_record::TxAction, TxRecord}; use crate::facade::tendermint_proto::google::protobuf::Timestamp; -#[cfg(feature = "abcipp")] -use crate::facade::tendermint_proto::v0_37::abci::ExtendedCommitInfo; use crate::facade::tendermint_proto::v0_37::abci::RequestPrepareProposal; -#[cfg(feature = "abcipp")] -use crate::node::ledger::shell::vote_extensions::iter_protocol_txs; use crate::node::ledger::shell::ShellMode; use crate::node::ledger::shims::abcipp_shim_types::shim::{response, TxBytes}; @@ -84,13 +74,7 @@ where txs.append(&mut decrypted_txs); // add vote extension protocol txs - let mut protocol_txs = self.build_protocol_txs( - alloc, - #[cfg(feature = "abcipp")] - req.local_last_commit, - #[cfg(not(feature = "abcipp"))] - &req.txs, - ); + let mut protocol_txs = self.build_protocol_txs(alloc, &req.txs); txs.append(&mut protocol_txs); txs @@ -345,78 +329,6 @@ where } /// Builds a batch of protocol transactions. - #[cfg(feature = "abcipp")] - fn build_protocol_txs( - &self, - _alloc: BlockAllocator, - local_last_commit: Option, - ) -> Vec { - // genesis should not contain vote extensions. - // - // this is because we have not decided any block through - // consensus yet (hence height 0), which in turn means we - // have not committed any vote extensions to a block either. - if self.wl_storage.storage.last_block.is_none() { - return vec![]; - } - - let (eth_events, bp_roots, valset_upds) = self.split_vote_extensions( - local_last_commit - .expect( - "Honest Namada validators will always sign \ - ethereum_events::Vext instances, even if no Ethereum \ - events were observed at a given block height. In fact, a \ - quorum of signed empty ethereum_events::Vext instances \ - commits the fact no events were observed by a majority \ - of validators. Therefore, for block heights greater than \ - zero, we should always have vote extensions.", - ) - .votes, - ); - - let ethereum_events = eth_events.map(|events| { - self.compress_ethereum_events(events) - .unwrap_or_else(|| panic!("{}", not_enough_voting_power_msg())) - }); - - let bp_roots = bp_roots.map(|bp_roots| { - self.compress_bridge_pool_roots(bp_roots) - .unwrap_or_else(|| panic!("{}", not_enough_voting_power_msg())) - }); - - let validator_set_update = - if self - .wl_storage - .ethbridge_queries() - .must_send_valset_upd(SendValsetUpd::AtPrevHeight) - { - Some(self.compress_valset_updates(valset_upds).unwrap_or_else( - || panic!("{}", not_enough_voting_power_msg()), - )) - } else { - None - }; - - let protocol_key = self - .mode - .get_protocol_key() - .expect("Validators should always have a protocol key"); - - // TODO(feature = "abcipp"): - // - alloc space for each protocol tx - // - handle space allocation errors - // - transition to new allocator state - iter_protocol_txs(VoteExtensionDigest { - ethereum_events, - bridge_pool_roots: bp_roots, - validator_set_update, - }) - .map(|tx| tx.sign(protocol_key).to_bytes()) - .collect() - } - - /// Builds a batch of protocol transactions. - #[cfg(not(feature = "abcipp"))] fn build_protocol_txs( &self, mut alloc: BlockAllocator, @@ -476,22 +388,11 @@ where } } -/// Returns a suitable message to be displayed when Tendermint -/// somehow decides on a block containing vote extensions -/// reflecting `<= 2/3` of the total stake. -#[cfg(feature = "abcipp")] -const fn not_enough_voting_power_msg() -> &'static str { - "A Tendermint quorum should never decide on a block including vote \ - extensions reflecting less than or equal to 2/3 of the total stake." -} - #[cfg(test)] // TODO: write tests for validator set update vote extensions in // prepare proposals mod test_prepare_proposal { use std::collections::BTreeSet; - #[cfg(feature = "abcipp")] - use std::collections::{BTreeSet, HashMap}; use borsh_ext::BorshSerializeExt; use namada::core::ledger::storage_api::collections::lazy_map::{ @@ -505,120 +406,38 @@ mod test_prepare_proposal { consensus_validator_set_handle, read_consensus_validator_set_addresses_with_stake, Epoch, }; - #[cfg(feature = "abcipp")] - use namada::proto::SignableEthMessage; use namada::proto::{Code, Data, Header, Section, Signature, Signed}; use namada::types::address::{self, Address}; use namada::types::ethereum_events::EthereumEvent; - #[cfg(feature = "abcipp")] - use namada::types::key::common; use namada::types::key::RefTo; use namada::types::storage::BlockHeight; use namada::types::token; use namada::types::token::Amount; use namada::types::transaction::protocol::EthereumTxData; use namada::types::transaction::{Fee, TxType, WrapperTx}; - #[cfg(feature = "abcipp")] - use namada::types::vote_extensions::bridge_pool_roots; use namada::types::vote_extensions::ethereum_events; - #[cfg(feature = "abcipp")] - use namada::types::vote_extensions::VoteExtension; use super::*; use crate::config::ValidatorLocalConfig; - #[cfg(feature = "abcipp")] - use crate::facade::tendermint_proto::abci::{ - ExtendedCommitInfo, ExtendedVoteInfo, - }; - #[cfg(feature = "abcipp")] - use crate::node::ledger::shell::test_utils::deactivate_bridge; - #[cfg(feature = "abcipp")] - use crate::node::ledger::shell::test_utils::get_bp_bytes_to_sign; - #[cfg(feature = "abcipp")] - use crate::node::ledger::shell::test_utils::setup_at_height; use crate::node::ledger::shell::test_utils::{ self, gen_keypair, get_pkh_from_address, TestShell, }; use crate::node::ledger::shims::abcipp_shim_types::shim::request::FinalizeBlock; use crate::wallet; - #[cfg(feature = "abcipp")] - fn get_local_last_commit(shell: &TestShell) -> Option { - let validator_addr = shell - .mode - .get_validator_address() - .expect("Test failed") - .to_owned(); - let evts = { - let prev_height = shell.wl_storage.storage.get_last_block_height(); - let ext = ethereum_events::Vext::empty( - prev_height, - validator_addr.clone(), - ); - let protocol_key = match &shell.mode { - ShellMode::Validator { data, .. } => { - &data.keys.protocol_keypair - } - _ => panic!("Test failed"), - }; - ext.sign(protocol_key) - }; - - let bp_root = { - let to_sign = get_bp_bytes_to_sign(); - let sig = Signed::<_, SignableEthMessage>::new( - shell.mode.get_eth_bridge_keypair().expect("Test failed"), - to_sign, - ) - .sig; - bridge_pool_roots::Vext { - block_height: shell.wl_storage.storage.get_last_block_height(), - validator_addr, - sig, - } - .sign(shell.mode.get_protocol_key().expect("Test failed")) - }; - - let vote_extension = VoteExtension { - ethereum_events: Some(evts), - bridge_pool_root: Some(bp_root), - validator_set_update: None, - } - .serialize_to_vec(); - - let vote = ExtendedVoteInfo { - vote_extension, - ..Default::default() - }; - - Some(ExtendedCommitInfo { - votes: vec![vote], - ..Default::default() - }) - } - /// Check if we are filtering out an invalid vote extension `vext` fn check_eth_events_filtering( shell: &TestShell, vext: Signed, ) { - #[cfg(feature = "abcipp")] - { - let filtered_votes: Vec<_> = - shell.filter_invalid_eth_events_vexts(vec![vext]).collect(); - assert_eq!(filtered_votes, vec![]); - } - #[cfg(not(feature = "abcipp"))] - { - let tx = EthereumTxData::EthEventsVext(vext) - .sign( - shell.mode.get_protocol_key().expect("Test failed"), - shell.chain_id.clone(), - ) - .to_bytes(); - let rsp = shell.mempool_validate(&tx, Default::default()); - assert!(rsp.code != 0, "{}", rsp.log); - } + let tx = EthereumTxData::EthEventsVext(vext) + .sign( + shell.mode.get_protocol_key().expect("Test failed"), + shell.chain_id.clone(), + ) + .to_bytes(); + let rsp = shell.mempool_validate(&tx, Default::default()); + assert!(rsp.code != 0, "{}", rsp.log); } const GAS_LIMIT_MULTIPLIER: u64 = 300_000; @@ -736,10 +555,6 @@ mod test_prepare_proposal { check_invalid(&shell, LAST_HEIGHT + 2); check_invalid(&shell, LAST_HEIGHT + 1); check_invalid(&shell, 0.into()); - #[cfg(feature = "abcipp")] - check_invalid(&shell, LAST_HEIGHT - 1); - #[cfg(feature = "abcipp")] - check_invalid(&shell, LAST_HEIGHT - 2); } /// Test if we are filtering out Ethereum events seen by @@ -770,104 +585,9 @@ mod test_prepare_proposal { check_eth_events_filtering(&shell, signed_vote_extension); } - /// Test if we are filtering out duped Ethereum events in - /// prepare proposals. - #[test] - #[cfg(feature = "abcipp")] - fn test_prepare_proposal_filter_duped_ethereum_events() { - const LAST_HEIGHT: BlockHeight = BlockHeight(3); - - let (shell, _recv, _, _) = test_utils::setup_at_height(LAST_HEIGHT); - - let (protocol_key, _, _) = wallet::defaults::validator_keys(); - let validator_addr = wallet::defaults::validator_address(); - - let ethereum_event = EthereumEvent::TransfersToNamada { - nonce: 0u64.into(), - transfers: vec![], - }; - let signed_vote_extension = { - let ev = ethereum_event; - let ext = ethereum_events::Vext { - validator_addr, - block_height: LAST_HEIGHT, - ethereum_events: vec![ev.clone(), ev.clone(), ev], - } - .sign(&protocol_key); - assert!(ext.verify(&protocol_key.ref_to()).is_ok()); - ext - }; - - let maybe_digest = - shell.compress_ethereum_events(vec![signed_vote_extension]); - - // we should be filtering out the vote extension with - // duped ethereum events; therefore, no valid vote - // extensions will remain, and we will get no - // digest from compressing nil vote extensions - assert!(maybe_digest.is_none()); - } - - /// Test that we do not include vote extensions voting on ethereum - /// events or signing bridge pool roots + nonces if the bridge - /// is inactive. - #[test] - #[cfg(feature = "abcipp")] - fn test_filter_vexts_bridge_inactive() { - let (mut shell, _, _, _) = setup_at_height(3); - deactivate_bridge(&mut shell); - let vext = get_local_last_commit(&shell); - let rsp = shell.prepare_proposal(RequestPrepareProposal { - local_last_commit: vext, - ..Default::default() - }); - assert!(rsp.txs.is_empty()); - } - - /// Creates an Ethereum events digest manually. - #[cfg(feature = "abcipp")] - fn manually_assemble_digest( - _protocol_key: &common::SecretKey, - ext: Signed, - last_height: BlockHeight, - ) -> ethereum_events::VextDigest { - use namada::types::vote_extensions::ethereum_events::MultiSignedEthEvent; - - let events = vec![MultiSignedEthEvent { - event: ext.data.ethereum_events[0].clone(), - signers: { - let mut s = BTreeSet::new(); - s.insert((ext.data.validator_addr.clone(), last_height)); - s - }, - }]; - let signatures = { - let mut s = HashMap::new(); - s.insert( - (ext.data.validator_addr.clone(), last_height), - ext.sig.clone(), - ); - s - }; - - let vote_extension_digest = - ethereum_events::VextDigest { events, signatures }; - - assert_eq!( - vec![ext], - vote_extension_digest.clone().decompress(last_height) - ); - - vote_extension_digest - } - /// Test if Ethereum events validation and inclusion in a block /// behaves as expected, considering <= 2/3 voting power. #[test] - #[cfg_attr( - feature = "abcipp", - should_panic(expected = "A Tendermint quorum should never") - )] fn test_prepare_proposal_vext_insufficient_voting_power() { use crate::facade::tendermint_proto::v0_37::abci::{ Validator, VoteInfo, @@ -1000,70 +720,25 @@ mod test_prepare_proposal { ext }; - #[cfg(feature = "abcipp")] - { - let bp_root = { - let to_sign = get_bp_bytes_to_sign(); - let sig = Signed::<_, SignableEthMessage>::new( - shell.mode.get_eth_bridge_keypair().expect("Test failed"), - to_sign, - ) - .sig; - bridge_pool_roots::Vext { - block_height: shell - .wl_storage - .storage - .get_last_block_height(), - validator_addr: shell - .mode - .get_validator_address() - .unwrap() - .clone(), - sig, - } - .sign(shell.mode.get_protocol_key().expect("Test failed")) - }; - let vote_extension = VoteExtension { - ethereum_events: Some(signed_eth_ev_vote_extension), - bridge_pool_root: Some(bp_root), - validator_set_update: None, - }; - let vote = ExtendedVoteInfo { - vote_extension: vote_extension.serialize_to_vec(), - ..Default::default() - }; - // this should panic - shell.prepare_proposal(RequestPrepareProposal { - local_last_commit: Some(ExtendedCommitInfo { - votes: vec![vote], - ..Default::default() - }), - ..Default::default() - }); - } - #[cfg(not(feature = "abcipp"))] - { - let vote = EthereumTxData::EthEventsVext( - signed_eth_ev_vote_extension.clone(), - ) - .sign(&protocol_key, shell.chain_id.clone()) - .to_bytes(); - let mut rsp = shell.prepare_proposal(RequestPrepareProposal { - txs: vec![vote.into()], - ..Default::default() - }); - assert_eq!(rsp.txs.len(), 1); - - let tx_bytes = rsp.txs.remove(0); - let got = Tx::try_from(&tx_bytes[..]).unwrap(); - let eth_tx_data = (&got).try_into().expect("Test failed"); - let rsp_ext = match eth_tx_data { - EthereumTxData::EthEventsVext(ext) => ext, - _ => panic!("Test failed"), - }; + let vote = + EthereumTxData::EthEventsVext(signed_eth_ev_vote_extension.clone()) + .sign(&protocol_key, shell.chain_id.clone()) + .to_bytes(); + let mut rsp = shell.prepare_proposal(RequestPrepareProposal { + txs: vec![vote.into()], + ..Default::default() + }); + assert_eq!(rsp.txs.len(), 1); + + let tx_bytes = rsp.txs.remove(0); + let got = Tx::try_from(&tx_bytes[..]).unwrap(); + let eth_tx_data = (&got).try_into().expect("Test failed"); + let rsp_ext = match eth_tx_data { + EthereumTxData::EthEventsVext(ext) => ext, + _ => panic!("Test failed"), + }; - assert_eq!(signed_eth_ev_vote_extension, rsp_ext); - } + assert_eq!(signed_eth_ev_vote_extension, rsp_ext); } /// Test that the decrypted txs are included diff --git a/apps/src/lib/node/ledger/shell/process_proposal.rs b/apps/src/lib/node/ledger/shell/process_proposal.rs index 235883837e..58c7e15eac 100644 --- a/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -12,8 +12,6 @@ use namada::types::internal::TxInQueue; use namada::types::transaction::protocol::{ ethereum_tx_data_variants, ProtocolTxType, }; -#[cfg(feature = "abcipp")] -use namada::types::voting_power::FractionalVotingPower; use namada_sdk::eth_bridge::{EthBridgeQueries, SendValsetUpd}; use super::block_alloc::{BlockSpace, EncryptedTxsBins}; @@ -31,8 +29,6 @@ pub struct ValidationMeta { /// Space and gas utilized by encrypted txs. pub encrypted_txs_bins: EncryptedTxsBins, /// Vote extension digest counters. - #[cfg(feature = "abcipp")] - pub digests: DigestCounters, /// Space utilized by all txs. pub txs_bin: TxBin, /// Check if the decrypted tx queue has any elements @@ -59,8 +55,6 @@ where EncryptedTxsBins::new(max_proposal_bytes, max_block_gas); let txs_bin = TxBin::init(max_proposal_bytes); Self { - #[cfg(feature = "abcipp")] - digests: DigestCounters::default(), decrypted_queue_has_remaining_txs: false, has_decrypted_txs: false, encrypted_txs_bins: encrypted_txs_bin, @@ -69,19 +63,6 @@ where } } -/// Contains stateful data about the number of vote extension -/// digests found as protocol transactions in a proposed block. -#[derive(Default)] -#[cfg(feature = "abcipp")] -pub struct DigestCounters { - /// The number of Ethereum events vote extensions found thus far. - pub eth_ev_digest_num: usize, - /// The number of Bridge pool root vote extensions found thus far. - pub bridge_pool_roots: usize, - /// The number of validator set update vote extensions found thus far. - pub valset_upd_digest_num: usize, -} - impl Shell where D: DB + for<'iter> DBIter<'iter> + Sync + 'static, @@ -99,126 +80,6 @@ where /// but we only reject the entire block if the order of the /// included txs violates the order decided upon in the previous /// block. - #[cfg(feature = "abcipp")] - pub fn process_proposal( - &self, - req: RequestProcessProposal, - ) -> ProcessProposal { - let tm_raw_hash_string = tm_raw_hash_to_string(&req.proposer_address); - let block_proposer = - find_validator_by_raw_hash(&self.wl_storage, tm_raw_hash_string) - .unwrap() - .expect( - "Unable to find native validator address of block \ - proposer from tendermint raw hash", - ); - tracing::info!( - proposer = ?HEXUPPER.encode(&req.proposer_address), - height = req.height, - hash = ?HEXUPPER.encode(&req.hash), - n_txs = req.txs.len(), - "Received block proposal", - ); - let (tx_results, metadata) = - self.process_txs(&req.txs, self.get_block_timestamp(req.time)); - - // We should not have more than one `ethereum_events::VextDigest` in - // a proposal from some round's leader. - let invalid_num_of_eth_ev_digests = - !self.has_proper_eth_events_num(&metadata); - if invalid_num_of_eth_ev_digests { - tracing::warn!( - proposer = ?HEXUPPER.encode(&req.proposer_address), - height = req.height, - hash = ?HEXUPPER.encode(&req.hash), - eth_ev_digest_num = metadata.digests.eth_ev_digest_num, - "Found invalid number of Ethereum events vote extension digests, proposed block \ - will be rejected" - ); - } - - // We should not have more than one `bridge_pool_roots::VextDigest` in - // a proposal from some round's leader. - let invalid_num_of_bp_root_digests = - !self.has_proper_bp_roots_num(&metadata); - if invalid_num_of_bp_root_digests { - tracing::warn!( - proposer = ?HEXUPPER.encode(&req.proposer_address), - height = req.height, - hash = ?HEXUPPER.encode(&req.hash), - eth_ev_digest_num = metadata.digests.bridge_pool_roots, - "Found invalid number of Ethereum bridge pool root vote extension \ - digests, proposed block will be rejected." - ); - } - - let invalid_num_of_valset_upd_digests = - !self.has_proper_valset_upd_num(&metadata); - if invalid_num_of_valset_upd_digests { - tracing::warn!( - proposer = ?HEXUPPER.encode(&req.proposer_address), - height = req.height, - hash = ?HEXUPPER.encode(&req.hash), - valset_upd_digest_num = metadata.digests.valset_upd_digest_num, - "Found invalid number of validator set update vote extension digests, proposed block \ - will be rejected" - ); - } - - // Erroneous transactions were detected when processing - // the leader's proposal. We allow txs that do not - // deserialize properly, that have invalid signatures - // and that have invalid wasm code to reach FinalizeBlock. - let invalid_txs = tx_results.iter().any(|res| { - let error = ErrorCodes::from_u32(res.code).expect( - "All error codes returned from process_single_tx are valid", - ); - !error.is_recoverable() - }); - if invalid_txs { - tracing::warn!( - proposer = ?HEXUPPER.encode(&req.proposer_address), - height = req.height, - hash = ?HEXUPPER.encode(&req.hash), - "Found invalid transactions, proposed block will be rejected" - ); - } - - let has_remaining_decrypted_txs = - metadata.decrypted_queue_has_remaining_txs; - if has_remaining_decrypted_txs { - tracing::warn!( - proposer = ?HEXUPPER.encode(&req.proposer_address), - height = req.height, - hash = ?HEXUPPER.encode(&req.hash), - "Not all decrypted txs from the previous height were included in - the proposal, the block will be rejected" - ); - } - - let will_reject_proposal = invalid_num_of_eth_ev_digests - || invalid_num_of_bp_root_digests - || invalid_num_of_valset_upd_digests - || invalid_txs - || has_remaining_decrypted_txs; - - let status = if will_reject_proposal { - ProposalStatus::Reject - } else { - ProposalStatus::Accept - }; - - ProcessProposal { - status: status as i32, - tx_results, - } - } - - /// Check all the txs in a block. Some txs may be incorrect, - /// but we only reject the entire block if the order of the - /// included txs violates the order decided upon in the previous - /// block. - #[cfg(not(feature = "abcipp"))] pub fn process_proposal( &self, req: RequestProcessProposal, @@ -357,58 +218,10 @@ where where I: Iterator>, { - #[cfg(feature = "abcipp")] - let mut voting_power = FractionalVotingPower::default(); - #[cfg(feature = "abcipp")] - let total_power = { - let epoch = self - .wl_storage - .pos_queries() - .get_epoch(self.wl_storage.storage.get_last_block_height()); - u64::from( - self.wl_storage.pos_queries().get_total_voting_power(epoch), - ) - }; - - if vote_extensions.all(|maybe_ext| { - maybe_ext - .map(|_power| { - #[cfg(feature = "abcipp")] - { - voting_power += FractionalVotingPower::new( - u64::from(_power), - total_power, - ) - .expect( - "The voting power we obtain from storage should \ - always be valid", - ); - } - }) - .is_some() - }) { - #[cfg(feature = "abcipp")] - if voting_power > FractionalVotingPower::TWO_THIRDS { - TxResult { - code: ErrorCodes::Ok.into(), - info: "Process proposal accepted this transaction".into(), - } - } else { - TxResult { - code: ErrorCodes::InvalidVoteExtension.into(), - info: "Process proposal rejected this proposal because \ - the backing stake of the vote extensions published \ - in the proposal was insufficient" - .into(), - } - } - - #[cfg(not(feature = "abcipp"))] - { - TxResult { - code: ErrorCodes::Ok.into(), - info: "Process proposal accepted this transaction".into(), - } + if vote_extensions.all(|maybe_ext| maybe_ext.is_some()) { + TxResult { + code: ErrorCodes::Ok.into(), + info: "Process proposal accepted this transaction".into(), } } else { TxResult { @@ -644,10 +457,6 @@ where &tx, ) .unwrap(); - #[cfg(feature = "abcipp")] - { - metadata.digests.eth_ev_digest_num += 1; - } let extensions = digest.decompress( self.wl_storage.storage.get_last_block_height(), ); @@ -665,10 +474,6 @@ where &tx, ) .unwrap(); - #[cfg(feature = "abcipp")] - { - metadata.digests.bridge_pool_roots += 1; - } let valid_extensions = self .validate_bp_roots_vext_list(digest) .map(|maybe_ext| { @@ -695,10 +500,6 @@ where .into(), }; } - #[cfg(feature = "abcipp")] - { - metadata.digests.valset_upd_digest_num += 1; - } let extensions = digest.decompress( self.wl_storage.storage.get_current_epoch().0, @@ -883,55 +684,6 @@ where Default::default() } - /// Checks if we have found the correct number of Ethereum events - /// vote extensions in [`DigestCounters`]. - #[cfg(feature = "abcipp")] - fn has_proper_eth_events_num(&self, meta: &ValidationMeta) -> bool { - if self.wl_storage.ethbridge_queries().is_bridge_active() { - meta.digests.eth_ev_digest_num - == usize::from(self.wl_storage.storage.last_block.is_some()) - } else { - meta.digests.eth_ev_digest_num == 0 - } - } - - /// Checks if we have found the correct number of Ethereum bridge pool - /// root vote extensions in [`DigestCounters`]. - #[cfg(feature = "abcipp")] - fn has_proper_bp_roots_num(&self, meta: &ValidationMeta) -> bool { - if self.wl_storage.ethbridge_queries().is_bridge_active() { - meta.digests.bridge_pool_roots - == usize::from(self.wl_storage.storage.last_block.is_some()) - } else { - meta.digests.bridge_pool_roots == 0 - } - } - - /// Checks if we have found the correct number of validator set update - /// vote extensions in [`DigestCounters`]. - #[cfg(feature = "abcipp")] - fn has_proper_valset_upd_num(&self, meta: &ValidationMeta) -> bool { - // TODO: check if this logic is correct for ABCI++ - self.wl_storage - .ethbridge_queries() - .is_bridge_active() - .then(|| { - if self - .wl_storage - .ethbridge_queries() - .must_send_valset_upd(SendValsetUpd::AtPrevHeight) - { - meta.digests.valset_upd_digest_num - == usize::from( - self.wl_storage.storage.last_block.is_some(), - ) - } else { - true - } - }) - .unwrap_or(meta.digests.valset_upd_digest_num == 0) - } - /// Checks if it is not possible to include encrypted txs at the current /// block height. pub(super) fn encrypted_txs_not_allowed(&self) -> bool { @@ -946,11 +698,6 @@ where /// are covered by the e2e tests. #[cfg(test)] mod test_process_proposal { - #[cfg(feature = "abcipp")] - use std::collections::HashMap; - - #[cfg(feature = "abcipp")] - use assert_matches::assert_matches; use namada::ledger::replay_protection; use namada::ledger::storage_api::StorageWrite; use namada::proto::{ @@ -965,10 +712,6 @@ mod test_process_proposal { use namada::types::token::Amount; use namada::types::transaction::protocol::EthereumTxData; use namada::types::transaction::{Fee, Solution, WrapperTx}; - #[cfg(feature = "abcipp")] - use namada::types::vote_extensions::bridge_pool_roots::MultiSignedVext; - #[cfg(feature = "abcipp")] - use namada::types::vote_extensions::ethereum_events::MultiSignedEthEvent; use namada::types::vote_extensions::{bridge_pool_roots, ethereum_events}; use super::*; @@ -977,153 +720,10 @@ mod test_process_proposal { ProcessProposal, TestError, TestShell, }; use crate::node::ledger::shims::abcipp_shim_types::shim::request::ProcessedTx; - #[cfg(feature = "abcipp")] - use crate::node::ledger::shims::abcipp_shim_types::shim::TxBytes; use crate::wallet; const GAS_LIMIT_MULTIPLIER: u64 = 100_000; - #[cfg(feature = "abcipp")] - fn get_empty_eth_ev_digest(shell: &TestShell) -> TxBytes { - let protocol_key = shell.mode.get_protocol_key().expect("Test failed"); - let addr = shell - .mode - .get_validator_address() - .expect("Test failed") - .clone(); - let ext = ethereum_events::Vext::empty( - shell.wl_storage.storage.get_last_block_height(), - addr.clone(), - ) - .sign(protocol_key); - EthereumTxData::EthereumEvents(ethereum_events::VextDigest { - signatures: { - let mut s = HashMap::new(); - s.insert( - (addr, shell.wl_storage.storage.get_last_block_height()), - ext.sig, - ); - s - }, - events: vec![], - }) - .sign(protocol_key, shell.chain_id.clone()) - .to_bytes() - } - - /// Craft the tx bytes for the block proposal digest containing - /// all the Bridge pool root vote extensions. - #[cfg(feature = "abcipp")] - fn get_bp_roots_vext(shell: &TestShell) -> Vec { - let bp_root = shell.extend_vote_with_bp_roots().expect("Test failed"); - let tx = shell - .compress_bridge_pool_roots(vec![bp_root]) - .expect("Test failed"); - EthereumTxData::BridgePool(tx) - .sign( - shell.mode.get_protocol_key().expect("Test failed"), - shell.chain_id.clone(), - ) - .to_bytes() - } - - /// Test that if a proposal contains more than one - /// `ethereum_events::VextDigest`, we reject it. - #[test] - #[cfg(feature = "abcipp")] - fn test_more_than_one_vext_digest_rejected() { - const LAST_HEIGHT: BlockHeight = BlockHeight(2); - let (shell, _recv, _, _) = test_utils::setup_at_height(LAST_HEIGHT); - let (protocol_key, _, _) = wallet::defaults::validator_keys(); - let vote_extension_digest = { - let validator_addr = wallet::defaults::validator_address(); - let signed_vote_extension = { - let ext = ethereum_events::Vext::empty( - LAST_HEIGHT, - validator_addr.clone(), - ) - .sign(&protocol_key); - assert!(ext.verify(&protocol_key.ref_to()).is_ok()); - ext - }; - // Ethereum events digest with no observed events - ethereum_events::VextDigest { - signatures: { - let mut s = HashMap::new(); - s.insert( - ( - validator_addr, - shell.wl_storage.storage.get_last_block_height(), - ), - signed_vote_extension.sig, - ); - s - }, - events: vec![], - } - }; - let tx = EthereumTxData::EthereumEvents(vote_extension_digest) - .sign(&protocol_key, shell.chain_id.clone()) - .to_bytes(); - let request = ProcessProposal { - txs: vec![tx.clone(), tx], - }; - let results = shell.process_proposal(request); - assert_matches!( - results, Err(TestError::RejectProposal(s)) if s.len() == 2 - ); - } - - /// Test that if more than one bridge pool root vote extension - /// is added to a block, we reject the proposal. - #[cfg(feature = "abcipp")] - #[test] - fn check_multiple_bp_root_vexts_rejected() { - let (mut shell, _recv, _, _) = test_utils::setup_at_height(3u64); - let vext = shell.extend_vote_with_bp_roots().expect("Test failed"); - let tx = - EthereumTxData::BridgePool(MultiSignedVext(HashSet::from([vext]))) - .sign( - shell.mode.get_protocol_key().expect("Test failed."), - shell.chain_id.clone(), - ) - .to_bytes(); - assert!( - shell - .process_proposal(ProcessProposal { - txs: vec![tx.clone(), tx] - }) - .is_err() - ); - } - - #[cfg(feature = "abcipp")] - fn check_rejected_eth_events_digest( - shell: &mut TestShell, - vote_extension_digest: ethereum_events::VextDigest, - protocol_key: common::SecretKey, - ) { - let tx = EthereumTxData::EthereumEvents(vote_extension_digest) - .sign(&protocol_key, shell.chain_id.clone()) - .to_bytes(); - let request = ProcessProposal { txs: vec![tx] }; - let response = if let Err(TestError::RejectProposal(resp)) = - shell.process_proposal(request) - { - if let [resp] = resp.as_slice() { - resp.clone() - } else { - panic!("Test failed") - } - } else { - panic!("Test failed") - }; - assert_eq!( - response.result.code, - u32::from(ErrorCodes::InvalidVoteExtension) - ); - } - /// Check that we reject an eth events protocol tx /// if the bridge is not active. #[test] @@ -1146,15 +746,12 @@ mod test_process_proposal { .to_bytes(); let request = ProcessProposal { txs: vec![tx] }; - #[cfg(not(feature = "abcipp"))] - { - let [resp]: [ProcessedTx; 1] = shell - .process_proposal(request.clone()) - .expect("Test failed") - .try_into() - .expect("Test failed"); - assert_eq!(resp.result.code, u32::from(ErrorCodes::Ok)); - } + let [resp]: [ProcessedTx; 1] = shell + .process_proposal(request.clone()) + .expect("Test failed") + .try_into() + .expect("Test failed"); + assert_eq!(resp.result.code, u32::from(ErrorCodes::Ok)); deactivate_bridge(&mut shell); let response = if let Err(TestError::RejectProposal(resp)) = shell.process_proposal(request) @@ -1200,16 +797,13 @@ mod test_process_proposal { .to_bytes(); let request = ProcessProposal { txs: vec![tx] }; - #[cfg(not(feature = "abcipp"))] - { - let [resp]: [ProcessedTx; 1] = shell - .process_proposal(request.clone()) - .expect("Test failed") - .try_into() - .expect("Test failed"); + let [resp]: [ProcessedTx; 1] = shell + .process_proposal(request.clone()) + .expect("Test failed") + .try_into() + .expect("Test failed"); - assert_eq!(resp.result.code, u32::from(ErrorCodes::Ok)); - } + assert_eq!(resp.result.code, u32::from(ErrorCodes::Ok)); deactivate_bridge(&mut shell); let response = if let Err(TestError::RejectProposal(resp)) = shell.process_proposal(request) @@ -1228,105 +822,6 @@ mod test_process_proposal { ); } - /// Check that we reject an bp roots vext - /// if the bridge is not active. - #[cfg(feature = "abcipp")] - #[test] - fn check_rejected_vext_bridge_inactive() { - let (mut shell, _a, _b, _c) = test_utils::setup_at_height(3); - shell.wl_storage.storage.block.height = - shell.wl_storage.storage.get_last_block_height(); - shell.commit(); - let protocol_key = shell.mode.get_protocol_key().expect("Test failed"); - let addr = shell.mode.get_validator_address().expect("Test failed"); - let to_sign = get_bp_bytes_to_sign(); - let sig = Signed::<_, SignableEthMessage>::new( - shell.mode.get_eth_bridge_keypair().expect("Test failed"), - to_sign, - ) - .sig; - let vote_ext = bridge_pool_roots::Vext { - block_height: shell.wl_storage.storage.get_last_block_height(), - validator_addr: addr.clone(), - sig, - } - .sign(shell.mode.get_protocol_key().expect("Test failed")); - let mut txs = vec![ - EthereumTxData::BridgePool(vote_ext.into()) - .sign(protocol_key, shell.chain_id.clone()) - .to_bytes(), - ]; - - let event = EthereumEvent::TransfersToNamada { - nonce: 0u64.into(), - transfers: vec![], - }; - let ext = ethereum_events::Vext { - validator_addr: addr.clone(), - block_height: shell.wl_storage.storage.get_last_block_height(), - ethereum_events: vec![event.clone()], - } - .sign(protocol_key); - let vote_extension_digest = ethereum_events::VextDigest { - signatures: { - let mut s = HashMap::new(); - s.insert( - ( - addr.clone(), - shell.wl_storage.storage.get_last_block_height(), - ), - ext.sig, - ); - s - }, - events: vec![MultiSignedEthEvent { - event, - signers: { - let mut s = BTreeSet::new(); - s.insert(( - addr.clone(), - shell.wl_storage.storage.get_last_block_height(), - )); - s - }, - }], - }; - txs.push( - EthereumTxData::EthereumEvents(vote_extension_digest) - .sign(protocol_key, shell.chain_id.clone()) - .to_bytes(), - ); - let request = ProcessProposal { txs }; - let resps: [ProcessedTx; 2] = shell - .process_proposal(request.clone()) - .expect("Test failed") - .try_into() - .expect("Test failed"); - for resp in resps { - assert_eq!(resp.result.code, u32::from(ErrorCodes::Ok)); - } - deactivate_bridge(&mut shell); - if let Err(TestError::RejectProposal(resp)) = - shell.process_proposal(request) - { - if let [resp1, resp2] = resp.as_slice() { - assert_eq!( - resp1.result.code, - u32::from(ErrorCodes::InvalidVoteExtension) - ); - assert_eq!( - resp2.result.code, - u32::from(ErrorCodes::InvalidVoteExtension) - ); - } else { - panic!("Test failed") - } - } else { - panic!("Test failed") - }; - } - - #[cfg(not(feature = "abcipp"))] fn check_rejected_eth_events( shell: &mut TestShell, vote_extension: ethereum_events::SignedVext, @@ -1380,42 +875,7 @@ mod test_process_proposal { ext.sig = test_utils::invalidate_signature(ext.sig); ext }; - #[cfg(feature = "abcipp")] - { - let vote_extension_digest = ethereum_events::VextDigest { - signatures: { - let mut s = HashMap::new(); - s.insert( - ( - addr.clone(), - shell.wl_storage.storage.get_last_block_height(), - ), - ext.sig, - ); - s - }, - events: vec![MultiSignedEthEvent { - event, - signers: { - let mut s = BTreeSet::new(); - s.insert(( - addr, - shell.wl_storage.storage.get_last_block_height(), - )); - s - }, - }], - }; - check_rejected_eth_events_digest( - &mut shell, - vote_extension_digest, - protocol_key, - ); - } - #[cfg(not(feature = "abcipp"))] - { - check_rejected_eth_events(&mut shell, ext, protocol_key); - } + check_rejected_eth_events(&mut shell, ext, protocol_key); } /// Test that if a proposal contains Ethereum events with @@ -1423,9 +883,6 @@ mod test_process_proposal { #[test] fn test_drop_vext_with_invalid_bheights() { const LAST_HEIGHT: BlockHeight = BlockHeight(3); - #[cfg(feature = "abcipp")] - const INVALID_HEIGHT: BlockHeight = BlockHeight(LAST_HEIGHT.0 - 1); - #[cfg(not(feature = "abcipp"))] const INVALID_HEIGHT: BlockHeight = BlockHeight(LAST_HEIGHT.0 + 1); let (mut shell, _recv, _, _) = test_utils::setup_at_height(LAST_HEIGHT); let (protocol_key, _, _) = wallet::defaults::validator_keys(); @@ -1445,33 +902,7 @@ mod test_process_proposal { assert!(ext.verify(&protocol_key.ref_to()).is_ok()); ext }; - #[cfg(feature = "abcipp")] - { - let vote_extension_digest = ethereum_events::VextDigest { - signatures: { - let mut s = HashMap::new(); - s.insert((addr.clone(), INVALID_HEIGHT), ext.sig); - s - }, - events: vec![MultiSignedEthEvent { - event, - signers: { - let mut s = BTreeSet::new(); - s.insert((addr, INVALID_HEIGHT)); - s - }, - }], - }; - check_rejected_eth_events_digest( - &mut shell, - vote_extension_digest, - protocol_key, - ); - } - #[cfg(not(feature = "abcipp"))] - { - check_rejected_eth_events(&mut shell, ext, protocol_key); - } + check_rejected_eth_events(&mut shell, ext, protocol_key); } /// Test that if a proposal contains Ethereum events with @@ -1500,33 +931,7 @@ mod test_process_proposal { assert!(ext.verify(&protocol_key.ref_to()).is_ok()); ext }; - #[cfg(feature = "abcipp")] - { - let vote_extension_digest = ethereum_events::VextDigest { - signatures: { - let mut s = HashMap::new(); - s.insert((addr.clone(), LAST_HEIGHT), ext.sig); - s - }, - events: vec![MultiSignedEthEvent { - event, - signers: { - let mut s = BTreeSet::new(); - s.insert((addr, LAST_HEIGHT)); - s - }, - }], - }; - check_rejected_eth_events_digest( - &mut shell, - vote_extension_digest, - protocol_key, - ); - } - #[cfg(not(feature = "abcipp"))] - { - check_rejected_eth_events(&mut shell, ext, protocol_key); - } + check_rejected_eth_events(&mut shell, ext, protocol_key); } /// Test that if a wrapper tx is not signed, the block is rejected @@ -1806,26 +1211,6 @@ mod test_process_proposal { outer_tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted)); txs.push(outer_tx); } - #[cfg(feature = "abcipp")] - let response = { - let request = ProcessProposal { - txs: vec![ - txs[0].to_bytes(), - txs[2].to_bytes(), - txs[1].to_bytes(), - get_empty_eth_ev_digest(&shell), - ], - }; - if let Err(TestError::RejectProposal(mut resp)) = - shell.process_proposal(request) - { - assert_eq!(resp.len(), 4); - resp.remove(1) - } else { - panic!("Test failed") - } - }; - #[cfg(not(feature = "abcipp"))] let response = { let request = ProcessProposal { txs: vec![ diff --git a/apps/src/lib/node/ledger/shell/queries.rs b/apps/src/lib/node/ledger/shell/queries.rs index aad3386bae..db971cc0cb 100644 --- a/apps/src/lib/node/ledger/shell/queries.rs +++ b/apps/src/lib/node/ledger/shell/queries.rs @@ -137,7 +137,6 @@ where // which is not possible from `namada` since we do not have // access to the `Shell` there #[cfg(test)] -#[cfg(not(feature = "abcipp"))] mod test_queries { use namada::core::ledger::storage::EPOCH_SWITCH_BLOCKS_DELAY; use namada::ledger::pos::PosQueries; @@ -202,27 +201,6 @@ mod test_queries { .must_send_valset_upd(SendValsetUpd::Now), can_send, ); - // TODO(feature = "abcipp"): test - // `SendValsetUpd::AtPrevHeight`; `idx` is the value - // of the current index being iterated over - // the array `epoch_assertions` - // - // ```ignore - // if let Some((epoch, height, can_send)) = - // epoch_assertions.get(_idx.wrapping_sub(1)).copied() - // { - // assert_eq!( - // shell.storage.get_epoch(height.into()), - // Some(Epoch(epoch)) - // ); - // assert_eq!( - // shell.storage.must_send_valset_upd( - // SendValsetUpd::AtPrevHeight - // ), - // can_send, - // ); - // } - // ``` let params = shell.wl_storage.pos_queries().get_pos_params(); let consensus_set: Vec = @@ -263,13 +241,6 @@ mod test_queries { }; } - #[cfg(feature = "abcipp")] - test_must_send_valset_upd! { - // TODO(feature = "abcipp"): add some epoch assertions - epoch_assertions: [] - } - - #[cfg(not(feature = "abcipp"))] test_must_send_valset_upd! { epoch_assertions: [ // (current epoch, current block height, can send valset upd) diff --git a/apps/src/lib/node/ledger/shell/vote_extensions.rs b/apps/src/lib/node/ledger/shell/vote_extensions.rs index 1675179061..f0d2ad17a0 100644 --- a/apps/src/lib/node/ledger/shell/vote_extensions.rs +++ b/apps/src/lib/node/ledger/shell/vote_extensions.rs @@ -4,22 +4,15 @@ pub mod bridge_pool_vext; pub mod eth_events; pub mod val_set_update; -#[cfg(feature = "abcipp")] -use namada::ledger::pos::PosQueries; use namada::proto::{SignableEthMessage, Signed}; use namada::types::keccak::keccak_hash; use namada::types::transaction::protocol::EthereumTxData; -#[cfg(feature = "abcipp")] -use namada::types::vote_extensions::VoteExtensionDigest; use namada::types::vote_extensions::{ bridge_pool_roots, ethereum_events, validator_set_update, VoteExtension, }; use namada_sdk::eth_bridge::{EthBridgeQueries, SendValsetUpd}; use super::*; -#[cfg(feature = "abcipp")] -use crate::facade::tendermint_proto::abci::ExtendedVoteInfo; -#[cfg(not(feature = "abcipp"))] use crate::node::ledger::shims::abcipp_shim_types::shim::TxBytes; /// Message to be passed to `.expect()` calls in this module. @@ -77,20 +70,6 @@ where D: DB + for<'iter> DBIter<'iter> + Sync + 'static, H: StorageHasher + Sync + 'static, { - /// The ExtendVote ABCI++ method implementation. - /// - /// INVARIANT: This method must be stateless. - #[cfg(feature = "abcipp")] - #[inline] - pub fn extend_vote( - &mut self, - _req: request::ExtendVote, - ) -> response::ExtendVote { - response::ExtendVote { - vote_extension: self.craft_extension().serialize_to_vec(), - } - } - /// Creates the data to be added to a vote extension. /// /// INVARIANT: This method must be stateless. @@ -128,12 +107,6 @@ where .to_owned(); let ext = ethereum_events::Vext { - #[cfg(feature = "abcipp")] - block_height: self - .wl_storage - .pos_queries() - .get_current_decision_height(), - #[cfg(not(feature = "abcipp"))] block_height: self.wl_storage.storage.get_last_block_height(), ethereum_events, validator_addr, @@ -237,180 +210,8 @@ where }) } - /// The VerifyVoteExtension ABCI++ method. - /// - /// This checks that the vote extension: - /// * Correctly deserializes. - /// * The Ethereum events vote extension within was correctly signed by a - /// consensus validator. - /// * The validator set update vote extension within was correctly signed by - /// a consensus validator, in case it could have been sent at the current - /// block height. - /// * The Ethereum events vote extension block height signed over is correct - /// (for replay protection). - /// * The validator set update vote extension block height signed over is - /// correct (for replay protection). - /// - /// INVARIANT: This method must be stateless. - #[cfg(feature = "abcipp")] - pub fn verify_vote_extension( - &self, - req: request::VerifyVoteExtension, - ) -> response::VerifyVoteExtension { - use crate::facade::tendermint_proto::abci::response_verify_vote_extension::VerifyStatus; - - let ext = match VoteExtension::try_from_slice(&req.vote_extension[..]) { - Ok(ext) => ext, - Err(err) => { - tracing::warn!( - ?err, - ?req.validator_address, - ?req.hash, - req.height, - "Received undeserializable vote extension" - ); - return response::VerifyVoteExtension { - status: VerifyStatus::Reject.into(), - }; - } - }; - - let validated_eth_events = - self.verify_ethereum_events(&req, ext.ethereum_events); - let validated_bp_roots = - self.verify_bridge_pool_root(&req, ext.bridge_pool_root); - let validated_valset_upd = - self.verify_valset_update(&req, ext.validator_set_update); - - response::VerifyVoteExtension { - status: if validated_eth_events - && validated_bp_roots - && validated_valset_upd - { - VerifyStatus::Accept.into() - } else { - VerifyStatus::Reject.into() - }, - } - } - - /// Check if [`ethereum_events::Vext`] instances are valid. - #[cfg(feature = "abcipp")] - pub fn verify_ethereum_events( - &self, - req: &request::VerifyVoteExtension, - ext: Option>, - ) -> bool { - if !self.wl_storage.ethbridge_queries().is_bridge_active() { - ext.is_none() - } else if let Some(ext) = ext { - self.validate_eth_events_vext( - ext, - self.wl_storage.pos_queries().get_current_decision_height(), - ) - .then_some(true) - .unwrap_or_else(| | { - tracing::warn!( - ?req.validator_address, - ?req.hash, - req.height, - "Received Ethereum events vote extension that didn't validate" - ); - false - }) - } else { - false - } - } - - /// Check if [`bridge_pool_roots::Vext`] instances are valid. - #[cfg(feature = "abcipp")] - pub fn verify_bridge_pool_root( - &self, - req: &request::VerifyVoteExtension, - ext: Option, - ) -> bool { - if self.wl_storage.ethbridge_queries().is_bridge_active() { - if let Some(ext) = ext { - self.validate_bp_roots_vext( - ext, - self.wl_storage.storage.get_last_block_height(), - ) - .then_some(true) - .unwrap_or_else(|| { - tracing::warn!( - ?req.validator_address, - ?req.hash, - req.height, - "Received Bridge pool root vote extension that didn't validate" - ); - false - }) - } else { - false - } - } else { - ext.is_none() - } - } - - /// Check if [`validator_set_update::Vext`] instances are valid. - #[cfg(feature = "abcipp")] - pub fn verify_valset_update( - &self, - req: &request::VerifyVoteExtension, - ext: Option, - ) -> bool { - let Some(ext) = ext else { - // if no validator set update was provided, - // we must check if we are not supposed to - // send one at the current block height. - // remember, we need to gather a quorum of - // votes, so this check is quite important! - // - // can send = true -> verify = false - // can send = false -> verify = true - // - // (we simply invert the can send logic) - let verify_passes = !self.wl_storage - .ethbridge_queries() - .must_send_valset_upd(SendValsetUpd::Now); - if !verify_passes { - tracing::warn!( - ?req.validator_address, - ?req.hash, - req.height, - "Expected validator set update, but got none" - ); - } - return verify_passes; - }; - self.wl_storage - .ethbridge_queries() - .must_send_valset_upd(SendValsetUpd::Now) - .then(|| { - // we have a valset update vext when we're expecting one, - // cool, let's validate it - self.validate_valset_upd_vext( - ext, - self.wl_storage.storage.get_current_epoch().0, - ) - }) - .unwrap_or_else(|| { - // oh no, validation failed - tracing::warn!( - ?req.validator_address, - ?req.hash, - req.height, - "Invalid validator set update vote extension" - ); - false - }) - } - /// Given a slice of [`TxBytes`], return an iterator over the /// ones we could deserialize to vote extension protocol txs. - #[cfg(not(feature = "abcipp"))] pub fn deserialize_vote_extensions<'shell>( &'shell self, txs: &'shell [TxBytes], @@ -450,64 +251,6 @@ where } }) } - - /// Deserializes `vote_extensions` as [`VoteExtension`] instances, filtering - /// out invalid data, and splits these into [`ethereum_events::Vext`] - /// and [`validator_set_update::Vext`] instances. - #[cfg(feature = "abcipp")] - #[allow(clippy::type_complexity)] - pub fn split_vote_extensions( - &self, - vote_extensions: Vec, - ) -> ( - Option>>, - Option>>, - Vec, - ) { - let mut eth_evs = vec![]; - let mut bp_roots = vec![]; - let mut valset_upds = vec![]; - let bridge_active = - self.wl_storage.ethbridge_queries().is_bridge_active(); - - for ext in deserialize_vote_extensions(vote_extensions) { - if let Some(validator_set_update) = ext.validator_set_update { - valset_upds.push(validator_set_update); - } - if bridge_active { - if let Some(events) = ext.ethereum_events { - eth_evs.push(events); - } - if let Some(roots) = ext.bridge_pool_root { - bp_roots.push(roots); - } - } - } - if bridge_active { - (Some(eth_evs), Some(bp_roots), valset_upds) - } else { - (None, None, valset_upds) - } - } -} - -/// Given a `Vec` of [`ExtendedVoteInfo`], return an iterator over the -/// ones we could deserialize to [`VoteExtension`] -/// instances. -#[cfg(feature = "abcipp")] -pub fn deserialize_vote_extensions( - vote_extensions: Vec, -) -> impl Iterator + 'static { - vote_extensions.into_iter().filter_map(|vote| { - VoteExtension::try_from_slice(&vote.vote_extension[..]) - .map_err(|err| { - tracing::error!( - ?err, - "Failed to deserialize data as a VoteExtension", - ); - }) - .ok() - }) } /// Yields an iterator over the protocol transactions 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 03ade4ae05..e1aa564d01 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 @@ -8,8 +8,6 @@ use namada::proto::Signed; use namada::types::keccak::keccak_hash; use namada::types::storage::BlockHeight; use namada::types::token; -#[cfg(feature = "abcipp")] -use namada::types::voting_power::FractionalVotingPower; use super::*; use crate::node::ledger::shell::Shell; @@ -51,7 +49,7 @@ where (token::Amount, Signed), VoteExtensionError, > { - // NOTE(not(feature = "abciplus")): for ABCI++, we should pass + // NOTE: for ABCI++, we should pass // `last_height` here, instead of `ext.data.block_height` let ext_height_epoch = match self .wl_storage @@ -81,17 +79,6 @@ where return Err(VoteExtensionError::EthereumBridgeInactive); } - #[cfg(feature = "abcipp")] - if ext.data.block_height != last_height { - tracing::debug!( - ext_height = ?ext.data.block_height, - ?last_height, - "Bridge pool root's vote extension issued for a block height \ - different from the expected last height." - ); - return Err(VoteExtensionError::UnexpectedBlockHeight); - } - #[cfg(not(feature = "abcipp"))] if ext.data.block_height > last_height { tracing::debug!( ext_height = ?ext.data.block_height, @@ -209,68 +196,10 @@ where ext_1.data.validator_addr == ext_2.data.validator_addr }) } - - /// Compresses a set of signed Bridge pool roots into a single - /// [`bridge_pool_roots::MultiSignedVext`], whilst filtering invalid - /// [`Signed`] instances in the process. - #[cfg(feature = "abcipp")] - pub fn compress_bridge_pool_roots( - &self, - vote_extensions: Vec>, - ) -> Option { - let vexts_epoch = self - .wl_storage - .pos_queries() - .get_epoch(self.wl_storage.storage.get_last_block_height()) - .expect( - "The epoch of the last block height should always be known", - ); - let total_voting_power = u64::from( - self.wl_storage - .pos_queries() - .get_total_voting_power(Some(vexts_epoch)), - ); - let mut voting_power = FractionalVotingPower::default(); - - let mut bp_root_sigs = bridge_pool_roots::MultiSignedVext::default(); - - for (validator_voting_power, vote_extension) in - self.filter_invalid_bp_roots_vexts(vote_extensions) - { - // update voting power - let validator_voting_power = u64::from(validator_voting_power); - voting_power += FractionalVotingPower::new( - validator_voting_power, - total_voting_power, - ) - .expect( - "The voting power we obtain from storage should always be \ - valid", - ); - tracing::debug!( - ?vote_extension.sig, - ?vote_extension.data.validator_addr, - "Inserting signature into bridge_pool_roots::MultSignedVext" - ); - bp_root_sigs.insert(vote_extension); - } - if voting_power <= FractionalVotingPower::TWO_THIRDS { - tracing::error!( - "Tendermint has decided on a block including Ethereum events \ - reflecting <= 2/3 of the total stake" - ); - None - } else { - Some(bp_root_sigs) - } - } } #[cfg(test)] mod test_bp_vote_extensions { - #[cfg(feature = "abcipp")] - use borsh::BorshDeserialize; - #[cfg(not(feature = "abcipp"))] use namada::core::ledger::eth_bridge::storage::bridge_pool::get_key_from_hash; use namada::ledger::pos::PosQueries; use namada::ledger::storage_api::StorageWrite; @@ -284,22 +213,13 @@ mod test_bp_vote_extensions { }; use namada::proto::{SignableEthMessage, Signed}; use namada::tendermint_proto::v0_37::abci::VoteInfo; - #[cfg(not(feature = "abcipp"))] use namada::types::ethereum_events::Uint; - #[cfg(not(feature = "abcipp"))] use namada::types::keccak::{keccak_hash, KeccakHash}; use namada::types::key::*; use namada::types::storage::BlockHeight; use namada::types::token; use namada::types::vote_extensions::bridge_pool_roots; - #[cfg(feature = "abcipp")] - use namada::types::vote_extensions::VoteExtension; - #[cfg(not(feature = "abcipp"))] use namada_sdk::eth_bridge::EthBridgeQueries; - #[cfg(feature = "abcipp")] - use tendermint_proto_abcipp::abci::response_verify_vote_extension::VerifyStatus; - #[cfg(feature = "abcipp")] - use tower_abci_abcipp::request; use crate::node::ledger::shell::test_utils::*; use crate::node::ledger::shims::abcipp_shim_types::shim::request::FinalizeBlock; @@ -432,51 +352,6 @@ mod test_bp_vote_extensions { )) } - /// Test that signed bridge pool Merkle roots and nonces - /// are added to vote extensions and pass verification. - #[cfg(feature = "abcipp")] - #[test] - fn test_bp_root_vext() { - let (mut shell, _, _, _) = setup_at_height(3u64); - let address = shell - .mode - .get_validator_address() - .expect("Test failed") - .clone(); - - let vote_extension = - ::try_from_slice( - &shell.extend_vote(Default::default()).vote_extension[..], - ) - .expect("Test failed"); - let to_sign = get_bp_bytes_to_sign(); - let sig = Signed::<_, SignableEthMessage>::new( - shell.mode.get_eth_bridge_keypair().expect("Test failed"), - to_sign, - ) - .sig; - let bp_root = bridge_pool_roots::Vext { - block_height: shell.wl_storage.storage.get_last_block_height(), - validator_addr: address.clone(), - sig, - } - .sign(shell.mode.get_protocol_key().expect("Test failed")); - - assert_eq!(vote_extension.bridge_pool_root, Some(bp_root)); - let req = request::VerifyVoteExtension { - hash: vec![], - validator_address: address - .raw_hash() - .expect("Test failed") - .as_bytes() - .to_vec(), - height: 0, - vote_extension: vote_extension.serialize_to_vec(), - }; - let res = shell.verify_vote_extension(req); - assert_eq!(res.status, i32::from(VerifyStatus::Accept)); - } - /// Test that we de-duplicate the bridge pool vexts /// in a block proposal by validator address. #[test] @@ -605,18 +480,6 @@ mod test_bp_vote_extensions { ); } - /// Test that an [`bridge_pool_roots::Vext`] that labels its included - /// block height as lower than the current block height is rejected. - #[cfg(feature = "abcipp")] - #[test] - fn test_block_height_too_low() { - let (shell, _, _, _) = setup_at_height(3u64); - reject_incorrect_block_number( - (shell.wl_storage.storage.get_last_block_height().0 - 1).into(), - &shell, - ); - } - /// Test if we reject Bridge pool roots vote extensions /// issued at genesis. #[test] @@ -675,7 +538,6 @@ mod test_bp_vote_extensions { /// Test that we can verify vext from several block heights /// prior. - #[cfg(not(feature = "abcipp"))] #[test] fn test_vext_for_old_height() { let (mut shell, _recv, _, _oracle_control_recv) = setup_at_height(1u64); @@ -743,7 +605,6 @@ mod test_bp_vote_extensions { /// Test that if the wrong block height is given for the provided root, /// we reject. - #[cfg(not(feature = "abcipp"))] #[test] fn test_wrong_height_for_root() { let (mut shell, _recv, _, _oracle_control_recv) = setup_at_height(1u64); diff --git a/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs b/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs index 257626c4d1..a22881384b 100644 --- a/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs +++ b/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs @@ -12,8 +12,6 @@ use namada::types::token; use namada::types::vote_extensions::ethereum_events::{ self, MultiSignedEthEvent, }; -#[cfg(feature = "abcipp")] -use namada::types::voting_power::FractionalVotingPower; use namada_sdk::eth_bridge::EthBridgeQueries; use super::*; @@ -55,7 +53,7 @@ where (token::Amount, Signed), VoteExtensionError, > { - // NOTE(not(feature = "abciplus")): for ABCI++, we should pass + // NOTE: for ABCI++, we should pass // `last_height` here, instead of `ext.data.block_height` let ext_height_epoch = match self .wl_storage @@ -84,17 +82,6 @@ where ); return Err(VoteExtensionError::EthereumBridgeInactive); } - #[cfg(feature = "abcipp")] - if ext.data.block_height != last_height { - tracing::debug!( - ext_height = ?ext.data.block_height, - ?last_height, - "Ethereum events vote extension issued for a block height \ - different from the expected last height." - ); - return Err(VoteExtensionError::UnexpectedBlockHeight); - } - #[cfg(not(feature = "abcipp"))] if ext.data.block_height > last_height { tracing::debug!( ext_height = ?ext.data.block_height, @@ -310,30 +297,11 @@ where &self, vote_extensions: Vec>, ) -> Option { - #[cfg(not(feature = "abcipp"))] #[allow(clippy::question_mark)] if self.wl_storage.storage.last_block.is_none() { return None; } - #[cfg(feature = "abcipp")] - let vexts_epoch = self - .wl_storage - .pos_queries() - .get_epoch(self.wl_storage.storage.get_last_block_height()) - .expect( - "The epoch of the last block height should always be known", - ); - - #[cfg(feature = "abcipp")] - let total_voting_power = u64::from( - self.wl_storage - .pos_queries() - .get_total_voting_power(Some(vexts_epoch)), - ); - #[cfg(feature = "abcipp")] - let mut voting_power = FractionalVotingPower::default(); - let mut event_observers = BTreeMap::new(); let mut signatures = HashMap::new(); @@ -343,20 +311,6 @@ where let validator_addr = vote_extension.data.validator_addr; let block_height = vote_extension.data.block_height; - // update voting power - #[cfg(feature = "abcipp")] - { - let validator_voting_power = u64::from(_validator_voting_power); - voting_power += FractionalVotingPower::new( - validator_voting_power, - total_voting_power, - ) - .expect( - "The voting power we obtain from storage should always be \ - valid", - ); - } - // register all ethereum events seen by `validator_addr` for ev in vote_extension.data.ethereum_events { let signers = @@ -387,15 +341,6 @@ where } } - #[cfg(feature = "abcipp")] - if voting_power <= FractionalVotingPower::TWO_THIRDS { - tracing::error!( - "Tendermint has decided on a block including Ethereum events \ - reflecting <= 2/3 of the total stake" - ); - return None; - } - let events: Vec = event_observers .into_iter() .map(|(event, signers)| MultiSignedEthEvent { event, signers }) @@ -409,8 +354,6 @@ where mod test_vote_extensions { use std::convert::TryInto; - #[cfg(feature = "abcipp")] - use borsh::BorshDeserialize; use borsh_ext::BorshSerializeExt; use namada::core::ledger::storage_api::collections::lazy_map::{ NestedSubKey, SubKey, @@ -422,32 +365,16 @@ mod test_vote_extensions { consensus_validator_set_handle, read_consensus_validator_set_addresses_with_stake, }; - #[cfg(feature = "abcipp")] - use namada::proto::{SignableEthMessage, Signed}; use namada::tendermint_proto::v0_37::abci::VoteInfo; use namada::types::address::testing::gen_established_address; - #[cfg(feature = "abcipp")] - use namada::types::eth_abi::Encode; use namada::types::ethereum_events::{ EthAddress, EthereumEvent, TransferToEthereum, Uint, }; use namada::types::hash::Hash; - #[cfg(feature = "abcipp")] - use namada::types::keccak::keccak_hash; - #[cfg(feature = "abcipp")] - use namada::types::keccak::KeccakHash; use namada::types::key::*; use namada::types::storage::{Epoch, InnerEthEventsQueue}; - #[cfg(feature = "abcipp")] - use namada::types::vote_extensions::bridge_pool_roots; use namada::types::vote_extensions::ethereum_events; - #[cfg(feature = "abcipp")] - use namada::types::vote_extensions::VoteExtension; - #[cfg(feature = "abcipp")] - use crate::facade::tendermint_proto::abci::response_verify_vote_extension::VerifyStatus; - #[cfg(feature = "abcipp")] - use crate::facade::tower_abci::request; use crate::node::ledger::shell::test_utils::*; use crate::node::ledger::shims::abcipp_shim_types::shim::request::FinalizeBlock; @@ -590,64 +517,6 @@ mod test_vote_extensions { assert_eq!(expected_events, got_events); } - /// Test that ethereum events are added to vote extensions. - /// Check that vote extensions pass verification. - #[cfg(feature = "abcipp")] - #[tokio::test] - async fn test_eth_events_vote_extension() { - let (mut shell, _, oracle, _) = setup_at_height(1); - let address = shell - .mode - .get_validator_address() - .expect("Test failed") - .clone(); - let event_1 = EthereumEvent::TransfersToEthereum { - nonce: 0.into(), - transfers: vec![TransferToEthereum { - amount: 100.into(), - asset: EthAddress([1; 20]), - receiver: EthAddress([2; 20]), - checksum: Hash::default(), - }], - relayer: gen_established_address(), - }; - let event_2 = EthereumEvent::NewContract { - name: "Test".to_string(), - address: EthAddress([0; 20]), - }; - oracle.send(event_1.clone()).await.expect("Test failed"); - oracle.send(event_2.clone()).await.expect("Test failed"); - let vote_extension = - ::try_from_slice( - &shell.extend_vote(Default::default()).vote_extension[..], - ) - .expect("Test failed"); - - let [event_first, event_second]: [EthereumEvent; 2] = vote_extension - .ethereum_events - .clone() - .expect("Test failed") - .data - .ethereum_events - .try_into() - .expect("Test failed"); - - assert_eq!(event_first, event_1); - assert_eq!(event_second, event_2); - let req = request::VerifyVoteExtension { - hash: vec![], - validator_address: address - .raw_hash() - .expect("Test failed") - .as_bytes() - .to_vec(), - height: 1, - vote_extension: vote_extension.serialize_to_vec(), - }; - let res = shell.verify_vote_extension(req); - assert_eq!(res.status, i32::from(VerifyStatus::Accept)); - } - /// Test that Ethereum events signed by a non-validator are rejected #[test] fn test_eth_events_must_be_signed_by_validator() { @@ -677,56 +546,6 @@ mod test_vote_extensions { validator_addr: address.clone(), } .sign(&signing_key); - #[cfg(feature = "abcipp")] - let req = request::VerifyVoteExtension { - hash: vec![], - validator_address: address - .raw_hash() - .expect("Test failed") - .as_bytes() - .to_vec(), - height: 0, - vote_extension: VoteExtension { - ethereum_events: Some(ethereum_events.clone()), - bridge_pool_root: { - let to_sign = keccak_hash( - [ - KeccakHash([0; 32]).encode().into_inner(), - Uint::from(0).encode().into_inner(), - ] - .concat(), - ); - let sig = Signed::<_, SignableEthMessage>::new( - shell - .mode - .get_eth_bridge_keypair() - .expect("Test failed"), - to_sign, - ) - .sig; - Some( - bridge_pool_roots::Vext { - block_height: shell - .wl_storage - .storage - .get_last_block_height(), - validator_addr: address, - sig, - } - .sign( - shell.mode.get_protocol_key().expect("Test failed"), - ), - ) - }, - validator_set_update: None, - } - .serialize_to_vec(), - }; - #[cfg(feature = "abcipp")] - assert_eq!( - shell.verify_vote_extension(req).status, - i32::from(VerifyStatus::Reject) - ); assert!(!shell.validate_eth_events_vext( ethereum_events, shell.wl_storage.pos_queries().get_current_decision_height(), @@ -868,52 +687,6 @@ mod test_vote_extensions { validator_addr: address.clone(), }; - #[cfg(feature = "abcipp")] - { - let signed_vext = ethereum_events - .clone() - .sign(shell.mode.get_protocol_key().expect("Test failed")); - let bp_root = { - let to_sign = keccak_hash( - [ - KeccakHash([0; 32]).encode().into_inner(), - Uint::from(0).encode().into_inner(), - ] - .concat(), - ); - let sig = Signed::<_, SignableEthMessage>::new( - shell.mode.get_eth_bridge_keypair().expect("Test failed"), - to_sign, - ) - .sig; - bridge_pool_roots::Vext { - block_height: shell - .wl_storage - .storage - .get_last_block_height(), - validator_addr: address.clone(), - sig, - } - .sign(shell.mode.get_protocol_key().expect("Test failed")) - }; - let req = request::VerifyVoteExtension { - hash: vec![], - validator_address: address.serialize_to_vec(), - height: 0, - vote_extension: VoteExtension { - ethereum_events: Some(signed_vext), - bridge_pool_root: Some(bp_root), - validator_set_update: None, - } - .serialize_to_vec(), - }; - - assert_eq!( - shell.verify_vote_extension(req).status, - i32::from(VerifyStatus::Reject) - ); - } - ethereum_events.block_height = shell.wl_storage.storage.get_last_block_height() + 1; let signed_vext = ethereum_events @@ -947,18 +720,6 @@ mod test_vote_extensions { } .sign(shell.mode.get_protocol_key().expect("Test failed")); - #[cfg(feature = "abcipp")] - let req = request::VerifyVoteExtension { - hash: vec![], - validator_address: address.serialize_to_vec(), - height: 0, - vote_extension: vote_ext.serialize_to_vec(), - }; - #[cfg(feature = "abcipp")] - assert_eq!( - shell.verify_vote_extension(req).status, - i32::from(VerifyStatus::Reject) - ); assert!(!shell.validate_eth_events_vext( vote_ext, shell.wl_storage.storage.get_last_block_height() diff --git a/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs b/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs index 3111714c57..dea8cca877 100644 --- a/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs +++ b/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs @@ -9,8 +9,6 @@ use namada::ledger::storage::{DBIter, DB}; use namada::types::storage::Epoch; use namada::types::token; use namada::types::vote_extensions::validator_set_update; -#[cfg(feature = "abcipp")] -use namada::types::voting_power::FractionalVotingPower; use super::*; use crate::node::ledger::shell::Shell; @@ -202,30 +200,11 @@ where &self, vote_extensions: Vec, ) -> Option { - #[cfg(not(feature = "abcipp"))] #[allow(clippy::question_mark)] if self.wl_storage.storage.last_block.is_none() { return None; } - #[cfg(feature = "abcipp")] - let vexts_epoch = self - .wl_storage - .pos_queries() - .get_epoch(self.wl_storage.storage.get_last_block_height()) - .expect( - "The epoch of the last block height should always be known", - ); - - #[cfg(feature = "abcipp")] - let total_voting_power = u64::from( - self.wl_storage - .pos_queries() - .get_total_voting_power(Some(vexts_epoch)), - ); - #[cfg(feature = "abcipp")] - let mut voting_power = FractionalVotingPower::default(); - let mut voting_powers = None; let mut signatures = HashMap::new(); @@ -241,20 +220,6 @@ where let validator_addr = vote_extension.data.validator_addr; let signing_epoch = vote_extension.data.signing_epoch; - // update voting power - #[cfg(feature = "abcipp")] - { - let validator_voting_power = u64::from(_validator_voting_power); - voting_power += FractionalVotingPower::new( - validator_voting_power, - total_voting_power, - ) - .expect( - "The voting power we obtain from storage should always be \ - valid", - ); - } - // register the signature of `validator_addr` let addr = validator_addr.clone(); let sig = vote_extension.sig.clone(); @@ -278,22 +243,6 @@ where } } - #[cfg(feature = "abcipp")] - if voting_power <= FractionalVotingPower::TWO_THIRDS { - tracing::error!( - "Tendermint has decided on a block including validator set \ - update vote extensions reflecting <= 2/3 of the total stake" - ); - return None; - } - - #[cfg(feature = "abcipp")] - let voting_powers = voting_powers.expect( - "We have enough voting power, so at least one validator set \ - update vote extension must have been validated.", - ); - - #[cfg(not(feature = "abcipp"))] let voting_powers = voting_powers.unwrap_or_default(); Some(validator_set_update::VextDigest { @@ -305,9 +254,6 @@ where #[cfg(test)] mod test_vote_extensions { - #[cfg(feature = "abcipp")] - #[cfg(feature = "abcipp")] - use borsh::BorshSerialize; use namada::core::ledger::storage_api::collections::lazy_map::{ NestedSubKey, SubKey, }; @@ -317,31 +263,11 @@ mod test_vote_extensions { consensus_validator_set_handle, read_consensus_validator_set_addresses_with_stake, Epoch, }; - #[cfg(feature = "abcipp")] - use namada::proto::{SignableEthMessage, Signed}; use namada::tendermint_proto::v0_37::abci::VoteInfo; - #[cfg(feature = "abcipp")] - use namada::types::eth_abi::Encode; - #[cfg(feature = "abcipp")] - use namada::types::ethereum_events::Uint; - #[cfg(feature = "abcipp")] - use namada::types::keccak::keccak_hash; - #[cfg(feature = "abcipp")] - use namada::types::keccak::KeccakHash; use namada::types::key::RefTo; - #[cfg(feature = "abcipp")] - use namada::types::vote_extensions::bridge_pool_roots; - #[cfg(feature = "abcipp")] - use namada::types::vote_extensions::ethereum_events; use namada::types::vote_extensions::validator_set_update; - #[cfg(feature = "abcipp")] - use namada::types::vote_extensions::VoteExtension; use namada_sdk::eth_bridge::EthBridgeQueries; - #[cfg(feature = "abcipp")] - use crate::facade::tendermint_proto::abci::response_verify_vote_extension::VerifyStatus; - #[cfg(feature = "abcipp")] - use crate::facade::tower_abci::request; use crate::node::ledger::shell::test_utils::{self, get_pkh_from_address}; use crate::node::ledger::shims::abcipp_shim_types::shim::request::FinalizeBlock; use crate::wallet; @@ -381,60 +307,10 @@ mod test_vote_extensions { } .sign(eth_bridge_key), ); - #[cfg(feature = "abcipp")] - { - let protocol_key = - shell.mode.get_protocol_key().expect("Test failed"); - let ethereum_events = ethereum_events::Vext::empty( - shell.wl_storage.pos_queries().get_current_decision_height(), - validator_addr.clone(), - ) - .sign(protocol_key); - let bp_root = { - let to_sign = keccak_hash( - [ - KeccakHash([0; 32]).encode().into_inner(), - Uint::from(0).encode().into_inner(), - ] - .concat(), - ); - let sig = Signed::<_, SignableEthMessage>::new( - shell.mode.get_eth_bridge_keypair().expect("Test failed"), - to_sign, - ) - .sig; - bridge_pool_roots::Vext { - block_height: shell - .wl_storage - .storage - .get_last_block_height(), - validator_addr, - sig, - } - .sign(shell.mode.get_protocol_key().expect("Test failed")) - }; - let req = request::VerifyVoteExtension { - vote_extension: VoteExtension { - ethereum_events: Some(ethereum_events), - bridge_pool_root: Some(bp_root), - validator_set_update, - } - .serialize_to_vec(), - ..Default::default() - }; - - assert_eq!( - shell.verify_vote_extension(req).status, - i32::from(VerifyStatus::Reject) - ); - } - #[cfg(not(feature = "abcipp"))] - { - assert!(!shell.validate_valset_upd_vext( - validator_set_update.unwrap(), - signing_epoch, - )) - } + assert!(!shell.validate_valset_upd_vext( + validator_set_update.unwrap(), + signing_epoch, + )) } /// Test that validator set update vote extensions signed by @@ -469,51 +345,6 @@ mod test_vote_extensions { } .sign(ð_bridge_key), ); - #[cfg(feature = "abcipp")] - { - let ethereum_events = ethereum_events::Vext::empty( - shell.wl_storage.pos_queries().get_current_decision_height(), - validator_addr.clone(), - ) - .sign(&_protocol_key); - let bp_root = { - let to_sign = keccak_hash( - [ - KeccakHash([0; 32]).encode().into_inner(), - Uint::from(0).encode().into_inner(), - ] - .concat(), - ); - let sig = Signed::<_, SignableEthMessage>::new( - shell.mode.get_eth_bridge_keypair().expect("Test failed"), - to_sign, - ) - .sig; - bridge_pool_roots::Vext { - block_height: shell - .wl_storage - .storage - .get_last_block_height(), - validator_addr, - sig, - } - .sign(shell.mode.get_protocol_key().expect("Test failed")) - }; - let req = request::VerifyVoteExtension { - vote_extension: VoteExtension { - ethereum_events: Some(ethereum_events), - bridge_pool_root: Some(bp_root), - validator_set_update, - } - .serialize_to_vec(), - ..Default::default() - }; - assert_eq!( - shell.verify_vote_extension(req).status, - i32::from(VerifyStatus::Reject) - ); - } - #[cfg(not(feature = "abcipp"))] assert!(!shell.validate_valset_upd_vext( validator_set_update.unwrap(), signing_epoch, @@ -675,69 +506,12 @@ mod test_vote_extensions { ext.sig = test_utils::invalidate_signature(ext.sig); Some(ext) }; - #[cfg(feature = "abcipp")] - { - let protocol_key = - shell.mode.get_protocol_key().expect("Test failed"); - let ethereum_events = ethereum_events::Vext::empty( - shell.wl_storage.pos_queries().get_current_decision_height(), - validator_addr.clone(), - ) - .sign(protocol_key); - let bp_root = { - let to_sign = keccak_hash( - [ - KeccakHash([0; 32]).encode().into_inner(), - Uint::from(0).encode().into_inner(), - ] - .concat(), - ); - let sig = Signed::<_, SignableEthMessage>::new( - shell.mode.get_eth_bridge_keypair().expect("Test failed"), - to_sign, - ) - .sig; - bridge_pool_roots::Vext { - block_height: shell - .wl_storage - .storage - .get_last_block_height(), - validator_addr, - sig, - } - .sign(shell.mode.get_protocol_key().expect("Test failed")) - }; - let req = request::VerifyVoteExtension { - vote_extension: VoteExtension { - ethereum_events: Some(ethereum_events), - bridge_pool_root: Some(bp_root), - validator_set_update: validator_set_update.clone(), - } - .serialize_to_vec(), - ..Default::default() - }; - assert_eq!( - shell.verify_vote_extension(req).status, - i32::from(VerifyStatus::Reject) - ); - } assert!(!shell.validate_valset_upd_vext( validator_set_update.unwrap(), signing_epoch, )); } - /// Test if we reject a vote extension that did not include a validator - /// set update at a required height. - #[test] - #[cfg(feature = "abcipp")] - fn test_reject_vext_if_no_valset_upd() { - // current decision height = 2 -> must send valset upd - let (shell, _recv, _, _) = test_utils::setup_at_height(1); - let req = request::VerifyVoteExtension::default(); - assert!(!shell.verify_valset_update(&req, None)); - } - /// Test if a [`validator_set_update::Vext`] is signed with a secp key /// that belongs to a consensus validator of some previous epoch #[test] diff --git a/apps/src/lib/node/ledger/shims/abcipp_shim.rs b/apps/src/lib/node/ledger/shims/abcipp_shim.rs index 4910cf2274..a7ce85fbae 100644 --- a/apps/src/lib/node/ledger/shims/abcipp_shim.rs +++ b/apps/src/lib/node/ledger/shims/abcipp_shim.rs @@ -7,29 +7,21 @@ use std::task::{Context, Poll}; use futures::future::FutureExt; use namada::proof_of_stake::find_validator_by_raw_hash; use namada::proto::Tx; -#[cfg(not(feature = "abcipp"))] use namada::types::hash::Hash; use namada::types::key::tm_raw_hash_to_string; -#[cfg(not(feature = "abcipp"))] -use namada::types::storage::BlockHash; -use namada::types::storage::BlockHeight; -#[cfg(not(feature = "abcipp"))] +use namada::types::storage::{BlockHash, BlockHeight}; use namada::types::transaction::hash_tx; use tokio::sync::broadcast; use tokio::sync::mpsc::UnboundedSender; use tower::Service; use super::abcipp_shim_types::shim::request::{FinalizeBlock, ProcessedTx}; -#[cfg(not(feature = "abcipp"))] -use super::abcipp_shim_types::shim::TxBytes; -use super::abcipp_shim_types::shim::{Error, Request, Response}; +use super::abcipp_shim_types::shim::{Error, Request, Response, TxBytes}; use crate::config; use crate::config::{Action, ActionAtHeight}; -#[cfg(not(feature = "abcipp"))] use crate::facade::tendermint_proto::v0_37::abci::{ RequestBeginBlock, ResponseDeliverTx, }; -#[cfg(not(feature = "abcipp"))] use crate::facade::tower_abci::response::DeliverTx; use crate::facade::tower_abci::{BoxError, Request as Req, Response as Resp}; use crate::node::ledger::shell::{EthereumOracleChannels, Shell}; @@ -40,9 +32,7 @@ use crate::node::ledger::shell::{EthereumOracleChannels, Shell}; #[derive(Debug)] pub struct AbcippShim { service: Shell, - #[cfg(not(feature = "abcipp"))] begin_block_request: Option, - #[cfg(not(feature = "abcipp"))] delivered_txs: Vec, shell_recv: std::sync::mpsc::Receiver<( Req, @@ -80,9 +70,7 @@ impl AbcippShim { vp_wasm_compilation_cache, tx_wasm_compilation_cache, ), - #[cfg(not(feature = "abcipp"))] begin_block_request: None, - #[cfg(not(feature = "abcipp"))] delivered_txs: vec![], shell_recv, }, @@ -96,7 +84,6 @@ impl AbcippShim { ) } - #[cfg(not(feature = "abcipp"))] /// Get the hash of the txs in the block pub fn get_hash(&self) -> Hash { let bytes: Vec = @@ -119,39 +106,11 @@ impl AbcippShim { } _ => unreachable!(), }), - #[cfg(feature = "abcipp")] - Req::FinalizeBlock(block) => { - let block_time = - self.service.get_block_timestamp(block.time.clone()); - let unprocessed_txs = block.txs.clone(); - let (processing_results, _) = - self.service.process_txs(&block.txs, block_time); - let mut txs = Vec::with_capacity(unprocessed_txs.len()); - for (result, tx) in processing_results - .into_iter() - .zip(unprocessed_txs.into_iter()) - { - txs.push(ProcessedTx { tx, result }); - } - let mut finalize_req: FinalizeBlock = block.into(); - finalize_req.txs = txs; - self.service - .call(Request::FinalizeBlock(finalize_req)) - .map_err(Error::from) - .and_then(|res| match res { - Response::FinalizeBlock(resp) => { - Ok(Resp::FinalizeBlock(resp.into())) - } - _ => Err(Error::ConvertResp(res)), - }) - } - #[cfg(not(feature = "abcipp"))] Req::BeginBlock(block) => { // we save this data to be forwarded to finalize later self.begin_block_request = Some(block); Ok(Resp::BeginBlock(Default::default())) } - #[cfg(not(feature = "abcipp"))] Req::DeliverTx(tx) => { let mut deliver: DeliverTx = Default::default(); // Attach events to this transaction if possible @@ -162,7 +121,6 @@ impl AbcippShim { self.delivered_txs.push(tx.tx); Ok(Resp::DeliverTx(deliver)) } - #[cfg(not(feature = "abcipp"))] Req::EndBlock(_) => { let begin_block_request = self.begin_block_request.take().unwrap(); diff --git a/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs b/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs index f44f172369..f128070898 100644 --- a/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs +++ b/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs @@ -6,20 +6,13 @@ pub mod shim { use thiserror::Error; use super::{Request as Req, Response as Resp}; - #[cfg(feature = "abcipp")] - use crate::facade::tendermint_proto::abci::{ - RequestExtendVote, RequestVerifyVoteExtension, ResponseExtendVote, - ResponseVerifyVoteExtension, - }; - #[cfg(not(feature = "abcipp"))] - use crate::facade::tendermint_proto::v0_37::abci::ResponseEndBlock; use crate::facade::tendermint_proto::v0_37::abci::{ RequestApplySnapshotChunk, RequestCheckTx, RequestCommit, RequestEcho, RequestFlush, RequestInfo, RequestInitChain, RequestListSnapshots, RequestLoadSnapshotChunk, RequestOfferSnapshot, RequestPrepareProposal, RequestProcessProposal, RequestQuery, ResponseApplySnapshotChunk, - ResponseCheckTx, ResponseCommit, ResponseEcho, ResponseFlush, - ResponseInfo, ResponseInitChain, ResponseListSnapshots, + ResponseCheckTx, ResponseCommit, ResponseEcho, ResponseEndBlock, + ResponseFlush, ResponseInfo, ResponseInitChain, ResponseListSnapshots, ResponseLoadSnapshotChunk, ResponseOfferSnapshot, ResponseQuery, VoteInfo, }; @@ -62,10 +55,6 @@ pub mod shim { ProcessProposal(RequestProcessProposal), #[allow(dead_code)] RevertProposal(request::RevertProposal), - #[cfg(feature = "abcipp")] - ExtendVote(RequestExtendVote), - #[cfg(feature = "abcipp")] - VerifyVoteExtension(RequestVerifyVoteExtension), FinalizeBlock(request::FinalizeBlock), Commit(RequestCommit), Flush(RequestFlush), @@ -89,12 +78,6 @@ pub mod shim { Req::Commit(inner) => Ok(Request::Commit(inner)), Req::Flush(inner) => Ok(Request::Flush(inner)), Req::Echo(inner) => Ok(Request::Echo(inner)), - #[cfg(feature = "abcipp")] - Req::ExtendVote(inner) => Ok(Request::ExtendVote(inner)), - #[cfg(feature = "abcipp")] - Req::VerifyVoteExtension(inner) => { - Ok(Request::VerifyVoteExtension(inner)) - } Req::CheckTx(inner) => Ok(Request::CheckTx(inner)), Req::ListSnapshots(inner) => Ok(Request::ListSnapshots(inner)), Req::OfferSnapshot(inner) => Ok(Request::OfferSnapshot(inner)), @@ -124,12 +107,7 @@ pub mod shim { VerifyHeader(response::VerifyHeader), ProcessProposal(response::ProcessProposal), RevertProposal(response::RevertProposal), - #[cfg(feature = "abcipp")] - ExtendVote(ResponseExtendVote), - #[cfg(feature = "abcipp")] - VerifyVoteExtension(ResponseVerifyVoteExtension), FinalizeBlock(response::FinalizeBlock), - #[cfg(not(feature = "abcipp"))] EndBlock(ResponseEndBlock), Commit(ResponseCommit), Flush(ResponseFlush), @@ -169,12 +147,6 @@ pub mod shim { Response::PrepareProposal(inner) => { Ok(Resp::PrepareProposal(inner.into())) } - #[cfg(feature = "abcipp")] - Response::ExtendVote(inner) => Ok(Resp::ExtendVote(inner)), - #[cfg(feature = "abcipp")] - Response::VerifyVoteExtension(inner) => { - Ok(Resp::VerifyVoteExtension(inner)) - } _ => Err(Error::ConvertResp(resp)), } } @@ -184,18 +156,12 @@ pub mod shim { pub mod request { use std::convert::TryFrom; - #[cfg(not(feature = "abcipp"))] use namada::tendermint_proto::v0_37::abci::RequestBeginBlock; use namada::types::hash::Hash; use namada::types::storage::{BlockHash, Header}; use namada::types::time::DateTimeUtc; - #[cfg(feature = "abcipp")] - use tendermint_proto_abcipp::abci::{ - Misbehavior as Evidence, RequestFinalizeBlock, - }; use super::VoteInfo; - #[cfg(not(feature = "abcipp"))] use crate::facade::tendermint_proto::v0_37::abci::Misbehavior as Evidence; pub struct VerifyHeader; @@ -219,28 +185,6 @@ pub mod shim { pub votes: Vec, } - #[cfg(feature = "abcipp")] - impl From for FinalizeBlock { - fn from(req: RequestFinalizeBlock) -> FinalizeBlock { - FinalizeBlock { - hash: BlockHash::try_from(req.hash.as_slice()).unwrap(), - header: Header { - hash: Hash::try_from(req.hash.as_slice()).unwrap(), - time: DateTimeUtc::try_from(req.time.unwrap()).unwrap(), - next_validators_hash: Hash::try_from( - req.next_validators_hash.as_slice(), - ) - .unwrap(), - }, - byzantine_validators: req.byzantine_validators, - txs: vec![], - proposer_address: req.proposer_address, - votes: req.decided_last_commit.unwrap().votes, - } - } - } - - #[cfg(not(feature = "abcipp"))] impl From for FinalizeBlock { fn from(req: RequestBeginBlock) -> FinalizeBlock { let header = req.header.unwrap(); @@ -268,36 +212,18 @@ pub mod shim { /// Custom types for response payloads pub mod response { use namada::ledger::events::Event; - #[cfg(feature = "abcipp")] - use namada::ledger::events::EventLevel; use crate::facade::tendermint_proto::v0_37::abci::{ Event as TmEvent, ResponsePrepareProposal, ResponseProcessProposal, ValidatorUpdate, }; - #[cfg(not(feature = "abcipp"))] use crate::facade::tendermint_proto::v0_37::types::ConsensusParams; - #[cfg(feature = "abcipp")] - use crate::facade::tendermint_proto::{ - abci::{ExecTxResult, ResponseFinalizeBlock}, - types::ConsensusParams, - }; #[derive(Debug, Default)] pub struct PrepareProposal { pub txs: Vec, } - #[cfg(feature = "abcipp")] - impl From for ResponsePrepareProposal { - fn from(_: PrepareProposal) -> Self { - // TODO(namada#198): When abci++ arrives, we should return a - // real response. - Self::default() - } - } - - #[cfg(not(feature = "abcipp"))] impl From for ResponsePrepareProposal { fn from(resp: PrepareProposal) -> Self { Self { txs: resp.txs } @@ -312,49 +238,12 @@ pub mod shim { pub info: String, } - #[cfg(feature = "abcipp")] - impl From for ExecTxResult { - fn from(TxResult { code, info }: TxResult) -> Self { - ExecTxResult { - code, - info, - ..Default::default() - } - } - } - - #[cfg(feature = "abcipp")] - impl From<&ExecTxResult> for TxResult { - fn from(ExecTxResult { code, info, .. }: &ExecTxResult) -> Self { - TxResult { - code: *code, - info: info.clone(), - } - } - } - #[derive(Debug, Default)] pub struct ProcessProposal { pub status: i32, pub tx_results: Vec, } - #[cfg(feature = "abcipp")] - impl From<&ProcessProposal> for ResponseProcessProposal { - fn from(resp: &ProcessProposal) -> Self { - Self { - status: resp.status, - tx_results: resp - .tx_results - .iter() - .map(|res| ExecTxResult::from(res.clone())) - .collect(), - ..Default::default() - } - } - } - - #[cfg(not(feature = "abcipp"))] impl From<&ProcessProposal> for ResponseProcessProposal { fn from(resp: &ProcessProposal) -> Self { Self { @@ -373,47 +262,6 @@ pub mod shim { pub consensus_param_updates: Option, } - #[cfg(feature = "abcipp")] - impl From for ResponseFinalizeBlock { - fn from(resp: FinalizeBlock) -> Self { - ResponseFinalizeBlock { - tx_results: resp - .events - .iter() - .filter(|event| matches!(event.level, EventLevel::Tx)) - .map(|event| ExecTxResult { - code: event - .get("code") - .map(|code| code.parse::().unwrap()) - .unwrap_or_default(), - log: event - .get("log") - .map(|log| log.to_owned()) - .unwrap_or_default(), - info: event - .get("info") - .map(|info| info.to_owned()) - .unwrap_or_default(), - gas_used: event - .get("gas_used") - .map(|gas| gas.parse::().unwrap()) - .unwrap_or_default(), - ..Default::default() - }) - .collect(), - events: resp - .events - .into_iter() - .map(TmEvent::from) - .collect(), - consensus_param_updates: resp.consensus_param_updates, - validator_updates: resp.validator_updates, - ..Default::default() - } - } - } - - #[cfg(not(feature = "abcipp"))] impl From for crate::facade::tendermint_proto::v0_37::abci::ResponseEndBlock { diff --git a/apps/src/lib/node/ledger/tendermint_node.rs b/apps/src/lib/node/ledger/tendermint_node.rs index 7698b4b08a..f57b843492 100644 --- a/apps/src/lib/node/ledger/tendermint_node.rs +++ b/apps/src/lib/node/ledger/tendermint_node.rs @@ -10,8 +10,6 @@ use namada::types::storage::BlockHeight; use namada::types::time::DateTimeUtc; use serde_json::json; use sha2::{Digest, Sha256}; -#[cfg(feature = "abcipp")] -use tendermint_abcipp::Moniker; use thiserror::Error; use tokio::fs::{self, File, OpenOptions}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -20,9 +18,7 @@ use tokio::process::Command; use crate::cli::namada_version; use crate::config; use crate::facade::tendermint::node::Id as TendermintNodeId; -#[cfg(feature = "abciplus")] -use crate::facade::tendermint::Moniker; -use crate::facade::tendermint::{block, Genesis}; +use crate::facade::tendermint::{block, Genesis, Moniker}; use crate::facade::tendermint_config::{ Error as TendermintError, TendermintConfig, }; @@ -96,9 +92,6 @@ pub async fn run( panic!("Tendermint failed to initialize with {:#?}", output); } - #[cfg(feature = "abcipp")] - write_tm_genesis(&home_dir, chain_id, genesis_time, &config).await; - #[cfg(not(feature = "abcipp"))] write_tm_genesis(&home_dir, chain_id, genesis_time).await; update_tendermint_config(&home_dir, config.cometbft).await?; @@ -392,7 +385,6 @@ async fn write_tm_genesis( home_dir: impl AsRef, chain_id: ChainId, genesis_time: DateTimeUtc, - #[cfg(feature = "abcipp")] config: &config::Tendermint, ) { let home_dir = home_dir.as_ref(); let path = home_dir.join("config").join("genesis.json"); @@ -428,11 +420,6 @@ async fn write_tm_genesis( time_iota_ms: block::Size::default_time_iota_ms(), }; genesis.consensus_params.block = size; - #[cfg(feature = "abcipp")] - { - genesis.consensus_params.timeout.commit = - config.consensus_timeout_commit.into(); - } let mut file = OpenOptions::new() .write(true) diff --git a/core/Cargo.toml b/core/Cargo.toml index 2ee442a3e4..7b4497e920 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true version.workspace = true [features] -default = ["abciplus", "ferveo-tpke"] +default = ["ferveo-tpke"] mainnet = [] ferveo-tpke = [ "ferveo", @@ -26,14 +26,6 @@ wasm-runtime = [ "rayon", ] -abciplus = [ - "ibc", - "ibc-derive", - "ibc-proto", - "tendermint", - "tendermint-proto", -] - ibc-mocks = [ "ibc/mocks", ] @@ -68,9 +60,9 @@ eyre.workspace = true ferveo = {optional = true, git = "https://github.com/anoma/ferveo", rev = "e5abd0acc938da90140351a65a26472eb495ce4d"} ferveo-common = {git = "https://github.com/anoma/ferveo", rev = "e5abd0acc938da90140351a65a26472eb495ce4d"} tpke = {package = "group-threshold-cryptography", optional = true, git = "https://github.com/anoma/ferveo", rev = "e5abd0acc938da90140351a65a26472eb495ce4d"} -ibc = { version = "0.47.0", default-features = false, features = ["serde"], optional = true} -ibc-derive = { version = "0.3.0", optional = true} -ibc-proto = {version = "0.37.1", default-features = false, optional = true} +ibc = { version = "0.47.0", default-features = false, features = ["serde"]} +ibc-derive = { version = "0.3.0"} +ibc-proto = {version = "0.37.1", default-features = false} ics23.workspace = true impl-num-traits = "0.1.2" index-set.workspace = true @@ -92,8 +84,8 @@ rayon = {version = "=1.5.3", optional = true} serde.workspace = true serde_json.workspace = true sha2.workspace = true -tendermint = {workspace = true, optional = true} -tendermint-proto = {workspace = true, optional = true} +tendermint = {workspace = true} +tendermint-proto = {workspace = true} thiserror.workspace = true tiny-keccak = {version = "2.0.2", features = ["keccak"]} tracing.workspace = true diff --git a/core/src/ledger/mod.rs b/core/src/ledger/mod.rs index 301cf78e08..93a48e76d9 100644 --- a/core/src/ledger/mod.rs +++ b/core/src/ledger/mod.rs @@ -3,7 +3,6 @@ pub mod eth_bridge; pub mod gas; pub mod governance; -#[cfg(any(feature = "abciplus", feature = "abcipp"))] pub mod ibc; pub mod inflation; pub mod parameters; diff --git a/core/src/ledger/storage/merkle_tree.rs b/core/src/ledger/storage/merkle_tree.rs index 3f4187b0da..f0bbd46208 100644 --- a/core/src/ledger/storage/merkle_tree.rs +++ b/core/src/ledger/storage/merkle_tree.rs @@ -735,7 +735,6 @@ pub struct Proof { pub base_proof: CommitmentProof, } -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] impl From for crate::tendermint::merkle::proof::ProofOps { fn from( Proof { diff --git a/core/src/ledger/storage/mod.rs b/core/src/ledger/storage/mod.rs index 3061dad876..5740a6e303 100644 --- a/core/src/ledger/storage/mod.rs +++ b/core/src/ledger/storage/mod.rs @@ -39,7 +39,6 @@ use crate::ledger::parameters::{self, EpochDuration, Parameters}; use crate::ledger::storage::merkle_tree::{ Error as MerkleTreeError, MerkleRoot, }; -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] use crate::tendermint::merkle::proof::ProofOps; use crate::types::address::{ masp, Address, EstablishedAddressGen, InternalAddress, @@ -939,7 +938,6 @@ where /// Tendermint-compatible. Requesting for a key /// belonging to the bridge pool will cause this /// method to error. - #[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] pub fn get_existence_proof( &self, key: &Key, diff --git a/core/src/proto/types.rs b/core/src/proto/types.rs index 0bf17ff8c5..45efed6b27 100644 --- a/core/src/proto/types.rs +++ b/core/src/proto/types.rs @@ -28,7 +28,6 @@ use thiserror::Error; use super::generated::types; use crate::ledger::gas::{self, GasMetering, VpGasMeter, VERIFY_TX_SIG_GAS}; use crate::ledger::storage::{KeccakHasher, Sha256Hasher, StorageHasher}; -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] use crate::tendermint_proto::v0_37::abci::ResponseDeliverTx; use crate::types::account::AccountPublicKeysMap; use crate::types::address::Address; @@ -1843,7 +1842,6 @@ impl Tx { } } -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] impl From for ResponseDeliverTx { #[cfg(not(feature = "ferveo-tpke"))] fn from(_tx: Tx) -> ResponseDeliverTx { diff --git a/core/src/types/hash.rs b/core/src/types/hash.rs index 9b69935add..af2d94d8ed 100644 --- a/core/src/types/hash.rs +++ b/core/src/types/hash.rs @@ -140,7 +140,6 @@ impl Hash { } } -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] impl From for crate::tendermint::Hash { fn from(hash: Hash) -> Self { Self::Sha256(hash.0) diff --git a/core/src/types/ibc.rs b/core/src/types/ibc.rs index ddc2b09a84..9490f1efdc 100644 --- a/core/src/types/ibc.rs +++ b/core/src/types/ibc.rs @@ -5,10 +5,18 @@ use std::collections::HashMap; use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use data_encoding::{DecodePartial, HEXLOWER, HEXLOWER_PERMISSIVE}; +use borsh_ext::BorshSerializeExt; +use data_encoding::{DecodePartial, HEXLOWER, HEXLOWER_PERMISSIVE, HEXUPPER}; use serde::{Deserialize, Serialize}; +use thiserror::Error; use super::address::HASH_LEN; +use crate::ibc::applications::transfer::{Memo, PrefixedDenom, TracePath}; +use crate::ibc::core::events::{ + Error as IbcEventError, IbcEvent as RawIbcEvent, +}; +use crate::tendermint::abci::Event as AbciEvent; +use crate::types::masp::PaymentAddress; /// The event type defined in ibc-rs for receiving a token pub const EVENT_TYPE_PACKET: &str = "fungible_token_packet"; @@ -99,116 +107,93 @@ pub struct IbcShieldedTransfer { pub masp_tx: masp_primitives::transaction::Transaction, } -#[cfg(any(feature = "abciplus", feature = "abcipp"))] -mod ibc_rs_conversion { - use std::collections::HashMap; - use std::str::FromStr; +#[allow(missing_docs)] +#[derive(Error, Debug)] +pub enum Error { + #[error("IBC event error: {0}")] + IbcEvent(IbcEventError), + #[error("IBC transfer memo HEX decoding error: {0}")] + DecodingHex(data_encoding::DecodeError), + #[error("IBC transfer memo decoding error: {0}")] + DecodingShieldedTransfer(std::io::Error), +} - use borsh::BorshDeserialize; - use borsh_ext::BorshSerializeExt; - use data_encoding::HEXUPPER; - use thiserror::Error; +/// Conversion functions result +pub type Result = std::result::Result; - use super::{IbcEvent, IbcShieldedTransfer, EVENT_TYPE_PACKET}; - use crate::ibc::applications::transfer::{Memo, PrefixedDenom, TracePath}; - use crate::ibc::core::events::{ - Error as IbcEventError, IbcEvent as RawIbcEvent, - }; - use crate::tendermint::abci::Event as AbciEvent; - use crate::types::masp::PaymentAddress; - - #[allow(missing_docs)] - #[derive(Error, Debug)] - pub enum Error { - #[error("IBC event error: {0}")] - IbcEvent(IbcEventError), - #[error("IBC transfer memo HEX decoding error: {0}")] - DecodingHex(data_encoding::DecodeError), - #[error("IBC transfer memo decoding error: {0}")] - DecodingShieldedTransfer(std::io::Error), - } +impl TryFrom for IbcEvent { + type Error = Error; - /// Conversion functions result - pub type Result = std::result::Result; - - impl TryFrom for IbcEvent { - type Error = Error; - - fn try_from(e: RawIbcEvent) -> Result { - let event_type = e.event_type().to_string(); - let abci_event = AbciEvent::try_from(e).map_err(Error::IbcEvent)?; - let attributes: HashMap<_, _> = abci_event - .attributes - .iter() - .map(|tag| (tag.key.to_string(), tag.value.to_string())) - .collect(); - Ok(Self { - event_type, - attributes, - }) - } + fn try_from(e: RawIbcEvent) -> Result { + let event_type = e.event_type().to_string(); + let abci_event = AbciEvent::try_from(e).map_err(Error::IbcEvent)?; + let attributes: HashMap<_, _> = abci_event + .attributes + .iter() + .map(|tag| (tag.key.to_string(), tag.value.to_string())) + .collect(); + Ok(Self { + event_type, + attributes, + }) } +} - /// Returns the trace path and the token string if the denom is an IBC - /// denom. - pub fn is_ibc_denom(denom: impl AsRef) -> Option<(TracePath, String)> { - let prefixed_denom = PrefixedDenom::from_str(denom.as_ref()).ok()?; - if prefixed_denom.trace_path.is_empty() { - return None; - } - // The base token isn't decoded because it could be non Namada token - Some(( - prefixed_denom.trace_path, - prefixed_denom.base_denom.to_string(), - )) +/// Returns the trace path and the token string if the denom is an IBC +/// denom. +pub fn is_ibc_denom(denom: impl AsRef) -> Option<(TracePath, String)> { + let prefixed_denom = PrefixedDenom::from_str(denom.as_ref()).ok()?; + if prefixed_denom.trace_path.is_empty() { + return None; } + // The base token isn't decoded because it could be non Namada token + Some(( + prefixed_denom.trace_path, + prefixed_denom.base_denom.to_string(), + )) +} - impl From for Memo { - fn from(shielded: IbcShieldedTransfer) -> Self { - let bytes = shielded.serialize_to_vec(); - HEXUPPER.encode(&bytes).into() - } +impl From for Memo { + fn from(shielded: IbcShieldedTransfer) -> Self { + let bytes = shielded.serialize_to_vec(); + HEXUPPER.encode(&bytes).into() } +} - impl TryFrom for IbcShieldedTransfer { - type Error = Error; +impl TryFrom for IbcShieldedTransfer { + type Error = Error; - fn try_from(memo: Memo) -> Result { - let bytes = HEXUPPER - .decode(memo.as_ref().as_bytes()) - .map_err(Error::DecodingHex)?; - Self::try_from_slice(&bytes) - .map_err(Error::DecodingShieldedTransfer) - } + fn try_from(memo: Memo) -> Result { + let bytes = HEXUPPER + .decode(memo.as_ref().as_bytes()) + .map_err(Error::DecodingHex)?; + Self::try_from_slice(&bytes).map_err(Error::DecodingShieldedTransfer) } +} - /// Get the shielded transfer from the memo - pub fn get_shielded_transfer( - event: &IbcEvent, - ) -> Result> { - if event.event_type != EVENT_TYPE_PACKET { - // This event is not for receiving a token - return Ok(None); - } - let is_success = - event.attributes.get("success") == Some(&"true".to_string()); - let receiver = event.attributes.get("receiver"); - let is_shielded = if let Some(receiver) = receiver { - PaymentAddress::from_str(receiver).is_ok() - } else { - false - }; - if !is_success || !is_shielded { - return Ok(None); - } - - event - .attributes - .get("memo") - .map(|memo| IbcShieldedTransfer::try_from(Memo::from(memo.clone()))) - .transpose() +/// Get the shielded transfer from the memo +pub fn get_shielded_transfer( + event: &IbcEvent, +) -> Result> { + if event.event_type != EVENT_TYPE_PACKET { + // This event is not for receiving a token + return Ok(None); + } + let is_success = + event.attributes.get("success") == Some(&"true".to_string()); + let receiver = event.attributes.get("receiver"); + let is_shielded = if let Some(receiver) = receiver { + PaymentAddress::from_str(receiver).is_ok() + } else { + false + }; + if !is_success || !is_shielded { + return Ok(None); } -} -#[cfg(any(feature = "abciplus", feature = "abcipp"))] -pub use ibc_rs_conversion::*; + event + .attributes + .get("memo") + .map(|memo| IbcShieldedTransfer::try_from(Memo::from(memo.clone()))) + .transpose() +} diff --git a/core/src/types/time.rs b/core/src/types/time.rs index 948bf6373f..99ddd25d6d 100644 --- a/core/src/types/time.rs +++ b/core/src/types/time.rs @@ -264,7 +264,6 @@ impl From for prost_types::Timestamp { } } -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] impl TryFrom for DateTimeUtc { @@ -301,7 +300,6 @@ impl From for Rfc3339String { } } -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] impl TryFrom for crate::tendermint::time::Time { type Error = crate::tendermint::Error; @@ -310,7 +308,6 @@ impl TryFrom for crate::tendermint::time::Time { } } -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] impl TryFrom for DateTimeUtc { type Error = chrono::ParseError; @@ -319,14 +316,12 @@ impl TryFrom for DateTimeUtc { } } -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] impl From for DurationNanos { fn from(val: crate::tendermint::Timeout) -> Self { Self::from(std::time::Duration::from(val)) } } -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] impl From for crate::tendermint::Timeout { fn from(val: DurationNanos) -> Self { Self::from(std::time::Duration::from(val)) diff --git a/core/src/types/vote_extensions.rs b/core/src/types/vote_extensions.rs index 2b532e5192..f38b4b494e 100644 --- a/core/src/types/vote_extensions.rs +++ b/core/src/types/vote_extensions.rs @@ -21,24 +21,3 @@ pub struct VoteExtension { /// Vote extension data related with validator set updates. pub validator_set_update: Option, } - -/// The digest of the signatures from different validators -/// in [`VoteExtension`] instances. -/// -/// From a [`VoteExtensionDigest`] we yield two signed -/// [`crate::types::transaction::protocol::ProtocolTxType`] transactions: -/// - A `ProtocolTxType::EthereumEvents` tx, and -/// - A `ProtocolTxType::ValidatorSetUpdate` tx -#[derive( - Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize, BorshSchema, -)] -#[cfg(feature = "abcipp")] -pub struct VoteExtensionDigest { - /// The digest of Ethereum events vote extension signatures. - pub ethereum_events: Option, - /// A set of signatures for the current Ethereum bridge pool root and - /// nonce. - pub bridge_pool_roots: Option, - /// The digest of validator set updates vote extension signatures. - pub validator_set_update: Option, -} diff --git a/core/src/types/vote_extensions/ethereum_events.rs b/core/src/types/vote_extensions/ethereum_events.rs index efd019c76b..beca881fcb 100644 --- a/core/src/types/vote_extensions/ethereum_events.rs +++ b/core/src/types/vote_extensions/ethereum_events.rs @@ -145,8 +145,6 @@ mod tests { use crate::types::hash::Hash; use crate::types::key; use crate::types::key::RefTo; - #[cfg(feature = "abcipp")] - use crate::types::storage::BlockHeight; /// Test the hashing of an Ethereum event #[test] @@ -204,7 +202,6 @@ mod tests { // so each of them signs `ext` with their respective sk let ext_1 = Signed::new(&sk_1, ext(validator_1.clone())); let ext_2 = Signed::new(&sk_2, ext(validator_2.clone())); - #[cfg(not(feature = "abcipp"))] let ext_3 = Signed::new(&sk_1, { let mut ext = Vext::empty( BlockHeight(last_block_height.0 - 1), @@ -216,21 +213,10 @@ mod tests { ext }); - #[cfg(feature = "abcipp")] - let ext = vec![ext_1, ext_2]; - #[cfg(not(feature = "abcipp"))] let ext = vec![ext_1, ext_2, ext_3]; // we have the `Signed` instances we need, // let us now compress them into a single `VextDigest` - #[cfg(feature = "abcipp")] - let signatures: HashMap<_, _> = [ - ((validator_1.clone(), last_block_height), ext[0].sig.clone()), - ((validator_2.clone(), last_block_height), ext[1].sig.clone()), - ] - .into_iter() - .collect(); - #[cfg(not(feature = "abcipp"))] let signatures: HashMap<_, _> = [ ((validator_1.clone(), last_block_height), ext[0].sig.clone()), ((validator_2.clone(), last_block_height), ext[1].sig.clone()), @@ -241,15 +227,7 @@ mod tests { ] .into_iter() .collect(); - #[cfg(feature = "abcipp")] - let signers = { - let mut s = BTreeSet::new(); - s.insert((validator_1.clone(), last_block_height)); - s.insert((validator_2, last_block_height)); - s - }; - #[cfg(not(feature = "abcipp"))] let signers = { let mut s = BTreeSet::new(); s.insert((validator_1.clone(), last_block_height)); diff --git a/encoding_spec/Cargo.toml b/encoding_spec/Cargo.toml index 61fe37995d..972c50a2cc 100644 --- a/encoding_spec/Cargo.toml +++ b/encoding_spec/Cargo.toml @@ -13,10 +13,7 @@ repository.workspace = true version.workspace = true [features] -default = ["abciplus"] -abciplus = [ - "namada/abciplus" -] +default = [] [dependencies] namada = {path = "../shared"} diff --git a/ethereum_bridge/Cargo.toml b/ethereum_bridge/Cargo.toml index bd1b8908b6..3adb7b9cd5 100644 --- a/ethereum_bridge/Cargo.toml +++ b/ethereum_bridge/Cargo.toml @@ -13,17 +13,7 @@ repository.workspace = true version.workspace = true [features] -default = ["abciplus"] - -abciplus = [ - "tendermint", - "tendermint-rpc", - "tendermint-proto", - "namada_core/abciplus", - "namada_core/tendermint", - "namada_proof_of_stake/abciplus", -] - +default = [] testing = [ "namada_core/testing", ] @@ -40,9 +30,9 @@ itertools.workspace = true serde.workspace = true serde_json.workspace = true rand.workspace = true -tendermint = {workspace = true, optional = true} -tendermint-rpc = {workspace = true, optional = true} -tendermint-proto = {workspace = true, optional = true} +tendermint = {workspace = true} +tendermint-rpc = {workspace = true} +tendermint-proto = {workspace = true} tracing = "0.1.30" [dev-dependencies] diff --git a/ethereum_bridge/src/storage/eth_bridge_queries.rs b/ethereum_bridge/src/storage/eth_bridge_queries.rs index 9acf47604a..62a326bf74 100644 --- a/ethereum_bridge/src/storage/eth_bridge_queries.rs +++ b/ethereum_bridge/src/storage/eth_bridge_queries.rs @@ -254,24 +254,6 @@ where /// Determines if it is possible to send a validator set update vote /// extension at the provided [`BlockHeight`] in [`SendValsetUpd`]. - #[cfg(feature = "abcipp")] - #[inline] - pub fn must_send_valset_upd(self, can_send: SendValsetUpd) -> bool { - if matches!(can_send, SendValsetUpd::Now) { - self.wl_storage - .pos_queries() - .is_deciding_offset_within_epoch(1) - } else { - // TODO: implement this method for ABCI++; should only be able to - // send a validator set update at the second block of an - // epoch - false - } - } - - /// Determines if it is possible to send a validator set update vote - /// extension at the provided [`BlockHeight`] in [`SendValsetUpd`]. - #[cfg(not(feature = "abcipp"))] #[inline] pub fn must_send_valset_upd(self, can_send: SendValsetUpd) -> bool { if matches!(can_send, SendValsetUpd::AtPrevHeight) { diff --git a/proof_of_stake/Cargo.toml b/proof_of_stake/Cargo.toml index 5506ec5174..19eb0e2493 100644 --- a/proof_of_stake/Cargo.toml +++ b/proof_of_stake/Cargo.toml @@ -13,10 +13,7 @@ repository.workspace = true version.workspace = true [features] -default = ["abciplus"] -abciplus = [ - "namada_core/abciplus", -] +default = [] # testing helpers testing = ["proptest"] diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index cfe7e6a8dc..8e68fec084 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -15,12 +15,6 @@ version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -abciplus = [ - "namada_core/abciplus", - "namada_proof_of_stake/abciplus", - "namada_ethereum_bridge/abciplus", -] - ferveo-tpke = [ "namada_core/ferveo-tpke", ] diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index d6147c6917..bff45b2d80 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -1,26 +1,13 @@ extern crate alloc; -pub use namada_core::proto; +pub use namada_core::{ibc, ibc_proto, proto, tendermint, tendermint_proto}; #[cfg(feature = "tendermint-rpc")] pub use tendermint_rpc; -#[cfg(feature = "tendermint-rpc-abcipp")] -pub use tendermint_rpc_abcipp as tendermint_rpc; use tx::{TX_INIT_ACCOUNT_WASM, VP_VALIDATOR_WASM}; pub use { bip39, borsh, masp_primitives, masp_proofs, namada_core as core, namada_proof_of_stake as proof_of_stake, zeroize, }; -#[cfg(feature = "abcipp")] -pub use { - ibc_abcipp as ibc, ibc_proto_abcipp as ibc_proto, - tendermint_abcipp as tendermint, - tendermint_proto_abcipp as tendermint_proto, -}; -#[cfg(feature = "abciplus")] -pub use { - namada_core::ibc, namada_core::ibc_proto, namada_core::tendermint, - namada_core::tendermint_proto, -}; pub mod eth_bridge; diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 40872b3460..b68451fbf7 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -15,7 +15,7 @@ version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["abciplus", "namada-sdk", "wasm-runtime"] +default = ["namada-sdk", "wasm-runtime"] mainnet = [ "namada_core/mainnet", ] @@ -57,13 +57,6 @@ http-client = [ "tendermint-rpc/http-client" ] -abciplus = [ - "namada_core/abciplus", - "namada_proof_of_stake/abciplus", - "namada_ethereum_bridge/abciplus", - "namada_sdk/abciplus", -] - ibc-mocks = [ "namada_core/ibc-mocks", "namada_sdk/ibc-mocks", diff --git a/shared/src/ledger/protocol/mod.rs b/shared/src/ledger/protocol/mod.rs index ad401a5f2f..d142781127 100644 --- a/shared/src/ledger/protocol/mod.rs +++ b/shared/src/ledger/protocol/mod.rs @@ -413,8 +413,14 @@ where } else { // Balance was insufficient for fee payment, move all the // available funds in the transparent balance of - // the fee payer. This branch should only be taken when using - // ABCI + // the fee payer. This shouldn't happen as it should be + // prevented from mempool. + tracing::error!( + "Transfer of tx fee cannot be applied to due to \ + insufficient funds. Falling back to transferring the \ + available balance which is less than the fee. This \ + shouldn't happen." + ); token_transfer( wl_storage, &wrapper.fee.token, @@ -433,17 +439,12 @@ where } } Err(e) => { - // Fee overflow, move all the available funds in the transparent - // balance of the fee payer. This branch should only be - // taken when using ABCI - token_transfer( - wl_storage, - &wrapper.fee.token, - &wrapper.fee_payer(), - block_proposer, - balance, - ) - .map_err(|e| Error::FeeError(e.to_string()))?; + // Fee overflow. This shouldn't happen as it should be prevented + // from mempool. + tracing::error!( + "Transfer of tx fee cannot be applied to due to fee overflow. \ + This shouldn't happen." + ); Err(Error::FeeError(format!( "{}. All the available transparent funds have been moved to \ diff --git a/shared/src/lib.rs b/shared/src/lib.rs index d0d1ea8b2b..0b0304ab3d 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -6,22 +6,10 @@ #![deny(rustdoc::broken_intra_doc_links)] #![deny(rustdoc::private_intra_doc_links)] +pub use namada_core::{ibc, ibc_proto, tendermint, tendermint_proto}; #[cfg(feature = "tendermint-rpc")] pub use tendermint_rpc; -#[cfg(feature = "tendermint-rpc-abcipp")] -pub use tendermint_rpc_abcipp as tendermint_rpc; pub use {bip39, namada_core as core, namada_proof_of_stake as proof_of_stake}; -#[cfg(feature = "abcipp")] -pub use { - ibc_abcipp as ibc, ibc_proto_abcipp as ibc_proto, - tendermint_abcipp as tendermint, - tendermint_proto_abcipp as tendermint_proto, -}; -#[cfg(feature = "abciplus")] -pub use { - namada_core::ibc, namada_core::ibc_proto, namada_core::tendermint, - namada_core::tendermint_proto, -}; pub mod ledger; pub use namada_core::proto; pub use namada_sdk; diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index 3b81ee176e..9e2da00a8a 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml @@ -13,6 +13,6 @@ repository.workspace = true version.workspace = true [dependencies] -namada_core = { path = "../core", default-features = false, features = ["abciplus"] } +namada_core = { path = "../core", default-features = false } borsh.workspace = true strum = {version = "0.24", features = ["derive"]} diff --git a/tests/Cargo.toml b/tests/Cargo.toml index ca4cfabb1f..de9b821ac9 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -13,24 +13,15 @@ repository.workspace = true version.workspace = true [features] -default = ["abciplus", "wasm-runtime"] +default = ["wasm-runtime"] mainnet = [ "namada/mainnet", ] -abciplus = [ - "namada/abciplus", - "namada/ibc-mocks", - "namada_apps/abciplus", - "namada_vp_prelude/abciplus", - "namada_tx_prelude/abciplus", - "namada_apps/abciplus" -] - wasm-runtime = ["namada/wasm-runtime"] integration = ["namada_apps/integration"] [dependencies] -namada = {path = "../shared", features = ["testing"]} +namada = {path = "../shared", features = ["testing", "ibc-mocks"]} namada_core = {path = "../core", features = ["testing"]} namada_sdk = {path = "../sdk"} namada_test_utils = {path = "../test_utils"} diff --git a/tx_prelude/Cargo.toml b/tx_prelude/Cargo.toml index 981b9c0c79..c23d66530e 100644 --- a/tx_prelude/Cargo.toml +++ b/tx_prelude/Cargo.toml @@ -13,12 +13,7 @@ repository.workspace = true version.workspace = true [features] -default = ["abciplus"] -abciplus = [ - "namada_core/abciplus", - "namada_proof_of_stake/abciplus", - "namada_vm_env/abciplus", -] +default = [] [dependencies] namada_core = {path = "../core", default-features = false} diff --git a/vm_env/Cargo.toml b/vm_env/Cargo.toml index 5a95bdbac0..332b5007c9 100644 --- a/vm_env/Cargo.toml +++ b/vm_env/Cargo.toml @@ -13,10 +13,7 @@ repository.workspace = true version.workspace = true [features] -default = ["abciplus"] -abciplus = [ - "namada_core/abciplus", -] +default = [] [dependencies] namada_core = {path = "../core", default-features = false} diff --git a/vp_prelude/Cargo.toml b/vp_prelude/Cargo.toml index 5384395b22..0766b39794 100644 --- a/vp_prelude/Cargo.toml +++ b/vp_prelude/Cargo.toml @@ -13,12 +13,7 @@ repository.workspace = true version.workspace = true [features] -default = ["abciplus"] -abciplus = [ - "namada_core/abciplus", - "namada_proof_of_stake/abciplus", - "namada_vm_env/abciplus", -] +default = [] [dependencies] namada_core = {path = "../core", default-features = false}