Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridges: Making relayer compatible with runtime upgrades #4256

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
98db78f
added RelayerVersion struct + compatible relayer version constant to …
svyatonik Apr 22, 2024
044242d
generate_bridge_reject_obsolete_headers_and_messages now uses a set o…
svyatonik Apr 22, 2024
94cb11d
added compatible relayer version constant to pallet_bridge_parachains…
svyatonik Apr 22, 2024
7a02460
added compatible relayer version constant to pallet_bridge_messages +…
svyatonik Apr 22, 2024
3a0767d
added runtime API to query compatible relayers version. Once runtimes…
svyatonik Apr 22, 2024
c09d2ac
removed unused methods
svyatonik Apr 22, 2024
bc6e3d3
pass best_block_id to submit_and_watch_signed_extrinsic
svyatonik Apr 22, 2024
39bb551
check relayer compatibility from finality relay
svyatonik Apr 22, 2024
ca0fff5
check relayer compatibility from finality relay
svyatonik Apr 22, 2024
ea1dbe5
check relayer compatibility from messages relay
svyatonik Apr 22, 2024
b698ab1
make relayer version an Option<_> until all chains will migrate to ne…
svyatonik Apr 22, 2024
00a14cb
fixed constant names
svyatonik Apr 23, 2024
2f3569d
remove OutboundLaneApi::compatible_relayer_version method
svyatonik Apr 23, 2024
f973f81
removed OUtboundLaneApi::compatible_relayer_version methods
svyatonik Apr 23, 2024
af38849
updated RelayerVersion documentation to support multiple running rela…
svyatonik Apr 23, 2024
f16296d
change ensure_relayer_compatibility behavior to abort relayer if we a…
svyatonik Apr 23, 2024
96908f5
include pallet name, pallet storage version and runtime state trie ve…
svyatonik Apr 23, 2024
eb8f1c9
added prdoc
svyatonik Apr 23, 2024
9680bd8
fixed tests compilation
svyatonik Apr 23, 2024
596b8aa
fix compilation of pallet-xcm-bridge-hub tests
svyatonik Apr 23, 2024
bf037a6
fix prdoc
svyatonik Apr 25, 2024
43c49e1
Merge branch 'master' into sv-bridge-relayer-compatibility-tests
svyatonik May 2, 2024
d3b5375
fmt
svyatonik May 2, 2024
d7297ca
- change the way BridgeRejectObsoleteHeadersAndMessages::IDENTIFIE is…
svyatonik May 3, 2024
4fa3aea
also add the RelayerVersion::from_manual to be used in the relayer
svyatonik May 3, 2024
54b32b3
fix compilation
svyatonik May 3, 2024
510c903
fixes
svyatonik May 3, 2024
7590930
typo
svyatonik May 3, 2024
81ec6fa
fix prdoc
svyatonik May 3, 2024
2e8fbb3
Merge branch 'master' into sv-bridge-relayer-compatibility-tests
svyatonik May 6, 2024
e5ca322
revert DirectSubmitGrandpaFinalityProofCallBuilder removal
svyatonik May 6, 2024
2a548e2
HeaderId -> Hash in simple_runtime_version args
svyatonik May 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion bridges/bin/runtime-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ workspace = true
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
hash-db = { version = "0.16.0", default-features = false }
log = { workspace = true }
const-fnv1a-hash = "1.1"
const_format = "0.2"
scale-info = { version = "2.11.1", default-features = false, features = ["derive"] }
static_assertions = { version = "1.1", optional = true }
tuplex = { version = "0.1", default-features = false }
Expand All @@ -26,6 +28,7 @@ bp-parachains = { path = "../../primitives/parachains", default-features = false
bp-polkadot-core = { path = "../../primitives/polkadot-core", default-features = false }
bp-relayers = { path = "../../primitives/relayers", default-features = false }
bp-runtime = { path = "../../primitives/runtime", default-features = false }
bp-test-utils = { path = "../../primitives/test-utils", default-features = false, optional = true }
bp-xcm-bridge-hub = { path = "../../primitives/xcm-bridge-hub", default-features = false }
bp-xcm-bridge-hub-router = { path = "../../primitives/xcm-bridge-hub-router", default-features = false }
pallet-bridge-grandpa = { path = "../../modules/grandpa", default-features = false }
Expand Down Expand Up @@ -63,6 +66,7 @@ std = [
"bp-polkadot-core/std",
"bp-relayers/std",
"bp-runtime/std",
"bp-test-utils?/std",
"bp-xcm-bridge-hub-router/std",
"bp-xcm-bridge-hub/std",
"codec/std",
Expand Down Expand Up @@ -99,4 +103,4 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
]
integrity-test = ["static_assertions"]
integrity-test = ["bp-test-utils", "static_assertions"]
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,25 @@ macro_rules! generate_bridge_reject_obsolete_headers_and_messages {
#[derive(Clone, codec::Decode, Default, codec::Encode, Eq, PartialEq, sp_runtime::RuntimeDebug, scale_info::TypeInfo)]
pub struct BridgeRejectObsoleteHeadersAndMessages;
impl sp_runtime::traits::SignedExtension for BridgeRejectObsoleteHeadersAndMessages {
const IDENTIFIER: &'static str = "BridgeRejectObsoleteHeadersAndMessages";
// What we do here is:
// - computing hash of all stringified **types**, passed to the macro
// - prefixing it with `BridgeReject_`
//
// So whenever any type passed to the `generate_bridge_reject_obsolete_headers_and_messages`
// changes, the `IDENTIFIER` is also changed. Keep in mind that it may change if the type
// stays the same, but e.g. name of type alias, used in type name changes:
// ```rust
// struct F<T>;
// type A = u32;
// type B = u32;
// ```
// Then `IDENTIFIER` of `F<A>` is not equal to `F<B>`, even though the type is the same.
const IDENTIFIER: &'static str = $crate::extensions::prelude::const_format::concatcp!(
"BridgeReject_",
$crate::extensions::prelude::const_fnv1a_hash::fnv1a_hash_str_128(
concat!($(stringify!($filter_call), )*)
)
);
type AccountId = $account_id;
type Call = $call;
type AdditionalSigned = ();
Expand Down Expand Up @@ -458,6 +476,11 @@ mod tests {
SecondFilterCall
);

assert_eq!(
BridgeRejectObsoleteHeadersAndMessages::IDENTIFIER,
"BridgeReject_163603100942600502516220926454699703369"
);

run_test(|| {
assert_err!(
BridgeRejectObsoleteHeadersAndMessages.validate(&42, &MockCall { data: 1 }, &(), 0),
Expand Down
6 changes: 6 additions & 0 deletions bridges/bin/runtime-common/src/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

//! Bridge-specific transaction extensions.

/// All crates that we use in extensions macro.
pub mod prelude {
pub use const_fnv1a_hash;
pub use const_format;
}

pub mod check_obsolete_extension;
pub mod priority_calculator;
pub mod refund_relayer_extension;
2 changes: 2 additions & 0 deletions bridges/bin/runtime-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ mod mock;

#[cfg(feature = "integrity-test")]
pub mod integrity;
#[cfg(feature = "integrity-test")]
pub mod relayer_compatibility;

const LOG_TARGET_BRIDGE_DISPATCH: &str = "runtime::bridge-dispatch";
5 changes: 4 additions & 1 deletion bridges/bin/runtime-common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use frame_support::{
use pallet_transaction_payment::Multiplier;
use sp_runtime::{
testing::H256,
traits::{BlakeTwo256, ConstU32, ConstU64, ConstU8},
traits::{BlakeTwo256, ConstU32, ConstU64, ConstU8, GetDefault},
FixedPointNumber, Perquintill,
};

Expand Down Expand Up @@ -182,6 +182,7 @@ impl pallet_transaction_payment::Config for TestRuntime {

impl pallet_bridge_grandpa::Config for TestRuntime {
type RuntimeEvent = RuntimeEvent;
type CompatibleWithRelayer = GetDefault;
type BridgedChain = BridgedUnderlyingChain;
type MaxFreeHeadersPerBlock = ConstU32<4>;
type FreeHeadersInterval = ConstU32<1_024>;
Expand All @@ -191,6 +192,7 @@ impl pallet_bridge_grandpa::Config for TestRuntime {

impl pallet_bridge_parachains::Config for TestRuntime {
type RuntimeEvent = RuntimeEvent;
type CompatibleWithRelayer = GetDefault;
type BridgesGrandpaPalletInstance = ();
type ParasPalletName = BridgedParasPalletName;
type ParaStoredHeaderDataBuilder =
Expand All @@ -202,6 +204,7 @@ impl pallet_bridge_parachains::Config for TestRuntime {

impl pallet_bridge_messages::Config for TestRuntime {
type RuntimeEvent = RuntimeEvent;
type CompatibleWithRelayer = GetDefault;
type WeightInfo = pallet_bridge_messages::weights::BridgeWeight<TestRuntime>;
type ActiveOutboundLanes = ActiveOutboundLanes;
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
Expand Down
Loading
Loading