Skip to content

Commit

Permalink
Merge pull request #3697 from anoma/tomas/refactor-tm-reexports
Browse files Browse the repository at this point in the history
refactor tendermint-rs reexports
  • Loading branch information
mergify[bot] authored Aug 28, 2024
2 parents 62be903 + a899f28 commit 2aef1e7
Show file tree
Hide file tree
Showing 41 changed files with 173 additions and 172 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Only re-exporting tendermint-rs v0.37 modules.
([\#3697](https://github.com/anoma/namada/pull/3697))
2 changes: 1 addition & 1 deletion crates/apps/src/bin/namada-client/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use color_eyre::eyre::Result;
use namada_apps_lib::cli::api::{CliApi, CliIo};
use namada_apps_lib::facade::tendermint_rpc::HttpClient;
use namada_apps_lib::tendermint_rpc::HttpClient;
use namada_apps_lib::{cli, logging};
use tracing_subscriber::filter::LevelFilter;

Expand Down
4 changes: 2 additions & 2 deletions crates/apps_lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3190,8 +3190,8 @@ pub mod args {
use crate::client::utils::PRE_GENESIS_DIR;
use crate::config::genesis::AddrOrPk;
use crate::config::{self, Action, ActionAtHeight};
use crate::facade::tendermint::Timeout;
use crate::facade::tendermint_rpc::Url;
use crate::tendermint::Timeout;
use crate::tendermint_rpc::Url;
use crate::wrap;

pub const ADDRESS: Arg<WalletAddress> = arg("address");
Expand Down
4 changes: 2 additions & 2 deletions crates/apps_lib/src/cli/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use namada_sdk::io::Io;
use namada_sdk::queries::Client;
use namada_sdk::rpc::wait_until_node_is_synched;

use crate::facade::tendermint_rpc::client::CompatMode;
use crate::facade::tendermint_rpc::{HttpClient, Url as TendermintUrl};
use crate::tendermint_rpc::client::CompatMode;
use crate::tendermint_rpc::{HttpClient, Url as TendermintUrl};

/// Trait for clients that can be used with the CLI.
#[async_trait::async_trait(?Send)]
Expand Down
2 changes: 1 addition & 1 deletion crates/apps_lib/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use namada_sdk::{
};

use crate::cli::{self, args};
use crate::facade::tendermint::merkle::proof::ProofOps;
use crate::tendermint::merkle::proof::ProofOps;

/// Query the status of a given transaction.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/apps_lib/src/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use crate::cli::{args, safe_exit};
use crate::client::tx::signing::{default_sign, SigningTxData};
use crate::client::tx::tx::ProcessTxResponse;
use crate::config::TendermintMode;
use crate::facade::tendermint_rpc::endpoint::broadcast::tx_sync::Response;
use crate::tendermint_node;
use crate::tendermint_rpc::endpoint::broadcast::tx_sync::Response;
use crate::wallet::{
gen_validator_keys, read_and_confirm_encryption_password, WalletTransport,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/apps_lib/src/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::config::genesis::transactions::{
use crate::config::genesis::{AddrOrPk, GenesisAddress};
use crate::config::global::GlobalConfig;
use crate::config::{self, genesis, get_default_namada_folder, TendermintMode};
use crate::facade::tendermint::node::Id as TendermintNodeId;
use crate::tendermint::node::Id as TendermintNodeId;
use crate::wallet::{pre_genesis, CliWalletUtils};
use crate::{tendermint_node, wasm_loader};

Expand Down
8 changes: 4 additions & 4 deletions crates/apps_lib/src/config/genesis/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use super::{templates, transactions};
use crate::config::genesis::templates::Validated;
use crate::config::utils::{set_ip, set_port};
use crate::config::{Config, TendermintMode};
use crate::facade::tendermint::node::Id as TendermintNodeId;
use crate::facade::tendermint_config::net::Address as TendermintAddress;
use crate::tendermint::node::Id as TendermintNodeId;
use crate::tendermint_config::net::Address as TendermintAddress;
use crate::tendermint_node::id_from_pk;
use crate::wallet::{Alias, CliWalletUtils};
use crate::wasm_loader;
Expand Down Expand Up @@ -497,7 +497,7 @@ pub fn finalize(
templates: templates::All<Validated>,
chain_id_prefix: ChainIdPrefix,
genesis_time: DateTimeUtc,
consensus_timeout_commit: crate::facade::tendermint::Timeout,
consensus_timeout_commit: crate::tendermint::Timeout,
) -> Finalized {
let genesis_time: Rfc3339String = genesis_time.into();
let consensus_timeout_commit: DurationNanos =
Expand Down Expand Up @@ -883,7 +883,7 @@ mod test {
let genesis_time = DateTimeUtc::from_str(GENESIS_TIME).unwrap();

let consensus_timeout_commit =
crate::facade::tendermint::Timeout::from_str("1s").unwrap();
crate::tendermint::Timeout::from_str("1s").unwrap();

let finalized_0 = finalize(
templates.clone(),
Expand Down
6 changes: 2 additions & 4 deletions crates/apps_lib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ use serde::{Deserialize, Serialize};
use thiserror::Error;

use crate::cli;
use crate::facade::tendermint_config::{
TendermintConfig, TxIndexConfig, TxIndexer,
};
use crate::tendermint_config::{TendermintConfig, TxIndexConfig, TxIndexer};

/// Base directory contains global config and chain directories.
pub const DEFAULT_BASE_DIR: &str = ".namada";
Expand Down Expand Up @@ -857,7 +855,7 @@ namespace = "cometbft"
#[cfg(test)]
mod tests {
use super::DEFAULT_COMETBFT_CONFIG;
use crate::facade::tendermint_config::TendermintConfig;
use crate::tendermint_config::TendermintConfig;

#[test]
fn test_default_cometbft_config() {
Expand Down
2 changes: 1 addition & 1 deletion crates/apps_lib/src/config/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{cmp, env};
use itertools::Either;

use crate::cli;
use crate::facade::tendermint_config::net::Address as TendermintAddress;
use crate::tendermint_config::net::Address as TendermintAddress;

/// Find how many threads to use from an environment variable if it's set and
/// valid (>= 1). If the environment variable is invalid, exits the process with
Expand Down
8 changes: 2 additions & 6 deletions crates/apps_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ pub mod tendermint_node;
pub mod wallet;
pub mod wasm_loader;

pub use namada_core::{tendermint, tendermint_proto};
pub use namada_sdk::*;

pub mod facade {
// TODO(namada#3248): only re-export v037 `tendermint-rs`
pub use namada_core::{tendermint, tendermint_proto};
pub use {tendermint_config, tendermint_rpc};
}
pub use {tendermint_config, tendermint_rpc};
4 changes: 2 additions & 2 deletions crates/apps_lib/src/tendermint_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use serde_json::json;
use sha2::{Digest, Sha256};
use thiserror::Error;

use crate::facade::tendermint::node::Id as TendermintNodeId;
use crate::facade::tendermint_config::Error as TendermintError;
use crate::tendermint::node::Id as TendermintNodeId;
use crate::tendermint_config::Error as TendermintError;

/// Env. var to output Tendermint log to stdout
pub const ENV_VAR_TM_STDOUT: &str = "NAMADA_CMT_STDOUT";
Expand Down
20 changes: 18 additions & 2 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,24 @@ pub mod bytes;
pub mod control_flow;
pub mod hints;

// TODO(namada#3248): only re-export v037 `tendermint-rs`
pub use {masp_primitives, tendermint, tendermint_proto};
pub use masp_primitives;
/// Re-export of tendermint v0.37
pub mod tendermint {
/// Re-export of tendermint v0.37 ABCI
pub mod abci {
pub use tendermint::abci::response::ApplySnapshotChunkResult;
pub use tendermint::abci::{
types, Code, Event, EventAttribute, MethodKind,
};
pub use tendermint::v0_37::abci::*;
}
pub use tendermint::*;
}
/// Re-export of tendermint-proto v0.37
pub mod tendermint_proto {
pub use tendermint_proto::google; // 💩
pub use tendermint_proto::v0_37::*;
}
/// Borsh binary encoding (re-exported) from official crate with custom ext.
pub mod borsh {
pub use borsh::*;
Expand Down
4 changes: 2 additions & 2 deletions crates/events/src/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ impl AttributesMap for Vec<namada_core::tendermint::abci::EventAttribute> {
}

impl AttributesMap
for Vec<namada_core::tendermint_proto::v0_37::abci::EventAttribute>
for Vec<namada_core::tendermint_proto::abci::EventAttribute>
{
#[inline]
fn insert_attribute<K, V>(&mut self, key: K, value: V)
where
K: Into<String>,
V: Into<String>,
{
self.push(namada_core::tendermint_proto::v0_37::abci::EventAttribute {
self.push(namada_core::tendermint_proto::abci::EventAttribute {
key: key.into(),
value: value.into(),
index: true,
Expand Down
6 changes: 3 additions & 3 deletions crates/events/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ impl Event {
}
}

impl From<Event> for namada_core::tendermint_proto::v0_37::abci::Event {
impl From<Event> for namada_core::tendermint_proto::abci::Event {
fn from(event: Event) -> Self {
Self {
r#type: {
Expand All @@ -485,14 +485,14 @@ impl From<Event> for namada_core::tendermint_proto::v0_37::abci::Event {
.attributes
.into_iter()
.map(|(key, value)| {
namada_core::tendermint_proto::v0_37::abci::EventAttribute {
namada_core::tendermint_proto::abci::EventAttribute {
key,
value,
index: true,
}
})
.chain(std::iter::once_with(|| {
namada_core::tendermint_proto::v0_37::abci::EventAttribute {
namada_core::tendermint_proto::abci::EventAttribute {
key: "event-level".to_string(),
value: event.level.to_string(),
index: true,
Expand Down
2 changes: 1 addition & 1 deletion crates/ibc/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ pub fn packet_from_event_attributes<A: AttributesMap>(
#[cfg(test)]
mod tests {
use namada_core::hash::Hash;
use namada_core::tendermint_proto::v0_37::abci::Event as AbciEventV037;
use namada_core::tendermint_proto::abci::Event as AbciEventV037;
use namada_events::extend::{
ComposeEvent as _, Domain, Height, Log,
RawReadFromEventAttributes as _, TxHash,
Expand Down
7 changes: 3 additions & 4 deletions crates/node/src/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ use tempfile::TempDir;

use crate::config::global::GlobalConfig;
use crate::config::TendermintMode;
use crate::facade::tendermint::v0_37::abci::request::InitChain;
use crate::facade::tendermint_proto::google::protobuf::Timestamp;
use crate::facade::tendermint_rpc;
use crate::shell::Shell;
use crate::{config, dry_run_tx};
use crate::tendermint::abci::request::InitChain;
use crate::tendermint_proto::google::protobuf::Timestamp;
use crate::{config, dry_run_tx, tendermint_rpc};

pub const WASM_DIR: &str = "../../wasm";

Expand Down
4 changes: 2 additions & 2 deletions crates/node/src/broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use namada_sdk::control_flow::time;
use namada_sdk::time::{DateTimeUtc, Utc};
use tokio::sync::mpsc::UnboundedReceiver;

use crate::facade::tendermint_rpc::client::CompatMode;
use crate::facade::tendermint_rpc::{Client, HttpClient};
use crate::tendermint_rpc::client::CompatMode;
use crate::tendermint_rpc::{Client, HttpClient};

const DEFAULT_BROADCAST_TIMEOUT: u64 = 180;
const BROADCASTER_TIMEOUT_ENV_VAR: &str = "NAMADA_BROADCASTER_TIMEOUT_SECS";
Expand Down
17 changes: 8 additions & 9 deletions crates/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ use namada_apps_lib::config::utils::{
convert_tm_addr_to_socket_addr, num_of_threads,
};
use namada_apps_lib::{config, wasm_loader};
pub use namada_apps_lib::{
tendermint, tendermint_config, tendermint_proto, tendermint_rpc,
};
use namada_sdk::chain::BlockHeight;
use namada_sdk::eth_bridge::ethers::providers::{Http, Provider};
use namada_sdk::migrations::ScheduledMigration;
Expand All @@ -60,18 +63,14 @@ use self::shims::abcipp_shim::AbciService;
use crate::broadcaster::Broadcaster;
use crate::config::{ethereum_bridge, TendermintMode};
use crate::ethereum_oracle as oracle;
use crate::facade::tendermint::v0_37::abci::response;
use crate::facade::tower_abci::{split, Server};
use crate::shell::{Error, MempoolTxType, Shell};
use crate::shims::abcipp_shim::AbcippShim;
use crate::shims::abcipp_shim_types::shim::{Request, Response};

pub mod facade {
pub use namada_apps_lib::facade::*;
pub mod tower_abci {
pub use tower_abci::v037::*;
pub use tower_abci::BoxError;
}
use crate::tendermint::abci::response;
use crate::tower_abci::{split, Server};
pub mod tower_abci {
pub use tower_abci::v037::*;
pub use tower_abci::BoxError;
}

/// Env. var to set a number of Tokio RT worker threads
Expand Down
4 changes: 2 additions & 2 deletions crates/node/src/shell/block_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ use std::marker::PhantomData;
use namada_sdk::parameters;
use namada_sdk::state::{self, WlState};

#[allow(unused_imports)]
use crate::facade::tendermint_proto::abci::RequestPrepareProposal;
use crate::shell::block_alloc::states::WithNormalTxs;
#[allow(unused_imports)]
use crate::tendermint_proto::abci::RequestPrepareProposal;

/// Block allocation failure status responses.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
Expand Down
15 changes: 6 additions & 9 deletions crates/node/src/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ use namada_vote_ext::ethereum_tx_data_variants;
use tendermint::abci::types::Misbehavior;

use super::*;
use crate::facade::tendermint::abci::types::VoteInfo;
use crate::facade::tendermint_proto;
use crate::protocol::{DispatchArgs, DispatchError};
use crate::shell::stats::InternalStats;
use crate::tendermint::abci::types::VoteInfo;
use crate::tendermint_proto;

impl<D, H> Shell<D, H>
where
Expand Down Expand Up @@ -248,14 +248,11 @@ where
// Apply validator set update
response.validator_updates = self
.get_abci_validator_updates(false, |pk, power| {
let pub_key = tendermint_proto::v0_37::crypto::PublicKey {
let pub_key = tendermint_proto::crypto::PublicKey {
sum: Some(key_to_tendermint(&pk).unwrap()),
};
let pub_key = Some(pub_key);
tendermint_proto::v0_37::abci::ValidatorUpdate {
pub_key,
power,
}
tendermint_proto::abci::ValidatorUpdate { pub_key, power }
})
.expect("Must be able to update validator set");
}
Expand Down Expand Up @@ -1093,7 +1090,7 @@ fn pos_votes_from_abci(
validator,
sig_info,
}| {
let crate::facade::tendermint::abci::types::Validator {
let crate::tendermint::abci::types::Validator {
address,
power,
} = validator;
Expand Down Expand Up @@ -1265,12 +1262,12 @@ mod test_finalize_block {
use test_log::test;

use super::*;
use crate::facade::tendermint::abci::types::Validator;
use crate::oracle::control::Command;
use crate::shell::test_utils::*;
use crate::shims::abcipp_shim_types::shim::request::{
FinalizeBlock, ProcessedTx,
};
use crate::tendermint::abci::types::Validator;

const WRAPPER_GAS_LIMIT: u64 = 1_500_000;
const STORAGE_VALUE: &str = "test_value";
Expand Down
Loading

0 comments on commit 2aef1e7

Please sign in to comment.