diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 21779e366e7..b868b959c62 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -90,19 +90,19 @@ jobs: exit 1 fi - - name: "Install: Rust stable toolchain" - uses: dtolnay/rust-toolchain@stable + - name: "Install: Rust beta toolchain" + uses: dtolnay/rust-toolchain@beta with: targets: wasm32v1-none - - name: "Check: Compiling gstd on stable" + - name: "Check: Compiling gstd on beta" run: | - cargo +stable check -p gstd --target wasm32v1-none - cargo +stable check --manifest-path utils/wasm-builder/test-program/Cargo.toml - cargo +stable check --manifest-path utils/cargo-gbuild/test-program/Cargo.toml --workspace --target wasm32v1-none + cargo +beta check -p gstd --target wasm32v1-none + cargo +beta check --manifest-path utils/wasm-builder/test-program/Cargo.toml + cargo +beta check --manifest-path utils/cargo-gbuild/test-program/Cargo.toml --workspace --target wasm32v1-none - name: "Check: crates-io packages publishing" - run: cargo +stable run --release -p crates-io publish --simulate --registry-path /tmp/cargo-http-registry + run: cargo +beta run --release -p crates-io publish --simulate --registry-path /tmp/cargo-http-registry fuzzer: runs-on: [kuberunner, github-runner-01] diff --git a/Cargo.toml b/Cargo.toml index 80e21c4cb3f..df191a23c7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2024" license = "GPL-3.0" homepage = "https://gear-tech.io" repository = "https://github.com/gear-tech/gear" -rust-version = "1.85" +rust-version = "1.88" [workspace] resolver = "3" diff --git a/common/src/auxiliary/mod.rs b/common/src/auxiliary/mod.rs index dc084cd5904..70f31df71d8 100644 --- a/common/src/auxiliary/mod.rs +++ b/common/src/auxiliary/mod.rs @@ -230,10 +230,10 @@ impl DoubleMapStorage for T { f: F, ) -> Option { T::with_storage_mut(|map| { - if let Some(inner_map) = map.inner.get_mut(&key1) { - if let Some(value) = inner_map.get_mut(&key2) { - return Some(f(value)); - } + if let Some(inner_map) = map.inner.get_mut(&key1) + && let Some(value) = inner_map.get_mut(&key2) + { + return Some(f(value)); } None diff --git a/common/src/gas_provider/internal.rs b/common/src/gas_provider/internal.rs index b55badc8c0e..24953639146 100644 --- a/common/src/gas_provider/internal.rs +++ b/common/src/gas_provider/internal.rs @@ -580,10 +580,10 @@ where return Err(InternalError::consumed_with_lock().into()); } - if let Some(system_reserve) = node.system_reserve() { - if !system_reserve.is_zero() { - return Err(InternalError::consumed_with_system_reservation().into()); - } + if let Some(system_reserve) = node.system_reserve() + && !system_reserve.is_zero() + { + return Err(InternalError::consumed_with_system_reservation().into()); } node.mark_consumed(); diff --git a/common/src/gas_provider/property_tests/assertions.rs b/common/src/gas_provider/property_tests/assertions.rs index afa18c6d29a..5a5f2d305b6 100644 --- a/common/src/gas_provider/property_tests/assertions.rs +++ b/common/src/gas_provider/property_tests/assertions.rs @@ -154,11 +154,11 @@ fn assert_removed_nodes_form_path( // Check that only `Cut` is removed after `consume` #[track_caller] fn assert_only_cut_node_removed(consumed: NodeId, removed_nodes: &RemovedNodes) { - if let Some(node) = removed_nodes.get(&consumed) { - if node.is_cut() { - // only `Cut` must be removed - assert_eq!(removed_nodes.len(), 1); - } + if let Some(node) = removed_nodes.get(&consumed) + && node.is_cut() + { + // only `Cut` must be removed + assert_eq!(removed_nodes.len(), 1); } } @@ -192,16 +192,16 @@ pub(super) fn assert_root_children_removed( #[track_caller] fn assert_another_root_not_removed(consumed: NodeId, removed_nodes: &RemovedNodes) { - if let Some(node) = removed_nodes.get(&consumed) { - if node.is_external() || node.is_reserved() { - assert_eq!( - removed_nodes - .iter() - .filter(|(_, v)| v.is_external() || v.is_reserved()) - .count(), - 1 // only `root_node` - ); - } + if let Some(node) = removed_nodes.get(&consumed) + && (node.is_external() || node.is_reserved()) + { + assert_eq!( + removed_nodes + .iter() + .filter(|(_, v)| v.is_external() || v.is_reserved()) + .count(), + 1 // only `root_node` + ); } } diff --git a/common/src/gas_provider/property_tests/mod.rs b/common/src/gas_provider/property_tests/mod.rs index dccd0b041a5..2d437fbccac 100644 --- a/common/src/gas_provider/property_tests/mod.rs +++ b/common/src/gas_provider/property_tests/mod.rs @@ -485,10 +485,8 @@ proptest! { // Check property: if node has non-zero value, it's a patron node (either not consumed or with unspec refs) // (Actually, patron can have 0 inner value, when `spend` decreased it's balance to 0, but it's an edge case) // `Cut` node can be not consumed with non zero value, but is not a patron - if let Some(value) = node.value() { - if value != 0 && !node.is_cut() { + if let Some(value) = node.value() && value != 0 && !node.is_cut() { assert!(node.is_patron()); - } } // Check property: all nodes have ancestor (node is a self-ancestor too) with value diff --git a/core/src/code/utils.rs b/core/src/code/utils.rs index fce0e3c512e..7980751562c 100644 --- a/core/src/code/utils.rs +++ b/core/src/code/utils.rs @@ -79,10 +79,10 @@ pub fn get_exports(module: &Module) -> BTreeSet { .as_ref() .expect("Exports section has been checked for already") { - if let ExternalKind::Func = entry.kind { - if let Some(entry) = DispatchKind::try_from_entry(&entry.name) { - entries.insert(entry); - } + if let ExternalKind::Func = entry.kind + && let Some(entry) = DispatchKind::try_from_entry(&entry.name) + { + entries.insert(entry); } } diff --git a/core/src/memory.rs b/core/src/memory.rs index 1252e62dd0a..7d296e08c91 100644 --- a/core/src/memory.rs +++ b/core/src/memory.rs @@ -378,32 +378,32 @@ impl AllocationsContext { }); } - if let Some(stack_end) = stack_end { - if stack_end > static_pages { - return Err(MemorySetupError::StackEndOutOfStaticMemory { - stack_end, - static_pages, - }); - } + if let Some(stack_end) = stack_end + && stack_end > static_pages + { + return Err(MemorySetupError::StackEndOutOfStaticMemory { + stack_end, + static_pages, + }); } - if let Some(page) = allocations.end() { - if page >= memory_size { - return Err(MemorySetupError::AllocatedPageOutOfAllowedInterval { - page, - static_pages, - memory_size, - }); - } + if let Some(page) = allocations.end() + && page >= memory_size + { + return Err(MemorySetupError::AllocatedPageOutOfAllowedInterval { + page, + static_pages, + memory_size, + }); } - if let Some(page) = allocations.start() { - if page < static_pages { - return Err(MemorySetupError::AllocatedPageOutOfAllowedInterval { - page, - static_pages, - memory_size, - }); - } + if let Some(page) = allocations.start() + && page < static_pages + { + return Err(MemorySetupError::AllocatedPageOutOfAllowedInterval { + page, + static_pages, + memory_size, + }); } Ok(()) @@ -460,11 +460,13 @@ impl AllocationsContext { /// Free specific memory page. pub fn free(&mut self, page: WasmPage) -> Result<(), AllocError> { - if let Some(heap) = self.heap { - if page >= heap.start() && page <= heap.end() && self.allocations.remove(page) { - self.allocations_changed = true; - return Ok(()); - } + if let Some(heap) = self.heap + && page >= heap.start() + && page <= heap.end() + && self.allocations.remove(page) + { + self.allocations_changed = true; + return Ok(()); } Err(AllocError::InvalidFree(page)) } diff --git a/docker/Dockerfile b/docker/Dockerfile index 973c2cf904e..72367aaff03 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,7 +2,7 @@ FROM amazonlinux:2023 as builder ARG PROFILE=production -ARG TOOLCHAIN=nightly-2025-05-09 +ARG TOOLCHAIN=nightly-2025-05-28 RUN yum update -y && \ yum install -y clang gcc git gzip make tar wget unzip && \ diff --git a/ethexe/docker/ethexe_builder.Dockerfile b/ethexe/docker/ethexe_builder.Dockerfile index 571aef82c30..92419a85be6 100644 --- a/ethexe/docker/ethexe_builder.Dockerfile +++ b/ethexe/docker/ethexe_builder.Dockerfile @@ -21,8 +21,8 @@ RUN wget https://sh.rustup.rs/rustup-init.sh RUN chmod +x rustup-init.sh RUN ./rustup-init.sh -y ENV PATH="/root/.cargo/bin:$PATH" -RUN rustup toolchain install nightly-2025-05-09 -RUN rustup target add wasm32v1-none --toolchain nightly-2025-05-09 +RUN rustup toolchain install nightly-2025-05-28 +RUN rustup target add wasm32v1-none --toolchain nightly-2025-05-28 # Build RUN cargo build -p ethexe-cli --profile $PROFILE diff --git a/ethexe/network/src/lib.rs b/ethexe/network/src/lib.rs index 1f080da1716..7fe28174196 100644 --- a/ethexe/network/src/lib.rs +++ b/ethexe/network/src/lib.rs @@ -388,13 +388,13 @@ impl NetworkService { // BehaviourEvent::Kad(kad::Event::RoutingUpdated { peer, .. }) => { let behaviour = self.swarm.behaviour_mut(); - if let Some(mdns4) = behaviour.mdns4.as_ref() { - if mdns4.discovered_nodes().any(|&p| p == peer) { - // we don't want local peers to appear in KadDHT. - // event can be emitted few times in a row for - // the same peer, so we just ignore `None` - let _res = behaviour.kad.remove_peer(&peer); - } + if let Some(mdns4) = behaviour.mdns4.as_ref() + && mdns4.discovered_nodes().any(|&p| p == peer) + { + // we don't want local peers to appear in KadDHT. + // event can be emitted few times in a row for + // the same peer, so we just ignore `None` + let _res = behaviour.kad.remove_peer(&peer); } } BehaviourEvent::Kad(_) => {} diff --git a/ethexe/observer/src/lib.rs b/ethexe/observer/src/lib.rs index b87f7511de0..8e6a137d888 100644 --- a/ethexe/observer/src/lib.rs +++ b/ethexe/observer/src/lib.rs @@ -176,32 +176,32 @@ impl Stream for ObserverService { return Poll::Ready(Some(Ok(ObserverEvent::Block(data)))); } - if self.sync_future.is_none() { - if let Some(header) = self.block_sync_queue.pop_front() { - let sync = ChainSync { - provider: self.provider.clone(), - db: self.db.clone(), - blobs_reader: self.blobs_reader.clone(), - config: self.config.clone(), - }; - self.sync_future = Some(Box::pin(sync.sync(header))); - } + if self.sync_future.is_none() + && let Some(header) = self.block_sync_queue.pop_front() + { + let sync = ChainSync { + provider: self.provider.clone(), + db: self.db.clone(), + blobs_reader: self.blobs_reader.clone(), + config: self.config.clone(), + }; + self.sync_future = Some(Box::pin(sync.sync(header))); } - if let Some(fut) = self.sync_future.as_mut() { - if let Poll::Ready(res) = fut.poll_unpin(cx) { - self.sync_future = None; + if let Some(fut) = self.sync_future.as_mut() + && let Poll::Ready(res) = fut.poll_unpin(cx) + { + self.sync_future = None; - let res = res.map(|(hash, codes)| { - for (code_id, code_info) in codes { - self.lookup_code(code_id, code_info.timestamp, code_info.tx_hash); - } + let res = res.map(|(hash, codes)| { + for (code_id, code_info) in codes { + self.lookup_code(code_id, code_info.timestamp, code_info.tx_hash); + } - ObserverEvent::BlockSynced(hash) - }); + ObserverEvent::BlockSynced(hash) + }); - return Poll::Ready(Some(res)); - } + return Poll::Ready(Some(res)); } if let Poll::Ready(Some(res)) = self.codes_futures.poll_next_unpin(cx) { diff --git a/examples/fungible-token/src/wasm.rs b/examples/fungible-token/src/wasm.rs index f1cb8a08cbe..4cdca9dd99e 100644 --- a/examples/fungible-token/src/wasm.rs +++ b/examples/fungible-token/src/wasm.rs @@ -146,13 +146,13 @@ impl FungibleToken { if from == &source || self.balances.get(&source).unwrap_or(&0) >= &amount { return true; } - if let Some(allowed_amount) = self.allowances.get(from).and_then(|m| m.get(&source)) { - if allowed_amount >= &amount { - self.allowances.entry(*from).and_modify(|m| { - m.entry(source).and_modify(|a| *a -= amount); - }); - return true; - } + if let Some(allowed_amount) = self.allowances.get(from).and_then(|m| m.get(&source)) + && allowed_amount >= &amount + { + self.allowances.entry(*from).and_modify(|m| { + m.entry(source).and_modify(|a| *a -= amount); + }); + return true; } false } diff --git a/gcli/src/cmd/config.rs b/gcli/src/cmd/config.rs index e7898221076..62ba1e593aa 100644 --- a/gcli/src/cmd/config.rs +++ b/gcli/src/cmd/config.rs @@ -80,10 +80,10 @@ impl ConfigSettings { /// there are more options in the settings. pub fn write(&self, path: Option) -> Result<()> { let conf = path.unwrap_or(Self::config()?); - if let Some(parent) = conf.parent() { - if !parent.exists() { - fs::create_dir_all(parent)?; - } + if let Some(parent) = conf.parent() + && !parent.exists() + { + fs::create_dir_all(parent)?; } fs::write(conf, toml::to_string_pretty(self)?).map_err(Into::into) diff --git a/gprimitives/src/lib.rs b/gprimitives/src/lib.rs index 14146513c1c..a1e835fccc5 100644 --- a/gprimitives/src/lib.rs +++ b/gprimitives/src/lib.rs @@ -184,11 +184,11 @@ impl fmt::Display for ActorId { let mut e1 = median; let mut s2 = median; - if let Some(precision) = f.precision() { - if precision < median { - e1 = precision; - s2 = len - precision; - } + if let Some(precision) = f.precision() + && precision < median + { + e1 = precision; + s2 = len - precision; } let p1 = &address_str[..e1]; diff --git a/gprimitives/src/utils.rs b/gprimitives/src/utils.rs index e891f1e338f..8352126aa42 100644 --- a/gprimitives/src/utils.rs +++ b/gprimitives/src/utils.rs @@ -83,11 +83,11 @@ impl fmt::Display for ByteSliceFormatter<'_> { let mut e1 = median; let mut s2 = median; - if let Some(precision) = f.precision() { - if precision < median { - e1 = precision; - s2 = len - precision; - } + if let Some(precision) = f.precision() + && precision < median + { + e1 = precision; + s2 = len - precision; } let out1_len = e1 * 2; diff --git a/gsdk/src/storage.rs b/gsdk/src/storage.rs index edb4714b90f..c9b9f02ce40 100644 --- a/gsdk/src/storage.rs +++ b/gsdk/src/storage.rs @@ -459,12 +459,11 @@ impl Api { let mut fetched_keys = 0; while let Some(key) = keys.next().await { - if let Some(storage_data) = storage.fetch_raw(key?).await? { - if let Ok(value) = + if let Some(storage_data) = storage.fetch_raw(key?).await? + && let Ok(value) = <(UserStoredMessage, Interval)>::decode(&mut &storage_data[..]) - { - mailbox.push(value); - } + { + mailbox.push(value); } fetched_keys += 1; diff --git a/gstd/codegen/src/utils.rs b/gstd/codegen/src/utils.rs index 26120b5842c..ffd1a2fc43c 100644 --- a/gstd/codegen/src/utils.rs +++ b/gstd/codegen/src/utils.rs @@ -71,10 +71,10 @@ pub fn with_suffix(i: &Ident, suffix: &str) -> Ident { /// Get arguments from the inputs for function signature pub fn get_args(inputs: &Punctuated) -> Expr { let idents = inputs.iter().filter_map(|param| { - if let syn::FnArg::Typed(pat_type) = param { - if let syn::Pat::Ident(pat_ident) = *pat_type.pat.clone() { - return Some(pat_ident.ident); - } + if let syn::FnArg::Typed(pat_type) = param + && let syn::Pat::Ident(pat_ident) = *pat_type.pat.clone() + { + return Some(pat_ident.ident); } None }); diff --git a/gtest/src/log.rs b/gtest/src/log.rs index b5b08bb65cf..58462614a13 100644 --- a/gtest/src/log.rs +++ b/gtest/src/log.rs @@ -366,22 +366,22 @@ impl PartialEq for Log { return false; } - if let Some(source) = self.source { - if source != other.source { - return false; - } + if let Some(source) = self.source + && source != other.source + { + return false; } - if let Some(destination) = self.destination { - if destination != other.destination { - return false; - } + if let Some(destination) = self.destination + && destination != other.destination + { + return false; } - if let Some(payload) = &self.payload { - if payload.inner() != other.payload.inner() { - return false; - } + if let Some(payload) = &self.payload + && payload.inner() != other.payload.inner() + { + return false; } true diff --git a/lazy-pages/src/lib.rs b/lazy-pages/src/lib.rs index 194a1dc1bd0..21f7f757782 100644 --- a/lazy-pages/src/lib.rs +++ b/lazy-pages/src/lib.rs @@ -122,10 +122,10 @@ pub fn initialize_for_program( let runtime_ctx = ctx.runtime_context_mut()?; // Check wasm program memory host address - if let Some(addr) = wasm_mem_addr { - if addr % region::page::size() != 0 { - return Err(Error::WasmMemAddrIsNotAligned(addr)); - } + if let Some(addr) = wasm_mem_addr + && addr % region::page::size() != 0 + { + return Err(Error::WasmMemAddrIsNotAligned(addr)); } // Check stack_end is less or equal than wasm memory size diff --git a/lazy-pages/src/sys/windows.rs b/lazy-pages/src/sys/windows.rs index 5a722b35ef2..4c33137e227 100644 --- a/lazy-pages/src/sys/windows.rs +++ b/lazy-pages/src/sys/windows.rs @@ -36,10 +36,11 @@ unsafe extern "system" fn exception_handler(exception_info: *mut EXCEPTION_PO where H: UserSignalHandler, { - let exception_record = (*exception_info).ExceptionRecord; + let exception_record = unsafe { *exception_info }.ExceptionRecord; - let is_access_violation = (*exception_record).ExceptionCode == EXCEPTION_ACCESS_VIOLATION; - let num_params = (*exception_record).NumberParameters; + let is_access_violation = + unsafe { *exception_record }.ExceptionCode == EXCEPTION_ACCESS_VIOLATION; + let num_params = unsafe { *exception_record }.NumberParameters; if !is_access_violation || num_params != 2 { log::trace!( "Skip exception in handler: is access violation: {}, parameters: {}", @@ -49,8 +50,8 @@ where return EXCEPTION_CONTINUE_SEARCH; } - let addr = (*exception_record).ExceptionInformation[1]; - let is_write = match (*exception_record).ExceptionInformation[0] { + let addr = unsafe { *exception_record }.ExceptionInformation[1]; + let is_write = match unsafe { *exception_record }.ExceptionInformation[0] { 0 /* read */ => Some(false), 1 /* write */ => Some(true), // we work with WASM memory which is handled by WASM executor @@ -70,11 +71,11 @@ where is_write, }; - if let Err(err) = H::handle(info) { + if let Err(err) = unsafe { H::handle(info) } { if let Error::OutOfWasmMemoryAccess | Error::WasmMemAddrIsNotSet = err { return EXCEPTION_CONTINUE_SEARCH; } else { - panic!("Signal handler failed: {}", err); + panic!("Signal handler failed: {err}"); } } @@ -91,7 +92,8 @@ where { const CALL_FIRST: bool = true; - let handle = AddVectoredExceptionHandler(CALL_FIRST as _, Some(exception_handler::)); + let handle = + unsafe { AddVectoredExceptionHandler(CALL_FIRST as _, Some(exception_handler::)) }; if handle.is_null() { Err(io::Error::last_os_error()) } else { diff --git a/pallets/gear/src/benchmarking/code.rs b/pallets/gear/src/benchmarking/code.rs index 3c45e6a660a..bd8551c8b14 100644 --- a/pallets/gear/src/benchmarking/code.rs +++ b/pallets/gear/src/benchmarking/code.rs @@ -374,11 +374,11 @@ where } // Add residual bytes to the last data segment - if residual_bytes != 0 { - if let Some(last) = module.data_segments.last_mut() { - last.value - .resize(data_segment_size as usize + residual_bytes as usize, 0xA5) - } + if residual_bytes != 0 + && let Some(last) = module.data_segments.last_mut() + { + last.value + .resize(data_segment_size as usize + residual_bytes as usize, 0xA5) } } diff --git a/pallets/gear/src/runtime_api.rs b/pallets/gear/src/runtime_api.rs index c79007037fc..ff794c29ef4 100644 --- a/pallets/gear/src/runtime_api.rs +++ b/pallets/gear/src/runtime_api.rs @@ -306,10 +306,9 @@ where ref dispatch, .. } = note + && from_main_chain(dispatch.id())? { - if from_main_chain(dispatch.id())? { - gas_info.min_limit = initial_gas; - } + gas_info.min_limit = initial_gas; } } } diff --git a/pallets/gear/src/tests.rs b/pallets/gear/src/tests.rs index 3b4e4838794..92d4c113c7c 100644 --- a/pallets/gear/src/tests.rs +++ b/pallets/gear/src/tests.rs @@ -16143,12 +16143,12 @@ pub(crate) mod utils { let mut actual_error = None; System::events().into_iter().for_each(|e| { - if let MockRuntimeEvent::Gear(Event::UserMessageSent { message, .. }) = e.event { - if let Some(details) = message.details() { - let (mid, code) = details.into_parts(); - if mid == message_id && code.is_error() { - actual_error = Some((message.payload_bytes().to_vec(), code)); - } + if let MockRuntimeEvent::Gear(Event::UserMessageSent { message, .. }) = e.event + && let Some(details) = message.details() + { + let (mid, code) = details.into_parts(); + if mid == message_id && code.is_error() { + actual_error = Some((message.payload_bytes().to_vec(), code)); } } }); diff --git a/pallets/payment/src/mock.rs b/pallets/payment/src/mock.rs index 834129d07fe..1e6fb0d5b9b 100644 --- a/pallets/payment/src/mock.rs +++ b/pallets/payment/src/mock.rs @@ -132,10 +132,10 @@ impl OnUnbalanced for DealWithFees { if let Some(author) = Authorship::author() { Balances::resolve_creating(&author, fees); } - if let Some(tips) = fees_then_tips.next() { - if let Some(author) = Authorship::author() { - Balances::resolve_creating(&author, tips); - } + if let Some(tips) = fees_then_tips.next() + && let Some(author) = Authorship::author() + { + Balances::resolve_creating(&author, tips); } } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5af1e431f2c..6aa0091df45 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2025-05-09" +channel = "nightly-2025-05-28" components = [ "llvm-tools" ] targets = [ "wasm32v1-none" ] diff --git a/utils/cargo-gbuild/tests/smoke.rs b/utils/cargo-gbuild/tests/smoke.rs index e386386900c..4c7ed0bb3fd 100644 --- a/utils/cargo-gbuild/tests/smoke.rs +++ b/utils/cargo-gbuild/tests/smoke.rs @@ -68,28 +68,22 @@ fn test_compile() -> Result<()> { #[test] fn test_program_tests() { - // NOTE: workaround for installing stable toolchain if not exist + // NOTE: workaround for installing beta toolchain if not exist // This is momently only for adapting the environment (nightly) // of our CI. { if option_env!("IN_NIX_SHELL").is_none() { let targets = Command::new("rustup") - .args(["target", "list", "--toolchain", "stable"]) + .args(["target", "list", "--toolchain", "beta"]) .output() .expect("Failed to list rust toolchains") .stdout; if !String::from_utf8_lossy(&targets).contains("wasm32v1-none (installed)") { assert!(Command::new("rustup") - .args([ - "toolchain", - "install", - "stable", - "--target", - "wasm32v1-none", - ]) + .args(["toolchain", "install", "beta", "--target", "wasm32v1-none",]) .status() - .expect("Failed to install stable toolchain") + .expect("Failed to install beta toolchain") .success()); } } @@ -97,7 +91,7 @@ fn test_program_tests() { assert!(Command::new("cargo") .current_dir("test-program") - .args(["+stable", "test", "--manifest-path", "Cargo.toml"]) + .args(["+beta", "test", "--manifest-path", "Cargo.toml"]) .status() .expect("Failed to run the tests of cargo-gbuild/test-program") .success()); diff --git a/utils/crates-io/src/lib.rs b/utils/crates-io/src/lib.rs index d9a63491d2e..3e1f2f7de27 100644 --- a/utils/crates-io/src/lib.rs +++ b/utils/crates-io/src/lib.rs @@ -117,7 +117,7 @@ pub const CARGO_REGISTRY_NAME: &str = "cargo-http-registry"; /// Test the input package pub fn test(package: &str, test: &str) -> Result { Command::new("cargo") - .args(["+stable", "test", "-p", package, "--", test]) + .args(["+beta", "test", "-p", package, "--", test]) .status() .map_err(Into::into) } @@ -126,7 +126,7 @@ pub fn test(package: &str, test: &str) -> Result { pub fn publish(manifest: &str) -> Result { Command::new("cargo") .args([ - "+stable", + "+beta", "publish", "--manifest-path", manifest, @@ -139,7 +139,7 @@ pub fn publish(manifest: &str) -> Result { /// Add owner to the input package pub fn add_owner(package: &str, owner: &str) -> Result { Command::new("cargo") - .args(["+stable", "owner", "--add", owner, package]) + .args(["+beta", "owner", "--add", owner, package]) .status() .map_err(Into::into) } diff --git a/utils/node-loader/src/batch_pool/api/nonce.rs b/utils/node-loader/src/batch_pool/api/nonce.rs index 70c622596cd..f46908ed4d0 100644 --- a/utils/node-loader/src/batch_pool/api/nonce.rs +++ b/utils/node-loader/src/batch_pool/api/nonce.rs @@ -54,10 +54,10 @@ fn hold_missed_nonces<'a>() -> Result> { } pub fn catch_missed_nonce(batch_res: &GClientResult, nonce: u64) -> Result<()> { - if let Err(err) = batch_res { - if is_missed_nonce_err(err) { - hold_missed_nonces()?.push(Reverse(nonce)); - } + if let Err(err) = batch_res + && is_missed_nonce_err(err) + { + hold_missed_nonces()?.push(Reverse(nonce)); } Ok(()) diff --git a/utils/validator-checks/src/blocks_production.rs b/utils/validator-checks/src/blocks_production.rs index 7635df4cb08..de5593cf972 100644 --- a/utils/validator-checks/src/blocks_production.rs +++ b/utils/validator-checks/src/blocks_production.rs @@ -35,22 +35,21 @@ impl BlocksProduction { } let logs = &block.header().digest.logs; - if let Some(DigestItem::PreRuntime(engine, bytes)) = logs.first() { - if *engine == BABE_ENGINE_ID { - if let Some(author) = BabePreDigest::decode(&mut bytes.as_ref()) - .ok() - .and_then(|pre| self.all_validators.get(pre.authority_index() as usize)) - { - if let Ok(index) = self.validators.binary_search(author) { - log::info!( - "Validated {:?} for blocks production.", - self.validators.remove(index) - ); - } - } - - return self.validators.is_empty(); + if let Some(DigestItem::PreRuntime(engine, bytes)) = logs.first() + && *engine == BABE_ENGINE_ID + { + if let Some(author) = BabePreDigest::decode(&mut bytes.as_ref()) + .ok() + .and_then(|pre| self.all_validators.get(pre.authority_index() as usize)) + && let Ok(index) = self.validators.binary_search(author) + { + log::info!( + "Validated {:?} for blocks production.", + self.validators.remove(index) + ); } + + return self.validators.is_empty(); } false diff --git a/utils/wasm-builder/src/smart_fs.rs b/utils/wasm-builder/src/smart_fs.rs index a953448d636..290c02d23bb 100644 --- a/utils/wasm-builder/src/smart_fs.rs +++ b/utils/wasm-builder/src/smart_fs.rs @@ -37,10 +37,10 @@ pub(crate) fn copy_if_newer(from: impl AsRef, to: impl AsRef) -> Res pub(crate) fn check_if_newer(left: impl AsRef, right: impl AsRef) -> Result { let right_metadata = fs::metadata(right); - if let Err(io_error) = right_metadata.as_ref() { - if io_error.kind() == ErrorKind::NotFound { - return Ok(true); - } + if let Err(io_error) = right_metadata.as_ref() + && io_error.kind() == ErrorKind::NotFound + { + return Ok(true); } let right_metadata = right_metadata.unwrap(); let left_metadata = fs::metadata(left)?; diff --git a/utils/wasm-gen/src/config/syscalls.rs b/utils/wasm-gen/src/config/syscalls.rs index 4f7d2e02ab1..ac0b0f1a553 100644 --- a/utils/wasm-gen/src/config/syscalls.rs +++ b/utils/wasm-gen/src/config/syscalls.rs @@ -59,12 +59,11 @@ impl SyscallsConfigBuilder { | ActorIdWithValue { actor_kind: actor, .. } = v + && actor.is_source() { - if actor.is_source() { - self.0 - .injection_types - .enable_syscall_import(InvocableSyscall::Loose(SyscallName::Source)); - } + self.0 + .injection_types + .enable_syscall_import(InvocableSyscall::Loose(SyscallName::Source)); } } self.0.params_config = params_config; diff --git a/utils/wasm-instrument/src/module.rs b/utils/wasm-instrument/src/module.rs index e92e34158b7..a1a09f292d1 100644 --- a/utils/wasm-instrument/src/module.rs +++ b/utils/wasm-instrument/src/module.rs @@ -1055,10 +1055,10 @@ impl ModuleFuncIndexShifter { { for func in section { for instruction in &mut func.instructions { - if let Instruction::Call(function_index) = instruction { - if *function_index >= self.inserted_at { - *function_index += 1 - } + if let Instruction::Call(function_index) = instruction + && *function_index >= self.inserted_at + { + *function_index += 1 } } } @@ -1072,10 +1072,10 @@ impl ModuleFuncIndexShifter { .filter(|_| self.export_section) { for export in section { - if let ExternalKind::Func = export.kind { - if export.index >= self.inserted_at { - export.index += 1 - } + if let ExternalKind::Func = export.kind + && export.index >= self.inserted_at + { + export.index += 1 } } } @@ -1107,10 +1107,9 @@ impl ModuleFuncIndexShifter { .start_section .as_mut() .filter(|_| self.start_section) + && *start_idx >= self.inserted_at { - if *start_idx >= self.inserted_at { - *start_idx += 1 - } + *start_idx += 1 } if let Some(section) = self diff --git a/utils/wasm-optimizer/src/cargo_toolchain.rs b/utils/wasm-optimizer/src/cargo_toolchain.rs index a684d4559e5..090f8978dde 100644 --- a/utils/wasm-optimizer/src/cargo_toolchain.rs +++ b/utils/wasm-optimizer/src/cargo_toolchain.rs @@ -34,7 +34,7 @@ pub(crate) struct Toolchain(String); impl Toolchain { /// This is a version of nightly toolchain, tested on our CI. - const PINNED_NIGHTLY_TOOLCHAIN: &'static str = "nightly-2025-05-09"; + const PINNED_NIGHTLY_TOOLCHAIN: &'static str = "nightly-2025-05-28"; /// Returns `Toolchain` representing the recommended nightly version. pub fn recommended_nightly() -> Self { @@ -63,7 +63,7 @@ impl Toolchain { let channels = TOOLCHAIN_CHANNELS.join("|"); let pattern = format!(r"(?:{channels})(?:-\d{{4}}-\d{{2}}-\d{{2}})?"); // Note this regex gives you a guaranteed match of the channel[-date] as group 0, - // for example: `nightly-2025-05-09` + // for example: `nightly-2025-05-28` Regex::new(&pattern).unwrap() }); diff --git a/utils/weight-diff/src/main.rs b/utils/weight-diff/src/main.rs index e56963a8c44..e0f7bc46884 100644 --- a/utils/weight-diff/src/main.rs +++ b/utils/weight-diff/src/main.rs @@ -252,16 +252,15 @@ impl<'ast> Visit<'ast> for StructuresVisitor { structure.generics = Generics::default(); - if let Fields::Named(ref mut fields) = structure.fields { - if fields + if let Fields::Named(ref mut fields) = structure.fields + && fields .named .last() .and_then(|field| field.ident.as_ref()) .filter(|ident| *ident == "_phantom") .is_some() - { - fields.named.pop(); - } + { + fields.named.pop(); } for field in structure.fields.iter_mut() { @@ -329,47 +328,44 @@ impl ImplementationVisitor { // first extract all the `*Costs` impls. if let Some((_, Path { segments, .. }, _)) = &mut implementation.trait_ { - if let Some(PathSegment { ident, arguments }) = segments.first_mut() { - if *ident == "From" { - if let Type::Path(TypePath { path, .. }) = &mut *implementation.self_ty { - let PathArguments::AngleBracketed(types) = arguments else { - unreachable!("unexpected From impl detected") - }; - - let Some(&mut GenericArgument::Type(ref mut ty)) = types.args.first_mut() - else { - unreachable!("unexpected From impl detected") - }; - - if let Type::Path(TypePath { path, .. }) = ty { - if let Some(PathSegment { arguments, .. }) = path.segments.first_mut() { - *arguments = PathArguments::None; - } - } + if let Some(PathSegment { ident, arguments }) = segments.first_mut() + && *ident == "From" + && let Type::Path(TypePath { path, .. }) = &mut *implementation.self_ty + { + let PathArguments::AngleBracketed(types) = arguments else { + unreachable!("unexpected From impl detected") + }; + + let Some(&mut GenericArgument::Type(ref mut ty)) = types.args.first_mut() else { + unreachable!("unexpected From impl detected") + }; + + if let Type::Path(TypePath { path, .. }) = ty + && let Some(PathSegment { arguments, .. }) = path.segments.first_mut() + { + *arguments = PathArguments::None; + } - if let Some(PathSegment { ident, .. }) = path.segments.first_mut() { - if TYPE_LIST.contains(&ident.to_string().as_str()) { - let Some(ImplItem::Fn(from_fn)) = implementation.items.first_mut() - else { - unreachable!("unexpected From impl detected") - }; - - let first_arg = from_fn.sig.inputs.first_mut().unwrap(); - match first_arg { - FnArg::Typed(typed) => match &mut *typed.ty { - Type::Path(path) => { - path.path.segments.first_mut().unwrap().arguments = - PathArguments::None; - - self.impls.push(implementation); - } - - _ => unreachable!("unexpected From impl detected"), - }, - _ => unreachable!("unexpected From impl detected"), - } + if let Some(PathSegment { ident, .. }) = path.segments.first_mut() + && TYPE_LIST.contains(&ident.to_string().as_str()) + { + let Some(ImplItem::Fn(from_fn)) = implementation.items.first_mut() else { + unreachable!("unexpected From impl detected") + }; + + let first_arg = from_fn.sig.inputs.first_mut().unwrap(); + match first_arg { + FnArg::Typed(typed) => match &mut *typed.ty { + Type::Path(path) => { + path.path.segments.first_mut().unwrap().arguments = + PathArguments::None; + + self.impls.push(implementation); } - } + + _ => unreachable!("unexpected From impl detected"), + }, + _ => unreachable!("unexpected From impl detected"), } } } @@ -393,19 +389,18 @@ impl ImplementationVisitor { implementation.generics = Generics::default(); - if let Type::Path(TypePath { path, .. }) = &mut *implementation.self_ty { - if let Some(PathSegment { arguments, ident }) = path.segments.first_mut() { - *arguments = PathArguments::None; - if *ident == "Schedule" { - // only leave process_costs method - implementation.items.retain_mut(|item| match item { - ImplItem::Fn(func) => func.sig.ident == "process_costs", - _ => false, - }); - - self.impls.push(implementation); - } - } + if let Type::Path(TypePath { path, .. }) = &mut *implementation.self_ty + && let Some(PathSegment { arguments, ident }) = path.segments.first_mut() + && *ident == "Schedule" + { + *arguments = PathArguments::None; + // only leave process_costs method + implementation.items.retain_mut(|item| match item { + ImplItem::Fn(func) => func.sig.ident == "process_costs", + _ => false, + }); + + self.impls.push(implementation); } } }