diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index fcdf6fb8215..8aa01264e3d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -55,7 +55,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.81.0 target: ${{ matrix.target }} override: true - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0a3c064e1c..3f32d47a798 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.81.0 components: rustfmt override: true - uses: Swatinem/rust-cache@v2 @@ -57,7 +57,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.81.0 - uses: Swatinem/rust-cache@v2 with: shared-key: "check" @@ -82,7 +82,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.81.0 components: clippy override: true - uses: Swatinem/rust-cache@v2 @@ -191,7 +191,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.81.0 override: true - uses: Swatinem/rust-cache@v2 with: @@ -205,7 +205,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: install - args: cargo-nextest --locked + args: cargo-nextest - uses: actions-rs/cargo@v1 with: command: nextest @@ -239,7 +239,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.81.0 components: rustfmt override: true - uses: actions/checkout@v3 @@ -274,7 +274,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.81.0 components: rustfmt override: true - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index 1816c95bf4a..281d0ccb854 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -11,11 +11,11 @@ jobs: markdown-link-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: - node-version: '18' + node-version: 18 - name: Install markdown-link-check run: npm install -g markdown-link-check - name: Check links in markdown files diff --git a/Cargo.lock b/Cargo.lock index f70c9ee664c..35c62d39de8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3674,6 +3674,12 @@ dependencies = [ "serde", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.45" @@ -5365,12 +5371,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -5385,10 +5392,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] diff --git a/massa-api/src/tests/public.rs b/massa-api/src/tests/public.rs index 36646137abd..05d1ddd5903 100644 --- a/massa-api/src/tests/public.rs +++ b/massa-api/src/tests/public.rs @@ -984,7 +984,7 @@ async fn get_datastore_entries() { .await .unwrap(); - let entry = response.get(0).unwrap(); + let entry = response.first().unwrap(); assert_eq!( entry.candidate_value.as_ref().unwrap(), diff --git a/massa-async-pool/src/test_exports/mod.rs b/massa-async-pool/src/test_exports/mod.rs index 69a116360c9..063eca7e08e 100644 --- a/massa-async-pool/src/test_exports/mod.rs +++ b/massa-async-pool/src/test_exports/mod.rs @@ -4,4 +4,3 @@ mod bootstrap; mod config; pub use bootstrap::*; -pub use config::*; diff --git a/massa-bootstrap/src/lib.rs b/massa-bootstrap/src/lib.rs index 62bb3109a4e..525cc026bdc 100644 --- a/massa-bootstrap/src/lib.rs +++ b/massa-bootstrap/src/lib.rs @@ -15,9 +15,7 @@ use massa_consensus_exports::bootstrapable_graph::BootstrapableGraph; use massa_final_state::FinalStateController; use massa_protocol_exports::BootstrapPeers; use parking_lot::RwLock; -use std::io::{self, ErrorKind}; use std::sync::Arc; -use std::time::{Duration, Instant}; mod bindings; mod client; @@ -66,6 +64,7 @@ impl GlobalBootstrapState { } } +/* trait BindingReadExact: io::Read { /// similar to std::io::Read::read_exact, but with a timeout that is function-global instead of per-individual-read fn read_exact_timeout( @@ -112,3 +111,4 @@ trait BindingReadExact: io::Read { /// Internal helper fn set_read_timeout(&mut self, deadline: Option) -> Result<(), std::io::Error>; } +*/ diff --git a/massa-bootstrap/src/messages.rs b/massa-bootstrap/src/messages.rs index 039de714134..e0cc2fa5669 100644 --- a/massa-bootstrap/src/messages.rs +++ b/massa-bootstrap/src/messages.rs @@ -84,6 +84,7 @@ pub enum BootstrapServerMessage { }, } +#[allow(clippy::to_string_trait_impl)] impl ToString for BootstrapServerMessage { fn to_string(&self) -> String { match self { diff --git a/massa-bootstrap/src/server.rs b/massa-bootstrap/src/server.rs index af51016d1d7..98618688dd6 100644 --- a/massa-bootstrap/src/server.rs +++ b/massa-bootstrap/src/server.rs @@ -63,11 +63,15 @@ use crate::{ white_black_list::SharedWhiteBlackList, BootstrapConfig, }; + +/* /// Specifies a common interface that can be used by standard, or mockers #[cfg_attr(test, mockall::automock)] pub trait BSEventPoller { fn poll(&mut self) -> Result; } +*/ + /// Abstraction layer over data produced by the listener, and transported /// over to the worker via a channel diff --git a/massa-bootstrap/src/tests/binders.rs b/massa-bootstrap/src/tests/binders.rs index e52b6c118e1..46ef5b1c699 100644 --- a/massa-bootstrap/src/tests/binders.rs +++ b/massa-bootstrap/src/tests/binders.rs @@ -59,7 +59,7 @@ impl BootstrapClientBinder { } pub(crate) fn test_default_config() -> BootstrapClientConfig { BootstrapClientConfig { - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, max_listeners_per_peer: MAX_LISTENERS_PER_PEER as u32, endorsement_count: ENDORSEMENT_COUNT, max_advertise_length: MAX_ADVERTISE_LENGTH, @@ -131,7 +131,7 @@ fn init_server_client_pair() -> (BootstrapServerBinder, BootstrapClientBinder) { server.0, server_keypair.clone(), BootstrapSrvBindCfg { - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, thread_count: THREAD_COUNT, max_datastore_key_length: MAX_DATASTORE_KEY_LENGTH, randomness_size_bytes: BOOTSTRAP_RANDOMNESS_SIZE_BYTES, diff --git a/massa-bootstrap/src/tests/config.rs b/massa-bootstrap/src/tests/config.rs index a443ed1777a..027e07637d7 100644 --- a/massa-bootstrap/src/tests/config.rs +++ b/massa-bootstrap/src/tests/config.rs @@ -48,7 +48,7 @@ impl Default for BootstrapConfig { max_simultaneous_bootstraps: 2, ip_list_max_size: 10, per_ip_min_interval: MassaTime::from_millis(10000), - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, max_datastore_key_length: MAX_DATASTORE_KEY_LENGTH, randomness_size_bytes: BOOTSTRAP_RANDOMNESS_SIZE_BYTES, thread_count: THREAD_COUNT, diff --git a/massa-bootstrap/src/tests/messages.rs b/massa-bootstrap/src/tests/messages.rs index 950f3101e88..bccd65fe8db 100644 --- a/massa-bootstrap/src/tests/messages.rs +++ b/massa-bootstrap/src/tests/messages.rs @@ -14,7 +14,7 @@ use massa_serialization::{DeserializeError, Deserializer, Serializer}; #[test] fn test_serialize_bootstrap_server_message() { let config = BootstrapClientConfig { - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, max_listeners_per_peer: MAX_LISTENERS_PER_PEER as u32, endorsement_count: ENDORSEMENT_COUNT, max_advertise_length: MAX_ADVERTISE_LENGTH, @@ -147,7 +147,7 @@ fn test_serialize_error_cases_clientmsg() { #[test] fn test_serialize_error_cases_servermsg() { let config = BootstrapClientConfig { - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, max_listeners_per_peer: MAX_LISTENERS_PER_PEER as u32, endorsement_count: ENDORSEMENT_COUNT, max_advertise_length: MAX_ADVERTISE_LENGTH, diff --git a/massa-bootstrap/src/tests/tools.rs b/massa-bootstrap/src/tests/tools.rs index ddfabd23734..f4615ebbda6 100644 --- a/massa-bootstrap/src/tests/tools.rs +++ b/massa-bootstrap/src/tests/tools.rs @@ -353,7 +353,7 @@ pub fn get_bootstrap_config(bootstrap_public_key: NodeId) -> BootstrapConfig { max_simultaneous_bootstraps: 2, ip_list_max_size: 10, per_ip_min_interval: MassaTime::from_millis(10000), - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, max_datastore_key_length: MAX_DATASTORE_KEY_LENGTH, randomness_size_bytes: BOOTSTRAP_RANDOMNESS_SIZE_BYTES, thread_count: THREAD_COUNT, diff --git a/massa-client/src/cmds.rs b/massa-client/src/cmds.rs index 0d5805d3b80..897883e6c46 100644 --- a/massa-client/src/cmds.rs +++ b/massa-client/src/cmds.rs @@ -866,7 +866,7 @@ impl Command { if let Ok(addresses_info) = client.public.get_addresses(vec![addr]).await { - match addresses_info.get(0) { + match addresses_info.first() { Some(info) => { if info.candidate_balance < total { client_warning!("this operation may be rejected due to insufficient balance"); @@ -911,7 +911,7 @@ impl Command { if !json { if let Ok(addresses_info) = client.public.get_addresses(vec![addr]).await { - match addresses_info.get(0) { + match addresses_info.first() { Some(info) => { if info.candidate_balance < fee || roll_count > info.candidate_roll_count @@ -948,7 +948,7 @@ impl Command { if !json { if let Ok(addresses_info) = client.public.get_addresses(vec![addr]).await { - match addresses_info.get(0) { + match addresses_info.first() { Some(info) => { if info.candidate_balance < fee { client_warning!("this operation may be rejected due to insufficient balance"); @@ -994,7 +994,7 @@ impl Command { let fee = parameters[4].parse::()?; if !json { if let Ok(addresses_info) = client.public.get_addresses(vec![addr]).await { - match addresses_info.get(0) { + match addresses_info.first() { Some(info) => { if info.candidate_balance < fee.saturating_add(max_coins) { client_warning!("this operation may be rejected due to insufficient balance"); @@ -1052,7 +1052,7 @@ impl Command { if let Ok(addresses_info) = client.public.get_addresses(vec![target_addr]).await { - match addresses_info.get(0) { + match addresses_info.first() { Some(info) => { if info.candidate_balance < total { client_warning!("this operation may be rejected due to insufficient balance"); diff --git a/massa-client/src/settings.rs b/massa-client/src/settings.rs index cd177d7cf88..541a5f52004 100644 --- a/massa-client/src/settings.rs +++ b/massa-client/src/settings.rs @@ -10,6 +10,7 @@ lazy_static::lazy_static! { pub static ref SETTINGS: Settings = build_massa_settings("massa-client", "MASSA_CLIENT"); } +#[allow(dead_code)] #[derive(Debug, Deserialize, Clone)] pub struct Settings { pub default_node: DefaultNode, diff --git a/massa-consensus-exports/src/test_exports/mod.rs b/massa-consensus-exports/src/test_exports/mod.rs index 824722968ba..fb2fa597dfe 100644 --- a/massa-consensus-exports/src/test_exports/mod.rs +++ b/massa-consensus-exports/src/test_exports/mod.rs @@ -1,5 +1,3 @@ // Copyright (c) 2022 MASSA LABS mod config; - -pub use config::*; diff --git a/massa-consensus-worker/src/lib.rs b/massa-consensus-worker/src/lib.rs index 7074c71d037..48e617a34c2 100644 --- a/massa-consensus-worker/src/lib.rs +++ b/massa-consensus-worker/src/lib.rs @@ -22,6 +22,7 @@ //! * If the dependencies are already available, the module checks if it can validate the block and add it to a clique. //! * If it's the second block received for the same slot we save it in order to denounce the creator in the future. //! * If it's the third or more we ignore the block unless we asked for it explicitly as a dependency. +//! //! If a queued block reaches the slot time at which it should be processed, the worker wakes up to check it and trigger, if necessary, the consensus algorithm. //! It then prunes the block graph and the caches. diff --git a/massa-consensus-worker/src/state/mod.rs b/massa-consensus-worker/src/state/mod.rs index 23560ae91cd..b6671934365 100644 --- a/massa-consensus-worker/src/state/mod.rs +++ b/massa-consensus-worker/src/state/mod.rs @@ -37,6 +37,7 @@ mod stats; mod tick; mod verifications; +#[allow(dead_code)] #[derive(Clone)] pub struct ConsensusState { /// Configuration diff --git a/massa-execution-exports/src/test_exports/mod.rs b/massa-execution-exports/src/test_exports/mod.rs index ec2eab01eb7..87922d29fb7 100644 --- a/massa-execution-exports/src/test_exports/mod.rs +++ b/massa-execution-exports/src/test_exports/mod.rs @@ -14,4 +14,3 @@ //! with an execution worker within tests. mod config; -pub use config::*; diff --git a/massa-execution-worker/src/context.rs b/massa-execution-worker/src/context.rs index a58576577b9..319f7e17b74 100644 --- a/massa-execution-worker/src/context.rs +++ b/massa-execution-worker/src/context.rs @@ -189,6 +189,7 @@ impl ExecutionContext { /// /// # arguments /// * `final_state`: thread-safe access to the final state. + /// /// Note that this will be used only for reading, never for writing /// /// # returns diff --git a/massa-execution-worker/src/controller.rs b/massa-execution-worker/src/controller.rs index 1bd253f4d8a..02d017b5c08 100644 --- a/massa-execution-worker/src/controller.rs +++ b/massa-execution-worker/src/controller.rs @@ -236,7 +236,7 @@ impl ExecutionController for ExecutionControllerImpl { ExecutionQueryRequestItem::OpExecutionStatusCandidate(id) => { let (speculative_v, _final_v) = execution_lock .get_ops_exec_status(&[id]) - .get(0) + .first() .map(|(s_v, f_v)| (*s_v, *f_v)) .expect("expected one return value"); match speculative_v { @@ -254,7 +254,7 @@ impl ExecutionController for ExecutionControllerImpl { ExecutionQueryRequestItem::OpExecutionStatusFinal(id) => { let (_speculative_v, final_v) = execution_lock .get_ops_exec_status(&[id]) - .get(0) + .first() .map(|(s_v, f_v)| (*s_v, *f_v)) .expect("expected one return value"); match final_v { diff --git a/massa-execution-worker/src/execution.rs b/massa-execution-worker/src/execution.rs index 297538ff8e9..350ea935cd7 100644 --- a/massa-execution-worker/src/execution.rs +++ b/massa-execution-worker/src/execution.rs @@ -1778,7 +1778,7 @@ impl ExecutionState { let call_stack_addr = context.get_call_stack(); // transfer fee - if let (Some(fee), Some(addr)) = (req.fee, call_stack_addr.get(0)) { + if let (Some(fee), Some(addr)) = (req.fee, call_stack_addr.first()) { context.transfer_coins(Some(*addr), None, fee, false)?; } } @@ -1823,13 +1823,13 @@ impl ExecutionState { let call_stack_addr = context.get_call_stack(); // transfer fee - if let (Some(fee), Some(addr)) = (req.fee, call_stack_addr.get(0)) { + if let (Some(fee), Some(addr)) = (req.fee, call_stack_addr.first()) { context.transfer_coins(Some(*addr), None, fee, false)?; } // transfer coins if let (Some(coins), Some(from), Some(to)) = - (req.coins, call_stack_addr.get(0), call_stack_addr.get(1)) + (req.coins, call_stack_addr.first(), call_stack_addr.get(1)) { context.transfer_coins(Some(*from), Some(*to), coins, false)?; } diff --git a/massa-execution-worker/src/tests/universe.rs b/massa-execution-worker/src/tests/universe.rs index bfffa6c80d9..0866d91931a 100644 --- a/massa-execution-worker/src/tests/universe.rs +++ b/massa-execution-worker/src/tests/universe.rs @@ -79,6 +79,7 @@ impl ExecutionForeignControllers { } } +#[allow(dead_code)] pub struct ExecutionTestUniverse { pub module_controller: Box, pub storage: Storage, diff --git a/massa-factory-exports/src/test_exports/mod.rs b/massa-factory-exports/src/test_exports/mod.rs index 27fe6c27396..bbf23fc9ee6 100644 --- a/massa-factory-exports/src/test_exports/mod.rs +++ b/massa-factory-exports/src/test_exports/mod.rs @@ -3,5 +3,4 @@ mod config; mod tools; -pub use config::*; pub use tools::*; diff --git a/massa-final-state/src/test_exports/mod.rs b/massa-final-state/src/test_exports/mod.rs index eae336d5a43..b40738d0768 100644 --- a/massa-final-state/src/test_exports/mod.rs +++ b/massa-final-state/src/test_exports/mod.rs @@ -5,5 +5,4 @@ mod config; mod mock; -pub use config::*; pub use mock::*; diff --git a/massa-grpc/src/tests/public.rs b/massa-grpc/src/tests/public.rs index d9941ce4ae9..4881aeacb2f 100644 --- a/massa-grpc/src/tests/public.rs +++ b/massa-grpc/src/tests/public.rs @@ -142,7 +142,7 @@ async fn get_operations() { let op_type = response .wrapped_operations - .get(0) + .first() .unwrap() .clone() .operation @@ -195,7 +195,7 @@ async fn get_blocks() { .unwrap() .into_inner(); - let s = result.wrapped_blocks.get(0).unwrap().clone().status; + let s = result.wrapped_blocks.first().unwrap().clone().status; assert_eq!(s, BlockStatus::Final as i32); stop_handle.stop(); @@ -328,7 +328,7 @@ async fn get_datastore_entries() { .unwrap() .into_inner(); - let data = result.datastore_entries.get(0).unwrap(); + let data = result.datastore_entries.first().unwrap(); // TODO candidate value should be an option in the api : issue #4427 assert!(data.candidate_value.is_empty()); assert_eq!(data.final_value, "toto".as_bytes()); @@ -539,7 +539,7 @@ async fn get_endorsements() { .into_inner(); assert_eq!(result.wrapped_endorsements.len(), 1); - let endorsement = result.wrapped_endorsements.get(0).unwrap(); + let endorsement = result.wrapped_endorsements.first().unwrap(); assert!(endorsement.is_final); assert!(endorsement.in_blocks.contains(&block_id.to_string())); @@ -583,7 +583,7 @@ async fn get_next_block_best_parents() { .into_inner(); assert_eq!(result.block_parents.len(), 2); - let parent = result.block_parents.get(0).unwrap(); + let parent = result.block_parents.first().unwrap(); assert_eq!( parent.block_id, "B1q4CBcuYo8YANEV34W4JRWVHrzcYns19VJfyAB7jT4qfitAnMC".to_string() @@ -651,7 +651,7 @@ async fn get_sc_execution_events() { .unwrap() .into_inner(); - let event = result.events.get(0).unwrap(); + let event = result.events.first().unwrap(); assert_eq!(event.data, "massa".as_bytes().to_vec()); assert!(event.context.is_some()); let context = event.context.as_ref().unwrap(); @@ -885,7 +885,7 @@ async fn get_selector_draws() { assert_eq!(result.draws.len(), 2); let slots: &Vec = result.draws.as_ref(); - let slot = slots.get(0).unwrap(); + let slot = slots.first().unwrap(); assert!(slot.slot.is_some()); assert!(!slot.endorsement_draws.is_empty()); assert!(slot.block_producer.is_some()); @@ -1159,7 +1159,7 @@ async fn search_blocks() { .unwrap() .into_inner(); - let block_result = result.block_infos.get(0).unwrap(); + let block_result = result.block_infos.first().unwrap(); assert_eq!(block_result.block_id, block_op.id.to_string()); // search address + slot range diff --git a/massa-ledger-exports/src/ledger_changes.rs b/massa-ledger-exports/src/ledger_changes.rs index 5c4e1eb5839..9cc0a42056e 100644 --- a/massa-ledger-exports/src/ledger_changes.rs +++ b/massa-ledger-exports/src/ledger_changes.rs @@ -839,8 +839,11 @@ impl LedgerChanges { /// and optionally if a datastore key write also exists in the address's datastore. /// Notes: /// - A ledger entry could be written to without any changes on the values associated, + /// /// for example if the value was changed multiple times in the same slot. + /// /// - This code assumes Delete cannot be shadowed by Set operations in the same slot, which may not be the case + /// /// when / if we allow full entry Delete given the current LedgerChanges::Delete handling. In that case, a rework may be necessary. /// /// # Arguments diff --git a/massa-ledger-worker/src/test_exports/mod.rs b/massa-ledger-worker/src/test_exports/mod.rs index 6519f517906..95d2d7ae437 100644 --- a/massa-ledger-worker/src/test_exports/mod.rs +++ b/massa-ledger-worker/src/test_exports/mod.rs @@ -4,4 +4,3 @@ mod bootstrap; mod config; pub use bootstrap::*; -pub use config::*; diff --git a/massa-models/src/clique.rs b/massa-models/src/clique.rs index 3fa76c31849..f60ef64b8f5 100644 --- a/massa-models/src/clique.rs +++ b/massa-models/src/clique.rs @@ -1,7 +1,5 @@ // Copyright (c) 2022 MASSA LABS -use core::usize; - use massa_serialization::{ Deserializer, SerializeError, Serializer, U32VarIntDeserializer, U32VarIntSerializer, U64VarIntDeserializer, U64VarIntSerializer, diff --git a/massa-models/src/ledger.rs b/massa-models/src/ledger.rs index f6875eb1b6a..95e85f1c44e 100644 --- a/massa-models/src/ledger.rs +++ b/massa-models/src/ledger.rs @@ -7,7 +7,6 @@ use crate::{ error::ModelsResult as Result, prehash::{PreHashMap, PreHashSet}, }; -use core::usize; use massa_serialization::{ Deserializer, SerializeError, Serializer, U64VarIntDeserializer, U64VarIntSerializer, }; diff --git a/massa-node/src/settings.rs b/massa-node/src/settings.rs index 3ee8de250e2..4d1d443dd39 100644 --- a/massa-node/src/settings.rs +++ b/massa-node/src/settings.rs @@ -91,6 +91,7 @@ pub struct FactorySettings { } /// Pool configuration, read from a file configuration +#[allow(dead_code)] #[derive(Debug, Deserialize, Clone)] pub struct PoolSettings { pub max_operation_pool_size: usize, @@ -194,6 +195,7 @@ pub struct MetricsSettings { } /// Protocol Configuration, read from toml user configuration file +#[allow(dead_code)] #[derive(Debug, Deserialize, Clone)] pub struct ProtocolSettings { /// after `ask_block_timeout` milliseconds we try to ask a block to another node diff --git a/massa-pool-exports/src/test_exports/mod.rs b/massa-pool-exports/src/test_exports/mod.rs index 824722968ba..fb2fa597dfe 100644 --- a/massa-pool-exports/src/test_exports/mod.rs +++ b/massa-pool-exports/src/test_exports/mod.rs @@ -1,5 +1,3 @@ // Copyright (c) 2022 MASSA LABS mod config; - -pub use config::*; diff --git a/massa-pos-exports/src/pos_final_state.rs b/massa-pos-exports/src/pos_final_state.rs index 4c86f3ce5e8..c7c336edd35 100644 --- a/massa-pos-exports/src/pos_final_state.rs +++ b/massa-pos-exports/src/pos_final_state.rs @@ -1062,7 +1062,7 @@ impl PoSFinalState { let results = db.multi_get_cf(query); - match (results.get(0), results.get(1)) { + match (results.first(), results.get(1)) { (Some(Ok(Some(serialized_fail))), Some(Ok(Some(serialized_success)))) => { let (_, fail) = self .cycle_info_deserializer diff --git a/massa-pos-exports/src/test_exports/mod.rs b/massa-pos-exports/src/test_exports/mod.rs index 0266e18e52a..2983f8c62b5 100644 --- a/massa-pos-exports/src/test_exports/mod.rs +++ b/massa-pos-exports/src/test_exports/mod.rs @@ -5,4 +5,3 @@ mod bootstrap; mod config; pub use bootstrap::*; -pub use config::*; diff --git a/massa-protocol-worker/src/handlers/block_handler/messages.rs b/massa-protocol-worker/src/handlers/block_handler/messages.rs index 0c435f05cf7..833a88accf5 100644 --- a/massa-protocol-worker/src/handlers/block_handler/messages.rs +++ b/massa-protocol-worker/src/handlers/block_handler/messages.rs @@ -7,9 +7,7 @@ use massa_models::{ }, secure_share::{SecureShareDeserializer, SecureShareSerializer}, }; -use massa_serialization::{ - Deserializer, SerializeError, Serializer, U64VarIntDeserializer, U64VarIntSerializer, -}; +use massa_serialization::{Deserializer, Serializer, U64VarIntDeserializer, U64VarIntSerializer}; use nom::{ error::{context, ContextError, ParseError}, sequence::tuple, @@ -120,12 +118,8 @@ impl Serializer for BlockMessageSerializer { value: &BlockMessage, buffer: &mut Vec, ) -> Result<(), massa_serialization::SerializeError> { - self.id_serializer.serialize( - &MessageTypeId::from(value).try_into().map_err(|_| { - SerializeError::GeneralError(String::from("Failed to serialize id")) - })?, - buffer, - )?; + self.id_serializer + .serialize(&MessageTypeId::from(value).into(), buffer)?; match value { BlockMessage::Header(header) => { self.secure_share_serializer.serialize(header, buffer)?; @@ -275,9 +269,7 @@ impl Deserializer for BlockMessageDeserializer { "Failed BlockDataRequest deserialization", tuple(( context("Failed BlockId deserialization", |input| { - self.block_id_deserializer - .deserialize(input) - .map(|(rest, id)| (rest, id)) + self.block_id_deserializer.deserialize(input) }), context("Failed infos deserialization", |input| { let (rest, raw_id) = self.id_deserializer.deserialize(input)?; @@ -317,9 +309,7 @@ impl Deserializer for BlockMessageDeserializer { "Failed BlockDataResponse deserialization", tuple(( context("Failed BlockId deserialization", |input| { - self.block_id_deserializer - .deserialize(input) - .map(|(rest, id)| (rest, id)) + self.block_id_deserializer.deserialize(input) }), context("Failed infos deserialization", |input| { let (rest, raw_id) = self.id_deserializer.deserialize(input)?; diff --git a/massa-protocol-worker/src/handlers/block_handler/mod.rs b/massa-protocol-worker/src/handlers/block_handler/mod.rs index 5beda278b51..b750cb3757d 100644 --- a/massa-protocol-worker/src/handlers/block_handler/mod.rs +++ b/massa-protocol-worker/src/handlers/block_handler/mod.rs @@ -27,9 +27,7 @@ mod retrieval; pub(crate) use messages::{BlockMessage, BlockMessageSerializer}; #[cfg(test)] -pub use messages::{ - AskForBlockInfo, BlockInfoReply, BlockMessageDeserializer, BlockMessageDeserializerArgs, -}; +pub use messages::{AskForBlockInfo, BlockInfoReply}; use super::{ endorsement_handler::{ diff --git a/massa-protocol-worker/src/handlers/endorsement_handler/messages.rs b/massa-protocol-worker/src/handlers/endorsement_handler/messages.rs index 18350203756..2e36072e9d4 100644 --- a/massa-protocol-worker/src/handlers/endorsement_handler/messages.rs +++ b/massa-protocol-worker/src/handlers/endorsement_handler/messages.rs @@ -2,9 +2,7 @@ use massa_models::{ endorsement::{Endorsement, EndorsementDeserializer, SecureShareEndorsement}, secure_share::{SecureShareDeserializer, SecureShareSerializer}, }; -use massa_serialization::{ - Deserializer, SerializeError, Serializer, U64VarIntDeserializer, U64VarIntSerializer, -}; +use massa_serialization::{Deserializer, Serializer, U64VarIntDeserializer, U64VarIntSerializer}; use nom::{ error::{context, ContextError, ParseError}, multi::length_count, @@ -56,12 +54,8 @@ impl Serializer for EndorsementMessageSerializer { value: &EndorsementMessage, buffer: &mut Vec, ) -> Result<(), massa_serialization::SerializeError> { - self.id_serializer.serialize( - &MessageTypeId::from(value).try_into().map_err(|_| { - SerializeError::GeneralError(String::from("Failed to serialize id")) - })?, - buffer, - )?; + self.id_serializer + .serialize(&MessageTypeId::from(value).into(), buffer)?; match value { EndorsementMessage::Endorsements(endorsements) => { self.length_endorsements_serializer diff --git a/massa-protocol-worker/src/handlers/operation_handler/messages.rs b/massa-protocol-worker/src/handlers/operation_handler/messages.rs index 3e07359cebe..40663164fea 100644 --- a/massa-protocol-worker/src/handlers/operation_handler/messages.rs +++ b/massa-protocol-worker/src/handlers/operation_handler/messages.rs @@ -63,12 +63,8 @@ impl Serializer for OperationMessageSerializer { value: &OperationMessage, buffer: &mut Vec, ) -> Result<(), SerializeError> { - self.id_serializer.serialize( - &MessageTypeId::from(value).try_into().map_err(|_| { - SerializeError::GeneralError(String::from("Failed to serialize id")) - })?, - buffer, - )?; + self.id_serializer + .serialize(&MessageTypeId::from(value).into(), buffer)?; match value { OperationMessage::OperationsAnnouncement(operations) => { self.operation_prefix_ids_serializer diff --git a/massa-protocol-worker/src/handlers/peer_handler/messages.rs b/massa-protocol-worker/src/handlers/peer_handler/messages.rs index 66f9e2afbd3..ac6a62df467 100644 --- a/massa-protocol-worker/src/handlers/peer_handler/messages.rs +++ b/massa-protocol-worker/src/handlers/peer_handler/messages.rs @@ -2,9 +2,7 @@ use std::{collections::HashMap, net::SocketAddr, ops::Bound::Included}; use massa_models::serialization::{IpAddrDeserializer, IpAddrSerializer}; use massa_protocol_exports::{PeerId, PeerIdDeserializer, PeerIdSerializer}; -use massa_serialization::{ - Deserializer, SerializeError, Serializer, U64VarIntDeserializer, U64VarIntSerializer, -}; +use massa_serialization::{Deserializer, Serializer, U64VarIntDeserializer, U64VarIntSerializer}; use nom::{ error::{context, ContextError, ParseError}, multi::length_count, @@ -65,12 +63,8 @@ impl Serializer for PeerManagementMessageSerializer { value: &PeerManagementMessage, buffer: &mut Vec, ) -> Result<(), massa_serialization::SerializeError> { - self.id_serializer.serialize( - &MessageTypeId::from(value).try_into().map_err(|_| { - SerializeError::GeneralError(String::from("Failed to serialize id")) - })?, - buffer, - )?; + self.id_serializer + .serialize(&MessageTypeId::from(value).into(), buffer)?; match value { PeerManagementMessage::NewPeerConnected((peer_id, listeners)) => { self.peer_id_serializer.serialize(peer_id, buffer)?; diff --git a/massa-protocol-worker/src/handlers/peer_handler/mod.rs b/massa-protocol-worker/src/handlers/peer_handler/mod.rs index bc531327bbb..7b583e5a3aa 100644 --- a/massa-protocol-worker/src/handlers/peer_handler/mod.rs +++ b/massa-protocol-worker/src/handlers/peer_handler/mod.rs @@ -56,6 +56,7 @@ mod tester; pub(crate) use messages::{PeerManagementMessage, PeerManagementMessageSerializer}; +#[allow(dead_code)] pub struct PeerManagementHandler { pub peer_db: SharedPeerDB, pub thread_join: Option>, diff --git a/massa-protocol-worker/src/handlers/peer_handler/models.rs b/massa-protocol-worker/src/handlers/peer_handler/models.rs index 1bf6209458d..7e3c05f44c8 100644 --- a/massa-protocol-worker/src/handlers/peer_handler/models.rs +++ b/massa-protocol-worker/src/handlers/peer_handler/models.rs @@ -186,6 +186,7 @@ pub enum PeerManagementCmd { Stop, } +#[allow(dead_code)] pub struct PeerManagementChannel { pub msg_sender: MassaSender, pub command_sender: MassaSender, diff --git a/massa-protocol-worker/src/messages.rs b/massa-protocol-worker/src/messages.rs index 20ea6c4b7ef..63807fdeb19 100644 --- a/massa-protocol-worker/src/messages.rs +++ b/massa-protocol-worker/src/messages.rs @@ -137,15 +137,7 @@ impl PeerNetMessagesSerializer for MessagesSerializer { /// Serialize the message fn serialize(&self, message: &Message, buffer: &mut Vec) -> PeerNetResult<()> { self.id_serializer - .serialize( - &MessageTypeId::from(message).try_into().map_err(|_| { - PeerNetError::HandlerError.error( - "MessagesSerializer", - Some(String::from("Failed to serialize id")), - ) - })?, - buffer, - ) + .serialize(&MessageTypeId::from(message).into(), buffer) .map_err(|err| { PeerNetError::HandlerError.error( "MessagesHandler", diff --git a/massa-protocol-worker/src/tests/universe.rs b/massa-protocol-worker/src/tests/universe.rs index 96c687434d1..2ae3ce16ffc 100644 --- a/massa-protocol-worker/src/tests/universe.rs +++ b/massa-protocol-worker/src/tests/universe.rs @@ -39,6 +39,7 @@ use num::rational::Ratio; use std::ops::Bound::Included; use tracing::{debug, log::warn}; +#[allow(dead_code)] pub struct ProtocolTestUniverse { pub module_controller: Box, module_manager: Box, diff --git a/massa-protocol-worker/src/wrap_network.rs b/massa-protocol-worker/src/wrap_network.rs index b69d3e8b971..d81f73e05bd 100644 --- a/massa-protocol-worker/src/wrap_network.rs +++ b/massa-protocol-worker/src/wrap_network.rs @@ -118,6 +118,7 @@ impl ActiveConnectionsTrait for SharedActiveConnections { } } +#[allow(dead_code)] #[cfg_attr(test, mockall::automock)] pub trait NetworkController: Send + Sync { fn get_active_connections(&self) -> Box; diff --git a/massa-storage/src/lib.rs b/massa-storage/src/lib.rs index d05490dcb64..1d150196aba 100644 --- a/massa-storage/src/lib.rs +++ b/massa-storage/src/lib.rs @@ -95,7 +95,8 @@ impl Storage { /// Creates a new `Storage` instance. Must be called only one time in the execution: /// - In the main for the node /// - At the top of the test in tests - /// All others instances of Storage must be cloned from this one using `clone()` or `clone_without_refs()`. + /// + /// All others instance of Storage must be cloned from this one using `clone()` or `clone_without_refs()`. pub fn create_root() -> Storage { Storage { blocks: Default::default(), diff --git a/massa-versioning/src/versioning.rs b/massa-versioning/src/versioning.rs index 2c73ef54941..3ad72745524 100644 --- a/massa-versioning/src/versioning.rs +++ b/massa-versioning/src/versioning.rs @@ -1123,7 +1123,7 @@ impl MipStoreRaw { .iter() .rev() .filter(|(mi, ms)| { - mi.components.get(component).is_some() + mi.components.contains_key(component) && matches!(ms.state, ComponentState::Active(_)) }) .find_map(|(mi, ms)| { diff --git a/massa-versioning/src/versioning_factory.rs b/massa-versioning/src/versioning_factory.rs index 8897226d36d..33a71989840 100644 --- a/massa-versioning/src/versioning_factory.rs +++ b/massa-versioning/src/versioning_factory.rs @@ -144,6 +144,7 @@ mod test { } } + #[allow(dead_code)] #[derive(Debug)] enum TestAddress { V0(TestAddressV0), diff --git a/massa-versioning/src/versioning_ser_der.rs b/massa-versioning/src/versioning_ser_der.rs index 339747f516b..463adb7c7a3 100644 --- a/massa-versioning/src/versioning_ser_der.rs +++ b/massa-versioning/src/versioning_ser_der.rs @@ -168,13 +168,7 @@ impl Deserializer for MipInfoDeserializer { tuple(( context("Failed component deserialization", |input| { let (rem, component_) = self.u32_deserializer.deserialize(input)?; - let component = - MipComponent::try_from(component_).map_err(|_| { - nom::Err::Error(ParseError::from_error_kind( - input, - nom::error::ErrorKind::Fail, - )) - })?; + let component = MipComponent::from(component_); IResult::Ok((rem, component)) }), context("Failed component version deserialization", |input| { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 27ae62c5bcb..1de01fa45c4 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.74.1" +channel = "1.81.0"