diff --git a/Cargo.lock b/Cargo.lock index 2efdc7c4cac0..9287f6dad04b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2173,7 +2173,6 @@ dependencies = [ "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", - "static_assertions", "substrate-wasm-builder", "testnet-parachains-constants", "xcm-runtime-apis", @@ -2331,7 +2330,6 @@ dependencies = [ "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", - "static_assertions", "substrate-wasm-builder", "testnet-parachains-constants", "westend-runtime-constants", diff --git a/bridges/bin/runtime-common/src/integrity.rs b/bridges/bin/runtime-common/src/integrity.rs index f661db8a2205..a0a9367dd140 100644 --- a/bridges/bin/runtime-common/src/integrity.rs +++ b/bridges/bin/runtime-common/src/integrity.rs @@ -27,17 +27,25 @@ use frame_support::{storage::generator::StorageValue, traits::Get, weights::Weig use frame_system::limits; use pallet_bridge_messages::WeightInfoExt as _; +// Re-export to avoid include all dependencies everywhere. +#[doc(hidden)] +pub mod __private { + pub use bp_xcm_bridge_hub; + pub use static_assertions; +} + /// Macro that ensures that the runtime configuration and chain primitives crate are sharing /// the same types (nonce, block number, hash, hasher, account id and header). #[macro_export] macro_rules! assert_chain_types( ( runtime: $r:path, this_chain: $this:path ) => { { + use frame_system::{Config as SystemConfig, pallet_prelude::{BlockNumberFor, HeaderFor}}; + use $crate::integrity::__private::static_assertions::assert_type_eq_all; + // if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard // configuration is used), or something has broke existing configuration (meaning that all bridged chains // and relays will stop functioning) - use frame_system::{Config as SystemConfig, pallet_prelude::{BlockNumberFor, HeaderFor}}; - use static_assertions::assert_type_eq_all; assert_type_eq_all!(<$r as SystemConfig>::Nonce, bp_runtime::NonceOf<$this>); assert_type_eq_all!(BlockNumberFor<$r>, bp_runtime::BlockNumberOf<$this>); @@ -60,14 +68,15 @@ macro_rules! assert_bridge_messages_pallet_types( bridged_chain: $bridged:path, ) => { { - // if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard - // configuration is used), or something has broke existing configuration (meaning that all bridged chains - // and relays will stop functioning) use $crate::messages_xcm_extension::XcmAsPlainPayload; + use $crate::integrity::__private::static_assertions::assert_type_eq_all; use bp_messages::ChainWithMessages; use bp_runtime::Chain; use pallet_bridge_messages::Config as MessagesConfig; - use static_assertions::assert_type_eq_all; + + // if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard + // configuration is used), or something has broke existing configuration (meaning that all bridged chains + // and relays will stop functioning) assert_type_eq_all!(<$r as MessagesConfig<$i>>::ThisChain, $this); assert_type_eq_all!(<$r as MessagesConfig<$i>>::BridgedChain, $bridged); diff --git a/bridges/modules/messages/src/proofs.rs b/bridges/modules/messages/src/proofs.rs index 18367029d72c..a3318833fa61 100644 --- a/bridges/modules/messages/src/proofs.rs +++ b/bridges/modules/messages/src/proofs.rs @@ -63,7 +63,7 @@ pub fn verify_messages_proof, I: 'static>( let nonces_range = nonces_start..=nonces_end; // receiving proofs where end < begin is ok (if proof includes outbound lane state) - let messages_in_the_proof = nonces_range.checked_len().unwrap_or(0); + let messages_in_the_proof = nonces_range.saturating_len(); if messages_in_the_proof != MessageNonce::from(messages_count) { return Err(VerificationError::MessagesCountMismatch) } diff --git a/bridges/modules/xcm-bridge-hub/src/exporter.rs b/bridges/modules/xcm-bridge-hub/src/exporter.rs index df02ab1298bd..5bca3ad8e277 100644 --- a/bridges/modules/xcm-bridge-hub/src/exporter.rs +++ b/bridges/modules/xcm-bridge-hub/src/exporter.rs @@ -23,7 +23,6 @@ use crate::{Config, Pallet, LOG_TARGET}; use bp_messages::source_chain::MessagesBridge; -use bp_runtime::RangeInclusiveExt; use bp_xcm_bridge_hub::XcmAsPlainPayload; use bridge_runtime_common::messages_xcm_extension::{LocalXcmQueueManager, SenderAndLane}; use pallet_bridge_messages::{Config as BridgeMessagesConfig, Pallet as BridgeMessagesPallet}; @@ -132,6 +131,7 @@ impl HaulBlob for DummyHaulBlob { mod tests { use super::*; use crate::mock::*; + use bp_runtime::RangeInclusiveExt; use frame_support::assert_ok; use xcm_executor::traits::export_xcm; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 987372984682..7a60a3f64840 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -121,7 +121,6 @@ snowbridge-runtime-common = { workspace = true } bridge-hub-common = { workspace = true } [dev-dependencies] -static_assertions = { workspace = true, default-features = true } bridge-hub-test-utils = { workspace = true, default-features = true } bridge-runtime-common = { features = [ "integrity-test", diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml index e2671d3d606d..4326cbf926d6 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml @@ -101,7 +101,6 @@ bridge-runtime-common = { workspace = true } bridge-hub-common = { workspace = true } [dev-dependencies] -static_assertions = { workspace = true, default-features = true } bridge-hub-test-utils = { workspace = true, default-features = true } bridge-runtime-common = { features = ["integrity-test"], workspace = true, default-features = true } sp-keyring = { workspace = true, default-features = true }