From 4e50e21a76b4cd19aa21381f3c0086169152eeba Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 12 Dec 2024 12:42:55 +0800 Subject: [PATCH] fix: post-rebase fixes. --- z2/src/setup.rs | 6 +++--- zilliqa/src/cfg.rs | 2 +- zilliqa/src/node_launcher.rs | 16 +++++++++------- zilliqa/tests/it/main.rs | 10 ++++++---- zilliqa/tests/it/persistence.rs | 2 +- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/z2/src/setup.rs b/z2/src/setup.rs index e3b990dd8..317fbd6d0 100644 --- a/z2/src/setup.rs +++ b/z2/src/setup.rs @@ -21,9 +21,9 @@ use zilliqa::{ block_request_limit_default, consensus_timeout_default, empty_block_timeout_default, eth_chain_id_default, failed_request_sleep_duration_default, local_address_default, max_blocks_in_flight_default, minimum_time_left_for_empty_block_default, - scilla_address_default, scilla_ext_libs_path_default, scilla_stdlib_dir_default, - state_rpc_limit_default, total_native_token_supply_default, Amount, ApiServer, - ConsensusConfig, GenesisDeposit, + remote_api_url_default, scilla_address_default, scilla_ext_libs_path_default, + scilla_stdlib_dir_default, state_rpc_limit_default, total_native_token_supply_default, + Amount, ApiServer, ConsensusConfig, GenesisDeposit, }, transaction::EvmGas, }; diff --git a/zilliqa/src/cfg.rs b/zilliqa/src/cfg.rs index eef12cee3..fb7fa6b4d 100644 --- a/zilliqa/src/cfg.rs +++ b/zilliqa/src/cfg.rs @@ -182,7 +182,7 @@ pub fn state_cache_size_default() -> usize { } pub fn remote_api_url_default() -> Url { - Url::parse(&format!("http://localhost:{}", json_rpc_port_default())).unwrap() + Url::parse("http://localhost:4201").unwrap() } pub fn eth_chain_id_default() -> u64 { diff --git a/zilliqa/src/node_launcher.rs b/zilliqa/src/node_launcher.rs index 5e709ab6b..adfe5f462 100644 --- a/zilliqa/src/node_launcher.rs +++ b/zilliqa/src/node_launcher.rs @@ -6,7 +6,7 @@ use std::{ use anyhow::{anyhow, Result}; use http::{header, Method}; -use jsonrpsee::{core::client::ClientT, RpcModule}; +use jsonrpsee::core::client::ClientT; use libp2p::{futures::StreamExt, PeerId}; use node::Node; use opentelemetry::KeyValue; @@ -182,9 +182,9 @@ impl NodeLauncher { async fn handle_watchdog(&mut self) -> Result<()> { // If watchdog is disabled, then do nothing. - // if systemd::daemon::watchdog_enabled(false).unwrap_or_default() == 0 { - // return Ok(()); - // } + if systemd::daemon::watchdog_enabled(false).unwrap_or_default() == 0 { + return Ok(()); + } // 1. Collect quick sample let self_highest = self @@ -195,6 +195,8 @@ impl NodeLauncher { .get_highest_canonical_block_number()? .ok_or_else(|| anyhow!("can't find highest block num in database!"))?; + tracing::debug!("WDT check {self_highest}"); + // 1.5 Debounce if self.watchdog.value == self_highest { self.watchdog.count += 1; @@ -222,14 +224,14 @@ impl NodeLauncher { "0x0".to_string() }); - let other_highest = result + let remote_highest = result .strip_prefix("0x") .map(|s| u64::from_str_radix(s, 16).unwrap_or_default()) .unwrap_or_default(); // 4. If self < others for > threshold, then we're stuck - if self_highest < other_highest { - tracing::warn!(?self_highest, ?other_highest, "WDT node stuck at"); + if self_highest < remote_highest { + tracing::warn!(?self_highest, ?remote_highest, "WDT node stuck at"); return Ok(()); } else { tracing::warn!( diff --git a/zilliqa/tests/it/main.rs b/zilliqa/tests/it/main.rs index a28ea87c5..cf5beef6f 100644 --- a/zilliqa/tests/it/main.rs +++ b/zilliqa/tests/it/main.rs @@ -68,9 +68,10 @@ use zilliqa::{ allowed_timestamp_skew_default, block_request_batch_size_default, block_request_limit_default, eth_chain_id_default, failed_request_sleep_duration_default, max_blocks_in_flight_default, minimum_time_left_for_empty_block_default, - scilla_address_default, scilla_ext_libs_path_default, scilla_stdlib_dir_default, - state_cache_size_default, state_rpc_limit_default, total_native_token_supply_default, - Amount, ApiServer, Checkpoint, ConsensusConfig, GenesisDeposit, NodeConfig, + remote_api_url_default, scilla_address_default, scilla_ext_libs_path_default, + scilla_stdlib_dir_default, state_cache_size_default, state_rpc_limit_default, + total_native_token_supply_default, Amount, ApiServer, Checkpoint, ConsensusConfig, + GenesisDeposit, NodeConfig, }, crypto::{SecretKey, TransactionPublicKey}, db, @@ -180,7 +181,8 @@ fn node( Arc::new(AtomicUsize::new(0)), )?; let node = Arc::new(Mutex::new(node)); - let rpc_module: RpcModule>> = zilliqa::api::rpc_module(node.clone()); + let rpc_module: RpcModule>> = + api::rpc_module(node.clone(), &api::all_enabled()); Ok(( TestNode { diff --git a/zilliqa/tests/it/persistence.rs b/zilliqa/tests/it/persistence.rs index fc158231b..1958d3a3d 100644 --- a/zilliqa/tests/it/persistence.rs +++ b/zilliqa/tests/it/persistence.rs @@ -13,7 +13,7 @@ use zilliqa::{ allowed_timestamp_skew_default, block_request_batch_size_default, block_request_limit_default, consensus_timeout_default, eth_chain_id_default, failed_request_sleep_duration_default, max_blocks_in_flight_default, - minimum_time_left_for_empty_block_default, scilla_address_default, + minimum_time_left_for_empty_block_default, remote_api_url_default, scilla_address_default, scilla_ext_libs_path_default, scilla_stdlib_dir_default, state_cache_size_default, state_rpc_limit_default, total_native_token_supply_default, ApiServer, Checkpoint, ConsensusConfig, NodeConfig,