From 5ab699052b618a3c9db9f3ff98025166bf1cbf6d Mon Sep 17 00:00:00 2001 From: bengtlofgren Date: Thu, 25 May 2023 18:21:32 +0200 Subject: [PATCH 01/14] feat: switch tendermint references to cometbft --- .../unreleased/miscellaneous/1476-cometbft.md | 2 + .github/workflows/build-and-test-bridge.yml | 6 -- apps/src/bin/namada-node/cli.rs | 4 +- apps/src/lib/client/tx.rs | 4 +- apps/src/lib/client/utils.rs | 69 ++++++++----------- apps/src/lib/config/mod.rs | 22 +++--- apps/src/lib/node/ledger/mod.rs | 57 ++++++++------- apps/src/lib/node/ledger/shell/mod.rs | 7 +- apps/src/lib/node/ledger/tendermint_node.rs | 32 ++++----- tests/src/e2e/helpers.rs | 2 +- tests/src/e2e/ledger_tests.rs | 20 ++---- tests/src/e2e/setup.rs | 12 ++-- wasm/checksums.json | 37 +++++----- 13 files changed, 124 insertions(+), 150 deletions(-) create mode 100644 .changelog/unreleased/miscellaneous/1476-cometbft.md diff --git a/.changelog/unreleased/miscellaneous/1476-cometbft.md b/.changelog/unreleased/miscellaneous/1476-cometbft.md new file mode 100644 index 0000000000..a1a23432ac --- /dev/null +++ b/.changelog/unreleased/miscellaneous/1476-cometbft.md @@ -0,0 +1,2 @@ +- Switch from unreleased Tendermint fork to an official CometBFT release + v0.37.1. ([\#1476](https://github.com/anoma/namada/pull/1476)) \ No newline at end of file diff --git a/.github/workflows/build-and-test-bridge.yml b/.github/workflows/build-and-test-bridge.yml index 1f8399a3d4..1cdba9e6a7 100644 --- a/.github/workflows/build-and-test-bridge.yml +++ b/.github/workflows/build-and-test-bridge.yml @@ -440,12 +440,6 @@ jobs: run: | wget -q -O- https://github.com/rui314/mold/releases/download/v${{ matrix.mold_version }}/mold-${{ matrix.mold_version }}-x86_64-linux.tar.gz | tar -xz mv mold-${{ matrix.mold_version }}-x86_64-linux/bin/mold /usr/local/bin - - name: Download masp parameters - run: | - mkdir /home/runner/work/masp - curl -o /home/runner/work/masp/masp-spend.params -sLO https://github.com/anoma/masp-mpc/releases/download/namada-trusted-setup/masp-spend.params?raw=true - curl -o /home/runner/work/masp/masp-output.params -sLO https://github.com/anoma/masp-mpc/releases/download/namada-trusted-setup/masp-output.params?raw=true - curl -o /home/runner/work/masp/masp-convert.params -sLO https://github.com/anoma/masp-mpc/releases/download/namada-trusted-setup/masp-convert.params?raw=true - name: Build run: make build env: diff --git a/apps/src/bin/namada-node/cli.rs b/apps/src/bin/namada-node/cli.rs index 240e81f90c..c3c6ad3bab 100644 --- a/apps/src/bin/namada-node/cli.rs +++ b/apps/src/bin/namada-node/cli.rs @@ -8,14 +8,14 @@ use namada_apps::node::ledger; pub fn main() -> Result<()> { let (cmd, mut ctx) = cli::namada_node_cli()?; if let Some(mode) = ctx.global_args.mode.clone() { - ctx.config.ledger.tendermint.tendermint_mode = mode; + ctx.config.ledger.cometbft.tendermint_mode = mode; } match cmd { cmds::NamadaNode::Ledger(sub) => match sub { cmds::Ledger::Run(cmds::LedgerRun(args)) => { let wasm_dir = ctx.wasm_dir(); sleep_until(args.start_time); - ctx.config.ledger.tendermint.tx_index = args.tx_index; + ctx.config.ledger.cometbft.tx_index = args.tx_index; ledger::run(ctx.config.ledger, wasm_dir); } cmds::Ledger::RunUntil(cmds::LedgerRunUntil(args)) => { diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index 6bbf8a0ffa..d212dfa8c2 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -292,13 +292,13 @@ pub async fn submit_init_validator< crate::wallet::save(&ctx.wallet) .unwrap_or_else(|err| eprintln!("{}", err)); - let tendermint_home = ctx.config.ledger.tendermint_dir(); + let tendermint_home = ctx.config.ledger.cometbft_dir(); tendermint_node::write_validator_key(&tendermint_home, &consensus_key); tendermint_node::write_validator_state(tendermint_home); // Write Namada config stuff or figure out how to do the above // tendermint_node things two epochs in the future!!! - ctx.config.ledger.tendermint.tendermint_mode = + ctx.config.ledger.cometbft.tendermint_mode = TendermintMode::Validator; ctx.config .write( diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index 328c2b1a70..127443f99e 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -290,7 +290,7 @@ pub async fn join_network( }) .clone(); - let tm_home_dir = chain_dir.join("tendermint"); + let tm_home_dir = chain_dir.join("cometbft"); // Write consensus key to tendermint home tendermint_node::write_validator_key( @@ -324,26 +324,21 @@ pub async fn join_network( tokio::task::spawn_blocking(move || { let mut config = Config::load(&base_dir, &chain_id, None); - config.ledger.tendermint.tendermint_mode = - TendermintMode::Validator; + config.ledger.cometbft.tendermint_mode = TendermintMode::Validator; // Validator node should turned off peer exchange reactor - config.ledger.tendermint.p2p_pex = false; + config.ledger.cometbft.p2p_pex = false; // Remove self from persistent peers - config - .ledger - .tendermint - .p2p_persistent_peers - .retain(|peer| { - if let TendermintAddress::Tcp { - peer_id: Some(peer_id), - .. - } = peer - { - node_id != *peer_id - } else { - true - } - }); + config.ledger.cometbft.p2p_persistent_peers.retain(|peer| { + if let TendermintAddress::Tcp { + peer_id: Some(peer_id), + .. + } = peer + { + node_id != *peer_id + } else { + true + } + }); config.write(&base_dir, &chain_id, true).unwrap(); }) .await @@ -456,7 +451,7 @@ pub fn init_network( let validator_dir = accounts_dir.join(name); let chain_dir = validator_dir.join(&accounts_temp_dir); - let tm_home_dir = chain_dir.join("tendermint"); + let tm_home_dir = chain_dir.join("cometbft"); // Find or generate tendermint node key let node_pk = try_parse_public_key( @@ -744,7 +739,7 @@ pub fn init_network( // directories. config.ledger.shell.base_dir = config::DEFAULT_BASE_DIR.into(); // Add a ledger P2P persistent peers - config.ledger.tendermint.p2p_persistent_peers = persistent_peers + config.ledger.cometbft.p2p_persistent_peers = persistent_peers .iter() .enumerate() .filter_map(|(index, peer)| @@ -755,37 +750,32 @@ pub fn init_network( None }) .collect(); - config.ledger.tendermint.consensus_timeout_commit = + config.ledger.cometbft.consensus_timeout_commit = consensus_timeout_commit; - config.ledger.tendermint.p2p_allow_duplicate_ip = - allow_duplicate_ip; - config.ledger.tendermint.p2p_addr_book_strict = !localhost; + config.ledger.cometbft.p2p_allow_duplicate_ip = allow_duplicate_ip; + config.ledger.cometbft.p2p_addr_book_strict = !localhost; // Clear the net address from the config and use it to set ports let net_address = validator_config.net_address.take().unwrap(); let first_port = SocketAddr::from_str(&net_address).unwrap().port(); if !localhost { config .ledger - .tendermint + .cometbft .p2p_address .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } - config.ledger.tendermint.p2p_address.set_port(first_port); + config.ledger.cometbft.p2p_address.set_port(first_port); if !localhost { config .ledger - .tendermint + .cometbft .rpc_address .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } - config - .ledger - .tendermint - .rpc_address - .set_port(first_port + 1); + config.ledger.cometbft.rpc_address.set_port(first_port + 1); config.ledger.shell.ledger_address.set_port(first_port + 2); // Validator node should turned off peer exchange reactor - config.ledger.tendermint.p2p_pex = false; + config.ledger.cometbft.p2p_pex = false; config.write(&validator_dir, &chain_id, true).unwrap(); }, @@ -793,19 +783,18 @@ pub fn init_network( // Update the ledger config persistent peers and save it let mut config = Config::load(&global_args.base_dir, &chain_id, None); - config.ledger.tendermint.p2p_persistent_peers = persistent_peers; - config.ledger.tendermint.consensus_timeout_commit = - consensus_timeout_commit; - config.ledger.tendermint.p2p_allow_duplicate_ip = allow_duplicate_ip; + config.ledger.cometbft.p2p_persistent_peers = persistent_peers; + config.ledger.cometbft.consensus_timeout_commit = consensus_timeout_commit; + config.ledger.cometbft.p2p_allow_duplicate_ip = allow_duplicate_ip; // Open P2P address if !localhost { config .ledger - .tendermint + .cometbft .p2p_address .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } - config.ledger.tendermint.p2p_addr_book_strict = !localhost; + config.ledger.cometbft.p2p_addr_book_strict = !localhost; config.ledger.genesis_time = genesis.genesis_time.into(); config .write(&global_args.base_dir, &chain_id, true) diff --git a/apps/src/lib/config/mod.rs b/apps/src/lib/config/mod.rs index d2ad05ae73..e0313115f8 100644 --- a/apps/src/lib/config/mod.rs +++ b/apps/src/lib/config/mod.rs @@ -30,8 +30,8 @@ pub const DEFAULT_WASM_DIR: &str = "wasm"; pub const DEFAULT_WASM_CHECKSUMS_FILE: &str = "checksums.json"; /// Chain-specific Namada configuration. Nested in chain dirs. pub const FILENAME: &str = "config.toml"; -/// Chain-specific Tendermint configuration. Nested in chain dirs. -pub const TENDERMINT_DIR: &str = "tendermint"; +/// Chain-specific CometBFT configuration. Nested in chain dirs. +pub const COMETBFT_DIR: &str = "cometbft"; /// Chain-specific Namada DB. Nested in chain dirs. pub const DB_DIR: &str = "db"; @@ -95,7 +95,7 @@ pub struct Ledger { pub genesis_time: Rfc3339String, pub chain_id: ChainId, pub shell: Shell, - pub tendermint: Tendermint, + pub cometbft: Tendermint, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -116,8 +116,8 @@ pub struct Shell { pub storage_read_past_height_limit: Option, /// Use the [`Ledger::db_dir()`] method to read the value. db_dir: PathBuf, - /// Use the [`Ledger::tendermint_dir()`] method to read the value. - tendermint_dir: PathBuf, + /// Use the [`Ledger::cometbft_dir()`] method to read the value. + cometbft_dir: PathBuf, /// An optional action to take when a given blockheight is reached. pub action_at_height: Option, } @@ -173,10 +173,10 @@ impl Ledger { // Default corresponds to 1 hour of past blocks at 1 block/sec storage_read_past_height_limit: Some(3600), db_dir: DB_DIR.into(), - tendermint_dir: TENDERMINT_DIR.into(), + cometbft_dir: COMETBFT_DIR.into(), action_at_height: None, }, - tendermint: Tendermint { + cometbft: Tendermint { rpc_address: SocketAddr::new( IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 26657, @@ -222,8 +222,8 @@ impl Ledger { } /// Get the directory path to Tendermint - pub fn tendermint_dir(&self) -> PathBuf { - self.shell.tendermint_dir(&self.chain_id) + pub fn cometbft_dir(&self) -> PathBuf { + self.shell.cometbft_dir(&self.chain_id) } } @@ -234,10 +234,10 @@ impl Shell { } /// Get the directory path to Tendermint - pub fn tendermint_dir(&self, chain_id: &ChainId) -> PathBuf { + pub fn cometbft_dir(&self, chain_id: &ChainId) -> PathBuf { self.base_dir .join(chain_id.as_str()) - .join(&self.tendermint_dir) + .join(&self.cometbft_dir) } } diff --git a/apps/src/lib/node/ledger/mod.rs b/apps/src/lib/node/ledger/mod.rs index 39a8460ac2..10beac63ce 100644 --- a/apps/src/lib/node/ledger/mod.rs +++ b/apps/src/lib/node/ledger/mod.rs @@ -408,7 +408,7 @@ fn start_abci_broadcaster_shell( task::JoinHandle<()>, thread::JoinHandle<()>, ) { - let rpc_address = config.tendermint.rpc_address.to_string(); + let rpc_address = config.cometbft.rpc_address.to_string(); let RunAuxSetup { vp_wasm_compilation_cache, tx_wasm_compilation_cache, @@ -421,37 +421,36 @@ fn start_abci_broadcaster_shell( tokio::sync::mpsc::unbounded_channel(); // Start broadcaster - let broadcaster = if matches!( - config.tendermint.tendermint_mode, - TendermintMode::Validator - ) { - let (bc_abort_send, bc_abort_recv) = - tokio::sync::oneshot::channel::<()>(); - - spawner - .spawn_abortable("Broadcaster", move |aborter| async move { - // Construct a service for broadcasting protocol txs from the - // ledger - let mut broadcaster = - Broadcaster::new(&rpc_address, broadcaster_receiver); - broadcaster.run(bc_abort_recv).await; - tracing::info!("Broadcaster is no longer running."); - - drop(aborter); - }) - .with_cleanup(async move { - let _ = bc_abort_send.send(()); - }) - } else { - spawn_dummy_task(()) - }; + let broadcaster = + if matches!(config.cometbft.tendermint_mode, TendermintMode::Validator) + { + let (bc_abort_send, bc_abort_recv) = + tokio::sync::oneshot::channel::<()>(); + + spawner + .spawn_abortable("Broadcaster", move |aborter| async move { + // Construct a service for broadcasting protocol txs from + // the ledger + let mut broadcaster = + Broadcaster::new(&rpc_address, broadcaster_receiver); + broadcaster.run(bc_abort_recv).await; + tracing::info!("Broadcaster is no longer running."); + + drop(aborter); + }) + .with_cleanup(async move { + let _ = bc_abort_send.send(()); + }) + } else { + spawn_dummy_task(()) + }; // Setup DB cache, it must outlive the DB instance that's in the shell let db_cache = rocksdb::Cache::new_lru_cache(db_block_cache_size_bytes as usize); // Construct our ABCI application. - let tendermint_mode = config.tendermint.tendermint_mode.clone(); + let tendermint_mode = config.cometbft.tendermint_mode.clone(); let ledger_address = config.shell.ledger_address; #[cfg(not(feature = "dev"))] let genesis = genesis::genesis(&config.shell.base_dir, &config.chain_id); @@ -566,17 +565,17 @@ fn start_tendermint( spawner: &mut AbortableSpawner, config: &config::Ledger, ) -> task::JoinHandle> { - let tendermint_dir = config.tendermint_dir(); + let tendermint_dir = config.cometbft_dir(); let chain_id = config.chain_id.clone(); let ledger_address = config.shell.ledger_address.to_string(); - let tendermint_config = config.tendermint.clone(); + let tendermint_config = config.cometbft.clone(); let genesis_time = config .genesis_time .clone() .try_into() .expect("expected RFC3339 genesis_time"); - // Channel for signalling shut down to Tendermint process + // Channel for signalling shut down to cometbft process let (tm_abort_send, tm_abort_recv) = tokio::sync::oneshot::channel::>(); diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index 457d988e93..2f5d443e16 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -186,8 +186,7 @@ pub fn reset(config: config::Ledger) -> Result<()> { res => res.map_err(Error::RemoveDB)?, }; // reset Tendermint state - tendermint_node::reset(config.tendermint_dir()) - .map_err(Error::Tendermint)?; + tendermint_node::reset(config.cometbft_dir()).map_err(Error::Tendermint)?; Ok(()) } @@ -195,7 +194,7 @@ pub fn rollback(config: config::Ledger) -> Result<()> { // Rollback Tendermint state tracing::info!("Rollback Tendermint state"); let tendermint_block_height = - tendermint_node::rollback(config.tendermint_dir()) + tendermint_node::rollback(config.cometbft_dir()) .map_err(Error::Tendermint)?; // Rollback Namada state @@ -295,7 +294,7 @@ where let chain_id = config.chain_id; let db_path = config.shell.db_dir(&chain_id); let base_dir = config.shell.base_dir; - let mode = config.tendermint.tendermint_mode; + let mode = config.cometbft.tendermint_mode; let storage_read_past_height_limit = config.shell.storage_read_past_height_limit; if !Path::new(&base_dir).is_dir() { diff --git a/apps/src/lib/node/ledger/tendermint_node.rs b/apps/src/lib/node/ledger/tendermint_node.rs index a69021e83d..fb0fc2748c 100644 --- a/apps/src/lib/node/ledger/tendermint_node.rs +++ b/apps/src/lib/node/ledger/tendermint_node.rs @@ -27,25 +27,25 @@ use crate::facade::tendermint_config::{ }; /// Env. var to output Tendermint log to stdout -pub const ENV_VAR_TM_STDOUT: &str = "NAMADA_TM_STDOUT"; +pub const ENV_VAR_TM_STDOUT: &str = "NAMADA_CMT_STDOUT"; #[derive(Error, Debug)] pub enum Error { - #[error("Failed to initialize Tendermint: {0}")] + #[error("Failed to initialize CometBFT: {0}")] Init(std::io::Error), - #[error("Failed to load Tendermint config file: {0}")] + #[error("Failed to load CometBFT config file: {0}")] LoadConfig(TendermintError), - #[error("Failed to open Tendermint config for writing: {0}")] + #[error("Failed to open CometBFT config for writing: {0}")] OpenWriteConfig(std::io::Error), - #[error("Failed to serialize Tendermint config TOML to string: {0}")] + #[error("Failed to serialize CometBFT config TOML to string: {0}")] ConfigSerializeToml(toml::ser::Error), - #[error("Failed to write Tendermint config: {0}")] + #[error("Failed to write CometBFT config: {0}")] WriteConfig(std::io::Error), - #[error("Failed to start up Tendermint node: {0}")] + #[error("Failed to start up CometBFT node: {0}")] StartUp(std::io::Error), #[error("{0}")] Runtime(String), - #[error("Failed to rollback tendermint state: {0}")] + #[error("Failed to rollback CometBFT state: {0}")] RollBack(String), #[error("Failed to convert to String: {0:?}")] TendermintPath(std::ffi::OsString), @@ -53,17 +53,17 @@ pub enum Error { pub type Result = std::result::Result; -/// Check if the TENDERMINT env var has been set and use that as the -/// location of the tendermint binary. Otherwise, assume it is on path +/// Check if the COMET env var has been set and use that as the +/// location of the COMET binary. Otherwise, assume it is on path /// /// Returns an error if the env var is defined but not a valid Unicode. fn from_env_or_default() -> Result { - match std::env::var("TENDERMINT") { + match std::env::var("COMETBFT") { Ok(path) => { - tracing::info!("Using tendermint path from env variable: {}", path); + tracing::info!("Using CometBFT path from env variable: {}", path); Ok(path) } - Err(std::env::VarError::NotPresent) => Ok(String::from("tendermint")), + Err(std::env::VarError::NotPresent) => Ok(String::from("cometbft")), Err(std::env::VarError::NotUnicode(msg)) => { Err(Error::TendermintPath(msg)) } @@ -138,7 +138,7 @@ pub async fn run( .kill_on_drop(true) .spawn() .map_err(Error::StartUp)?; - tracing::info!("Tendermint node started"); + tracing::info!("CometBFT node started"); tokio::select! { status = tendermint_node.wait() => { @@ -486,8 +486,8 @@ async fn write_tm_genesis( ) }); let data = serde_json::to_vec_pretty(&genesis) - .expect("Couldn't encode the Tendermint genesis file"); + .expect("Couldn't encode the CometBFT genesis file"); file.write_all(&data[..]) .await - .expect("Couldn't write the Tendermint genesis file"); + .expect("Couldn't write the CometBFT genesis file"); } diff --git a/tests/src/e2e/helpers.rs b/tests/src/e2e/helpers.rs index 3eff517d1d..11bd2f62e8 100644 --- a/tests/src/e2e/helpers.rs +++ b/tests/src/e2e/helpers.rs @@ -99,7 +99,7 @@ pub fn get_actor_rpc(test: &Test, who: &Who) -> String { }; let config = Config::load(base_dir, &test.net.chain_id, Some(tendermint_mode)); - config.ledger.tendermint.rpc_address.to_string() + config.ledger.cometbft.rpc_address.to_string() } /// Get the public key of the validator diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index 5029bea080..bcfc145776 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -182,7 +182,7 @@ fn test_namada_shuts_down_if_tendermint_dies() -> Result<()> { // 2. Kill the tendermint node sleep(1); Command::new("pkill") - .args(["tendermint"]) + .args(["cometbft"]) .spawn() .expect("Test failed") .wait() @@ -3959,12 +3959,8 @@ fn test_genesis_validators() -> Result<()> { // `join-network` use the defaults let update_config = |ix: u8, mut config: Config| { let first_port = net_address_port_0 + 6 * (ix as u16 + 1); - config.ledger.tendermint.p2p_address.set_port(first_port); - config - .ledger - .tendermint - .rpc_address - .set_port(first_port + 1); + config.ledger.cometbft.p2p_address.set_port(first_port); + config.ledger.cometbft.rpc_address.set_port(first_port + 1); config.ledger.shell.ledger_address.set_port(first_port + 2); config }; @@ -4148,12 +4144,8 @@ fn double_signing_gets_slashed() -> Result<()> { let update_config = |ix: u8, mut config: Config| { let first_port = net_address_port_0 + 6 * (ix as u16 + 1); - config.ledger.tendermint.p2p_address.set_port(first_port); - config - .ledger - .tendermint - .rpc_address - .set_port(first_port + 1); + config.ledger.cometbft.p2p_address.set_port(first_port); + config.ledger.cometbft.rpc_address.set_port(first_port + 1); config.ledger.shell.ledger_address.set_port(first_port + 2); config }; @@ -4175,7 +4167,7 @@ fn double_signing_gets_slashed() -> Result<()> { let node_sk = key::common::SecretKey::Ed25519(node_sk); let tm_home_dir = validator_0_base_dir_copy .join(test.net.chain_id.as_str()) - .join("tendermint"); + .join("cometbft"); let _node_pk = client::utils::write_tendermint_node_key(&tm_home_dir, node_sk); diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index c6a8eb8959..317a41b402 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -427,16 +427,16 @@ impl Test { pub fn working_dir() -> PathBuf { let working_dir = fs::canonicalize("..").unwrap(); - // Check that tendermint is either on $PATH or `TENDERMINT` env var is set - if std::env::var("TENDERMINT").is_err() { + // Check that cometbft is either on $PATH or `COMETBFT` env var is set + if std::env::var("COMETBFT").is_err() { Command::new("which") - .arg("tendermint") + .arg("cometbft") .assert() .try_success() .expect( - "The env variable TENDERMINT must be set and point to a local \ - build of the tendermint abci++ branch, or the tendermint \ - binary must be on PATH", + "The env variable COMETBFT must be set and point to a local \ + build of the cometbft abci++ branch, or the cometbft binary \ + must be on PATH", ); } working_dir diff --git a/wasm/checksums.json b/wasm/checksums.json index 4c277ea699..544d711eb0 100644 --- a/wasm/checksums.json +++ b/wasm/checksums.json @@ -1,21 +1,20 @@ { - "tx_bond.wasm": "tx_bond.5edc70343a861ad0c364a31b5a496fa4512d7ad4a3bf70fb19e8ad1fdd752c2e.wasm", - "tx_change_validator_commission.wasm": "tx_change_validator_commission.cdac7616f73bcdb994cea7d3cb439b21895495aa4f680fc405f28ba6c6715e77.wasm", - "tx_ibc.wasm": "tx_ibc.bd3750ef3c6d60e170ed21da08d240630614947af9d3db27f8bcebce283e3f83.wasm", - "tx_init_account.wasm": "tx_init_account.5c718152efc0ea1f47ed9ff059d760b9574c509848aa6f7be491b183ddde1021.wasm", - "tx_init_proposal.wasm": "tx_init_proposal.8d00a82a694748bdba75da76b7c3bed8d18885be9e235e7d45579ad66e27300f.wasm", - "tx_init_validator.wasm": "tx_init_validator.bd9f044807b4f70d54c1259e9db6c51cd6f9c8c5db7ab3a8516555d1fa1dd328.wasm", - "tx_reveal_pk.wasm": "tx_reveal_pk.37aaa9063e03f5eff3a6cd74e625b2fb54027418ecec143de05217a16ec29049.wasm", - "tx_transfer.wasm": "tx_transfer.bcca7fead00b79477fa94bef362f05e945bb325780463bed88b5468ee3e91b63.wasm", - "tx_unbond.wasm": "tx_unbond.e43b2ed891cd2733855d78d55f0ae34b66208c36114c7b0239093cd338712c4b.wasm", - "tx_unjail_validator.wasm": "tx_unjail_validator.9100bf186b4cafe98cc9d2dfa3775a6e698395023a42cab63b153a3ecc51d89d.wasm", - "tx_update_vp.wasm": "tx_update_vp.0c2af0693061733c0bdbdec19952d92eb805d55505de7ffdef62fdf1d6e60011.wasm", - "tx_vote_proposal.wasm": "tx_vote_proposal.beb1c659c66cf02869c2269ee0f09f229372b1b9f56cbc858437401929f1fcb5.wasm", - "tx_withdraw.wasm": "tx_withdraw.8be0862edd903662a12b4d2f76e8568bfba24541352f905c565dcad16f7c19d5.wasm", - "vp_implicit.wasm": "vp_implicit.edc3c4165e6202b8b90f19abe23f3cf5205d90c5772eed47702b895f9bddcc72.wasm", - "vp_masp.wasm": "vp_masp.08352c4c1b5dfa641d40e6de48486c335516841e44733c459cdcca2874e616b7.wasm", - "vp_testnet_faucet.wasm": "vp_testnet_faucet.a02d139ee9ec06a3937ad02c54c60eb5bfe7ee856a3887603089a31aa849a87a.wasm", - "vp_token.wasm": "vp_token.fd63f1c85c28f531074a6a2dfa655fbb3a259f7398644f591858991dbee83a50.wasm", - "vp_user.wasm": "vp_user.6825e6936d14710d93002e27962935dfe60b010dce17bb7ca004c26670476b4a.wasm", - "vp_validator.wasm": "vp_validator.fcc27c29217b9d0ee64adb47bd0c0ec9355d854641eb680e7f24f7f94a63ae03.wasm" + "tx_bond.wasm": "tx_bond.1ac4fc75655415a08a628bc07133d0141ade4086253b4f96673e9eb7da45726a.wasm", + "tx_change_validator_commission.wasm": "tx_change_validator_commission.4dcd692eeb90658506d2eb284c7da90c08bb8d2a625f914573e99efebbfb94ed.wasm", + "tx_ibc.wasm": "tx_ibc.729f25abd2e77152eeec492c01a3d79db56c0ddb9ff235cb12590037387f4aa1.wasm", + "tx_init_account.wasm": "tx_init_account.53ef514d4f5eb4cb4a8a83894be08833777e4eb3aec7c7edbd147991b7d275f4.wasm", + "tx_init_proposal.wasm": "tx_init_proposal.008bd96153886cdeff1ad68fc0978d35ad7a4edc19becf71d8f8c3e5d1f4b1a5.wasm", + "tx_init_validator.wasm": "tx_init_validator.d87634e95f47c4ed43806a23f2cdcea5e3c8c964987ab4059013a531a3cf91ae.wasm", + "tx_reveal_pk.wasm": "tx_reveal_pk.0b1b66ec606b0ce85717e8a026872ef7f6edb936510d60abf0126d2936e34c5a.wasm", + "tx_transfer.wasm": "tx_transfer.57f62e5edc9ac962add374599cccf9de2d5b8341cfcbc6c11021f6947253da9a.wasm", + "tx_unbond.wasm": "tx_unbond.30f386ba0b79017c060e9e828f61b2f25590999c3e321ea33f06a7bcf2f0f63e.wasm", + "tx_update_vp.wasm": "tx_update_vp.24b8501c7df4ee482fbab8411a5e8666d36267302783998e6dd3ccc92a2eb802.wasm", + "tx_vote_proposal.wasm": "tx_vote_proposal.e38b9a1e138aba5482e4429522218172a1c5ef91279e7b2c213fe2749c9220e7.wasm", + "tx_withdraw.wasm": "tx_withdraw.2d54fbffe9ab316cf63122ffe2f6c9b6f43e2da0145a5ea75dd99d5e86018fb0.wasm", + "vp_implicit.wasm": "vp_implicit.2057db599475eb1dc96e5b40c9f39eec8748f92bfd45713e85abea9c5b9a3021.wasm", + "vp_masp.wasm": "vp_masp.3f1f0b555faaf9260b19b04e8277fc52889a6cb0f8bd225b08c4777dba23a65d.wasm", + "vp_testnet_faucet.wasm": "vp_testnet_faucet.05c6758273d11980f03bf58af4edeacb935a22c89aa915c9767825924b5bd00f.wasm", + "vp_token.wasm": "vp_token.61e54faa78931c6fd3cd4ef3d03495d735ed1052037f3cc395079d34db63de16.wasm", + "vp_user.wasm": "vp_user.f46b6efec59564fe82aa7e8fd1cfa503f4c86ae881b3704ee6080998fa0313dc.wasm", + "vp_validator.wasm": "vp_validator.78a51f16ad2ab2dcc10c77c66b31d3bd7f5e2c0d2181b1ef4bf52049f9469ab2.wasm" } \ No newline at end of file From e7fadaa355774d543ea256ff1bb54fc18f41d15f Mon Sep 17 00:00:00 2001 From: Adrian Brink Date: Tue, 30 May 2023 09:20:01 +0200 Subject: [PATCH 02/14] Passthrough of all Tendermint config options via Namada config --- apps/src/bin/namada-node/cli.rs | 7 +- apps/src/lib/client/tx.rs | 2 +- apps/src/lib/client/utils.rs | 84 +-- apps/src/lib/config/mod.rs | 566 +++++++++++++++++--- apps/src/lib/config/utils.rs | 15 + apps/src/lib/node/ledger/broadcaster.rs | 4 +- apps/src/lib/node/ledger/mod.rs | 69 +-- apps/src/lib/node/ledger/shell/mod.rs | 2 +- apps/src/lib/node/ledger/tendermint_node.rs | 104 ++-- tests/src/e2e/helpers.rs | 2 +- tests/src/e2e/ledger_tests.rs | 24 +- 11 files changed, 682 insertions(+), 197 deletions(-) diff --git a/apps/src/bin/namada-node/cli.rs b/apps/src/bin/namada-node/cli.rs index c3c6ad3bab..5dfa976362 100644 --- a/apps/src/bin/namada-node/cli.rs +++ b/apps/src/bin/namada-node/cli.rs @@ -7,15 +7,18 @@ use namada_apps::node::ledger; pub fn main() -> Result<()> { let (cmd, mut ctx) = cli::namada_node_cli()?; + // fixme: not sure why this is set here, since it's settable in the config file if let Some(mode) = ctx.global_args.mode.clone() { - ctx.config.ledger.cometbft.tendermint_mode = mode; + ctx.config.ledger.shell.tendermint_mode = mode; } match cmd { cmds::NamadaNode::Ledger(sub) => match sub { cmds::Ledger::Run(cmds::LedgerRun(args)) => { let wasm_dir = ctx.wasm_dir(); sleep_until(args.start_time); - ctx.config.ledger.cometbft.tx_index = args.tx_index; + + // fixme: not sure why this is set here, since it's settable in the config file + // ctx.config.ledger.tendermint.tx_index = args.tx_index; ledger::run(ctx.config.ledger, wasm_dir); } cmds::Ledger::RunUntil(cmds::LedgerRunUntil(args)) => { diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index d212dfa8c2..3731453fb5 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -298,7 +298,7 @@ pub async fn submit_init_validator< // Write Namada config stuff or figure out how to do the above // tendermint_node things two epochs in the future!!! - ctx.config.ledger.cometbft.tendermint_mode = + ctx.config.ledger.shell.tendermint_mode = TendermintMode::Validator; ctx.config .write( diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index 127443f99e..1ae17882a9 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -324,21 +324,28 @@ pub async fn join_network( tokio::task::spawn_blocking(move || { let mut config = Config::load(&base_dir, &chain_id, None); - config.ledger.cometbft.tendermint_mode = TendermintMode::Validator; + config.ledger.shell.tendermint_mode = + TendermintMode::Validator; // Validator node should turned off peer exchange reactor - config.ledger.cometbft.p2p_pex = false; + // fixme: we shouldn't be setting config values that are settable in the actual config.toml + // config.ledger.tendermint_config.p2p.pex = false; // Remove self from persistent peers - config.ledger.cometbft.p2p_persistent_peers.retain(|peer| { - if let TendermintAddress::Tcp { - peer_id: Some(peer_id), - .. - } = peer - { - node_id != *peer_id - } else { - true - } - }); + config + .ledger + .cometbft + .p2p + .persistent_peers + .retain(|peer| { + if let TendermintAddress::Tcp { + peer_id: Some(peer_id), + .. + } = peer + { + node_id != *peer_id + } else { + true + } + }); config.write(&base_dir, &chain_id, true).unwrap(); }) .await @@ -739,7 +746,7 @@ pub fn init_network( // directories. config.ledger.shell.base_dir = config::DEFAULT_BASE_DIR.into(); // Add a ledger P2P persistent peers - config.ledger.cometbft.p2p_persistent_peers = persistent_peers + config.ledger.cometbft.p2p.persistent_peers = persistent_peers .iter() .enumerate() .filter_map(|(index, peer)| @@ -750,32 +757,45 @@ pub fn init_network( None }) .collect(); - config.ledger.cometbft.consensus_timeout_commit = + // fixme: We shouldn't be hardcoding these. The timeouts should only be set in the config files. + config.ledger.cometbft.consensus.timeout_commit = consensus_timeout_commit; - config.ledger.cometbft.p2p_allow_duplicate_ip = allow_duplicate_ip; - config.ledger.cometbft.p2p_addr_book_strict = !localhost; + // fixme: We shouldn't be hardcoding these. The timeouts should only be set in the config files. + config.ledger.cometbft.p2p.allow_duplicate_ip = + allow_duplicate_ip; + // fixme: We shouldn't be hardcoding these. The timeouts should only be set in the config files. + config.ledger.cometbft.p2p.addr_book_strict = !localhost; // Clear the net address from the config and use it to set ports let net_address = validator_config.net_address.take().unwrap(); + let ip = SocketAddr::from_str(&net_address).unwrap().ip(); let first_port = SocketAddr::from_str(&net_address).unwrap().port(); if !localhost { config .ledger .cometbft - .p2p_address - .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); + .p2p + .laddr = TendermintAddress::from_str(&format!("0.0.0.0:{}", first_port)).unwrap(); + // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } - config.ledger.cometbft.p2p_address.set_port(first_port); + config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(&format!("{}:{}", ip, first_port)).unwrap(); if !localhost { config .ledger .cometbft - .rpc_address - .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); + .rpc + .laddr = TendermintAddress::from_str(&format!("0.0.0.0:{}", first_port+1)).unwrap(); + // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } - config.ledger.cometbft.rpc_address.set_port(first_port + 1); - config.ledger.shell.ledger_address.set_port(first_port + 2); + config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str(&format!("{}:{}", ip, first_port+1)).unwrap(); + // config + // .ledger + // .tendermint + // .rpc_address + // .set_port(first_port + 1); + config.ledger.cometbft.proxy_app = TendermintAddress::from_str(&format!("{}:{}", ip, first_port+2)).unwrap(); // Validator node should turned off peer exchange reactor - config.ledger.cometbft.p2p_pex = false; + // fixme: no hardcoding config values + config.ledger.cometbft.p2p.pex = false; config.write(&validator_dir, &chain_id, true).unwrap(); }, @@ -783,18 +803,20 @@ pub fn init_network( // Update the ledger config persistent peers and save it let mut config = Config::load(&global_args.base_dir, &chain_id, None); - config.ledger.cometbft.p2p_persistent_peers = persistent_peers; - config.ledger.cometbft.consensus_timeout_commit = consensus_timeout_commit; - config.ledger.cometbft.p2p_allow_duplicate_ip = allow_duplicate_ip; + config.ledger.cometbft.p2p.persistent_peers = persistent_peers; + config.ledger.cometbft.consensus.timeout_commit = + consensus_timeout_commit; + config.ledger.cometbft.p2p.allow_duplicate_ip = allow_duplicate_ip; // Open P2P address if !localhost { config .ledger .cometbft - .p2p_address - .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); + .p2p + .laddr = TendermintAddress::from_str("0.0.0.0").unwrap(); + // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } - config.ledger.cometbft.p2p_addr_book_strict = !localhost; + config.ledger.cometbft.p2p.addr_book_strict = !localhost; config.ledger.genesis_time = genesis.genesis_time.into(); config .write(&global_args.base_dir, &chain_id, true) diff --git a/apps/src/lib/config/mod.rs b/apps/src/lib/config/mod.rs index e0313115f8..c43f5ab141 100644 --- a/apps/src/lib/config/mod.rs +++ b/apps/src/lib/config/mod.rs @@ -8,7 +8,6 @@ use std::fs::{create_dir_all, File}; use std::io::Write; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::path::{Path, PathBuf}; -use std::str::FromStr; use directories::ProjectDirs; use namada::types::chain::ChainId; @@ -18,8 +17,7 @@ use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::cli; -use crate::facade::tendermint::Timeout; -use crate::facade::tendermint_config::net::Address as TendermintAddress; +use crate::facade::tendermint_config::{TendermintConfig, TxIndexer, TxIndexConfig}; /// Base directory contains global config and chain directories. pub const DEFAULT_BASE_DIR: &str = ".namada"; @@ -95,13 +93,13 @@ pub struct Ledger { pub genesis_time: Rfc3339String, pub chain_id: ChainId, pub shell: Shell, - pub cometbft: Tendermint, + pub cometbft: TendermintConfig, } #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Shell { pub base_dir: PathBuf, - pub ledger_address: SocketAddr, + // pub ledger_address: SocketAddr, /// RocksDB block cache maximum size in bytes. /// When not set, defaults to 1/3 of the available memory. pub block_cache_bytes: Option, @@ -120,36 +118,8 @@ pub struct Shell { cometbft_dir: PathBuf, /// An optional action to take when a given blockheight is reached. pub action_at_height: Option, -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct Tendermint { - pub rpc_address: SocketAddr, - pub p2p_address: SocketAddr, - /// The persistent peers addresses must include node ID - pub p2p_persistent_peers: Vec, - /// Turns the peer exchange reactor on or off. Validator node will want the - /// pex turned off. - pub p2p_pex: bool, - /// Toggle to disable guard against peers connecting from the same IP - pub p2p_allow_duplicate_ip: bool, - /// Set `true` for strict address routability rules - /// Set `false` for private or local networks - pub p2p_addr_book_strict: bool, - /// Tendermint Consensus Parameters - pub consensus_timeout_propose: Timeout, - pub consensus_timeout_propose_delta: Timeout, - pub consensus_timeout_prevote: Timeout, - pub consensus_timeout_prevote_delta: Timeout, - pub consensus_timeout_precommit: Timeout, - pub consensus_timeout_precommit_delta: Timeout, - pub consensus_timeout_commit: Timeout, + /// Specify if tendermint is started as validator, fullnode or seednode pub tendermint_mode: TendermintMode, - pub instrumentation_prometheus: bool, - pub instrumentation_prometheus_listen_addr: SocketAddr, - pub instrumentation_namespace: String, - /// Toggle to enable tx indexing - pub tx_index: bool, } impl Ledger { @@ -158,15 +128,18 @@ impl Ledger { chain_id: ChainId, mode: TendermintMode, ) -> Self { + let mut tendermint_config = TendermintConfig::parse_toml(DEFAULT_COMETBFT_CONFIG).unwrap(); + tendermint_config.instrumentation.namespace = "namada_tm".to_string(); + tendermint_config.tx_index = TxIndexConfig{indexer: TxIndexer::Null}; Self { genesis_time: Rfc3339String("1970-01-01T00:00:00Z".to_owned()), chain_id, shell: Shell { base_dir: base_dir.as_ref().to_owned(), - ledger_address: SocketAddr::new( - IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), - 26658, - ), + // ledger_address: SocketAddr::new( + // IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), + // 26658, + // ), block_cache_bytes: None, vp_wasm_compilation_cache_bytes: None, tx_wasm_compilation_cache_bytes: None, @@ -175,39 +148,9 @@ impl Ledger { db_dir: DB_DIR.into(), cometbft_dir: COMETBFT_DIR.into(), action_at_height: None, - }, - cometbft: Tendermint { - rpc_address: SocketAddr::new( - IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), - 26657, - ), - p2p_address: SocketAddr::new( - IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), - 26656, - ), - p2p_persistent_peers: vec![], - p2p_pex: true, - p2p_allow_duplicate_ip: false, - p2p_addr_book_strict: true, - consensus_timeout_propose: Timeout::from_str("3s").unwrap(), - consensus_timeout_propose_delta: Timeout::from_str("500ms") - .unwrap(), - consensus_timeout_prevote: Timeout::from_str("1s").unwrap(), - consensus_timeout_prevote_delta: Timeout::from_str("500ms") - .unwrap(), - consensus_timeout_precommit: Timeout::from_str("1s").unwrap(), - consensus_timeout_precommit_delta: Timeout::from_str("500ms") - .unwrap(), - consensus_timeout_commit: Timeout::from_str("1s").unwrap(), tendermint_mode: mode, - instrumentation_prometheus: false, - instrumentation_prometheus_listen_addr: SocketAddr::new( - IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), - 26661, - ), - instrumentation_namespace: "namadan_tm".to_string(), - tx_index: false, }, + cometbft: tendermint_config, } } @@ -399,6 +342,15 @@ pub fn get_default_namada_folder() -> PathBuf { } } +mod tests { + use super::*; + + #[test] + fn test_default_cometbft_config() { + assert!(TendermintConfig::parse_toml(DEFAULT_COMETBFT_CONFIG).is_ok()); + } +} + pub const VALUE_AFTER_TABLE_ERROR_MSG: &str = r#" Error while serializing to toml. It means that some nested structure is followed by simple fields. @@ -421,3 +373,479 @@ And this is correct nested:Nested, } "#; + +pub const DEFAULT_COMETBFT_CONFIG: &str = r#" + +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or +# relative to the home directory (e.g. "data"). The home directory is +# "$HOME/.cometbft" by default, but could be changed via $CMTHOME env variable +# or --home cmd flag. + +####################################################################### +### Main Base Config Options ### +####################################################################### + +# TCP or UNIX socket address of the ABCI application, +# or the name of an ABCI application compiled in with the CometBFT binary +proxy_app = "tcp://127.0.0.1:26658" + +# A custom human readable name for this node +moniker = "technodrome" + +# If this node is many blocks behind the tip of the chain, BlockSync +# allows them to catchup quickly by downloading blocks in parallel +# and verifying their commits +# +# Deprecated: this key will be removed and BlockSync will be enabled +# unconditionally in the next major release. +block_sync = true + +# Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb +# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# - pure go +# - stable +# * cleveldb (uses levigo wrapper) +# - fast +# - requires gcc +# - use cleveldb build tag (go build -tags cleveldb) +# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) +# - EXPERIMENTAL +# - may be faster is some use-cases (random reads - indexer) +# - use boltdb build tag (go build -tags boltdb) +# * rocksdb (uses github.com/tecbot/gorocksdb) +# - EXPERIMENTAL +# - requires gcc +# - use rocksdb build tag (go build -tags rocksdb) +# * badgerdb (uses github.com/dgraph-io/badger) +# - EXPERIMENTAL +# - use badgerdb build tag (go build -tags badgerdb) +db_backend = "goleveldb" + +# Database directory +db_dir = "data" + +# Output level for logging, including package level options +log_level = "info" + +# Output format: 'plain' (colored text) or 'json' +log_format = "plain" + +##### additional base config options ##### + +# Path to the JSON file containing the initial validator set and other meta data +genesis_file = "config/genesis.json" + +# Path to the JSON file containing the private key to use as a validator in the consensus protocol +priv_validator_key_file = "config/priv_validator_key.json" + +# Path to the JSON file containing the last sign state of a validator +priv_validator_state_file = "data/priv_validator_state.json" + +# TCP or UNIX socket address for CometBFT to listen on for +# connections from an external PrivValidator process +priv_validator_laddr = "" + +# Path to the JSON file containing the private key to use for node authentication in the p2p protocol +node_key_file = "config/node_key.json" + +# Mechanism to connect to the ABCI application: socket | grpc +abci = "socket" + +# If true, query the ABCI app on connecting to a new peer +# so the app can decide if we should keep the connection or not +filter_peers = false + + +####################################################################### +### Advanced Configuration Options ### +####################################################################### + +####################################################### +### RPC Server Configuration Options ### +####################################################### +[rpc] + +# TCP or UNIX socket address for the RPC server to listen on +laddr = "tcp://127.0.0.1:26657" + +# A list of origins a cross-domain request can be executed from +# Default value '[]' disables cors support +# Use '["*"]' to allow any origin +cors_allowed_origins = [] + +# A list of methods the client is allowed to use with cross-domain requests +cors_allowed_methods = ["HEAD", "GET", "POST", ] + +# A list of non simple headers the client is allowed to use with cross-domain requests +cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] + +# TCP or UNIX socket address for the gRPC server to listen on +# NOTE: This server only supports /broadcast_tx_commit +grpc_laddr = "" + +# Maximum number of simultaneous connections. +# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +grpc_max_open_connections = 900 + +# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool +unsafe = false + +# Maximum number of simultaneous connections (including WebSocket). +# Does not include gRPC connections. See grpc_max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +max_open_connections = 900 + +# Maximum number of unique clientIDs that can /subscribe +# If you're using /broadcast_tx_commit, set to the estimated maximum number +# of broadcast_tx_commit calls per block. +max_subscription_clients = 100 + +# Maximum number of unique queries a given client can /subscribe to +# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to +# the estimated # maximum number of broadcast_tx_commit calls per block. +max_subscriptions_per_client = 5 + +# Experimental parameter to specify the maximum number of events a node will +# buffer, per subscription, before returning an error and closing the +# subscription. Must be set to at least 100, but higher values will accommodate +# higher event throughput rates (and will use more memory). +experimental_subscription_buffer_size = 200 + +# Experimental parameter to specify the maximum number of RPC responses that +# can be buffered per WebSocket client. If clients cannot read from the +# WebSocket endpoint fast enough, they will be disconnected, so increasing this +# parameter may reduce the chances of them being disconnected (but will cause +# the node to use more memory). +# +# Must be at least the same as "experimental_subscription_buffer_size", +# otherwise connections could be dropped unnecessarily. This value should +# ideally be somewhat higher than "experimental_subscription_buffer_size" to +# accommodate non-subscription-related RPC responses. +experimental_websocket_write_buffer_size = 200 + +# If a WebSocket client cannot read fast enough, at present we may +# silently drop events instead of generating an error or disconnecting the +# client. +# +# Enabling this experimental parameter will cause the WebSocket connection to +# be closed instead if it cannot read fast enough, allowing for greater +# predictability in subscription behavior. +experimental_close_on_slow_client = false + +# How long to wait for a tx to be committed during /broadcast_tx_commit. +# WARNING: Using a value larger than 10s will result in increasing the +# global HTTP write timeout, which applies to all connections and endpoints. +# See https://github.com/tendermint/tendermint/issues/3435 +timeout_broadcast_tx_commit = "10s" + +# Maximum size of request body, in bytes +max_body_bytes = 1000000 + +# Maximum size of request header, in bytes +max_header_bytes = 1048576 + +# The path to a file containing certificate that is used to create the HTTPS server. +# Might be either absolute path or path related to CometBFT's config directory. +# If the certificate is signed by a certificate authority, +# the certFile should be the concatenation of the server's certificate, any intermediates, +# and the CA's certificate. +# NOTE: both tls_cert_file and tls_key_file must be present for CometBFT to create HTTPS server. +# Otherwise, HTTP server is run. +tls_cert_file = "" + +# The path to a file containing matching private key that is used to create the HTTPS server. +# Might be either absolute path or path related to CometBFT's config directory. +# NOTE: both tls-cert-file and tls-key-file must be present for CometBFT to create HTTPS server. +# Otherwise, HTTP server is run. +tls_key_file = "" + +# pprof listen address (https://golang.org/pkg/net/http/pprof) +pprof_laddr = "" + +####################################################### +### P2P Configuration Options ### +####################################################### +[p2p] + +# Address to listen for incoming connections +laddr = "tcp://0.0.0.0:26656" + +# Address to advertise to peers for them to dial +# If empty, will use the same port as the laddr, +# and will introspect on the listener or use UPnP +# to figure out the address. ip and port are required +# example: 159.89.10.97:26656 +external_address = "" + +# Comma separated list of seed nodes to connect to +seeds = "" + +# Comma separated list of nodes to keep persistent connections to +persistent_peers = "" + +# UPNP port forwarding +upnp = false + +# Path to address book +addr_book_file = "config/addrbook.json" + +# Set true for strict address routability rules +# Set false for private or local networks +addr_book_strict = true + +# Maximum number of inbound peers +max_num_inbound_peers = 40 + +# Maximum number of outbound peers to connect to, excluding persistent peers +max_num_outbound_peers = 10 + +# List of node IDs, to which a connection will be (re)established ignoring any existing limits +unconditional_peer_ids = "" + +# Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) +persistent_peers_max_dial_period = "0s" + +# Time to wait before flushing messages out on the connection +flush_throttle_timeout = "100ms" + +# Maximum size of a message packet payload, in bytes +max_packet_msg_payload_size = 1024 + +# Rate at which packets can be sent, in bytes/second +send_rate = 5120000 + +# Rate at which packets can be received, in bytes/second +recv_rate = 5120000 + +# Set true to enable the peer-exchange reactor +pex = true + +# Seed mode, in which node constantly crawls the network and looks for +# peers. If another node asks it for addresses, it responds and disconnects. +# +# Does not work if the peer-exchange reactor is disabled. +seed_mode = false + +# Comma separated list of peer IDs to keep private (will not be gossiped to other peers) +private_peer_ids = "" + +# Toggle to disable guard against peers connecting from the same ip. +allow_duplicate_ip = false + +# Peer connection configuration. +handshake_timeout = "20s" +dial_timeout = "3s" + +####################################################### +### Mempool Configuration Option ### +####################################################### +[mempool] + +# Mempool version to use: +# 1) "v0" - (default) FIFO mempool. +# 2) "v1" - prioritized mempool (deprecated; will be removed in the next release). +version = "v0" + +recheck = true +broadcast = true +wal_dir = "" + +# Maximum number of transactions in the mempool +size = 5000 + +# Limit the total size of all txs in the mempool. +# This only accounts for raw transactions (e.g. given 1MB transactions and +# max_txs_bytes=5MB, mempool will only accept 5 transactions). +max_txs_bytes = 1073741824 + +# Size of the cache (used to filter transactions we saw earlier) in transactions +cache_size = 10000 + +# Do not remove invalid transactions from the cache (default: false) +# Set to true if it's not possible for any invalid transaction to become valid +# again in the future. +keep-invalid-txs-in-cache = false + +# Maximum size of a single transaction. +# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. +max_tx_bytes = 1048576 + +# Maximum size of a batch of transactions to send to a peer +# Including space needed by encoding (one varint per transaction). +# XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796 +max_batch_bytes = 0 + +# ttl-duration, if non-zero, defines the maximum amount of time a transaction +# can exist for in the mempool. +# +# Note, if ttl-num-blocks is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if it's +# insertion time into the mempool is beyond ttl-duration. +ttl-duration = "0s" + +# ttl-num-blocks, if non-zero, defines the maximum number of blocks a transaction +# can exist for in the mempool. +# +# Note, if ttl-duration is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if +# it's insertion time into the mempool is beyond ttl-duration. +ttl-num-blocks = 0 + +####################################################### +### State Sync Configuration Options ### +####################################################### +[statesync] +# State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine +# snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in +# the network to take and serve state machine snapshots. State sync is not attempted if the node +# has any local state (LastBlockHeight > 0). The node will have a truncated block history, +# starting from the height of the snapshot. +enable = false + +# RPC servers (comma-separated) for light client verification of the synced state machine and +# retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding +# header hash obtained from a trusted source, and a period during which validators can be trusted. +# +# For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 +# weeks) during which they can be financially punished (slashed) for misbehavior. +rpc_servers = "" +trust_height = 0 +trust_hash = "" +trust_period = "168h0m0s" + +# Time to spend discovering snapshots before initiating a restore. +discovery_time = "15s" + +# Temporary directory for state sync snapshot chunks, defaults to the OS tempdir (typically /tmp). +# Will create a new, randomly named directory within, and remove it when done. +temp_dir = "" + +# The timeout duration before re-requesting a chunk, possibly from a different +# peer (default: 1 minute). +chunk_request_timeout = "10s" + +# The number of concurrent chunk fetchers to run (default: 1). +chunk_fetchers = "4" + +####################################################### +### Block Sync Configuration Options ### +####################################################### +[blocksync] + +# Block Sync version to use: +# +# In v0.37, v1 and v2 of the block sync protocols were deprecated. +# Please use v0 instead. +# +# 1) "v0" - the default block sync implementation +version = "v0" + +####################################################### +### Consensus Configuration Options ### +####################################################### +[consensus] + +wal_file = "data/cs.wal/wal" + +# How long we wait for a proposal block before prevoting nil +timeout_propose = "3s" +# How much timeout_propose increases with each round +timeout_propose_delta = "500ms" +# How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil) +timeout_prevote = "1s" +# How much the timeout_prevote increases with each round +timeout_prevote_delta = "500ms" +# How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil) +timeout_precommit = "1s" +# How much the timeout_precommit increases with each round +timeout_precommit_delta = "500ms" +# How long we wait after committing a block, before starting on the new +# height (this gives us a chance to receive some more precommits, even +# though we already have +2/3). +timeout_commit = "1s" + +# How many blocks to look back to check existence of the node's consensus votes before joining consensus +# When non-zero, the node will panic upon restart +# if the same consensus key was used to sign {double_sign_check_height} last blocks. +# So, validators should stop the state machine, wait for some blocks, and then restart the state machine to avoid panic. +double_sign_check_height = 0 + +# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) +skip_timeout_commit = false + +# EmptyBlocks mode and possible interval between empty blocks +create_empty_blocks = true +create_empty_blocks_interval = "0s" + +# Reactor sleep duration parameters +peer_gossip_sleep_duration = "100ms" +peer_query_maj23_sleep_duration = "2s" + +####################################################### +### Storage Configuration Options ### +####################################################### +[storage] + +# Set to true to discard ABCI responses from the state store, which can save a +# considerable amount of disk space. Set to false to ensure ABCI responses are +# persisted. ABCI responses are required for /block_results RPC queries, and to +# reindex events in the command-line tool. +discard_abci_responses = false + +####################################################### +### Transaction Indexer Configuration Options ### +####################################################### +[tx_index] + +# What indexer to use for transactions +# +# The application will set which txs to index. In some cases a node operator will be able +# to decide which txs to index based on configuration set in the application. +# +# Options: +# 1) "null" +# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). +# - When "kv" is chosen "tx.height" and "tx.hash" will always be indexed. +# 3) "psql" - the indexer services backed by PostgreSQL. +# When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed. +indexer = "kv" + +# The PostgreSQL connection configuration, the connection format: +# postgresql://:@:/? +psql-conn = "" + +####################################################### +### Instrumentation Configuration Options ### +####################################################### +[instrumentation] + +# When true, Prometheus metrics are served under /metrics on +# PrometheusListenAddr. +# Check out the documentation for the list of available metrics. +prometheus = false + +# Address to listen for Prometheus collector(s) connections +prometheus_listen_addr = ":26660" + +# Maximum number of simultaneous connections. +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +max_open_connections = 3 + +# Instrumentation namespace +namespace = "cometbft" + +"#; diff --git a/apps/src/lib/config/utils.rs b/apps/src/lib/config/utils.rs index 19b2648d3b..fe46741122 100644 --- a/apps/src/lib/config/utils.rs +++ b/apps/src/lib/config/utils.rs @@ -6,6 +6,8 @@ use std::{cmp, env}; use itertools::Either; use crate::cli; +use std::net::{SocketAddr, ToSocketAddrs}; +use crate::facade::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 @@ -45,6 +47,19 @@ fn num_of_threads_aux( } } +// fixme: Handle this gracefully with either an Option or a Result. Ensure that hostname resolution works. +pub fn convert_tm_addr_to_socket_addr(tm_addr: &TendermintAddress) -> SocketAddr { + let tm_addr = tm_addr.clone(); + match tm_addr { + TendermintAddress::Tcp { peer_id, host, port } => { + return (host, port).to_socket_addrs().unwrap().next().unwrap(); + }, + TendermintAddress::Unix { path } => { + panic!("Unix addresses aren't currently supported.") + } + } +} + #[cfg(test)] mod test { use std::panic; diff --git a/apps/src/lib/node/ledger/broadcaster.rs b/apps/src/lib/node/ledger/broadcaster.rs index 199ab953c1..915a7eee67 100644 --- a/apps/src/lib/node/ledger/broadcaster.rs +++ b/apps/src/lib/node/ledger/broadcaster.rs @@ -1,3 +1,5 @@ +use std::net::SocketAddr; + use tokio::sync::mpsc::UnboundedReceiver; use crate::facade::tendermint_rpc::{Client, HttpClient}; @@ -13,7 +15,7 @@ pub struct Broadcaster { impl Broadcaster { /// Create a new broadcaster that will send Http messages /// over the given url. - pub fn new(url: &str, receiver: UnboundedReceiver>) -> Self { + pub fn new(url: SocketAddr, receiver: UnboundedReceiver>) -> Self { Self { client: HttpClient::new(format!("http://{}", url).as_str()) .unwrap(), diff --git a/apps/src/lib/node/ledger/mod.rs b/apps/src/lib/node/ledger/mod.rs index 10beac63ce..8f5317ad22 100644 --- a/apps/src/lib/node/ledger/mod.rs +++ b/apps/src/lib/node/ledger/mod.rs @@ -23,7 +23,7 @@ use tower::ServiceBuilder; use self::abortable::AbortableSpawner; use self::shims::abcipp_shim::AbciService; use crate::cli::args; -use crate::config::utils::num_of_threads; +use crate::config::utils::{num_of_threads, convert_tm_addr_to_socket_addr}; use crate::config::TendermintMode; use crate::facade::tendermint_proto::abci::CheckTxType; use crate::facade::tower_abci::{response, split, Server}; @@ -408,7 +408,7 @@ fn start_abci_broadcaster_shell( task::JoinHandle<()>, thread::JoinHandle<()>, ) { - let rpc_address = config.cometbft.rpc_address.to_string(); + let rpc_address = convert_tm_addr_to_socket_addr(&config.cometbft.rpc.laddr); let RunAuxSetup { vp_wasm_compilation_cache, tx_wasm_compilation_cache, @@ -421,37 +421,38 @@ fn start_abci_broadcaster_shell( tokio::sync::mpsc::unbounded_channel(); // Start broadcaster - let broadcaster = - if matches!(config.cometbft.tendermint_mode, TendermintMode::Validator) - { - let (bc_abort_send, bc_abort_recv) = - tokio::sync::oneshot::channel::<()>(); - - spawner - .spawn_abortable("Broadcaster", move |aborter| async move { - // Construct a service for broadcasting protocol txs from - // the ledger - let mut broadcaster = - Broadcaster::new(&rpc_address, broadcaster_receiver); - broadcaster.run(bc_abort_recv).await; - tracing::info!("Broadcaster is no longer running."); - - drop(aborter); - }) - .with_cleanup(async move { - let _ = bc_abort_send.send(()); - }) - } else { - spawn_dummy_task(()) - }; + let broadcaster = if matches!( + config.shell.tendermint_mode, + TendermintMode::Validator + ) { + let (bc_abort_send, bc_abort_recv) = + tokio::sync::oneshot::channel::<()>(); + + spawner + .spawn_abortable("Broadcaster", move |aborter| async move { + // Construct a service for broadcasting protocol txs from the + // ledger + let mut broadcaster = + Broadcaster::new(rpc_address, broadcaster_receiver); + broadcaster.run(bc_abort_recv).await; + tracing::info!("Broadcaster is no longer running."); + + drop(aborter); + }) + .with_cleanup(async move { + let _ = bc_abort_send.send(()); + }) + } else { + spawn_dummy_task(()) + }; // Setup DB cache, it must outlive the DB instance that's in the shell let db_cache = rocksdb::Cache::new_lru_cache(db_block_cache_size_bytes as usize); // Construct our ABCI application. - let tendermint_mode = config.cometbft.tendermint_mode.clone(); - let ledger_address = config.shell.ledger_address; + let tendermint_mode = config.shell.tendermint_mode.clone(); + let proxy_app_address = convert_tm_addr_to_socket_addr(&config.cometbft.proxy_app); #[cfg(not(feature = "dev"))] let genesis = genesis::genesis(&config.shell.base_dir, &config.chain_id); #[cfg(feature = "dev")] @@ -475,7 +476,7 @@ fn start_abci_broadcaster_shell( let res = run_abci( abci_service, service_handle, - ledger_address, + proxy_app_address, abci_abort_recv, ) .await; @@ -512,7 +513,7 @@ fn start_abci_broadcaster_shell( async fn run_abci( abci_service: AbciService, service_handle: tokio::sync::broadcast::Sender<()>, - ledger_address: SocketAddr, + proxy_app_address: SocketAddr, abort_recv: tokio::sync::oneshot::Receiver<()>, ) -> shell::Result<()> { // Split it into components. @@ -540,7 +541,7 @@ async fn run_abci( .unwrap(); tokio::select! { // Run the server with the ABCI service - status = server.listen(ledger_address) => { + status = server.listen(proxy_app_address) => { status.map_err(|err| Error::TowerServer(err.to_string())) }, resp_sender = abort_recv => { @@ -567,8 +568,8 @@ fn start_tendermint( ) -> task::JoinHandle> { let tendermint_dir = config.cometbft_dir(); let chain_id = config.chain_id.clone(); - let ledger_address = config.shell.ledger_address.to_string(); - let tendermint_config = config.cometbft.clone(); + let proxy_app_address = config.cometbft.proxy_app.to_string(); + let config = config.clone(); let genesis_time = config .genesis_time .clone() @@ -585,8 +586,8 @@ fn start_tendermint( tendermint_dir, chain_id, genesis_time, - ledger_address, - tendermint_config, + proxy_app_address, + config, tm_abort_recv, ) .map_err(Error::Tendermint) diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index 2f5d443e16..3605ff49be 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -294,7 +294,7 @@ where let chain_id = config.chain_id; let db_path = config.shell.db_dir(&chain_id); let base_dir = config.shell.base_dir; - let mode = config.cometbft.tendermint_mode; + let mode = config.shell.tendermint_mode; let storage_read_past_height_limit = config.shell.storage_read_past_height_limit; if !Path::new(&base_dir).is_dir() { diff --git a/apps/src/lib/node/ledger/tendermint_node.rs b/apps/src/lib/node/ledger/tendermint_node.rs index fb0fc2748c..155b2933e3 100644 --- a/apps/src/lib/node/ledger/tendermint_node.rs +++ b/apps/src/lib/node/ledger/tendermint_node.rs @@ -1,4 +1,5 @@ use std::env; +use std::net::SocketAddr; use std::path::{Path, PathBuf}; use std::process::Stdio; use std::str::FromStr; @@ -75,15 +76,15 @@ pub async fn run( home_dir: PathBuf, chain_id: ChainId, genesis_time: DateTimeUtc, - ledger_address: String, - config: config::Tendermint, + proxy_app_address: String, + config: config::Ledger, abort_recv: tokio::sync::oneshot::Receiver< tokio::sync::oneshot::Sender<()>, >, ) -> Result<()> { let home_dir_string = home_dir.to_string_lossy().to_string(); let tendermint_path = from_env_or_default()?; - let mode = config.tendermint_mode.to_str().to_owned(); + let mode = config.shell.tendermint_mode.to_str().to_owned(); #[cfg(feature = "dev")] // This has to be checked before we run tendermint init @@ -115,13 +116,13 @@ pub async fn run( #[cfg(not(feature = "abcipp"))] write_tm_genesis(&home_dir, chain_id, genesis_time).await; - update_tendermint_config(&home_dir, config).await?; + update_tendermint_config(&home_dir, config.cometbft).await?; let mut tendermint_node = Command::new(&tendermint_path); tendermint_node.args([ "start", "--proxy_app", - &ledger_address, + &proxy_app_address, "--home", &home_dir_string, ]); @@ -348,23 +349,24 @@ pub fn write_validator_state(home_dir: impl AsRef) { async fn update_tendermint_config( home_dir: impl AsRef, - tendermint_config: config::Tendermint, + config: TendermintConfig, ) -> Result<()> { let home_dir = home_dir.as_ref(); let path = home_dir.join("config").join("config.toml"); - let mut config = - TendermintConfig::load_toml_file(&path).map_err(Error::LoadConfig)?; + let mut config = config.clone(); + // let mut config = + // TendermintConfig::load_toml_file(&path).map_err(Error::LoadConfig)?; config.moniker = Moniker::from_str(&format!("{}-{}", config.moniker, namada_version())) .expect("Invalid moniker"); - config.p2p.laddr = - TendermintAddress::from_str(&tendermint_config.p2p_address.to_string()) - .unwrap(); - config.p2p.persistent_peers = tendermint_config.p2p_persistent_peers; - config.p2p.pex = tendermint_config.p2p_pex; - config.p2p.allow_duplicate_ip = tendermint_config.p2p_allow_duplicate_ip; + // config.p2p.laddr = + // TendermintAddress::from_str(&tendermint_config.p2p_address.to_string()) + // .unwrap(); + // config.p2p.persistent_peers = tendermint_config.p2p_persistent_peers; + // config.p2p.pex = tendermint_config.p2p_pex; + // config.p2p.allow_duplicate_ip = tendermint_config.p2p_allow_duplicate_ip; // In "dev", only produce blocks when there are txs or when the AppHash // changes @@ -375,47 +377,47 @@ async fn update_tendermint_config( // again in the future. config.mempool.keep_invalid_txs_in_cache = false; - config.rpc.laddr = - TendermintAddress::from_str(&tendermint_config.rpc_address.to_string()) - .unwrap(); + // config.rpc.laddr = + // TendermintAddress::from_str(&tendermint_config.rpc_address.to_string()) + // .unwrap(); // Bumped from the default `1_000_000`, because some WASMs can be // quite large config.rpc.max_body_bytes = 2_000_000; - config.instrumentation.prometheus = - tendermint_config.instrumentation_prometheus; - config.instrumentation.prometheus_listen_addr = tendermint_config - .instrumentation_prometheus_listen_addr - .to_string(); - config.instrumentation.namespace = - tendermint_config.instrumentation_namespace; - - #[cfg(feature = "abciplus")] - { - config.consensus.timeout_propose = - tendermint_config.consensus_timeout_propose; - config.consensus.timeout_propose_delta = - tendermint_config.consensus_timeout_propose_delta; - config.consensus.timeout_prevote = - tendermint_config.consensus_timeout_prevote; - config.consensus.timeout_prevote_delta = - tendermint_config.consensus_timeout_prevote_delta; - config.consensus.timeout_precommit = - tendermint_config.consensus_timeout_precommit; - config.consensus.timeout_precommit_delta = - tendermint_config.consensus_timeout_precommit_delta; - config.consensus.timeout_commit = - tendermint_config.consensus_timeout_commit; - } - - let indexer = if tendermint_config.tx_index { - TxIndexer::Kv - } else { - TxIndexer::Null - }; - #[cfg(feature = "abcipp")] - let indexer = [indexer]; - config.tx_index = TxIndexConfig { indexer }; + // config.instrumentation.prometheus = + // tendermint_config.instrumentation_prometheus; + // config.instrumentation.prometheus_listen_addr = tendermint_config + // .instrumentation_prometheus_listen_addr + // .to_string(); + // config.instrumentation.namespace = + // tendermint_config.instrumentation_namespace; + + // #[cfg(feature = "abciplus")] + // { + // config.consensus.timeout_propose = + // tendermint_config.consensus_timeout_propose; + // config.consensus.timeout_propose_delta = + // tendermint_config.consensus_timeout_propose_delta; + // config.consensus.timeout_prevote = + // tendermint_config.consensus_timeout_prevote; + // config.consensus.timeout_prevote_delta = + // tendermint_config.consensus_timeout_prevote_delta; + // config.consensus.timeout_precommit = + // tendermint_config.consensus_timeout_precommit; + // config.consensus.timeout_precommit_delta = + // tendermint_config.consensus_timeout_precommit_delta; + // config.consensus.timeout_commit = + // tendermint_config.consensus_timeout_commit; + // } + + // let indexer = if tendermint_config.tx_index { + // TxIndexer::Kv + // } else { + // TxIndexer::Null + // }; + // #[cfg(feature = "abcipp")] + // let indexer = [indexer]; + // config.tx_index = TxIndexConfig { indexer }; let mut file = OpenOptions::new() .write(true) diff --git a/tests/src/e2e/helpers.rs b/tests/src/e2e/helpers.rs index 11bd2f62e8..321f1ab975 100644 --- a/tests/src/e2e/helpers.rs +++ b/tests/src/e2e/helpers.rs @@ -99,7 +99,7 @@ pub fn get_actor_rpc(test: &Test, who: &Who) -> String { }; let config = Config::load(base_dir, &test.net.chain_id, Some(tendermint_mode)); - config.ledger.cometbft.rpc_address.to_string() + config.ledger.cometbft.rpc.laddr.to_string() } /// Get the public key of the validator diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index bcfc145776..8ef80e665e 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -27,9 +27,11 @@ use namada_apps::client::tx::CLIShieldedUtils; use namada_apps::config::genesis::genesis_config::{ GenesisConfig, ParametersConfig, PosParamsConfig, }; +use namada_apps::config::utils::convert_tm_addr_to_socket_addr; use namada_test_utils::TestWasms; use serde_json::json; use setup::constants::*; +use tendermint_config::net::Address as TendermintAddress; use super::helpers::{ get_height, is_debug_mode, wait_for_block_height, wait_for_wasm_pre_compile, @@ -3959,9 +3961,14 @@ fn test_genesis_validators() -> Result<()> { // `join-network` use the defaults let update_config = |ix: u8, mut config: Config| { let first_port = net_address_port_0 + 6 * (ix as u16 + 1); - config.ledger.cometbft.p2p_address.set_port(first_port); - config.ledger.cometbft.rpc_address.set_port(first_port + 1); - config.ledger.shell.ledger_address.set_port(first_port + 2); + let p2p_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.p2p.laddr).ip().to_string(); + println!("ERROR: {}", p2p_addr); + println!("ERROR: {}", first_port); + config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(&format!("{}:{}", p2p_addr, first_port)).unwrap(); + let rpc_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.rpc.laddr).ip().to_string(); + config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str(&format!("{}:{}", rpc_addr, first_port+1)).unwrap(); + let proxy_app_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.proxy_app).ip().to_string(); + config.ledger.cometbft.proxy_app = TendermintAddress::from_str(&format!("{}:{}", proxy_app_addr, first_port+2)).unwrap(); config }; @@ -4144,9 +4151,14 @@ fn double_signing_gets_slashed() -> Result<()> { let update_config = |ix: u8, mut config: Config| { let first_port = net_address_port_0 + 6 * (ix as u16 + 1); - config.ledger.cometbft.p2p_address.set_port(first_port); - config.ledger.cometbft.rpc_address.set_port(first_port + 1); - config.ledger.shell.ledger_address.set_port(first_port + 2); + let p2p_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.p2p.laddr).ip().to_string(); + println!("ERROR: {}", p2p_addr); + println!("ERROR: {}", first_port); + config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(&format!("{}:{}", p2p_addr, first_port)).unwrap(); + let rpc_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.rpc.laddr).ip().to_string(); + config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str(&format!("{}:{}", rpc_addr, first_port+1)).unwrap(); + let proxy_app_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.proxy_app).ip().to_string(); + config.ledger.cometbft.proxy_app = TendermintAddress::from_str(&format!("{}:{}", proxy_app_addr, first_port+2)).unwrap(); config }; From 9a99098ea8a81265bdc129f7eee100af66dd7d48 Mon Sep 17 00:00:00 2001 From: Adrian Brink Date: Tue, 30 May 2023 10:02:06 +0200 Subject: [PATCH 03/14] Fix clippy warnings --- apps/src/lib/client/utils.rs | 2 +- apps/src/lib/config/mod.rs | 7 +++++-- apps/src/lib/config/utils.rs | 6 +++--- apps/src/lib/node/ledger/tendermint_node.rs | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index 1ae17882a9..a5dc7568d4 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::env; use std::fs::{self, File, OpenOptions}; use std::io::Write; -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +use std::net::{SocketAddr}; use std::path::{Path, PathBuf}; use std::str::FromStr; diff --git a/apps/src/lib/config/mod.rs b/apps/src/lib/config/mod.rs index c43f5ab141..0c97c630b5 100644 --- a/apps/src/lib/config/mod.rs +++ b/apps/src/lib/config/mod.rs @@ -6,7 +6,7 @@ pub mod utils; use std::fs::{create_dir_all, File}; use std::io::Write; -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + use std::path::{Path, PathBuf}; use directories::ProjectDirs; @@ -343,7 +343,10 @@ pub fn get_default_namada_folder() -> PathBuf { } mod tests { - use super::*; + + #![allow(unused_imports)] + use crate::facade::tendermint_config::TendermintConfig; + use super::DEFAULT_COMETBFT_CONFIG; #[test] fn test_default_cometbft_config() { diff --git a/apps/src/lib/config/utils.rs b/apps/src/lib/config/utils.rs index fe46741122..16ce4751c6 100644 --- a/apps/src/lib/config/utils.rs +++ b/apps/src/lib/config/utils.rs @@ -51,10 +51,10 @@ fn num_of_threads_aux( pub fn convert_tm_addr_to_socket_addr(tm_addr: &TendermintAddress) -> SocketAddr { let tm_addr = tm_addr.clone(); match tm_addr { - TendermintAddress::Tcp { peer_id, host, port } => { - return (host, port).to_socket_addrs().unwrap().next().unwrap(); + TendermintAddress::Tcp { peer_id: _, host, port } => { + (host, port).to_socket_addrs().unwrap().next().unwrap() }, - TendermintAddress::Unix { path } => { + TendermintAddress::Unix { path: _ } => { panic!("Unix addresses aren't currently supported.") } } diff --git a/apps/src/lib/node/ledger/tendermint_node.rs b/apps/src/lib/node/ledger/tendermint_node.rs index 155b2933e3..6f88a3c20d 100644 --- a/apps/src/lib/node/ledger/tendermint_node.rs +++ b/apps/src/lib/node/ledger/tendermint_node.rs @@ -1,5 +1,5 @@ use std::env; -use std::net::SocketAddr; + use std::path::{Path, PathBuf}; use std::process::Stdio; use std::str::FromStr; @@ -22,9 +22,9 @@ use tokio::process::Command; use crate::cli::namada_version; use crate::config; use crate::facade::tendermint::{block, Genesis}; -use crate::facade::tendermint_config::net::Address as TendermintAddress; + use crate::facade::tendermint_config::{ - Error as TendermintError, TendermintConfig, TxIndexConfig, TxIndexer, + Error as TendermintError, TendermintConfig, }; /// Env. var to output Tendermint log to stdout From c4a10cddd4c4c59a00514c5a6cffef9fe7454d24 Mon Sep 17 00:00:00 2001 From: Adrian Brink Date: Tue, 30 May 2023 10:26:21 +0200 Subject: [PATCH 04/14] Fix IBC tests --- tests/src/e2e/helpers.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/src/e2e/helpers.rs b/tests/src/e2e/helpers.rs index 321f1ab975..5845564494 100644 --- a/tests/src/e2e/helpers.rs +++ b/tests/src/e2e/helpers.rs @@ -15,6 +15,7 @@ use namada::types::key::*; use namada::types::storage::Epoch; use namada::types::token; use namada_apps::config::genesis::genesis_config; +use namada_apps::config::utils::convert_tm_addr_to_socket_addr; use namada_apps::config::{Config, TendermintMode}; use super::setup::{ @@ -99,7 +100,9 @@ pub fn get_actor_rpc(test: &Test, who: &Who) -> String { }; let config = Config::load(base_dir, &test.net.chain_id, Some(tendermint_mode)); - config.ledger.cometbft.rpc.laddr.to_string() + let ip = convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr).ip().to_string(); + let port = convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr).port().to_string(); + format!("{}:{}", ip, port) } /// Get the public key of the validator From 4c4b769fad26ad272e96f4489d4fe5021b3a222c Mon Sep 17 00:00:00 2001 From: Adrian Brink Date: Tue, 30 May 2023 10:46:04 +0200 Subject: [PATCH 05/14] Fix format errors --- apps/src/bin/namada-node/cli.rs | 9 +-- apps/src/lib/client/utils.rs | 70 ++++++++++++--------- apps/src/lib/config/mod.rs | 14 +++-- apps/src/lib/config/utils.rs | 17 +++-- apps/src/lib/node/ledger/mod.rs | 54 ++++++++-------- apps/src/lib/node/ledger/tendermint_node.rs | 10 ++- tests/src/e2e/helpers.rs | 10 ++- tests/src/e2e/ledger_tests.rs | 60 ++++++++++++++---- 8 files changed, 152 insertions(+), 92 deletions(-) diff --git a/apps/src/bin/namada-node/cli.rs b/apps/src/bin/namada-node/cli.rs index 5dfa976362..536c36a89a 100644 --- a/apps/src/bin/namada-node/cli.rs +++ b/apps/src/bin/namada-node/cli.rs @@ -7,7 +7,8 @@ use namada_apps::node::ledger; pub fn main() -> Result<()> { let (cmd, mut ctx) = cli::namada_node_cli()?; - // fixme: not sure why this is set here, since it's settable in the config file + // fixme: not sure why this is set here, since it's settable in the config + // file if let Some(mode) = ctx.global_args.mode.clone() { ctx.config.ledger.shell.tendermint_mode = mode; } @@ -16,9 +17,9 @@ pub fn main() -> Result<()> { cmds::Ledger::Run(cmds::LedgerRun(args)) => { let wasm_dir = ctx.wasm_dir(); sleep_until(args.start_time); - - // fixme: not sure why this is set here, since it's settable in the config file - // ctx.config.ledger.tendermint.tx_index = args.tx_index; + // fixme: not sure why this is set here, since it's settable in + // the config file ctx.config.ledger.tendermint. + // tx_index = args.tx_index; ledger::run(ctx.config.ledger, wasm_dir); } cmds::Ledger::RunUntil(cmds::LedgerRunUntil(args)) => { diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index a5dc7568d4..18d78a41d7 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::env; use std::fs::{self, File, OpenOptions}; use std::io::Write; -use std::net::{SocketAddr}; +use std::net::SocketAddr; use std::path::{Path, PathBuf}; use std::str::FromStr; @@ -324,12 +324,12 @@ pub async fn join_network( tokio::task::spawn_blocking(move || { let mut config = Config::load(&base_dir, &chain_id, None); - config.ledger.shell.tendermint_mode = - TendermintMode::Validator; + config.ledger.shell.tendermint_mode = TendermintMode::Validator; // Validator node should turned off peer exchange reactor - // fixme: we shouldn't be setting config values that are settable in the actual config.toml - // config.ledger.tendermint_config.p2p.pex = false; - // Remove self from persistent peers + // fixme: we shouldn't be setting config values that are settable in + // the actual config.toml config.ledger. + // tendermint_config.p2p.pex = false; Remove self from + // persistent peers config .ledger .cometbft @@ -757,42 +757,55 @@ pub fn init_network( None }) .collect(); - // fixme: We shouldn't be hardcoding these. The timeouts should only be set in the config files. + // fixme: We shouldn't be hardcoding these. The timeouts should only + // be set in the config files. config.ledger.cometbft.consensus.timeout_commit = consensus_timeout_commit; - // fixme: We shouldn't be hardcoding these. The timeouts should only be set in the config files. + // fixme: We shouldn't be hardcoding these. The timeouts should only + // be set in the config files. config.ledger.cometbft.p2p.allow_duplicate_ip = allow_duplicate_ip; - // fixme: We shouldn't be hardcoding these. The timeouts should only be set in the config files. + // fixme: We shouldn't be hardcoding these. The timeouts should only + // be set in the config files. config.ledger.cometbft.p2p.addr_book_strict = !localhost; // Clear the net address from the config and use it to set ports let net_address = validator_config.net_address.take().unwrap(); let ip = SocketAddr::from_str(&net_address).unwrap().ip(); let first_port = SocketAddr::from_str(&net_address).unwrap().port(); if !localhost { - config - .ledger - .cometbft - .p2p - .laddr = TendermintAddress::from_str(&format!("0.0.0.0:{}", first_port)).unwrap(); - // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); + config.ledger.cometbft.p2p.laddr = + TendermintAddress::from_str(&format!( + "0.0.0.0:{}", + first_port + )) + .unwrap(); + // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } - config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(&format!("{}:{}", ip, first_port)).unwrap(); + config.ledger.cometbft.p2p.laddr = + TendermintAddress::from_str(&format!("{}:{}", ip, first_port)) + .unwrap(); if !localhost { - config - .ledger - .cometbft - .rpc - .laddr = TendermintAddress::from_str(&format!("0.0.0.0:{}", first_port+1)).unwrap(); - // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); + config.ledger.cometbft.rpc.laddr = + TendermintAddress::from_str(&format!( + "0.0.0.0:{}", + first_port + 1 + )) + .unwrap(); + // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } - config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str(&format!("{}:{}", ip, first_port+1)).unwrap(); + config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( + &format!("{}:{}", ip, first_port + 1), + ) + .unwrap(); // config // .ledger // .tendermint // .rpc_address // .set_port(first_port + 1); - config.ledger.cometbft.proxy_app = TendermintAddress::from_str(&format!("{}:{}", ip, first_port+2)).unwrap(); + config.ledger.cometbft.proxy_app = TendermintAddress::from_str( + &format!("{}:{}", ip, first_port + 2), + ) + .unwrap(); // Validator node should turned off peer exchange reactor // fixme: no hardcoding config values config.ledger.cometbft.p2p.pex = false; @@ -809,12 +822,9 @@ pub fn init_network( config.ledger.cometbft.p2p.allow_duplicate_ip = allow_duplicate_ip; // Open P2P address if !localhost { - config - .ledger - .cometbft - .p2p - .laddr = TendermintAddress::from_str("0.0.0.0").unwrap(); - // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); + config.ledger.cometbft.p2p.laddr = + TendermintAddress::from_str("0.0.0.0").unwrap(); + // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } config.ledger.cometbft.p2p.addr_book_strict = !localhost; config.ledger.genesis_time = genesis.genesis_time.into(); diff --git a/apps/src/lib/config/mod.rs b/apps/src/lib/config/mod.rs index 0c97c630b5..63584df76b 100644 --- a/apps/src/lib/config/mod.rs +++ b/apps/src/lib/config/mod.rs @@ -6,7 +6,6 @@ pub mod utils; use std::fs::{create_dir_all, File}; use std::io::Write; - use std::path::{Path, PathBuf}; use directories::ProjectDirs; @@ -17,7 +16,9 @@ use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::cli; -use crate::facade::tendermint_config::{TendermintConfig, TxIndexer, TxIndexConfig}; +use crate::facade::tendermint_config::{ + TendermintConfig, TxIndexConfig, TxIndexer, +}; /// Base directory contains global config and chain directories. pub const DEFAULT_BASE_DIR: &str = ".namada"; @@ -128,9 +129,12 @@ impl Ledger { chain_id: ChainId, mode: TendermintMode, ) -> Self { - let mut tendermint_config = TendermintConfig::parse_toml(DEFAULT_COMETBFT_CONFIG).unwrap(); + let mut tendermint_config = + TendermintConfig::parse_toml(DEFAULT_COMETBFT_CONFIG).unwrap(); tendermint_config.instrumentation.namespace = "namada_tm".to_string(); - tendermint_config.tx_index = TxIndexConfig{indexer: TxIndexer::Null}; + tendermint_config.tx_index = TxIndexConfig { + indexer: TxIndexer::Null, + }; Self { genesis_time: Rfc3339String("1970-01-01T00:00:00Z".to_owned()), chain_id, @@ -345,8 +349,8 @@ pub fn get_default_namada_folder() -> PathBuf { mod tests { #![allow(unused_imports)] - use crate::facade::tendermint_config::TendermintConfig; use super::DEFAULT_COMETBFT_CONFIG; + use crate::facade::tendermint_config::TendermintConfig; #[test] fn test_default_cometbft_config() { diff --git a/apps/src/lib/config/utils.rs b/apps/src/lib/config/utils.rs index 16ce4751c6..ca038dcb42 100644 --- a/apps/src/lib/config/utils.rs +++ b/apps/src/lib/config/utils.rs @@ -1,12 +1,12 @@ //! Configuration utilities +use std::net::{SocketAddr, ToSocketAddrs}; use std::str::FromStr; use std::{cmp, env}; use itertools::Either; use crate::cli; -use std::net::{SocketAddr, ToSocketAddrs}; use crate::facade::tendermint_config::net::Address as TendermintAddress; /// Find how many threads to use from an environment variable if it's set and @@ -47,13 +47,18 @@ fn num_of_threads_aux( } } -// fixme: Handle this gracefully with either an Option or a Result. Ensure that hostname resolution works. -pub fn convert_tm_addr_to_socket_addr(tm_addr: &TendermintAddress) -> SocketAddr { +// fixme: Handle this gracefully with either an Option or a Result. Ensure that +// hostname resolution works. +pub fn convert_tm_addr_to_socket_addr( + tm_addr: &TendermintAddress, +) -> SocketAddr { let tm_addr = tm_addr.clone(); match tm_addr { - TendermintAddress::Tcp { peer_id: _, host, port } => { - (host, port).to_socket_addrs().unwrap().next().unwrap() - }, + TendermintAddress::Tcp { + peer_id: _, + host, + port, + } => (host, port).to_socket_addrs().unwrap().next().unwrap(), TendermintAddress::Unix { path: _ } => { panic!("Unix addresses aren't currently supported.") } diff --git a/apps/src/lib/node/ledger/mod.rs b/apps/src/lib/node/ledger/mod.rs index 8f5317ad22..12f7c31284 100644 --- a/apps/src/lib/node/ledger/mod.rs +++ b/apps/src/lib/node/ledger/mod.rs @@ -23,7 +23,7 @@ use tower::ServiceBuilder; use self::abortable::AbortableSpawner; use self::shims::abcipp_shim::AbciService; use crate::cli::args; -use crate::config::utils::{num_of_threads, convert_tm_addr_to_socket_addr}; +use crate::config::utils::{convert_tm_addr_to_socket_addr, num_of_threads}; use crate::config::TendermintMode; use crate::facade::tendermint_proto::abci::CheckTxType; use crate::facade::tower_abci::{response, split, Server}; @@ -408,7 +408,8 @@ fn start_abci_broadcaster_shell( task::JoinHandle<()>, thread::JoinHandle<()>, ) { - let rpc_address = convert_tm_addr_to_socket_addr(&config.cometbft.rpc.laddr); + let rpc_address = + convert_tm_addr_to_socket_addr(&config.cometbft.rpc.laddr); let RunAuxSetup { vp_wasm_compilation_cache, tx_wasm_compilation_cache, @@ -421,30 +422,28 @@ fn start_abci_broadcaster_shell( tokio::sync::mpsc::unbounded_channel(); // Start broadcaster - let broadcaster = if matches!( - config.shell.tendermint_mode, - TendermintMode::Validator - ) { - let (bc_abort_send, bc_abort_recv) = - tokio::sync::oneshot::channel::<()>(); - - spawner - .spawn_abortable("Broadcaster", move |aborter| async move { - // Construct a service for broadcasting protocol txs from the - // ledger - let mut broadcaster = - Broadcaster::new(rpc_address, broadcaster_receiver); - broadcaster.run(bc_abort_recv).await; - tracing::info!("Broadcaster is no longer running."); - - drop(aborter); - }) - .with_cleanup(async move { - let _ = bc_abort_send.send(()); - }) - } else { - spawn_dummy_task(()) - }; + let broadcaster = + if matches!(config.shell.tendermint_mode, TendermintMode::Validator) { + let (bc_abort_send, bc_abort_recv) = + tokio::sync::oneshot::channel::<()>(); + + spawner + .spawn_abortable("Broadcaster", move |aborter| async move { + // Construct a service for broadcasting protocol txs from + // the ledger + let mut broadcaster = + Broadcaster::new(rpc_address, broadcaster_receiver); + broadcaster.run(bc_abort_recv).await; + tracing::info!("Broadcaster is no longer running."); + + drop(aborter); + }) + .with_cleanup(async move { + let _ = bc_abort_send.send(()); + }) + } else { + spawn_dummy_task(()) + }; // Setup DB cache, it must outlive the DB instance that's in the shell let db_cache = @@ -452,7 +451,8 @@ fn start_abci_broadcaster_shell( // Construct our ABCI application. let tendermint_mode = config.shell.tendermint_mode.clone(); - let proxy_app_address = convert_tm_addr_to_socket_addr(&config.cometbft.proxy_app); + let proxy_app_address = + convert_tm_addr_to_socket_addr(&config.cometbft.proxy_app); #[cfg(not(feature = "dev"))] let genesis = genesis::genesis(&config.shell.base_dir, &config.chain_id); #[cfg(feature = "dev")] diff --git a/apps/src/lib/node/ledger/tendermint_node.rs b/apps/src/lib/node/ledger/tendermint_node.rs index 6f88a3c20d..213a6d3ecf 100644 --- a/apps/src/lib/node/ledger/tendermint_node.rs +++ b/apps/src/lib/node/ledger/tendermint_node.rs @@ -1,5 +1,4 @@ use std::env; - use std::path::{Path, PathBuf}; use std::process::Stdio; use std::str::FromStr; @@ -22,7 +21,6 @@ use tokio::process::Command; use crate::cli::namada_version; use crate::config; use crate::facade::tendermint::{block, Genesis}; - use crate::facade::tendermint_config::{ Error as TendermintError, TendermintConfig, }; @@ -362,8 +360,8 @@ async fn update_tendermint_config( .expect("Invalid moniker"); // config.p2p.laddr = - // TendermintAddress::from_str(&tendermint_config.p2p_address.to_string()) - // .unwrap(); + // TendermintAddress::from_str(&tendermint_config.p2p_address. + // to_string()) .unwrap(); // config.p2p.persistent_peers = tendermint_config.p2p_persistent_peers; // config.p2p.pex = tendermint_config.p2p_pex; // config.p2p.allow_duplicate_ip = tendermint_config.p2p_allow_duplicate_ip; @@ -378,8 +376,8 @@ async fn update_tendermint_config( config.mempool.keep_invalid_txs_in_cache = false; // config.rpc.laddr = - // TendermintAddress::from_str(&tendermint_config.rpc_address.to_string()) - // .unwrap(); + // TendermintAddress::from_str(&tendermint_config.rpc_address. + // to_string()) .unwrap(); // Bumped from the default `1_000_000`, because some WASMs can be // quite large config.rpc.max_body_bytes = 2_000_000; diff --git a/tests/src/e2e/helpers.rs b/tests/src/e2e/helpers.rs index 5845564494..f40e5c33d0 100644 --- a/tests/src/e2e/helpers.rs +++ b/tests/src/e2e/helpers.rs @@ -100,8 +100,14 @@ pub fn get_actor_rpc(test: &Test, who: &Who) -> String { }; let config = Config::load(base_dir, &test.net.chain_id, Some(tendermint_mode)); - let ip = convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr).ip().to_string(); - let port = convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr).port().to_string(); + let ip = + convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr) + .ip() + .to_string(); + let port = + convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr) + .port() + .to_string(); format!("{}:{}", ip, port) } diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index 8ef80e665e..04193033f7 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -3961,14 +3961,32 @@ fn test_genesis_validators() -> Result<()> { // `join-network` use the defaults let update_config = |ix: u8, mut config: Config| { let first_port = net_address_port_0 + 6 * (ix as u16 + 1); - let p2p_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.p2p.laddr).ip().to_string(); + let p2p_addr = + convert_tm_addr_to_socket_addr(&config.ledger.cometbft.p2p.laddr) + .ip() + .to_string(); println!("ERROR: {}", p2p_addr); println!("ERROR: {}", first_port); - config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(&format!("{}:{}", p2p_addr, first_port)).unwrap(); - let rpc_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.rpc.laddr).ip().to_string(); - config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str(&format!("{}:{}", rpc_addr, first_port+1)).unwrap(); - let proxy_app_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.proxy_app).ip().to_string(); - config.ledger.cometbft.proxy_app = TendermintAddress::from_str(&format!("{}:{}", proxy_app_addr, first_port+2)).unwrap(); + config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str( + &format!("{}:{}", p2p_addr, first_port), + ) + .unwrap(); + let rpc_addr = + convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr) + .ip() + .to_string(); + config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( + &format!("{}:{}", rpc_addr, first_port + 1), + ) + .unwrap(); + let proxy_app_addr = + convert_tm_addr_to_socket_addr(&config.ledger.cometbft.proxy_app) + .ip() + .to_string(); + config.ledger.cometbft.proxy_app = TendermintAddress::from_str( + &format!("{}:{}", proxy_app_addr, first_port + 2), + ) + .unwrap(); config }; @@ -4151,14 +4169,32 @@ fn double_signing_gets_slashed() -> Result<()> { let update_config = |ix: u8, mut config: Config| { let first_port = net_address_port_0 + 6 * (ix as u16 + 1); - let p2p_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.p2p.laddr).ip().to_string(); + let p2p_addr = + convert_tm_addr_to_socket_addr(&config.ledger.tendermint.p2p.laddr) + .ip() + .to_string(); println!("ERROR: {}", p2p_addr); println!("ERROR: {}", first_port); - config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(&format!("{}:{}", p2p_addr, first_port)).unwrap(); - let rpc_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.rpc.laddr).ip().to_string(); - config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str(&format!("{}:{}", rpc_addr, first_port+1)).unwrap(); - let proxy_app_addr = convert_tm_addr_to_socket_addr(&config.ledger.tendermint.proxy_app).ip().to_string(); - config.ledger.cometbft.proxy_app = TendermintAddress::from_str(&format!("{}:{}", proxy_app_addr, first_port+2)).unwrap(); + config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str( + &format!("{}:{}", p2p_addr, first_port), + ) + .unwrap(); + let rpc_addr = + convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr) + .ip() + .to_string(); + config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( + &format!("{}:{}", rpc_addr, first_port + 1), + ) + .unwrap(); + let proxy_app_addr = + convert_tm_addr_to_socket_addr(&config.ledger.cometbft.proxy_app) + .ip() + .to_string(); + config.ledger.cometbft.proxy_app = TendermintAddress::from_str( + &format!("{}:{}", proxy_app_addr, first_port + 2), + ) + .unwrap(); config }; From c1d3080b1bc990e83f0b8ab6851d90ee1f1cad31 Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Thu, 15 Jun 2023 10:00:37 +0200 Subject: [PATCH 06/14] fix: tendermint address needs port --- apps/src/lib/client/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index 18d78a41d7..2caa1aabce 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -823,7 +823,7 @@ pub fn init_network( // Open P2P address if !localhost { config.ledger.cometbft.p2p.laddr = - TendermintAddress::from_str("0.0.0.0").unwrap(); + TendermintAddress::from_str("0.0.0.0:26656").unwrap(); // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } config.ledger.cometbft.p2p.addr_book_strict = !localhost; From 16b72026c84728b465bb9de880d883a47df86d7b Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Thu, 15 Jun 2023 10:32:04 +0200 Subject: [PATCH 07/14] fix: compilation errors --- tests/src/e2e/ledger_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index 04193033f7..2cb2c4b5bd 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -4170,7 +4170,7 @@ fn double_signing_gets_slashed() -> Result<()> { let update_config = |ix: u8, mut config: Config| { let first_port = net_address_port_0 + 6 * (ix as u16 + 1); let p2p_addr = - convert_tm_addr_to_socket_addr(&config.ledger.tendermint.p2p.laddr) + convert_tm_addr_to_socket_addr(&config.ledger.cometbft.p2p.laddr) .ip() .to_string(); println!("ERROR: {}", p2p_addr); From d32e75fb0251f15a71f3fadb34cb2a33e3f2a734 Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Thu, 15 Jun 2023 11:04:28 +0200 Subject: [PATCH 08/14] format --- apps/src/lib/client/tx.rs | 3 +- apps/src/lib/client/utils.rs | 53 ++++++++++++++---------------------- tests/src/e2e/helpers.rs | 7 ++--- 3 files changed, 25 insertions(+), 38 deletions(-) diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index 3731453fb5..dc59e56f7e 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -298,8 +298,7 @@ pub async fn submit_init_validator< // Write Namada config stuff or figure out how to do the above // tendermint_node things two epochs in the future!!! - ctx.config.ledger.shell.tendermint_mode = - TendermintMode::Validator; + ctx.config.ledger.shell.tendermint_mode = TendermintMode::Validator; ctx.config .write( &ctx.config.ledger.shell.base_dir, diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index 2caa1aabce..f14d1dc259 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -330,22 +330,17 @@ pub async fn join_network( // the actual config.toml config.ledger. // tendermint_config.p2p.pex = false; Remove self from // persistent peers - config - .ledger - .cometbft - .p2p - .persistent_peers - .retain(|peer| { - if let TendermintAddress::Tcp { - peer_id: Some(peer_id), - .. - } = peer - { - node_id != *peer_id - } else { - true - } - }); + config.ledger.cometbft.p2p.persistent_peers.retain(|peer| { + if let TendermintAddress::Tcp { + peer_id: Some(peer_id), + .. + } = peer + { + node_id != *peer_id + } else { + true + } + }); config.write(&base_dir, &chain_id, true).unwrap(); }) .await @@ -763,8 +758,7 @@ pub fn init_network( consensus_timeout_commit; // fixme: We shouldn't be hardcoding these. The timeouts should only // be set in the config files. - config.ledger.cometbft.p2p.allow_duplicate_ip = - allow_duplicate_ip; + config.ledger.cometbft.p2p.allow_duplicate_ip = allow_duplicate_ip; // fixme: We shouldn't be hardcoding these. The timeouts should only // be set in the config files. config.ledger.cometbft.p2p.addr_book_strict = !localhost; @@ -773,24 +767,20 @@ pub fn init_network( let ip = SocketAddr::from_str(&net_address).unwrap().ip(); let first_port = SocketAddr::from_str(&net_address).unwrap().port(); if !localhost { - config.ledger.cometbft.p2p.laddr = - TendermintAddress::from_str(&format!( - "0.0.0.0:{}", - first_port - )) - .unwrap(); + config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str( + &format!("0.0.0.0:{}", first_port), + ) + .unwrap(); // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(&format!("{}:{}", ip, first_port)) .unwrap(); if !localhost { - config.ledger.cometbft.rpc.laddr = - TendermintAddress::from_str(&format!( - "0.0.0.0:{}", - first_port + 1 - )) - .unwrap(); + config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( + &format!("0.0.0.0:{}", first_port + 1), + ) + .unwrap(); // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( @@ -817,8 +807,7 @@ pub fn init_network( // Update the ledger config persistent peers and save it let mut config = Config::load(&global_args.base_dir, &chain_id, None); config.ledger.cometbft.p2p.persistent_peers = persistent_peers; - config.ledger.cometbft.consensus.timeout_commit = - consensus_timeout_commit; + config.ledger.cometbft.consensus.timeout_commit = consensus_timeout_commit; config.ledger.cometbft.p2p.allow_duplicate_ip = allow_duplicate_ip; // Open P2P address if !localhost { diff --git a/tests/src/e2e/helpers.rs b/tests/src/e2e/helpers.rs index f40e5c33d0..60dc119051 100644 --- a/tests/src/e2e/helpers.rs +++ b/tests/src/e2e/helpers.rs @@ -100,10 +100,9 @@ pub fn get_actor_rpc(test: &Test, who: &Who) -> String { }; let config = Config::load(base_dir, &test.net.chain_id, Some(tendermint_mode)); - let ip = - convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr) - .ip() - .to_string(); + let ip = convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr) + .ip() + .to_string(); let port = convert_tm_addr_to_socket_addr(&config.ledger.cometbft.rpc.laddr) .port() From 037227b37ef5a89cd307f34fcbdb69f9d81af8e9 Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Fri, 16 Jun 2023 09:49:15 +0200 Subject: [PATCH 09/14] fix: address review comments --- apps/src/bin/namada-node/cli.rs | 9 +--- apps/src/lib/client/utils.rs | 27 ++---------- apps/src/lib/config/mod.rs | 27 +++++------- apps/src/lib/node/ledger/tendermint_node.rs | 47 --------------------- tests/src/e2e/ledger_tests.rs | 6 +-- 5 files changed, 18 insertions(+), 98 deletions(-) diff --git a/apps/src/bin/namada-node/cli.rs b/apps/src/bin/namada-node/cli.rs index 536c36a89a..5194921de8 100644 --- a/apps/src/bin/namada-node/cli.rs +++ b/apps/src/bin/namada-node/cli.rs @@ -7,19 +7,12 @@ use namada_apps::node::ledger; pub fn main() -> Result<()> { let (cmd, mut ctx) = cli::namada_node_cli()?; - // fixme: not sure why this is set here, since it's settable in the config - // file - if let Some(mode) = ctx.global_args.mode.clone() { - ctx.config.ledger.shell.tendermint_mode = mode; - } + match cmd { cmds::NamadaNode::Ledger(sub) => match sub { cmds::Ledger::Run(cmds::LedgerRun(args)) => { let wasm_dir = ctx.wasm_dir(); sleep_until(args.start_time); - // fixme: not sure why this is set here, since it's settable in - // the config file ctx.config.ledger.tendermint. - // tx_index = args.tx_index; ledger::run(ctx.config.ledger, wasm_dir); } cmds::Ledger::RunUntil(cmds::LedgerRunUntil(args)) => { diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index f14d1dc259..f676e470bb 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -323,13 +323,9 @@ pub async fn join_network( let chain_id = chain_id.clone(); tokio::task::spawn_blocking(move || { let mut config = Config::load(&base_dir, &chain_id, None); - config.ledger.shell.tendermint_mode = TendermintMode::Validator; - // Validator node should turned off peer exchange reactor - // fixme: we shouldn't be setting config values that are settable in - // the actual config.toml config.ledger. - // tendermint_config.p2p.pex = false; Remove self from - // persistent peers + + // Remove self from persistent peers config.ledger.cometbft.p2p.persistent_peers.retain(|peer| { if let TendermintAddress::Tcp { peer_id: Some(peer_id), @@ -752,15 +748,10 @@ pub fn init_network( None }) .collect(); - // fixme: We shouldn't be hardcoding these. The timeouts should only - // be set in the config files. + config.ledger.cometbft.consensus.timeout_commit = consensus_timeout_commit; - // fixme: We shouldn't be hardcoding these. The timeouts should only - // be set in the config files. config.ledger.cometbft.p2p.allow_duplicate_ip = allow_duplicate_ip; - // fixme: We shouldn't be hardcoding these. The timeouts should only - // be set in the config files. config.ledger.cometbft.p2p.addr_book_strict = !localhost; // Clear the net address from the config and use it to set ports let net_address = validator_config.net_address.take().unwrap(); @@ -771,7 +762,6 @@ pub fn init_network( &format!("0.0.0.0:{}", first_port), ) .unwrap(); - // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(&format!("{}:{}", ip, first_port)) @@ -781,24 +771,16 @@ pub fn init_network( &format!("0.0.0.0:{}", first_port + 1), ) .unwrap(); - // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( &format!("{}:{}", ip, first_port + 1), ) .unwrap(); - // config - // .ledger - // .tendermint - // .rpc_address - // .set_port(first_port + 1); + config.ledger.cometbft.proxy_app = TendermintAddress::from_str( &format!("{}:{}", ip, first_port + 2), ) .unwrap(); - // Validator node should turned off peer exchange reactor - // fixme: no hardcoding config values - config.ledger.cometbft.p2p.pex = false; config.write(&validator_dir, &chain_id, true).unwrap(); }, @@ -813,7 +795,6 @@ pub fn init_network( if !localhost { config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str("0.0.0.0:26656").unwrap(); - // .set_ip(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); } config.ledger.cometbft.p2p.addr_book_strict = !localhost; config.ledger.genesis_time = genesis.genesis_time.into(); diff --git a/apps/src/lib/config/mod.rs b/apps/src/lib/config/mod.rs index 63584df76b..4a6be155aa 100644 --- a/apps/src/lib/config/mod.rs +++ b/apps/src/lib/config/mod.rs @@ -140,10 +140,6 @@ impl Ledger { chain_id, shell: Shell { base_dir: base_dir.as_ref().to_owned(), - // ledger_address: SocketAddr::new( - // IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), - // 26658, - // ), block_cache_bytes: None, vp_wasm_compilation_cache_bytes: None, tx_wasm_compilation_cache_bytes: None, @@ -346,18 +342,6 @@ pub fn get_default_namada_folder() -> PathBuf { } } -mod tests { - - #![allow(unused_imports)] - use super::DEFAULT_COMETBFT_CONFIG; - use crate::facade::tendermint_config::TendermintConfig; - - #[test] - fn test_default_cometbft_config() { - assert!(TendermintConfig::parse_toml(DEFAULT_COMETBFT_CONFIG).is_ok()); - } -} - pub const VALUE_AFTER_TABLE_ERROR_MSG: &str = r#" Error while serializing to toml. It means that some nested structure is followed by simple fields. @@ -856,3 +840,14 @@ max_open_connections = 3 namespace = "cometbft" "#; + +#[cfg(test)] +mod tests { + use super::DEFAULT_COMETBFT_CONFIG; + use crate::facade::tendermint_config::TendermintConfig; + + #[test] + fn test_default_cometbft_config() { + assert!(TendermintConfig::parse_toml(DEFAULT_COMETBFT_CONFIG).is_ok()); + } +} diff --git a/apps/src/lib/node/ledger/tendermint_node.rs b/apps/src/lib/node/ledger/tendermint_node.rs index 213a6d3ecf..f5583e7010 100644 --- a/apps/src/lib/node/ledger/tendermint_node.rs +++ b/apps/src/lib/node/ledger/tendermint_node.rs @@ -352,20 +352,11 @@ async fn update_tendermint_config( let home_dir = home_dir.as_ref(); let path = home_dir.join("config").join("config.toml"); let mut config = config.clone(); - // let mut config = - // TendermintConfig::load_toml_file(&path).map_err(Error::LoadConfig)?; config.moniker = Moniker::from_str(&format!("{}-{}", config.moniker, namada_version())) .expect("Invalid moniker"); - // config.p2p.laddr = - // TendermintAddress::from_str(&tendermint_config.p2p_address. - // to_string()) .unwrap(); - // config.p2p.persistent_peers = tendermint_config.p2p_persistent_peers; - // config.p2p.pex = tendermint_config.p2p_pex; - // config.p2p.allow_duplicate_ip = tendermint_config.p2p_allow_duplicate_ip; - // In "dev", only produce blocks when there are txs or when the AppHash // changes config.consensus.create_empty_blocks = true; // !cfg!(feature = "dev"); @@ -375,48 +366,10 @@ async fn update_tendermint_config( // again in the future. config.mempool.keep_invalid_txs_in_cache = false; - // config.rpc.laddr = - // TendermintAddress::from_str(&tendermint_config.rpc_address. - // to_string()) .unwrap(); // Bumped from the default `1_000_000`, because some WASMs can be // quite large config.rpc.max_body_bytes = 2_000_000; - // config.instrumentation.prometheus = - // tendermint_config.instrumentation_prometheus; - // config.instrumentation.prometheus_listen_addr = tendermint_config - // .instrumentation_prometheus_listen_addr - // .to_string(); - // config.instrumentation.namespace = - // tendermint_config.instrumentation_namespace; - - // #[cfg(feature = "abciplus")] - // { - // config.consensus.timeout_propose = - // tendermint_config.consensus_timeout_propose; - // config.consensus.timeout_propose_delta = - // tendermint_config.consensus_timeout_propose_delta; - // config.consensus.timeout_prevote = - // tendermint_config.consensus_timeout_prevote; - // config.consensus.timeout_prevote_delta = - // tendermint_config.consensus_timeout_prevote_delta; - // config.consensus.timeout_precommit = - // tendermint_config.consensus_timeout_precommit; - // config.consensus.timeout_precommit_delta = - // tendermint_config.consensus_timeout_precommit_delta; - // config.consensus.timeout_commit = - // tendermint_config.consensus_timeout_commit; - // } - - // let indexer = if tendermint_config.tx_index { - // TxIndexer::Kv - // } else { - // TxIndexer::Null - // }; - // #[cfg(feature = "abcipp")] - // let indexer = [indexer]; - // config.tx_index = TxIndexConfig { indexer }; - let mut file = OpenOptions::new() .write(true) .truncate(true) diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index 2cb2c4b5bd..44f69514b1 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -3965,8 +3965,7 @@ fn test_genesis_validators() -> Result<()> { convert_tm_addr_to_socket_addr(&config.ledger.cometbft.p2p.laddr) .ip() .to_string(); - println!("ERROR: {}", p2p_addr); - println!("ERROR: {}", first_port); + config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str( &format!("{}:{}", p2p_addr, first_port), ) @@ -4173,8 +4172,7 @@ fn double_signing_gets_slashed() -> Result<()> { convert_tm_addr_to_socket_addr(&config.ledger.cometbft.p2p.laddr) .ip() .to_string(); - println!("ERROR: {}", p2p_addr); - println!("ERROR: {}", first_port); + config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str( &format!("{}:{}", p2p_addr, first_port), ) From f11b12a4bc8575d205d6d84195723545c01c991b Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Thu, 15 Jun 2023 10:12:30 +0200 Subject: [PATCH 10/14] added changelog --- .changelog/unreleased/features/1570-tendermint-config.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/features/1570-tendermint-config.md diff --git a/.changelog/unreleased/features/1570-tendermint-config.md b/.changelog/unreleased/features/1570-tendermint-config.md new file mode 100644 index 0000000000..888fda8928 --- /dev/null +++ b/.changelog/unreleased/features/1570-tendermint-config.md @@ -0,0 +1,2 @@ +- Enable users to change any tendermint config options via namada config. + ([#1570](https://github.com/anoma/namada/pull/1570)) \ No newline at end of file From 4ccb9cfed85a4408006bf5054502182944041f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 16 Jun 2023 12:55:02 +0200 Subject: [PATCH 11/14] cli/node: remove unused tx-index argument --- apps/src/lib/cli.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/apps/src/lib/cli.rs b/apps/src/lib/cli.rs index 352a7a603a..75c86924a9 100644 --- a/apps/src/lib/cli.rs +++ b/apps/src/lib/cli.rs @@ -843,7 +843,6 @@ pub mod cmds { // The `run` command is the default if no sub-command given .or(Some(Self::Run(LedgerRun(args::LedgerRun { start_time: None, - tx_index: false, })))) }) } @@ -1901,7 +1900,6 @@ pub mod args { pub const STORAGE_KEY: Arg = arg("storage-key"); pub const SUB_PREFIX: ArgOpt = arg_opt("sub-prefix"); pub const SUSPEND_ACTION: ArgFlag = flag("suspend"); - pub const TENDERMINT_TX_INDEX: ArgFlag = flag("tx-index"); pub const TIMEOUT_HEIGHT: ArgOpt = arg_opt("timeout-height"); pub const TIMEOUT_SEC_OFFSET: ArgOpt = arg_opt("timeout-sec-offset"); pub const TM_ADDRESS: Arg = arg("tm-address"); @@ -1980,17 +1978,12 @@ pub mod args { #[derive(Clone, Debug)] pub struct LedgerRun { pub start_time: Option, - pub tx_index: bool, } impl Args for LedgerRun { fn parse(matches: &ArgMatches) -> Self { let start_time = NAMADA_START_TIME.parse(matches); - let tx_index = TENDERMINT_TX_INDEX.parse(matches); - Self { - start_time, - tx_index, - } + Self { start_time } } fn def(app: App) -> App { @@ -2002,11 +1995,6 @@ pub mod args { equivalent:\n2023-01-20T12:12:12Z\n2023-01-20 \ 12:12:12Z\n2023- 01-20T12: 12:12Z", )) - .arg( - TENDERMINT_TX_INDEX - .def() - .about("Enable Tendermint tx indexing."), - ) } } From abfe2090808faa00d32c10577a38fb5c90d1e04c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 16 Jun 2023 13:05:58 +0200 Subject: [PATCH 12/14] cli: remove global tendermint `--mode` arg --- apps/src/lib/cli.rs | 10 +--------- apps/src/lib/cli/context.rs | 2 +- apps/src/lib/client/utils.rs | 6 +----- tests/src/e2e/ledger_tests.rs | 5 ----- tests/src/e2e/setup.rs | 20 +------------------- 5 files changed, 4 insertions(+), 39 deletions(-) diff --git a/apps/src/lib/cli.rs b/apps/src/lib/cli.rs index 75c86924a9..b3078037ff 100644 --- a/apps/src/lib/cli.rs +++ b/apps/src/lib/cli.rs @@ -1776,7 +1776,7 @@ pub mod args { use super::context::*; use super::utils::*; use super::{ArgGroup, ArgMatches}; - use crate::config::{self, Action, ActionAtHeight, TendermintMode}; + use crate::config::{self, Action, ActionAtHeight}; use crate::facade::tendermint::Timeout; use crate::facade::tendermint_config::net::Address as TendermintAddress; @@ -1863,7 +1863,6 @@ pub mod args { pub const MASP_VALUE: Arg = arg("value"); pub const MAX_COMMISSION_RATE_CHANGE: Arg = arg("max-commission-rate-change"); - pub const MODE: ArgOpt = arg_opt("mode"); pub const NET_ADDRESS: Arg = arg("net-address"); pub const NAMADA_START_TIME: ArgOpt = arg_opt("time"); pub const NO_CONVERSIONS: ArgFlag = flag("no-conversions"); @@ -1930,7 +1929,6 @@ pub mod args { pub chain_id: Option, pub base_dir: PathBuf, pub wasm_dir: Option, - pub mode: Option, } impl Global { @@ -1939,12 +1937,10 @@ pub mod args { let chain_id = CHAIN_ID_OPT.parse(matches); let base_dir = BASE_DIR.parse(matches); let wasm_dir = WASM_DIR.parse(matches); - let mode = MODE.parse(matches).map(TendermintMode::from); Global { chain_id, base_dir, wasm_dir, - mode, } } @@ -1968,10 +1964,6 @@ pub mod args { `NAMADA_WASM_DIR` environment variable, but the argument \ takes precedence, if specified.", )) - .arg(MODE.def().about( - "The mode in which to run Namada. Options are \n\t * \ - Validator (default)\n\t * Full\n\t * Seed", - )) } } diff --git a/apps/src/lib/cli/context.rs b/apps/src/lib/cli/context.rs index 630d329515..dbe1cec667 100644 --- a/apps/src/lib/cli/context.rs +++ b/apps/src/lib/cli/context.rs @@ -89,7 +89,7 @@ impl Context { let mut config = Config::load( &global_args.base_dir, &global_config.default_chain_id, - global_args.mode.clone(), + None, ); let chain_dir = global_args diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index f676e470bb..ee63ecb1d2 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -233,11 +233,7 @@ pub async fn join_network( let base_dir = base_dir.clone(); let chain_id = chain_id.clone(); tokio::task::spawn_blocking(move || { - let mut config = Config::load( - &base_dir, - &chain_id, - global_args.mode.clone(), - ); + let mut config = Config::load(&base_dir, &chain_id, None); config.wasm_dir = wasm_dir; config.write(&base_dir, &chain_id, true).unwrap(); }) diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index 44f69514b1..71fe06ecab 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -2537,7 +2537,6 @@ fn pos_init_validator() -> Result<()> { Some(60), &test.working_dir, validator_1_base_dir, - None, loc, )?; @@ -3760,7 +3759,6 @@ fn test_genesis_validators() -> Result<()> { Some(5), &working_dir, &test_dir, - None, format!("{}:{}", std::file!(), std::line!()), )?; init_genesis_validator_0.assert_success(); @@ -3802,7 +3800,6 @@ fn test_genesis_validators() -> Result<()> { Some(5), &working_dir, &test_dir, - None, format!("{}:{}", std::file!(), std::line!()), )?; init_genesis_validator_1.assert_success(); @@ -3879,7 +3876,6 @@ fn test_genesis_validators() -> Result<()> { Some(5), &working_dir, &test_dir, - None, format!("{}:{}", std::file!(), std::line!()), )?; @@ -4227,7 +4223,6 @@ fn double_signing_gets_slashed() -> Result<()> { Some(40), &test.working_dir, validator_0_base_dir_copy, - None, loc, )?; validator_0_copy.exp_string("Namada ledger node started")?; diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index 317a41b402..98ff2012fd 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -167,7 +167,6 @@ pub fn network( Some(5), &working_dir, &test_dir, - None, format!("{}:{}", std::file!(), std::line!()), )?; @@ -394,19 +393,7 @@ impl Test { S: AsRef, { let base_dir = self.get_base_dir(&who); - let mode = match &who { - Who::NonValidator => "full", - Who::Validator(_) => "validator", - }; - run_cmd( - bin, - args, - timeout_sec, - &self.working_dir, - base_dir, - Some(mode), - loc, - ) + run_cmd(bin, args, timeout_sec, &self.working_dir, base_dir, loc) } pub fn get_base_dir(&self, who: &Who) -> PathBuf { @@ -673,7 +660,6 @@ pub fn run_cmd( timeout_sec: Option, working_dir: impl AsRef, base_dir: impl AsRef, - mode: Option<&str>, loc: String, ) -> Result where @@ -699,10 +685,6 @@ where .current_dir(working_dir) .args(["--base-dir", &base_dir.as_ref().to_string_lossy()]); - if let Some(mode) = mode { - run_cmd.args(["--mode", mode]); - } - run_cmd.args(args); let args: String = From 221ca9dc5005e376efe3f8dacbe62f17d7f99917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 16 Jun 2023 15:59:26 +0200 Subject: [PATCH 13/14] test/e2e/ibc_tests: remove unused "tx-index" arg --- tests/src/e2e/ibc_tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 00ee58d52b..d43d7de242 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -99,7 +99,7 @@ fn run_ledger_ibc() -> Result<()> { test_a, Who::Validator(0), Bin::Node, - &["ledger", "run", "--tx-index"], + &["ledger", "run"], Some(40) )?; ledger_a.exp_string("Namada ledger node started")?; @@ -108,7 +108,7 @@ fn run_ledger_ibc() -> Result<()> { test_b, Who::Validator(0), Bin::Node, - &["ledger", "run", "--tx-index"], + &["ledger", "run"], Some(40) )?; ledger_b.exp_string("Namada ledger node started")?; From 525d348d00e0ef8de1420f2f491ba66ef912cc93 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 16 Jun 2023 15:18:15 +0000 Subject: [PATCH 14/14] [ci] wasm checksums update --- wasm/checksums.json | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/wasm/checksums.json b/wasm/checksums.json index 544d711eb0..4c277ea699 100644 --- a/wasm/checksums.json +++ b/wasm/checksums.json @@ -1,20 +1,21 @@ { - "tx_bond.wasm": "tx_bond.1ac4fc75655415a08a628bc07133d0141ade4086253b4f96673e9eb7da45726a.wasm", - "tx_change_validator_commission.wasm": "tx_change_validator_commission.4dcd692eeb90658506d2eb284c7da90c08bb8d2a625f914573e99efebbfb94ed.wasm", - "tx_ibc.wasm": "tx_ibc.729f25abd2e77152eeec492c01a3d79db56c0ddb9ff235cb12590037387f4aa1.wasm", - "tx_init_account.wasm": "tx_init_account.53ef514d4f5eb4cb4a8a83894be08833777e4eb3aec7c7edbd147991b7d275f4.wasm", - "tx_init_proposal.wasm": "tx_init_proposal.008bd96153886cdeff1ad68fc0978d35ad7a4edc19becf71d8f8c3e5d1f4b1a5.wasm", - "tx_init_validator.wasm": "tx_init_validator.d87634e95f47c4ed43806a23f2cdcea5e3c8c964987ab4059013a531a3cf91ae.wasm", - "tx_reveal_pk.wasm": "tx_reveal_pk.0b1b66ec606b0ce85717e8a026872ef7f6edb936510d60abf0126d2936e34c5a.wasm", - "tx_transfer.wasm": "tx_transfer.57f62e5edc9ac962add374599cccf9de2d5b8341cfcbc6c11021f6947253da9a.wasm", - "tx_unbond.wasm": "tx_unbond.30f386ba0b79017c060e9e828f61b2f25590999c3e321ea33f06a7bcf2f0f63e.wasm", - "tx_update_vp.wasm": "tx_update_vp.24b8501c7df4ee482fbab8411a5e8666d36267302783998e6dd3ccc92a2eb802.wasm", - "tx_vote_proposal.wasm": "tx_vote_proposal.e38b9a1e138aba5482e4429522218172a1c5ef91279e7b2c213fe2749c9220e7.wasm", - "tx_withdraw.wasm": "tx_withdraw.2d54fbffe9ab316cf63122ffe2f6c9b6f43e2da0145a5ea75dd99d5e86018fb0.wasm", - "vp_implicit.wasm": "vp_implicit.2057db599475eb1dc96e5b40c9f39eec8748f92bfd45713e85abea9c5b9a3021.wasm", - "vp_masp.wasm": "vp_masp.3f1f0b555faaf9260b19b04e8277fc52889a6cb0f8bd225b08c4777dba23a65d.wasm", - "vp_testnet_faucet.wasm": "vp_testnet_faucet.05c6758273d11980f03bf58af4edeacb935a22c89aa915c9767825924b5bd00f.wasm", - "vp_token.wasm": "vp_token.61e54faa78931c6fd3cd4ef3d03495d735ed1052037f3cc395079d34db63de16.wasm", - "vp_user.wasm": "vp_user.f46b6efec59564fe82aa7e8fd1cfa503f4c86ae881b3704ee6080998fa0313dc.wasm", - "vp_validator.wasm": "vp_validator.78a51f16ad2ab2dcc10c77c66b31d3bd7f5e2c0d2181b1ef4bf52049f9469ab2.wasm" + "tx_bond.wasm": "tx_bond.5edc70343a861ad0c364a31b5a496fa4512d7ad4a3bf70fb19e8ad1fdd752c2e.wasm", + "tx_change_validator_commission.wasm": "tx_change_validator_commission.cdac7616f73bcdb994cea7d3cb439b21895495aa4f680fc405f28ba6c6715e77.wasm", + "tx_ibc.wasm": "tx_ibc.bd3750ef3c6d60e170ed21da08d240630614947af9d3db27f8bcebce283e3f83.wasm", + "tx_init_account.wasm": "tx_init_account.5c718152efc0ea1f47ed9ff059d760b9574c509848aa6f7be491b183ddde1021.wasm", + "tx_init_proposal.wasm": "tx_init_proposal.8d00a82a694748bdba75da76b7c3bed8d18885be9e235e7d45579ad66e27300f.wasm", + "tx_init_validator.wasm": "tx_init_validator.bd9f044807b4f70d54c1259e9db6c51cd6f9c8c5db7ab3a8516555d1fa1dd328.wasm", + "tx_reveal_pk.wasm": "tx_reveal_pk.37aaa9063e03f5eff3a6cd74e625b2fb54027418ecec143de05217a16ec29049.wasm", + "tx_transfer.wasm": "tx_transfer.bcca7fead00b79477fa94bef362f05e945bb325780463bed88b5468ee3e91b63.wasm", + "tx_unbond.wasm": "tx_unbond.e43b2ed891cd2733855d78d55f0ae34b66208c36114c7b0239093cd338712c4b.wasm", + "tx_unjail_validator.wasm": "tx_unjail_validator.9100bf186b4cafe98cc9d2dfa3775a6e698395023a42cab63b153a3ecc51d89d.wasm", + "tx_update_vp.wasm": "tx_update_vp.0c2af0693061733c0bdbdec19952d92eb805d55505de7ffdef62fdf1d6e60011.wasm", + "tx_vote_proposal.wasm": "tx_vote_proposal.beb1c659c66cf02869c2269ee0f09f229372b1b9f56cbc858437401929f1fcb5.wasm", + "tx_withdraw.wasm": "tx_withdraw.8be0862edd903662a12b4d2f76e8568bfba24541352f905c565dcad16f7c19d5.wasm", + "vp_implicit.wasm": "vp_implicit.edc3c4165e6202b8b90f19abe23f3cf5205d90c5772eed47702b895f9bddcc72.wasm", + "vp_masp.wasm": "vp_masp.08352c4c1b5dfa641d40e6de48486c335516841e44733c459cdcca2874e616b7.wasm", + "vp_testnet_faucet.wasm": "vp_testnet_faucet.a02d139ee9ec06a3937ad02c54c60eb5bfe7ee856a3887603089a31aa849a87a.wasm", + "vp_token.wasm": "vp_token.fd63f1c85c28f531074a6a2dfa655fbb3a259f7398644f591858991dbee83a50.wasm", + "vp_user.wasm": "vp_user.6825e6936d14710d93002e27962935dfe60b010dce17bb7ca004c26670476b4a.wasm", + "vp_validator.wasm": "vp_validator.fcc27c29217b9d0ee64adb47bd0c0ec9355d854641eb680e7f24f7f94a63ae03.wasm" } \ No newline at end of file