From f94ac1af3c2220cd3956bcde7e443b0a1b0934d2 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 1 Apr 2025 11:59:24 +0300 Subject: [PATCH 01/45] explicit usize convertion Signed-off-by: Iulian Barbu --- .gitignore | 4 ++++ polkadot/runtime/parachains/src/inclusion/mod.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4fe0701fde684..2bd0c812be8ed 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,7 @@ target/ *.scale justfile rustc-ice-* +.bacon-locations +bacon.log +bacon-ls.log +.config/bacon.toml diff --git a/polkadot/runtime/parachains/src/inclusion/mod.rs b/polkadot/runtime/parachains/src/inclusion/mod.rs index 03dc20b67344e..648af57ffdee1 100644 --- a/polkadot/runtime/parachains/src/inclusion/mod.rs +++ b/polkadot/runtime/parachains/src/inclusion/mod.rs @@ -1320,7 +1320,7 @@ impl CandidateCheckContext { horizontal_messages: &[polkadot_primitives::OutboundHrmpMessage], ) -> Result<(), AcceptanceCheckErr> { ensure!( - head_data.0.len() <= self.config.max_head_data_size as _, + head_data.0.len() <= self.config.max_head_data_size as usize, AcceptanceCheckErr::HeadDataTooLarge, ); @@ -1331,7 +1331,7 @@ impl CandidateCheckContext { AcceptanceCheckErr::PrematureCodeUpgrade, ); ensure!( - new_validation_code.0.len() <= self.config.max_code_size as _, + new_validation_code.0.len() <= self.config.max_code_size as usize, AcceptanceCheckErr::NewCodeTooLarge, ); } From 73bd02a98559340a563e32995882bcfe1e405ebe Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 1 Apr 2025 16:56:11 +0300 Subject: [PATCH 02/45] fix compilation issues Signed-off-by: Iulian Barbu --- bridges/modules/parachains/src/call_ext.rs | 2 +- polkadot/node/core/chain-selection/src/db_backend/v1.rs | 2 +- polkadot/runtime/common/src/crowdloan/mod.rs | 2 +- substrate/utils/wasm-builder/src/version.rs | 9 ++++++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bridges/modules/parachains/src/call_ext.rs b/bridges/modules/parachains/src/call_ext.rs index b67da03a6315c..cc839ce9bd710 100644 --- a/bridges/modules/parachains/src/call_ext.rs +++ b/bridges/modules/parachains/src/call_ext.rs @@ -108,7 +108,7 @@ impl, I: 'static> SubmitParachainHeadsHelper { .0 .checked_sub(stored_best_head.best_head_hash.at_relay_block_number) { - Some(improved_by) if improved_by > Zero::zero() => improved_by, + Some(improved_by) if improved_by > u32::zero() => improved_by, _ => { log::trace!( target: crate::LOG_TARGET, diff --git a/polkadot/node/core/chain-selection/src/db_backend/v1.rs b/polkadot/node/core/chain-selection/src/db_backend/v1.rs index 8831b1e3c36cc..83f78cdf7d074 100644 --- a/polkadot/node/core/chain-selection/src/db_backend/v1.rs +++ b/polkadot/node/core/chain-selection/src/db_backend/v1.rs @@ -246,7 +246,7 @@ impl Backend for DbBackend { }) .enumerate() .take_while(|(idx, r)| { - r.as_ref().map_or(true, |(at, _)| *at <= up_to.into() && *idx < max_elements) + r.as_ref().map_or(true, |(at, _)| *at <= up_to as u64 && *idx < max_elements) }) .map(|(_, v)| v) .collect::, _>>()?; diff --git a/polkadot/runtime/common/src/crowdloan/mod.rs b/polkadot/runtime/common/src/crowdloan/mod.rs index 74bccf56adf4e..446417fc81c89 100644 --- a/polkadot/runtime/common/src/crowdloan/mod.rs +++ b/polkadot/runtime/common/src/crowdloan/mod.rs @@ -625,7 +625,7 @@ pub mod pallet { pub fn add_memo(origin: OriginFor, index: ParaId, memo: Vec) -> DispatchResult { let who = ensure_signed(origin)?; - ensure!(memo.len() <= T::MaxMemoLength::get().into(), Error::::MemoTooLarge); + ensure!(memo.len() <= T::MaxMemoLength::get() as usize, Error::::MemoTooLarge); let fund = Funds::::get(index).ok_or(Error::::InvalidParaId)?; let (balance, _) = Self::contribution_get(fund.fund_index, &who); diff --git a/substrate/utils/wasm-builder/src/version.rs b/substrate/utils/wasm-builder/src/version.rs index 3a0a306d737db..cb00a095b02e8 100644 --- a/substrate/utils/wasm-builder/src/version.rs +++ b/substrate/utils/wasm-builder/src/version.rs @@ -113,7 +113,14 @@ impl Ord for Version { to_compare .iter() - .find_map(|(l, r)| if l != r { l.partial_cmp(&r) } else { None }) + .find_map(|(l, r)| { + if l != r { + l.as_ref() + .and_then(|l_inner| r.as_ref().and_then(|r_inner| l_inner.partial_cmp(r_inner))) + } else { + None + } + }) // We already checked this right at the beginning, so we should never return here // `Equal`. .unwrap_or(Ordering::Equal) From 5d6c0726d73c151cb2ba5eb6024e3f86b26b0ef5 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 1 Apr 2025 17:16:55 +0300 Subject: [PATCH 03/45] more compilation issues fixes Signed-off-by: Iulian Barbu --- substrate/frame/revive/src/limits.rs | 2 +- substrate/utils/wasm-builder/src/version.rs | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/substrate/frame/revive/src/limits.rs b/substrate/frame/revive/src/limits.rs index 09c611a9b640f..66b40c60edb5a 100644 --- a/substrate/frame/revive/src/limits.rs +++ b/substrate/frame/revive/src/limits.rs @@ -216,7 +216,7 @@ pub mod code { (program.code().len() as u64).saturating_mul(EXTRA_OVERHEAD_PER_CODE_BYTE.into()), ); - if memory_size > STATIC_MEMORY_BYTES.into() { + if memory_size > STATIC_MEMORY_BYTES as u64 { log::debug!(target: LOG_TARGET, "static memory too large: {memory_size} limit: {STATIC_MEMORY_BYTES}"); return Err(Error::::StaticMemoryTooLarge.into()) } diff --git a/substrate/utils/wasm-builder/src/version.rs b/substrate/utils/wasm-builder/src/version.rs index cb00a095b02e8..3a4e4c2375917 100644 --- a/substrate/utils/wasm-builder/src/version.rs +++ b/substrate/utils/wasm-builder/src/version.rs @@ -113,14 +113,7 @@ impl Ord for Version { to_compare .iter() - .find_map(|(l, r)| { - if l != r { - l.as_ref() - .and_then(|l_inner| r.as_ref().and_then(|r_inner| l_inner.partial_cmp(r_inner))) - } else { - None - } - }) + .find_map(|(l, r)| if l != r { l.as_ref().partial_cmp(&r.as_ref()) } else { None }) // We already checked this right at the beginning, so we should never return here // `Equal`. .unwrap_or(Ordering::Equal) From a23c8b378dcbe16d0113a0f284bfddadba604648 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 14:36:29 +0000 Subject: [PATCH 04/45] Update from github-actions[bot] running command 'prdoc' --- prdoc/pr_8118.prdoc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 prdoc/pr_8118.prdoc diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc new file mode 100644 index 0000000000000..75d0fdcfa05ef --- /dev/null +++ b/prdoc/pr_8118.prdoc @@ -0,0 +1,28 @@ +title: ' fix: conversions within the code by making them explicit' +doc: +- audience: Todo + description: |- + # Description + + Syncing templates for stable2412-4 fails for parachain-template: https://github.com/paritytech/polkadot-sdk/actions/runs/14179073884/job/39721894007. This fixes compilation of downstream usage of the crates based on master, and then we should backport to `stable2412` & `stable2503`. + + ## Integration + + N/A + + ## Review Notes + + The changes in this PR were done by compiling `parachin-template` repo with path dependencies based on `master` & `stable2412` branches, until it compiled successfully for `stable2412`, while for `master` (which should be similar to `2503`) there are still compilation errors but they are due to not bringing the new code from `polkadot-sdk` monorepo to `parachain-template` repository, not due to dependencies failing to compile. +crates: +- name: polkadot-runtime-parachains + bump: major +- name: pallet-bridge-parachains + bump: major +- name: polkadot-node-core-chain-selection + bump: major +- name: polkadot-runtime-common + bump: major +- name: substrate-wasm-builder + bump: major +- name: pallet-revive + bump: major From 09ef1b64f34422d80ed6f039caad4bcf61ea352f Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 1 Apr 2025 17:47:13 +0300 Subject: [PATCH 05/45] polished prdoc Signed-off-by: Iulian Barbu --- prdoc/pr_8118.prdoc | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 75d0fdcfa05ef..22bfe24579f41 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -2,27 +2,17 @@ title: ' fix: conversions within the code by making them explicit' doc: - audience: Todo description: |- - # Description - - Syncing templates for stable2412-4 fails for parachain-template: https://github.com/paritytech/polkadot-sdk/actions/runs/14179073884/job/39721894007. This fixes compilation of downstream usage of the crates based on master, and then we should backport to `stable2412` & `stable2503`. - - ## Integration - - N/A - - ## Review Notes - - The changes in this PR were done by compiling `parachin-template` repo with path dependencies based on `master` & `stable2412` branches, until it compiled successfully for `stable2412`, while for `master` (which should be similar to `2503`) there are still compilation errors but they are due to not bringing the new code from `polkadot-sdk` monorepo to `parachain-template` repository, not due to dependencies failing to compile. + Fix various compilation issues for crates in polkadot-sdk which are consumed by the templates. crates: - name: polkadot-runtime-parachains - bump: major + bump: patch - name: pallet-bridge-parachains - bump: major + bump: patch - name: polkadot-node-core-chain-selection - bump: major + bump: patch - name: polkadot-runtime-common - bump: major + bump: patch - name: substrate-wasm-builder - bump: major + bump: patch - name: pallet-revive - bump: major + bump: patch From 7a60b8ad8f872f2583422ed7965d6f60ca4d9ced Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 1 Apr 2025 17:51:11 +0300 Subject: [PATCH 06/45] fix title Signed-off-by: Iulian Barbu --- prdoc/pr_8118.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 22bfe24579f41..dc222703448b4 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,4 +1,4 @@ -title: ' fix: conversions within the code by making them explicit' +title: Fix conversions within the code by making them explicit doc: - audience: Todo description: |- From 91617312c27d87f7a851c71b5b9d717c9cc0dc0a Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 1 Apr 2025 17:58:19 +0300 Subject: [PATCH 07/45] simplify fix Signed-off-by: Iulian Barbu --- substrate/utils/wasm-builder/src/version.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/utils/wasm-builder/src/version.rs b/substrate/utils/wasm-builder/src/version.rs index 3a4e4c2375917..3d6179b71281c 100644 --- a/substrate/utils/wasm-builder/src/version.rs +++ b/substrate/utils/wasm-builder/src/version.rs @@ -113,7 +113,7 @@ impl Ord for Version { to_compare .iter() - .find_map(|(l, r)| if l != r { l.as_ref().partial_cmp(&r.as_ref()) } else { None }) + .find_map(|(l, r)| if l != r { l.partial_cmp(r) } else { None }) // We already checked this right at the beginning, so we should never return here // `Equal`. .unwrap_or(Ordering::Equal) From 8612c78251be02c965b3fdcfe845135b390907c5 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 1 Apr 2025 18:01:39 +0300 Subject: [PATCH 08/45] fix prdoc title Signed-off-by: Iulian Barbu --- prdoc/pr_8118.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index dc222703448b4..3198075c7c08b 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,4 +1,4 @@ -title: Fix conversions within the code by making them explicit +title: Fix compilation through explicit conversions doc: - audience: Todo description: |- From 10706cba8be4fd63a38fa3a893e257c5d437e792 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 1 Apr 2025 18:04:53 +0300 Subject: [PATCH 09/45] add audience Signed-off-by: Iulian Barbu --- prdoc/pr_8118.prdoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 3198075c7c08b..ba9eb899ef319 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,8 +1,9 @@ title: Fix compilation through explicit conversions doc: -- audience: Todo +- audience: Node Dev, Runtime Dev description: |- Fix various compilation issues for crates in polkadot-sdk which are consumed by the templates. + crates: - name: polkadot-runtime-parachains bump: patch From 1d7980c405e4b30372256b7c8fa19d43e48d6ec0 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 1 Apr 2025 21:10:13 +0300 Subject: [PATCH 10/45] fix prdoc Signed-off-by: Iulian Barbu --- prdoc/pr_8118.prdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index ba9eb899ef319..97e06a5c7013d 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,8 +1,8 @@ title: Fix compilation through explicit conversions doc: -- audience: Node Dev, Runtime Dev +- audience: [Node Dev, Runtime Dev] description: |- - Fix various compilation issues for crates in polkadot-sdk which are consumed by the templates. + Fix various compilation issues for crates in polkadot-sdk which are consumed by the templates. crates: - name: polkadot-runtime-parachains From da3b68a5710be8bc785ac77e0bed295aab645057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 4 Apr 2025 14:28:51 +0200 Subject: [PATCH 11/45] Bump deranged & time --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 736fd100f1057..0a7c08a299cab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5241,9 +5241,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.11" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +checksum = "28cfac68e08048ae1883171632c2aef3ebc555621ae56fbccce1cbf22dd7f058" dependencies = [ "powerfmt", ] @@ -25491,9 +25491,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.36" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ "deranged", "itoa", @@ -25508,15 +25508,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" dependencies = [ "num-conv", "time-core", From 611031bc21660bd8579782710e936038664ebccc Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Fri, 4 Apr 2025 22:04:45 +0300 Subject: [PATCH 12/45] fix compilation after upgrading degraded Signed-off-by: Iulian Barbu --- substrate/frame/society/src/tests.rs | 8 ++++---- substrate/frame/staking/src/tests.rs | 4 ++-- substrate/primitives/npos-elections/src/mock.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/substrate/frame/society/src/tests.rs b/substrate/frame/society/src/tests.rs index 22832f18b6fe0..fd8da746d649d 100644 --- a/substrate/frame/society/src/tests.rs +++ b/substrate/frame/society/src/tests.rs @@ -279,7 +279,7 @@ fn bidding_works() { assert_eq!(Pot::::get(), 1_800); assert_eq!(Balances::free_balance(Society::account_id()), 8_800); // No more candidates satisfy the requirements - assert_eq!(candidacies(), vec![]); + assert_eq!(candidacies(), vec![] as Vec<(u128, Candidacy)>); assert_ok!(Society::defender_vote(Origin::signed(10), true)); // Keep defender around // Next period System::run_to_block::(16); @@ -587,7 +587,7 @@ fn suspended_candidate_rejected_works() { next_intake(); conclude_intake(false, None); assert_eq!(members(), vec![10, 20, 30, 40, 50]); - assert_eq!(candidates(), vec![]); + assert_eq!(candidates(), vec![] as Vec); assert_eq!(Balances::free_balance(60), 25); assert_eq!(Balances::reserved_balance(60), 0); assert_eq!(Balances::free_balance(Society::account_id()), 10030); @@ -1301,7 +1301,7 @@ fn resign_candidacy_works() { assert_eq!(candidates(), vec![30]); assert_ok!(Society::resign_candidacy(Origin::signed(30))); // 30 candidacy has gone. - assert_eq!(candidates(), vec![]); + assert_eq!(candidates(), vec![] as Vec); }); } @@ -1318,6 +1318,6 @@ fn drop_candidate_works() { System::run_to_block::(12); assert_ok!(Society::drop_candidate(Origin::signed(50), 40)); // 40 candidacy has gone. - assert_eq!(candidates(), vec![]); + assert_eq!(candidates(), vec![] as Vec); }); } diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 1b3411b65360d..4879522d3c11d 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -7363,8 +7363,8 @@ mod ledger { assert_eq!(ledger_updated.stash, stash); // Check `active` and `total` values match the original ledger set by controller. - assert_eq!(ledger_updated.active, (10 + ctlr).into()); - assert_eq!(ledger_updated.total, (10 + ctlr).into()); + assert_eq!(ledger_updated.active, (10 + ctlr) as u128); + assert_eq!(ledger_updated.total, (10 + ctlr) as u128); } }) } diff --git a/substrate/primitives/npos-elections/src/mock.rs b/substrate/primitives/npos-elections/src/mock.rs index 91757404145f3..717c20124b4fb 100644 --- a/substrate/primitives/npos-elections/src/mock.rs +++ b/substrate/primitives/npos-elections/src/mock.rs @@ -302,7 +302,7 @@ pub fn check_assignments_sum(assignments: &[Assignment()); - assert_eq!(sum, T::ACCURACY.saturated_into(), "Assignment ratio sum is not 100%"); + assert_eq!(sum, T::ACCURACY.saturated_into::(), "Assignment ratio sum is not 100%"); } } From 28aaff990ebd57fa5624df3f4e79b9573542f03b Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Fri, 4 Apr 2025 22:24:22 +0300 Subject: [PATCH 13/45] more fixes Signed-off-by: Iulian Barbu --- bridges/relays/messages/src/message_race_delivery.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/relays/messages/src/message_race_delivery.rs b/bridges/relays/messages/src/message_race_delivery.rs index b09533a4ddc1d..a184e0ec5acc9 100644 --- a/bridges/relays/messages/src/message_race_delivery.rs +++ b/bridges/relays/messages/src/message_race_delivery.rs @@ -510,7 +510,7 @@ where .flat_map(|(_, subrange)| { subrange .iter() - .filter(|(nonce, _)| range.contains(nonce)) + .filter(|(nonce, _)| range.contains(&nonce)) .map(|(_, details)| details.dispatch_weight) }) .fold(Weight::zero(), |total, weight| total.saturating_add(weight)) From 195349fe2773d47848813cca61507822ee0c6d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 5 Apr 2025 09:21:46 +0200 Subject: [PATCH 14/45] Update bridges/relays/messages/src/message_race_delivery.rs --- bridges/relays/messages/src/message_race_delivery.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/relays/messages/src/message_race_delivery.rs b/bridges/relays/messages/src/message_race_delivery.rs index a184e0ec5acc9..b09533a4ddc1d 100644 --- a/bridges/relays/messages/src/message_race_delivery.rs +++ b/bridges/relays/messages/src/message_race_delivery.rs @@ -510,7 +510,7 @@ where .flat_map(|(_, subrange)| { subrange .iter() - .filter(|(nonce, _)| range.contains(&nonce)) + .filter(|(nonce, _)| range.contains(nonce)) .map(|(_, details)| details.dispatch_weight) }) .fold(Weight::zero(), |total, weight| total.saturating_add(weight)) From 11195881c3cc0af31e5fd0694741d60c3a129841 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Mon, 7 Apr 2025 11:17:17 +0300 Subject: [PATCH 15/45] fix compilation issue Signed-off-by: Iulian Barbu --- bridges/relays/messages/src/message_race_delivery.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridges/relays/messages/src/message_race_delivery.rs b/bridges/relays/messages/src/message_race_delivery.rs index b09533a4ddc1d..3db3c1ba11acc 100644 --- a/bridges/relays/messages/src/message_race_delivery.rs +++ b/bridges/relays/messages/src/message_race_delivery.rs @@ -1,4 +1,4 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// Copyright 2019-2021 Parity Technologies (UK) Ltd.message_race_delivera // This file is part of Parity Bridges Common. // Parity Bridges Common is free software: you can redistribute it and/or modify @@ -510,7 +510,7 @@ where .flat_map(|(_, subrange)| { subrange .iter() - .filter(|(nonce, _)| range.contains(nonce)) + .filter(|(nonce, _)| range.contains(*nonce)) .map(|(_, details)| details.dispatch_weight) }) .fold(Weight::zero(), |total, weight| total.saturating_add(weight)) From 7d2a97d127f549a5a1ff84f5265185de11644071 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Mon, 7 Apr 2025 12:34:20 +0300 Subject: [PATCH 16/45] fix more compilation issues Signed-off-by: Iulian Barbu --- substrate/frame/broker/src/core_mask.rs | 2 +- substrate/frame/nomination-pools/src/mock.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/broker/src/core_mask.rs b/substrate/frame/broker/src/core_mask.rs index 0ce3186b916dd..e02ee396e177a 100644 --- a/substrate/frame/broker/src/core_mask.rs +++ b/substrate/frame/broker/src/core_mask.rs @@ -181,7 +181,7 @@ mod tests { assert_eq!(u128::from(CoreMask::complete()), 0xfffff_fffff_fffff_fffff); assert_eq!( 0x12345_67890_abcde_f0123u128, - CoreMask([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x01, 0x23]).into(), + u128::from(CoreMask([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x01, 0x23])), ); } diff --git a/substrate/frame/nomination-pools/src/mock.rs b/substrate/frame/nomination-pools/src/mock.rs index b97d98d66948e..aefb1d2055541 100644 --- a/substrate/frame/nomination-pools/src/mock.rs +++ b/substrate/frame/nomination-pools/src/mock.rs @@ -737,7 +737,7 @@ mod test { use super::*; #[test] fn u256_to_balance_convert_works() { - assert_eq!(U256ToBalance::convert(0u32.into()), Zero::zero()); + assert_eq!(U256ToBalance::convert(0u32.into()), u128::zero()); assert_eq!(U256ToBalance::convert(Balance::max_value().into()), Balance::max_value()) } From c273bb8090fb499db436cfa3e54be3f018318be0 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Mon, 7 Apr 2025 14:23:46 +0300 Subject: [PATCH 17/45] one more fix Signed-off-by: Iulian Barbu --- polkadot/node/core/approval-voting/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/node/core/approval-voting/src/tests.rs b/polkadot/node/core/approval-voting/src/tests.rs index 9fe716833b882..6575eb6580f3e 100644 --- a/polkadot/node/core/approval-voting/src/tests.rs +++ b/polkadot/node/core/approval-voting/src/tests.rs @@ -816,7 +816,7 @@ impl ChainBuilder { parent_hash != Self::GENESIS_PARENT_HASH, "cannot add block with genesis parent hash" ); - assert!(self.blocks_by_hash.len() < u8::MAX.into()); + assert!(self.blocks_by_hash.len() < u8::MAX as usize); self.add_block_inner(hash, parent_hash, number, config) } From eb99995ef0b40abff3de23b185d959b614142ee3 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Mon, 7 Apr 2025 15:07:45 +0300 Subject: [PATCH 18/45] fix polkadot/service tests Signed-off-by: Iulian Barbu --- polkadot/node/service/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/node/service/src/tests.rs b/polkadot/node/service/src/tests.rs index 78bbfcd5444f0..7c229cfed05a7 100644 --- a/polkadot/node/service/src/tests.rs +++ b/polkadot/node/service/src/tests.rs @@ -243,7 +243,7 @@ impl ChainBuilder { parent_hash != Self::GENESIS_PARENT_HASH, "cannot add block with genesis parent hash" ); - assert!(self.0.blocks_by_hash.len() < u8::MAX.into()); + assert!(self.0.blocks_by_hash.len() < u8::MAX as usize); self.add_block_inner(hash, parent_hash, number) } From 3dd4fb519d81d35ab24ed835824c6e810d749262 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Mon, 7 Apr 2025 16:24:23 +0300 Subject: [PATCH 19/45] fix yet another Signed-off-by: Iulian Barbu --- cumulus/pallets/parachain-system/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/pallets/parachain-system/src/mock.rs b/cumulus/pallets/parachain-system/src/mock.rs index ea0f227d72579..0a3df489b3630 100644 --- a/cumulus/pallets/parachain-system/src/mock.rs +++ b/cumulus/pallets/parachain-system/src/mock.rs @@ -379,7 +379,7 @@ impl BlockTests { .unwrap_or(*n as RelayChainBlockNumber); // clear pending updates, as applicable if let Some(upgrade_block) = self.pending_upgrade { - if n >= &upgrade_block.into() { + if n >= &(upgrade_block as u64) { self.pending_upgrade = None; } } From a333b40d90b598043855dbbccf47374ee87c1393 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 14:05:29 +0000 Subject: [PATCH 20/45] Update from github-actions[bot] running command 'prdoc --force' --- prdoc/pr_8118.prdoc | 53 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 97e06a5c7013d..90bc3dc79fbc2 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,19 +1,54 @@ -title: Fix compilation through explicit conversions +title: ' Fix compilation by making conversions explicit' doc: -- audience: [Node Dev, Runtime Dev] +- audience: Todo description: |- - Fix various compilation issues for crates in polkadot-sdk which are consumed by the templates. + # Description + Syncing templates for stable2412-4 fails for each template because of compilation issues like we've seen here: https://github.com/paritytech/polkadot-sdk/pull/8094. Failing PRs given in the Review Notes section. + + This fixes compilation of downstream usage of the crates based on master. We should backport to `stable2412` & `stable2503`. I used rustc 1.84.1 to test the fixes. + + Closes #8007 + + ## Integration + + N/A + + ## Review Notes + + The changes in this PR were backported locally on top of `stable2412` and then path dependencies were added in the following PRs (opened after syncing them with stable2412-4) for each template's monorepo dependencies: + + 1. https://github.com/paritytech/polkadot-sdk-parachain-template/pull/26. We can not sync templates for parachain-template for stable2412-4 until stable2412-5 (which should include this PR backported), but we can still sync it for past patches (1,2,3) if we would use the `polkadot-sdk` 0.12.2 (published with stable2412-4). So it would be a mix of crates published over a few patches, but it doesn't matter to users, since we don't version the templates repos (we try to keep them in sync with latest & greatest). + 2. https://github.com/paritytech/polkadot-sdk-minimal-template/pull/22 - can not merge due to compilation issues, which should be fixed with stable2412-5 if this PR gets backported to stable2412 branch by then. + 3. https://github.com/paritytech/polkadot-sdk-solochain-template/pull/23 - can not merge due to compilation issues, which should be fixed with stable2412-5 if this PR gets backported to stable2412 branch by then. + + **NOTE**: For next stable releases we should double check each template builds correctly with path dependencies based on the stable release just before publishing the crates from there. A CI job that does this automatically might be added by then: https://github.com/paritytech/polkadot-sdk/issues/8123. crates: - name: polkadot-runtime-parachains - bump: patch + bump: major - name: pallet-bridge-parachains - bump: patch + bump: major - name: polkadot-node-core-chain-selection - bump: patch + bump: major - name: polkadot-runtime-common - bump: patch + bump: major - name: substrate-wasm-builder - bump: patch + bump: major - name: pallet-revive - bump: patch + bump: major +- name: pallet-society + bump: major +- name: pallet-staking + bump: major +- name: sp-npos-elections + bump: major +- name: pallet-broker + bump: major +- name: pallet-nomination-pools + bump: major +- name: polkadot-node-core-approval-voting + bump: major +- name: polkadot-service + bump: major +- name: cumulus-pallet-parachain-system + bump: major From 70aa1de3db3fdff99b7e46a2688a6fd4e3feea9e Mon Sep 17 00:00:00 2001 From: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:18:08 +0300 Subject: [PATCH 21/45] Update prdoc/pr_8118.prdoc --- prdoc/pr_8118.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 90bc3dc79fbc2..92abec8bda6a4 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,4 +1,4 @@ -title: ' Fix compilation by making conversions explicit' +title: Fix compilation by making conversions explicit doc: - audience: Todo description: |- From 7a1b174032e1079b68f8a123739cffc2f0a8c372 Mon Sep 17 00:00:00 2001 From: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:18:27 +0300 Subject: [PATCH 22/45] Update prdoc/pr_8118.prdoc --- prdoc/pr_8118.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 92abec8bda6a4..165e6f965b996 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,6 +1,6 @@ title: Fix compilation by making conversions explicit doc: -- audience: Todo +- audience: [Node Dev, Runtime Dev] description: |- # Description From a89df75f910bbcd4ac4e3152b4463b91c3c5bd2b Mon Sep 17 00:00:00 2001 From: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:18:49 +0300 Subject: [PATCH 23/45] Update prdoc/pr_8118.prdoc --- prdoc/pr_8118.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 165e6f965b996..6077e529a4078 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -25,7 +25,7 @@ doc: **NOTE**: For next stable releases we should double check each template builds correctly with path dependencies based on the stable release just before publishing the crates from there. A CI job that does this automatically might be added by then: https://github.com/paritytech/polkadot-sdk/issues/8123. crates: - name: polkadot-runtime-parachains - bump: major + bump: patch - name: pallet-bridge-parachains bump: major - name: polkadot-node-core-chain-selection From 8cf821e2cfc473dda18f9d4c71e6d266b4c883c7 Mon Sep 17 00:00:00 2001 From: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:19:13 +0300 Subject: [PATCH 24/45] Update prdoc/pr_8118.prdoc --- prdoc/pr_8118.prdoc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 6077e529a4078..087e856902203 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -35,20 +35,20 @@ crates: - name: substrate-wasm-builder bump: major - name: pallet-revive - bump: major + bump: patch - name: pallet-society - bump: major + bump: patch - name: pallet-staking - bump: major + bump: patch - name: sp-npos-elections - bump: major + bump: patch - name: pallet-broker - bump: major + bump: patch - name: pallet-nomination-pools - bump: major + bump: patch - name: polkadot-node-core-approval-voting - bump: major + bump: patch - name: polkadot-service - bump: major + bump: patch - name: cumulus-pallet-parachain-system - bump: major + bump: patch From ca7416b201f789a45dad146fe7138f5331380bb9 Mon Sep 17 00:00:00 2001 From: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:20:54 +0300 Subject: [PATCH 25/45] Apply suggestions from code review --- prdoc/pr_8118.prdoc | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 087e856902203..74e0cf7ac47ef 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -2,38 +2,18 @@ title: Fix compilation by making conversions explicit doc: - audience: [Node Dev, Runtime Dev] description: |- - # Description - - Syncing templates for stable2412-4 fails for each template because of compilation issues like we've seen here: https://github.com/paritytech/polkadot-sdk/pull/8094. Failing PRs given in the Review Notes section. - - This fixes compilation of downstream usage of the crates based on master. We should backport to `stable2412` & `stable2503`. I used rustc 1.84.1 to test the fixes. - - Closes #8007 - - ## Integration - - N/A - - ## Review Notes - - The changes in this PR were backported locally on top of `stable2412` and then path dependencies were added in the following PRs (opened after syncing them with stable2412-4) for each template's monorepo dependencies: - - 1. https://github.com/paritytech/polkadot-sdk-parachain-template/pull/26. We can not sync templates for parachain-template for stable2412-4 until stable2412-5 (which should include this PR backported), but we can still sync it for past patches (1,2,3) if we would use the `polkadot-sdk` 0.12.2 (published with stable2412-4). So it would be a mix of crates published over a few patches, but it doesn't matter to users, since we don't version the templates repos (we try to keep them in sync with latest & greatest). - 2. https://github.com/paritytech/polkadot-sdk-minimal-template/pull/22 - can not merge due to compilation issues, which should be fixed with stable2412-5 if this PR gets backported to stable2412 branch by then. - 3. https://github.com/paritytech/polkadot-sdk-solochain-template/pull/23 - can not merge due to compilation issues, which should be fixed with stable2412-5 if this PR gets backported to stable2412 branch by then. - - **NOTE**: For next stable releases we should double check each template builds correctly with path dependencies based on the stable release just before publishing the crates from there. A CI job that does this automatically might be added by then: https://github.com/paritytech/polkadot-sdk/issues/8123. + Fix various compilation issues for crates in polkadot-sdk which are consumed by the templates. crates: - name: polkadot-runtime-parachains bump: patch - name: pallet-bridge-parachains - bump: major + bump: patch - name: polkadot-node-core-chain-selection - bump: major + bump: patch - name: polkadot-runtime-common - bump: major + bump: patch - name: substrate-wasm-builder - bump: major + bump: patch - name: pallet-revive bump: patch - name: pallet-society From 12f6db081a381e7589c49b64cd0c909d85bba31f Mon Sep 17 00:00:00 2001 From: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:22:20 +0300 Subject: [PATCH 26/45] Update prdoc/pr_8118.prdoc --- prdoc/pr_8118.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 74e0cf7ac47ef..86db47f154a22 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -2,7 +2,7 @@ title: Fix compilation by making conversions explicit doc: - audience: [Node Dev, Runtime Dev] description: |- - Fix various compilation issues for crates in polkadot-sdk which are consumed by the templates. + Fix various compilation issues for crates in polkadot-sdk after upgrading degrade to 0.4.1. crates: - name: polkadot-runtime-parachains bump: patch From 89fd3bde83a5a8439f3bba106b51a0e475222ff8 Mon Sep 17 00:00:00 2001 From: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Date: Tue, 8 Apr 2025 09:01:36 +0300 Subject: [PATCH 27/45] Update message_race_delivery.rs Co-authored-by: teor --- bridges/relays/messages/src/message_race_delivery.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/relays/messages/src/message_race_delivery.rs b/bridges/relays/messages/src/message_race_delivery.rs index 3db3c1ba11acc..8047b69fc198e 100644 --- a/bridges/relays/messages/src/message_race_delivery.rs +++ b/bridges/relays/messages/src/message_race_delivery.rs @@ -1,4 +1,4 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd.message_race_delivera +// Copyright 2019-2021 Parity Technologies (UK) Ltd. // This file is part of Parity Bridges Common. // Parity Bridges Common is free software: you can redistribute it and/or modify From 120906db5fb68909e66914ea963f4193deb579f0 Mon Sep 17 00:00:00 2001 From: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:25:48 +0300 Subject: [PATCH 28/45] Update polkadot/node/core/chain-selection/src/db_backend/v1.rs Co-authored-by: Guillaume Thiolliere --- polkadot/node/core/chain-selection/src/db_backend/v1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/node/core/chain-selection/src/db_backend/v1.rs b/polkadot/node/core/chain-selection/src/db_backend/v1.rs index 83f78cdf7d074..dcd2e9c595687 100644 --- a/polkadot/node/core/chain-selection/src/db_backend/v1.rs +++ b/polkadot/node/core/chain-selection/src/db_backend/v1.rs @@ -246,7 +246,7 @@ impl Backend for DbBackend { }) .enumerate() .take_while(|(idx, r)| { - r.as_ref().map_or(true, |(at, _)| *at <= up_to as u64 && *idx < max_elements) + r.as_ref().map_or(true, |(at, _)| *at <= up_to && *idx < max_elements) }) .map(|(_, v)| v) .collect::, _>>()?; From adf6ac6454cff1bf7fac1cccd12954e742a7a112 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 8 Apr 2025 18:48:25 +0300 Subject: [PATCH 29/45] use explicit From conversions instead of 'as' Signed-off-by: Iulian Barbu --- cumulus/pallets/parachain-system/src/mock.rs | 2 +- polkadot/node/core/approval-voting/src/tests.rs | 5 ++--- polkadot/node/service/src/tests.rs | 2 +- polkadot/runtime/common/src/crowdloan/mod.rs | 2 +- polkadot/runtime/parachains/src/inclusion/mod.rs | 4 ++-- substrate/frame/revive/src/limits.rs | 2 +- substrate/frame/staking/src/tests.rs | 4 ++-- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cumulus/pallets/parachain-system/src/mock.rs b/cumulus/pallets/parachain-system/src/mock.rs index 0a3df489b3630..3bf645a5de23a 100644 --- a/cumulus/pallets/parachain-system/src/mock.rs +++ b/cumulus/pallets/parachain-system/src/mock.rs @@ -379,7 +379,7 @@ impl BlockTests { .unwrap_or(*n as RelayChainBlockNumber); // clear pending updates, as applicable if let Some(upgrade_block) = self.pending_upgrade { - if n >= &(upgrade_block as u64) { + if *n >= u64::from(upgrade_block) { self.pending_upgrade = None; } } diff --git a/polkadot/node/core/approval-voting/src/tests.rs b/polkadot/node/core/approval-voting/src/tests.rs index 6575eb6580f3e..8d378399d9337 100644 --- a/polkadot/node/core/approval-voting/src/tests.rs +++ b/polkadot/node/core/approval-voting/src/tests.rs @@ -260,8 +260,7 @@ where _relay_vrf_story: polkadot_node_primitives::approval::v1::RelayVRFStory, _assignment: &polkadot_node_primitives::approval::v2::AssignmentCertV2, _backing_groups: Vec, - ) -> Result - { + ) -> Result { self.1(validator_index) } } @@ -816,7 +815,7 @@ impl ChainBuilder { parent_hash != Self::GENESIS_PARENT_HASH, "cannot add block with genesis parent hash" ); - assert!(self.blocks_by_hash.len() < u8::MAX as usize); + assert!(self.blocks_by_hash.len() < usize::from(u8::MAX)); self.add_block_inner(hash, parent_hash, number, config) } diff --git a/polkadot/node/service/src/tests.rs b/polkadot/node/service/src/tests.rs index 7c229cfed05a7..b657f73b058fa 100644 --- a/polkadot/node/service/src/tests.rs +++ b/polkadot/node/service/src/tests.rs @@ -243,7 +243,7 @@ impl ChainBuilder { parent_hash != Self::GENESIS_PARENT_HASH, "cannot add block with genesis parent hash" ); - assert!(self.0.blocks_by_hash.len() < u8::MAX as usize); + assert!(self.0.blocks_by_hash.len() < usize::from(u8::MAX)); self.add_block_inner(hash, parent_hash, number) } diff --git a/polkadot/runtime/common/src/crowdloan/mod.rs b/polkadot/runtime/common/src/crowdloan/mod.rs index 446417fc81c89..e42b18fae358a 100644 --- a/polkadot/runtime/common/src/crowdloan/mod.rs +++ b/polkadot/runtime/common/src/crowdloan/mod.rs @@ -625,7 +625,7 @@ pub mod pallet { pub fn add_memo(origin: OriginFor, index: ParaId, memo: Vec) -> DispatchResult { let who = ensure_signed(origin)?; - ensure!(memo.len() <= T::MaxMemoLength::get() as usize, Error::::MemoTooLarge); + ensure!(memo.len() <= usize::from(T::MaxMemoLength::get()), Error::::MemoTooLarge); let fund = Funds::::get(index).ok_or(Error::::InvalidParaId)?; let (balance, _) = Self::contribution_get(fund.fund_index, &who); diff --git a/polkadot/runtime/parachains/src/inclusion/mod.rs b/polkadot/runtime/parachains/src/inclusion/mod.rs index 648af57ffdee1..accfc75ade338 100644 --- a/polkadot/runtime/parachains/src/inclusion/mod.rs +++ b/polkadot/runtime/parachains/src/inclusion/mod.rs @@ -1320,7 +1320,7 @@ impl CandidateCheckContext { horizontal_messages: &[polkadot_primitives::OutboundHrmpMessage], ) -> Result<(), AcceptanceCheckErr> { ensure!( - head_data.0.len() <= self.config.max_head_data_size as usize, + head_data.0.len() <= usize::from(self.config.max_head_data_size), AcceptanceCheckErr::HeadDataTooLarge, ); @@ -1331,7 +1331,7 @@ impl CandidateCheckContext { AcceptanceCheckErr::PrematureCodeUpgrade, ); ensure!( - new_validation_code.0.len() <= self.config.max_code_size as usize, + new_validation_code.0.len() <= usize::from(self.config.max_code_size), AcceptanceCheckErr::NewCodeTooLarge, ); } diff --git a/substrate/frame/revive/src/limits.rs b/substrate/frame/revive/src/limits.rs index 66b40c60edb5a..4c6e7d753de94 100644 --- a/substrate/frame/revive/src/limits.rs +++ b/substrate/frame/revive/src/limits.rs @@ -216,7 +216,7 @@ pub mod code { (program.code().len() as u64).saturating_mul(EXTRA_OVERHEAD_PER_CODE_BYTE.into()), ); - if memory_size > STATIC_MEMORY_BYTES as u64 { + if memory_size > u64::from(STATIC_MEMORY_BYTES) { log::debug!(target: LOG_TARGET, "static memory too large: {memory_size} limit: {STATIC_MEMORY_BYTES}"); return Err(Error::::StaticMemoryTooLarge.into()) } diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 4879522d3c11d..b0998c38ce8d1 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -7363,8 +7363,8 @@ mod ledger { assert_eq!(ledger_updated.stash, stash); // Check `active` and `total` values match the original ledger set by controller. - assert_eq!(ledger_updated.active, (10 + ctlr) as u128); - assert_eq!(ledger_updated.total, (10 + ctlr) as u128); + assert_eq!(ledger_updated.active, u128::from((10 + ctlr))); + assert_eq!(ledger_updated.total, u128::from((10 + ctlr))); } }) } From b1e105ab5c4141f6399499d670e18d9c4162f6c4 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Tue, 8 Apr 2025 19:00:44 +0300 Subject: [PATCH 30/45] remove unnecessary paranthesis Signed-off-by: Iulian Barbu --- substrate/frame/staking/src/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index b0998c38ce8d1..96c2059862bb0 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -7363,8 +7363,8 @@ mod ledger { assert_eq!(ledger_updated.stash, stash); // Check `active` and `total` values match the original ledger set by controller. - assert_eq!(ledger_updated.active, u128::from((10 + ctlr))); - assert_eq!(ledger_updated.total, u128::from((10 + ctlr))); + assert_eq!(ledger_updated.active, u128::from(10 + ctlr)); + assert_eq!(ledger_updated.total, u128::from(10 + ctlr)); } }) } From 39803747ac9ab36e0efdfd32c936f263457e93cb Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Wed, 9 Apr 2025 11:09:11 +0300 Subject: [PATCH 31/45] handle out of bounds usize conversion Signed-off-by: Iulian Barbu --- .../runtime/parachains/src/inclusion/mod.rs | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/polkadot/runtime/parachains/src/inclusion/mod.rs b/polkadot/runtime/parachains/src/inclusion/mod.rs index accfc75ade338..796a9e2b9b510 100644 --- a/polkadot/runtime/parachains/src/inclusion/mod.rs +++ b/polkadot/runtime/parachains/src/inclusion/mod.rs @@ -353,6 +353,8 @@ pub mod pallet { /// The `para_head` hash in the candidate descriptor doesn't match the hash of the actual /// para head in the commitments. ParaHeadMismatch, + /// Out of bounds conversion. + OutOfBoundsConversion, } /// Candidates pending availability by `ParaId`. They form a chain starting from the latest @@ -391,6 +393,8 @@ enum AcceptanceCheckErr { HrmpWatermark, /// The candidate violated this outbound HRMP acceptance criteria. OutboundHrmp, + /// Check involves size convertion to pointer size which is out of bounds. + UnsupportedPointerSize, } impl From for AcceptanceCheckErr { @@ -1181,6 +1185,7 @@ impl AcceptanceCheckErr { UpwardMessages => Error::::InvalidUpwardMessages, HrmpWatermark => Error::::HrmpWatermarkMishandling, OutboundHrmp => Error::::InvalidOutboundHrmp, + UnsupportedPointerSize => Error::::OutOfBoundsConversion, } } } @@ -1319,19 +1324,34 @@ impl CandidateCheckContext { hrmp_watermark: BlockNumberFor, horizontal_messages: &[polkadot_primitives::OutboundHrmpMessage], ) -> Result<(), AcceptanceCheckErr> { - ensure!( - head_data.0.len() <= usize::from(self.config.max_head_data_size), - AcceptanceCheckErr::HeadDataTooLarge, - ); + // Safe convertions when `self.config.max_head_data_size` is in bounds of `usize` type. + let max_head_data_size = + usize::try_from(self.config.max_head_data_size).map_err(|err| { + log::error!( + target: LOG_TARGET, + "Acceptance check involves an unsupported conversion to pointer size: {err}", + ); + AcceptanceCheckErr::UnsupportedPointerSize + })?; + ensure!(head_data.0.len() <= max_head_data_size, AcceptanceCheckErr::HeadDataTooLarge,); // if any, the code upgrade attempt is allowed. if let Some(new_validation_code) = new_validation_code { + // Safe convertions when `self.config.max_code_size` is in bounds of `usize` type. + let max_code_size = usize::try_from(self.config.max_code_size).map_err(|err| { + log::error!( + target: LOG_TARGET, + "Acceptance check involves an unsupported conversion to pointer size: {err}", + ); + AcceptanceCheckErr::UnsupportedPointerSize + })?; + ensure!( paras::Pallet::::can_upgrade_validation_code(para_id), AcceptanceCheckErr::PrematureCodeUpgrade, ); ensure!( - new_validation_code.0.len() <= usize::from(self.config.max_code_size), + new_validation_code.0.len() <= max_code_size, AcceptanceCheckErr::NewCodeTooLarge, ); } From 4ab7d01ddcebb4a8d0128460860add4e1162b729 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 08:24:25 +0000 Subject: [PATCH 32/45] Update from github-actions[bot] running command 'fmt' --- polkadot/node/core/approval-voting/src/tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/polkadot/node/core/approval-voting/src/tests.rs b/polkadot/node/core/approval-voting/src/tests.rs index 8d378399d9337..ab5a137f04197 100644 --- a/polkadot/node/core/approval-voting/src/tests.rs +++ b/polkadot/node/core/approval-voting/src/tests.rs @@ -260,7 +260,8 @@ where _relay_vrf_story: polkadot_node_primitives::approval::v1::RelayVRFStory, _assignment: &polkadot_node_primitives::approval::v2::AssignmentCertV2, _backing_groups: Vec, - ) -> Result { + ) -> Result + { self.1(validator_index) } } From 5a1274f9ab49cd16d84aaa2c4a92d3a5de274ba4 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Wed, 9 Apr 2025 12:50:05 +0300 Subject: [PATCH 33/45] proper handling errors and rest of conversions Signed-off-by: Iulian Barbu --- .../runtime/parachains/src/inclusion/mod.rs | 24 ++++--------------- prdoc/pr_8118.prdoc | 2 +- substrate/frame/society/src/tests.rs | 10 ++++---- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/polkadot/runtime/parachains/src/inclusion/mod.rs b/polkadot/runtime/parachains/src/inclusion/mod.rs index 796a9e2b9b510..5740532fb90b4 100644 --- a/polkadot/runtime/parachains/src/inclusion/mod.rs +++ b/polkadot/runtime/parachains/src/inclusion/mod.rs @@ -353,8 +353,6 @@ pub mod pallet { /// The `para_head` hash in the candidate descriptor doesn't match the hash of the actual /// para head in the commitments. ParaHeadMismatch, - /// Out of bounds conversion. - OutOfBoundsConversion, } /// Candidates pending availability by `ParaId`. They form a chain starting from the latest @@ -393,8 +391,6 @@ enum AcceptanceCheckErr { HrmpWatermark, /// The candidate violated this outbound HRMP acceptance criteria. OutboundHrmp, - /// Check involves size convertion to pointer size which is out of bounds. - UnsupportedPointerSize, } impl From for AcceptanceCheckErr { @@ -1185,7 +1181,6 @@ impl AcceptanceCheckErr { UpwardMessages => Error::::InvalidUpwardMessages, HrmpWatermark => Error::::HrmpWatermarkMishandling, OutboundHrmp => Error::::InvalidOutboundHrmp, - UnsupportedPointerSize => Error::::OutOfBoundsConversion, } } } @@ -1325,26 +1320,15 @@ impl CandidateCheckContext { horizontal_messages: &[polkadot_primitives::OutboundHrmpMessage], ) -> Result<(), AcceptanceCheckErr> { // Safe convertions when `self.config.max_head_data_size` is in bounds of `usize` type. - let max_head_data_size = - usize::try_from(self.config.max_head_data_size).map_err(|err| { - log::error!( - target: LOG_TARGET, - "Acceptance check involves an unsupported conversion to pointer size: {err}", - ); - AcceptanceCheckErr::UnsupportedPointerSize - })?; + let max_head_data_size = usize::try_from(self.config.max_head_data_size) + .map_err(|_| AcceptanceCheckErr::HeadDataTooLarge)?; ensure!(head_data.0.len() <= max_head_data_size, AcceptanceCheckErr::HeadDataTooLarge,); // if any, the code upgrade attempt is allowed. if let Some(new_validation_code) = new_validation_code { // Safe convertions when `self.config.max_code_size` is in bounds of `usize` type. - let max_code_size = usize::try_from(self.config.max_code_size).map_err(|err| { - log::error!( - target: LOG_TARGET, - "Acceptance check involves an unsupported conversion to pointer size: {err}", - ); - AcceptanceCheckErr::UnsupportedPointerSize - })?; + let max_code_size = usize::try_from(self.config.max_code_size) + .map_err(|_| AcceptanceCheckErr::NewCodeTooLarge)?; ensure!( paras::Pallet::::can_upgrade_validation_code(para_id), diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 86db47f154a22..087734c28be37 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -5,7 +5,7 @@ doc: Fix various compilation issues for crates in polkadot-sdk after upgrading degrade to 0.4.1. crates: - name: polkadot-runtime-parachains - bump: patch + bump: patch - name: pallet-bridge-parachains bump: patch - name: polkadot-node-core-chain-selection diff --git a/substrate/frame/society/src/tests.rs b/substrate/frame/society/src/tests.rs index fd8da746d649d..1d2f45cae4f6a 100644 --- a/substrate/frame/society/src/tests.rs +++ b/substrate/frame/society/src/tests.rs @@ -279,9 +279,9 @@ fn bidding_works() { assert_eq!(Pot::::get(), 1_800); assert_eq!(Balances::free_balance(Society::account_id()), 8_800); // No more candidates satisfy the requirements - assert_eq!(candidacies(), vec![] as Vec<(u128, Candidacy)>); + assert_eq!(candidacies(), Vec::<(u128, Candidacy)>::new()); assert_ok!(Society::defender_vote(Origin::signed(10), true)); // Keep defender around - // Next period + // Next period System::run_to_block::(16); // Same members assert_eq!(members(), vec![10, 30, 40, 50]); @@ -587,7 +587,7 @@ fn suspended_candidate_rejected_works() { next_intake(); conclude_intake(false, None); assert_eq!(members(), vec![10, 20, 30, 40, 50]); - assert_eq!(candidates(), vec![] as Vec); + assert_eq!(candidates(), Vec::::new()); assert_eq!(Balances::free_balance(60), 25); assert_eq!(Balances::reserved_balance(60), 0); assert_eq!(Balances::free_balance(Society::account_id()), 10030); @@ -1301,7 +1301,7 @@ fn resign_candidacy_works() { assert_eq!(candidates(), vec![30]); assert_ok!(Society::resign_candidacy(Origin::signed(30))); // 30 candidacy has gone. - assert_eq!(candidates(), vec![] as Vec); + assert_eq!(candidates(), Vec::::new()); }); } @@ -1318,6 +1318,6 @@ fn drop_candidate_works() { System::run_to_block::(12); assert_ok!(Society::drop_candidate(Origin::signed(50), 40)); // 40 candidacy has gone. - assert_eq!(candidates(), vec![] as Vec); + assert_eq!(candidates(), Vec::::new()); }); } From a3a461d417b9e1d96afb58fc5dd56fdf9d384c5c Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:14:14 +0000 Subject: [PATCH 34/45] Update from github-actions[bot] running command 'fmt' --- substrate/frame/society/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/society/src/tests.rs b/substrate/frame/society/src/tests.rs index 1d2f45cae4f6a..57ad5d838760b 100644 --- a/substrate/frame/society/src/tests.rs +++ b/substrate/frame/society/src/tests.rs @@ -281,7 +281,7 @@ fn bidding_works() { // No more candidates satisfy the requirements assert_eq!(candidacies(), Vec::<(u128, Candidacy)>::new()); assert_ok!(Society::defender_vote(Origin::signed(10), true)); // Keep defender around - // Next period + // Next period System::run_to_block::(16); // Same members assert_eq!(members(), vec![10, 30, 40, 50]); From 4257827daf183141e3062cb4caba9b78593d7d0d Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Wed, 9 Apr 2025 22:03:02 +0300 Subject: [PATCH 35/45] update prdoc and downgrade degrade to 0.4.0 Signed-off-by: Iulian Barbu --- Cargo.lock | 4 ++-- prdoc/pr_8118.prdoc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4c38297d534c..02f26c784bfa2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5302,9 +5302,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cfac68e08048ae1883171632c2aef3ebc555621ae56fbccce1cbf22dd7f058" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", ] diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 087734c28be37..2b52505a4a4ac 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,8 +1,8 @@ -title: Fix compilation by making conversions explicit +title: Make a subset of conversions explicit doc: - audience: [Node Dev, Runtime Dev] description: |- - Fix various compilation issues for crates in polkadot-sdk after upgrading degrade to 0.4.1. + Make some of the conversions safer or explicit. crates: - name: polkadot-runtime-parachains bump: patch From af5df687fbb4c876d8da162f8872ab213384f370 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Wed, 9 Apr 2025 22:26:41 +0300 Subject: [PATCH 36/45] fix prdoc Signed-off-by: Iulian Barbu --- prdoc/pr_8118.prdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 2b52505a4a4ac..1a303bf29e045 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,8 +1,8 @@ -title: Make a subset of conversions explicit +title: Make a subset of conversions explicit and safer doc: - audience: [Node Dev, Runtime Dev] description: |- - Make some of the conversions safer or explicit. + Make a subset of conversions explicit and safer. crates: - name: polkadot-runtime-parachains bump: patch From e610b8f3428b936d0b71b9ed6a7923ba30eb18bd Mon Sep 17 00:00:00 2001 From: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Date: Thu, 10 Apr 2025 13:52:51 +0300 Subject: [PATCH 37/45] Update prdoc/pr_8118.prdoc --- prdoc/pr_8118.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 1a303bf29e045..6b060ec1354c5 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -2,7 +2,7 @@ title: Make a subset of conversions explicit and safer doc: - audience: [Node Dev, Runtime Dev] description: |- - Make a subset of conversions explicit and safer. + Use From impls or type annotations for a subset of type inference based conversions. crates: - name: polkadot-runtime-parachains bump: patch From b26273a130822afbb23fc385b86bf42e9ce53234 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Thu, 10 Apr 2025 16:48:50 +0300 Subject: [PATCH 38/45] rever unnecessary changes Signed-off-by: Iulian Barbu --- bridges/modules/parachains/src/call_ext.rs | 2 +- cumulus/pallets/parachain-system/src/mock.rs | 2 +- .../node/core/approval-voting/src/tests.rs | 5 ++-- .../core/chain-selection/src/db_backend/v1.rs | 2 +- polkadot/node/service/src/tests.rs | 2 +- polkadot/runtime/common/src/crowdloan/mod.rs | 2 +- prdoc/pr_8118.prdoc | 30 ++----------------- substrate/frame/broker/src/core_mask.rs | 2 +- substrate/frame/nomination-pools/src/mock.rs | 2 +- substrate/frame/revive/src/limits.rs | 2 +- substrate/frame/society/src/tests.rs | 8 ++--- substrate/frame/staking/src/tests.rs | 4 +-- .../primitives/npos-elections/src/mock.rs | 2 +- substrate/utils/wasm-builder/src/version.rs | 2 +- 14 files changed, 20 insertions(+), 47 deletions(-) diff --git a/bridges/modules/parachains/src/call_ext.rs b/bridges/modules/parachains/src/call_ext.rs index cc839ce9bd710..b67da03a6315c 100644 --- a/bridges/modules/parachains/src/call_ext.rs +++ b/bridges/modules/parachains/src/call_ext.rs @@ -108,7 +108,7 @@ impl, I: 'static> SubmitParachainHeadsHelper { .0 .checked_sub(stored_best_head.best_head_hash.at_relay_block_number) { - Some(improved_by) if improved_by > u32::zero() => improved_by, + Some(improved_by) if improved_by > Zero::zero() => improved_by, _ => { log::trace!( target: crate::LOG_TARGET, diff --git a/cumulus/pallets/parachain-system/src/mock.rs b/cumulus/pallets/parachain-system/src/mock.rs index 3bf645a5de23a..7a4984bfa5f1c 100644 --- a/cumulus/pallets/parachain-system/src/mock.rs +++ b/cumulus/pallets/parachain-system/src/mock.rs @@ -379,7 +379,7 @@ impl BlockTests { .unwrap_or(*n as RelayChainBlockNumber); // clear pending updates, as applicable if let Some(upgrade_block) = self.pending_upgrade { - if *n >= u64::from(upgrade_block) { + if n >= upgrade_block.into() { self.pending_upgrade = None; } } diff --git a/polkadot/node/core/approval-voting/src/tests.rs b/polkadot/node/core/approval-voting/src/tests.rs index ab5a137f04197..61326c3386763 100644 --- a/polkadot/node/core/approval-voting/src/tests.rs +++ b/polkadot/node/core/approval-voting/src/tests.rs @@ -260,8 +260,7 @@ where _relay_vrf_story: polkadot_node_primitives::approval::v1::RelayVRFStory, _assignment: &polkadot_node_primitives::approval::v2::AssignmentCertV2, _backing_groups: Vec, - ) -> Result - { + ) -> Result { self.1(validator_index) } } @@ -816,7 +815,7 @@ impl ChainBuilder { parent_hash != Self::GENESIS_PARENT_HASH, "cannot add block with genesis parent hash" ); - assert!(self.blocks_by_hash.len() < usize::from(u8::MAX)); + assert!(self.blocks_by_hash.len() < u8::MAX.into()); self.add_block_inner(hash, parent_hash, number, config) } diff --git a/polkadot/node/core/chain-selection/src/db_backend/v1.rs b/polkadot/node/core/chain-selection/src/db_backend/v1.rs index dcd2e9c595687..8831b1e3c36cc 100644 --- a/polkadot/node/core/chain-selection/src/db_backend/v1.rs +++ b/polkadot/node/core/chain-selection/src/db_backend/v1.rs @@ -246,7 +246,7 @@ impl Backend for DbBackend { }) .enumerate() .take_while(|(idx, r)| { - r.as_ref().map_or(true, |(at, _)| *at <= up_to && *idx < max_elements) + r.as_ref().map_or(true, |(at, _)| *at <= up_to.into() && *idx < max_elements) }) .map(|(_, v)| v) .collect::, _>>()?; diff --git a/polkadot/node/service/src/tests.rs b/polkadot/node/service/src/tests.rs index b657f73b058fa..78bbfcd5444f0 100644 --- a/polkadot/node/service/src/tests.rs +++ b/polkadot/node/service/src/tests.rs @@ -243,7 +243,7 @@ impl ChainBuilder { parent_hash != Self::GENESIS_PARENT_HASH, "cannot add block with genesis parent hash" ); - assert!(self.0.blocks_by_hash.len() < usize::from(u8::MAX)); + assert!(self.0.blocks_by_hash.len() < u8::MAX.into()); self.add_block_inner(hash, parent_hash, number) } diff --git a/polkadot/runtime/common/src/crowdloan/mod.rs b/polkadot/runtime/common/src/crowdloan/mod.rs index e42b18fae358a..74bccf56adf4e 100644 --- a/polkadot/runtime/common/src/crowdloan/mod.rs +++ b/polkadot/runtime/common/src/crowdloan/mod.rs @@ -625,7 +625,7 @@ pub mod pallet { pub fn add_memo(origin: OriginFor, index: ParaId, memo: Vec) -> DispatchResult { let who = ensure_signed(origin)?; - ensure!(memo.len() <= usize::from(T::MaxMemoLength::get()), Error::::MemoTooLarge); + ensure!(memo.len() <= T::MaxMemoLength::get().into(), Error::::MemoTooLarge); let fund = Funds::::get(index).ok_or(Error::::InvalidParaId)?; let (balance, _) = Self::contribution_get(fund.fund_index, &who); diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 6b060ec1354c5..33c2e958d9806 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,34 +1,8 @@ -title: Make a subset of conversions explicit and safer +title: Safer conversions in polkadot-runtime-parachains doc: - audience: [Node Dev, Runtime Dev] description: |- - Use From impls or type annotations for a subset of type inference based conversions. + Use TryFrom impls instead of `as` operator for conversions. crates: - name: polkadot-runtime-parachains bump: patch -- name: pallet-bridge-parachains - bump: patch -- name: polkadot-node-core-chain-selection - bump: patch -- name: polkadot-runtime-common - bump: patch -- name: substrate-wasm-builder - bump: patch -- name: pallet-revive - bump: patch -- name: pallet-society - bump: patch -- name: pallet-staking - bump: patch -- name: sp-npos-elections - bump: patch -- name: pallet-broker - bump: patch -- name: pallet-nomination-pools - bump: patch -- name: polkadot-node-core-approval-voting - bump: patch -- name: polkadot-service - bump: patch -- name: cumulus-pallet-parachain-system - bump: patch diff --git a/substrate/frame/broker/src/core_mask.rs b/substrate/frame/broker/src/core_mask.rs index e02ee396e177a..0ce3186b916dd 100644 --- a/substrate/frame/broker/src/core_mask.rs +++ b/substrate/frame/broker/src/core_mask.rs @@ -181,7 +181,7 @@ mod tests { assert_eq!(u128::from(CoreMask::complete()), 0xfffff_fffff_fffff_fffff); assert_eq!( 0x12345_67890_abcde_f0123u128, - u128::from(CoreMask([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x01, 0x23])), + CoreMask([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x01, 0x23]).into(), ); } diff --git a/substrate/frame/nomination-pools/src/mock.rs b/substrate/frame/nomination-pools/src/mock.rs index aefb1d2055541..b97d98d66948e 100644 --- a/substrate/frame/nomination-pools/src/mock.rs +++ b/substrate/frame/nomination-pools/src/mock.rs @@ -737,7 +737,7 @@ mod test { use super::*; #[test] fn u256_to_balance_convert_works() { - assert_eq!(U256ToBalance::convert(0u32.into()), u128::zero()); + assert_eq!(U256ToBalance::convert(0u32.into()), Zero::zero()); assert_eq!(U256ToBalance::convert(Balance::max_value().into()), Balance::max_value()) } diff --git a/substrate/frame/revive/src/limits.rs b/substrate/frame/revive/src/limits.rs index 4c6e7d753de94..09c611a9b640f 100644 --- a/substrate/frame/revive/src/limits.rs +++ b/substrate/frame/revive/src/limits.rs @@ -216,7 +216,7 @@ pub mod code { (program.code().len() as u64).saturating_mul(EXTRA_OVERHEAD_PER_CODE_BYTE.into()), ); - if memory_size > u64::from(STATIC_MEMORY_BYTES) { + if memory_size > STATIC_MEMORY_BYTES.into() { log::debug!(target: LOG_TARGET, "static memory too large: {memory_size} limit: {STATIC_MEMORY_BYTES}"); return Err(Error::::StaticMemoryTooLarge.into()) } diff --git a/substrate/frame/society/src/tests.rs b/substrate/frame/society/src/tests.rs index 57ad5d838760b..cff2bb0234614 100644 --- a/substrate/frame/society/src/tests.rs +++ b/substrate/frame/society/src/tests.rs @@ -281,7 +281,7 @@ fn bidding_works() { // No more candidates satisfy the requirements assert_eq!(candidacies(), Vec::<(u128, Candidacy)>::new()); assert_ok!(Society::defender_vote(Origin::signed(10), true)); // Keep defender around - // Next period + // Next period System::run_to_block::(16); // Same members assert_eq!(members(), vec![10, 30, 40, 50]); @@ -587,7 +587,7 @@ fn suspended_candidate_rejected_works() { next_intake(); conclude_intake(false, None); assert_eq!(members(), vec![10, 20, 30, 40, 50]); - assert_eq!(candidates(), Vec::::new()); + assert_eq!(candidates(), vec![]); assert_eq!(Balances::free_balance(60), 25); assert_eq!(Balances::reserved_balance(60), 0); assert_eq!(Balances::free_balance(Society::account_id()), 10030); @@ -1301,7 +1301,7 @@ fn resign_candidacy_works() { assert_eq!(candidates(), vec![30]); assert_ok!(Society::resign_candidacy(Origin::signed(30))); // 30 candidacy has gone. - assert_eq!(candidates(), Vec::::new()); + assert_eq!(candidates(), vec![]); }); } @@ -1318,6 +1318,6 @@ fn drop_candidate_works() { System::run_to_block::(12); assert_ok!(Society::drop_candidate(Origin::signed(50), 40)); // 40 candidacy has gone. - assert_eq!(candidates(), Vec::::new()); + assert_eq!(candidates(), vec![]); }); } diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 00187793e7699..20b9b55c8f69d 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -7385,8 +7385,8 @@ mod ledger { assert_eq!(ledger_updated.stash, stash); // Check `active` and `total` values match the original ledger set by controller. - assert_eq!(ledger_updated.active, u128::from(10 + ctlr)); - assert_eq!(ledger_updated.total, u128::from(10 + ctlr)); + assert_eq!(ledger_updated.active, (10 + ctlr).into()); + assert_eq!(ledger_updated.total, (10 + ctlr).into()); } }) } diff --git a/substrate/primitives/npos-elections/src/mock.rs b/substrate/primitives/npos-elections/src/mock.rs index 717c20124b4fb..91757404145f3 100644 --- a/substrate/primitives/npos-elections/src/mock.rs +++ b/substrate/primitives/npos-elections/src/mock.rs @@ -302,7 +302,7 @@ pub fn check_assignments_sum(assignments: &[Assignment()); - assert_eq!(sum, T::ACCURACY.saturated_into::(), "Assignment ratio sum is not 100%"); + assert_eq!(sum, T::ACCURACY.saturated_into(), "Assignment ratio sum is not 100%"); } } diff --git a/substrate/utils/wasm-builder/src/version.rs b/substrate/utils/wasm-builder/src/version.rs index 3d6179b71281c..3a0a306d737db 100644 --- a/substrate/utils/wasm-builder/src/version.rs +++ b/substrate/utils/wasm-builder/src/version.rs @@ -113,7 +113,7 @@ impl Ord for Version { to_compare .iter() - .find_map(|(l, r)| if l != r { l.partial_cmp(r) } else { None }) + .find_map(|(l, r)| if l != r { l.partial_cmp(&r) } else { None }) // We already checked this right at the beginning, so we should never return here // `Equal`. .unwrap_or(Ordering::Equal) From 8d4d0800bb5affc1a10bccd7c8403e6ba34ef14b Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Thu, 10 Apr 2025 16:54:57 +0300 Subject: [PATCH 39/45] some leftovers Signed-off-by: Iulian Barbu --- bridges/relays/messages/src/message_race_delivery.rs | 2 +- cumulus/pallets/parachain-system/src/mock.rs | 2 +- polkadot/node/core/approval-voting/src/tests.rs | 3 ++- substrate/frame/society/src/tests.rs | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bridges/relays/messages/src/message_race_delivery.rs b/bridges/relays/messages/src/message_race_delivery.rs index 8047b69fc198e..b09533a4ddc1d 100644 --- a/bridges/relays/messages/src/message_race_delivery.rs +++ b/bridges/relays/messages/src/message_race_delivery.rs @@ -510,7 +510,7 @@ where .flat_map(|(_, subrange)| { subrange .iter() - .filter(|(nonce, _)| range.contains(*nonce)) + .filter(|(nonce, _)| range.contains(nonce)) .map(|(_, details)| details.dispatch_weight) }) .fold(Weight::zero(), |total, weight| total.saturating_add(weight)) diff --git a/cumulus/pallets/parachain-system/src/mock.rs b/cumulus/pallets/parachain-system/src/mock.rs index 7a4984bfa5f1c..ea0f227d72579 100644 --- a/cumulus/pallets/parachain-system/src/mock.rs +++ b/cumulus/pallets/parachain-system/src/mock.rs @@ -379,7 +379,7 @@ impl BlockTests { .unwrap_or(*n as RelayChainBlockNumber); // clear pending updates, as applicable if let Some(upgrade_block) = self.pending_upgrade { - if n >= upgrade_block.into() { + if n >= &upgrade_block.into() { self.pending_upgrade = None; } } diff --git a/polkadot/node/core/approval-voting/src/tests.rs b/polkadot/node/core/approval-voting/src/tests.rs index 61326c3386763..df31dd8a2f46b 100644 --- a/polkadot/node/core/approval-voting/src/tests.rs +++ b/polkadot/node/core/approval-voting/src/tests.rs @@ -260,7 +260,8 @@ where _relay_vrf_story: polkadot_node_primitives::approval::v1::RelayVRFStory, _assignment: &polkadot_node_primitives::approval::v2::AssignmentCertV2, _backing_groups: Vec, - ) -> Result { + ) -> Result + { self.1(validator_index) } } diff --git a/substrate/frame/society/src/tests.rs b/substrate/frame/society/src/tests.rs index cff2bb0234614..d5027742c677e 100644 --- a/substrate/frame/society/src/tests.rs +++ b/substrate/frame/society/src/tests.rs @@ -279,7 +279,7 @@ fn bidding_works() { assert_eq!(Pot::::get(), 1_800); assert_eq!(Balances::free_balance(Society::account_id()), 8_800); // No more candidates satisfy the requirements - assert_eq!(candidacies(), Vec::<(u128, Candidacy)>::new()); + assert_eq!(candidacies(), vec![]); assert_ok!(Society::defender_vote(Origin::signed(10), true)); // Keep defender around // Next period System::run_to_block::(16); From 2076e2c93aa0824ea2418c2a60a69bf0c2e3dad5 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 10 Apr 2025 13:59:30 +0000 Subject: [PATCH 40/45] Update from github-actions[bot] running command 'fmt' --- polkadot/node/core/approval-voting/src/tests.rs | 2 +- substrate/frame/society/src/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/polkadot/node/core/approval-voting/src/tests.rs b/polkadot/node/core/approval-voting/src/tests.rs index df31dd8a2f46b..9fe716833b882 100644 --- a/polkadot/node/core/approval-voting/src/tests.rs +++ b/polkadot/node/core/approval-voting/src/tests.rs @@ -260,7 +260,7 @@ where _relay_vrf_story: polkadot_node_primitives::approval::v1::RelayVRFStory, _assignment: &polkadot_node_primitives::approval::v2::AssignmentCertV2, _backing_groups: Vec, - ) -> Result + ) -> Result { self.1(validator_index) } diff --git a/substrate/frame/society/src/tests.rs b/substrate/frame/society/src/tests.rs index d5027742c677e..22832f18b6fe0 100644 --- a/substrate/frame/society/src/tests.rs +++ b/substrate/frame/society/src/tests.rs @@ -281,7 +281,7 @@ fn bidding_works() { // No more candidates satisfy the requirements assert_eq!(candidacies(), vec![]); assert_ok!(Society::defender_vote(Origin::signed(10), true)); // Keep defender around - // Next period + // Next period System::run_to_block::(16); // Same members assert_eq!(members(), vec![10, 30, 40, 50]); From ef51bd353dcadf89697ed22436e33c3c8200a37c Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Fri, 11 Apr 2025 17:37:00 +0300 Subject: [PATCH 41/45] revert deranged upgrade Signed-off-by: Iulian Barbu --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02f26c784bfa2..b79d21bca22ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5302,9 +5302,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.4.0" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", ] @@ -25272,9 +25272,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.41" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8" dependencies = [ "deranged", "itoa", @@ -25289,15 +25289,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.4" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.22" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", From 14d5d9a6e68fcd63c0cfa4765f06c553d4d4efc5 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Fri, 11 Apr 2025 17:40:01 +0300 Subject: [PATCH 42/45] rever gitignore Signed-off-by: Iulian Barbu --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2bd0c812be8ed..4fe0701fde684 100644 --- a/.gitignore +++ b/.gitignore @@ -42,7 +42,3 @@ target/ *.scale justfile rustc-ice-* -.bacon-locations -bacon.log -bacon-ls.log -.config/bacon.toml From 7ca615683073bdeb156c952e0af9dc3fa25a4973 Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Fri, 11 Apr 2025 17:44:22 +0300 Subject: [PATCH 43/45] fix time hash in cargo.lock Signed-off-by: Iulian Barbu --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index b79d21bca22ad..188b3c23983e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25274,7 +25274,7 @@ dependencies = [ name = "time" version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", From aea2caed8e12d11af293657bcba4c44a6ffbb6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 11 Apr 2025 18:29:15 +0200 Subject: [PATCH 44/45] Update polkadot/runtime/parachains/src/inclusion/mod.rs --- polkadot/runtime/parachains/src/inclusion/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/runtime/parachains/src/inclusion/mod.rs b/polkadot/runtime/parachains/src/inclusion/mod.rs index 5740532fb90b4..50fef26163d8c 100644 --- a/polkadot/runtime/parachains/src/inclusion/mod.rs +++ b/polkadot/runtime/parachains/src/inclusion/mod.rs @@ -1322,7 +1322,7 @@ impl CandidateCheckContext { // Safe convertions when `self.config.max_head_data_size` is in bounds of `usize` type. let max_head_data_size = usize::try_from(self.config.max_head_data_size) .map_err(|_| AcceptanceCheckErr::HeadDataTooLarge)?; - ensure!(head_data.0.len() <= max_head_data_size, AcceptanceCheckErr::HeadDataTooLarge,); + ensure!(head_data.0.len() <= max_head_data_size, AcceptanceCheckErr::HeadDataTooLarge); // if any, the code upgrade attempt is allowed. if let Some(new_validation_code) = new_validation_code { From 44a5a0e664c9522a3ce908a6321e5d54ccd7f4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 11 Apr 2025 18:29:23 +0200 Subject: [PATCH 45/45] Update prdoc/pr_8118.prdoc --- prdoc/pr_8118.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_8118.prdoc b/prdoc/pr_8118.prdoc index 33c2e958d9806..ae997635d7da1 100644 --- a/prdoc/pr_8118.prdoc +++ b/prdoc/pr_8118.prdoc @@ -1,6 +1,6 @@ title: Safer conversions in polkadot-runtime-parachains doc: -- audience: [Node Dev, Runtime Dev] +- audience: Runtime Dev description: |- Use TryFrom impls instead of `as` operator for conversions. crates: