diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 0775ea61..eda146da 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -51,7 +51,7 @@ jobs: cache-all-crates: true - name: Cargo check - run: cargo check + run: cargo check --workspace check-benchmarking: name: Cargo check (benchmarking) @@ -70,10 +70,13 @@ jobs: cache-on-failure: true cache-all-crates: true - - name: Cargo check (benchmarking) - run: > - cd node && - cargo check --features=runtime-benchmarks + - name: Cargo check (Rococo) (benchmarking) + run: | + cargo check --workspace --features=rococo,runtime-benchmarks + + #- name: Cargo check (Polkadot) (benchmarking) + # run: | + # cargo check --workspace --features=polkadot,runtime-benchmarks test: name: Test @@ -93,6 +96,17 @@ jobs: cache-on-failure: true cache-all-crates: true - # TODO: enable `--all-features`. - name: Run tests - run: cargo test --workspace + run: | + cargo test --workspace + cargo test --workspace --features=runtime-benchmarks + + - name: Run (Rococo) runtime tests + run: | + cargo test -p polkadot-bulletin-chain-runtime --features=rococo + cargo test -p polkadot-bulletin-chain-runtime --features=rococo,runtime-benchmarks + + #- name: Run (Polkadot) runtime tests + # run: | + # cargo test -p polkadot-bulletin-chain-runtime --features=polkadot + # cargo test -p polkadot-bulletin-chain-runtime --features=polkadot,runtime-benchmarks diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a22cb5b6..33860239 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,7 +84,7 @@ jobs: - name: Install Rust run: | rustup update stable --no-self-update - rustup target add wasm32-unknown-unknown + rustup target add wasm32v1-none - name: Install linux dependencies if: (matrix.os == '' || startsWith(matrix.os, 'ubuntu')) diff --git a/Cargo.lock b/Cargo.lock index 604ad63b..4af308f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1796,9 +1796,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "cfg_aliases" @@ -4821,7 +4821,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.16", - "socket2 0.4.10", + "socket2 0.5.10", "tokio", "tower-service", "tracing", @@ -8891,6 +8891,7 @@ dependencies = [ "bp-runtime", "bp-test-utils", "bridge-runtime-common", + "cfg-if", "frame-benchmarking", "frame-executive", "frame-support 28.0.0", @@ -8909,6 +8910,7 @@ dependencies = [ "pallet-grandpa", "pallet-offences", "pallet-relayer-set", + "pallet-revive", "pallet-session", "pallet-staking", "pallet-sudo", diff --git a/Cargo.toml b/Cargo.toml index d9390379..1217343b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ repository = "https://github.com/zdave-parity/polkadot-bulletin-chain.git" [workspace.dependencies] array-bytes = { version = "6.1" } +cfg-if = { version = "1.0" } clap = { version = "4.2.5" } codec = { package = "parity-scale-codec", version = "3.7.5", default-features = false } futures = { version = "0.3.21" } @@ -15,8 +16,8 @@ scale-info = { version = "2.11.6", default-features = false } serde = { version = "1.0.126" } serde_json = { version = "1.0.132", default-features = false } static_assertions = { version = "1.1" } -try-runtime-cli = { version = "0.42" } tracing = { version = "0.1.41", default-features = false } +try-runtime-cli = { version = "0.42" } [workspace] resolver = "2" @@ -29,4 +30,6 @@ members = [ "runtime", ] [profile.release] +# Polkadot runtime requires unwinding. +opt-level = 3 panic = "unwind" diff --git a/node/Cargo.toml b/node/Cargo.toml index 58ad642b..0a4a9a2b 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -67,7 +67,10 @@ try-runtime-cli = { optional = true, workspace = true } substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" } [features] -default = [] +default = [ + # TODO: temporary let's activate rococo by default + "rococo", +] # Dependencies that are only required if runtime benchmarking should be built. runtime-benchmarks = [ "frame-benchmarking-cli/runtime-benchmarks", @@ -83,7 +86,9 @@ try-runtime = [ "frame-system/try-runtime", "polkadot-bulletin-chain-runtime/try-runtime", "sp-runtime/try-runtime", - "try-runtime-cli?/try-runtime", + "try-runtime-cli/try-runtime", ] -# To bridge with Rococo Bridge Hub instead of Polkadot Bridge Hub +# To bridge with Rococo Bridge Hub rococo = ["polkadot-bulletin-chain-runtime/rococo"] +# To bridge with PeoplePolkadot +polkadot = ["polkadot-bulletin-chain-runtime/polkadot"] diff --git a/pallets/common/Cargo.toml b/pallets/common/Cargo.toml index 56919cc8..79cf18f0 100644 --- a/pallets/common/Cargo.toml +++ b/pallets/common/Cargo.toml @@ -15,7 +15,6 @@ codec = { workspace = true } scale-info = { features = ["derive"], workspace = true } polkadot-sdk-frame = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false, features = [ - "experimental", "runtime", ] } diff --git a/pallets/relayer-set/Cargo.toml b/pallets/relayer-set/Cargo.toml index 25724f06..e897d498 100644 --- a/pallets/relayer-set/Cargo.toml +++ b/pallets/relayer-set/Cargo.toml @@ -15,7 +15,6 @@ log = { workspace = true, default-features = true } scale-info = { features = ["derive"], workspace = true } polkadot-sdk-frame = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false, features = [ - "experimental", "runtime", ] } diff --git a/pallets/transaction-storage/Cargo.toml b/pallets/transaction-storage/Cargo.toml index 26d2b283..41a960d9 100644 --- a/pallets/transaction-storage/Cargo.toml +++ b/pallets/transaction-storage/Cargo.toml @@ -19,7 +19,6 @@ log = { workspace = true, default-features = true } scale-info = { features = ["derive"], workspace = true } polkadot-sdk-frame = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false, features = [ - "experimental", "runtime", ] } sp-transaction-storage-proof = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false } diff --git a/pallets/validator-set/Cargo.toml b/pallets/validator-set/Cargo.toml index 2559c1de..6d0bfde6 100644 --- a/pallets/validator-set/Cargo.toml +++ b/pallets/validator-set/Cargo.toml @@ -11,7 +11,6 @@ log = { workspace = true, default-features = true } scale-info = { features = ["derive"], workspace = true } polkadot-sdk-frame = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false, features = [ - "experimental", "runtime", ] } sp-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 7506d729..444b5cce 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -12,6 +12,7 @@ repository = "https://github.com/paritytech/polkadot-bulletin-chain/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] +cfg-if = { workspace = true } codec = { workspace = true, features = ["derive"] } log = { workspace = true } scale-info = { features = ["derive"], workspace = true } @@ -80,11 +81,12 @@ xcm = { default-features = false, git = "https://github.com/paritytech/polkadot- xcm-builder = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", package = "staging-xcm-builder" } xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", package = "staging-xcm-executor" } -# TODO: just to pass `--features runtime-benchmarks` +# TODO: just to pass `--features runtime-benchmarks` or `--features try-runtime` pallet-xcm = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" } pallet-staking = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" } sp-staking = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" } parachains-common = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" } +pallet-revive = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" } [build-dependencies] substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", optional = true } @@ -163,6 +165,7 @@ std = [ "xcm/std", "pallet-bridge-relayers/std", + "pallet-revive?/std", "pallet-staking?/std", "pallet-xcm?/std", "parachains-common?/std", @@ -202,6 +205,7 @@ runtime-benchmarks = [ "xcm-executor/runtime-benchmarks", "xcm/runtime-benchmarks", + "pallet-revive?/runtime-benchmarks", "pallet-staking/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "parachains-common/runtime-benchmarks", @@ -227,7 +231,8 @@ try-runtime = [ "pallet-bridge-relayers/try-runtime", "pallet-relayer-set/try-runtime", - "pallet-staking?/try-runtime", + "pallet-revive/try-runtime", + "pallet-staking/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-transaction-storage/try-runtime", "pallet-validator-set/try-runtime", @@ -237,3 +242,4 @@ try-runtime = [ "sp-runtime/try-runtime", ] rococo = [] +polkadot = [] diff --git a/runtime/src/bridge_config.rs b/runtime/src/bridge_config.rs index 239eef99..6470e75b 100644 --- a/runtime/src/bridge_config.rs +++ b/runtime/src/bridge_config.rs @@ -1,4 +1,6 @@ -//! With Polkadot Bridge Hub bridge configuration. +#![cfg(feature = "rococo")] + +//! With Rococo Bridge Hub bridge configuration. use crate::{ xcm_config::{decode_bridge_message, XcmConfig}, @@ -25,7 +27,6 @@ use xcm_executor::XcmExecutor; pub const XCM_LANE: LegacyLaneId = LegacyLaneId([0, 0, 0, 0]); parameter_types! { - // TODO: (change to Polkadot - or make this `pub storage` for supporting Rococo and Polkadot) pub RococoGlobalConsensusNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH); pub BridgedNetwork: NetworkId = RococoGlobalConsensusNetwork::get(); pub RococoGlobalConsensusNetworkLocation: Location = Location::new( @@ -41,8 +42,6 @@ parameter_types! { /// A name of parachains pallet at Pokadot. pub const AtRococoParasPalletName: &'static str = bp_rococo::PARAS_PALLET_NAME; -// /// Chain identifier of Polkadot Bridge Hub. -// pub const BridgeHubPolkadotChainId: ChainId = bp_runtime::BRIDGE_HUB_POLKADOT_CHAIN_ID; /// A number of Polkadot Bridge Hub head digests that we keep in the storage. pub const BridgeHubRococoHeadsToKeep: u32 = 1024; /// A maximal size of Polkadot Bridge Hub head digest. @@ -244,8 +243,8 @@ where .map_err(drop) .and_then(|payload| decode_bridge_message(payload).map(|(_, xcm)| xcm).map_err(drop)) .and_then(|xcm| xcm.try_into().map_err(drop)) - // TODO: FAIL-CI Weight::MAX maybe change for something else, hard-coded or Weight::MAX/4... - // TODO: (real weights) https://github.com/paritytech/polkadot-bulletin-chain/issues/22 + // TODO: FAIL-CI Weight::MAX maybe change for something else, hard-coded or + // Weight::MAX/4... TODO: (real weights) https://github.com/paritytech/polkadot-bulletin-chain/issues/22 .and_then(|xcm| XcmExecutor::::prepare(xcm, Weight::MAX).map_err(drop)) .map(|weighed_xcm| weighed_xcm.weight_of()) .unwrap_or(Weight::zero()) @@ -305,8 +304,8 @@ where } } -/// Export XCM messages to be relayed to the Polkadot Bridge Hub chain. -pub type ToBridgeHubRococoHaulBlobExporter = HaulBlobExporter< +/// Export XCM messages to be relayed to the Rococo Bridge Hub chain. +pub type ToBridgeHaulBlobExporter = HaulBlobExporter< XcmBlobHauler, RococoGlobalConsensusNetworkLocation, AlwaysV5, diff --git a/runtime/src/genesis_config_presets.rs b/runtime/src/genesis_config_presets.rs index f9a45abc..0ec6d3bc 100644 --- a/runtime/src/genesis_config_presets.rs +++ b/runtime/src/genesis_config_presets.rs @@ -1,9 +1,19 @@ use crate::{ - bridge_config::XCM_LANE, opaque::SessionKeys, AccountId, BabeConfig, BridgeRococoGrandpaConfig, - BridgeRococoMessagesConfig, BridgeRococoParachainsConfig, RelayerSetConfig, - RuntimeGenesisConfig, SessionConfig, Signature, SudoConfig, ValidatorSetConfig, - BABE_GENESIS_EPOCH_CONFIG, + opaque::SessionKeys, AccountId, BabeConfig, RelayerSetConfig, RuntimeGenesisConfig, + SessionConfig, Signature, SudoConfig, ValidatorSetConfig, BABE_GENESIS_EPOCH_CONFIG, }; + +#[cfg(feature = "polkadot")] +use crate::{ + bridge_config::XCM_LANE, BridgePolkadotGrandpaConfig, BridgePolkadotMessagesConfig, + BridgePolkadotParachainsConfig, +}; +#[cfg(feature = "rococo")] +use crate::{ + bridge_config::XCM_LANE, BridgeRococoGrandpaConfig, BridgeRococoMessagesConfig, + BridgeRococoParachainsConfig, +}; + use scale_info::prelude::format; use sp_consensus_babe::AuthorityId as BabeId; use sp_consensus_grandpa::AuthorityId as GrandpaId; @@ -45,6 +55,7 @@ fn session_keys(babe: BabeId, grandpa: GrandpaId) -> SessionKeys { /// Configure initial storage state for FRAME modules. fn testnet_genesis( initial_authorities: Vec<(AccountId, BabeId, GrandpaId)>, + bridges_pallet_owner: Option, root_key: AccountId, ) -> serde_json::Value { let config = RuntimeGenesisConfig { @@ -74,16 +85,35 @@ fn testnet_genesis( // would want to use separate keys for the relayers. initial_relayers: initial_authorities.into_iter().map(|x| x.0).collect::>(), }, + #[cfg(feature = "rococo")] bridge_rococo_grandpa: BridgeRococoGrandpaConfig { - owner: Some(root_key.clone()), + owner: bridges_pallet_owner.clone(), ..Default::default() }, + #[cfg(feature = "rococo")] bridge_rococo_parachains: BridgeRococoParachainsConfig { - owner: Some(root_key.clone()), + owner: bridges_pallet_owner.clone(), ..Default::default() }, + #[cfg(feature = "rococo")] bridge_rococo_messages: BridgeRococoMessagesConfig { - owner: Some(root_key), + owner: bridges_pallet_owner, + opened_lanes: vec![XCM_LANE], + ..Default::default() + }, + #[cfg(feature = "polkadot")] + bridge_polkadot_grandpa: BridgePolkadotGrandpaConfig { + owner: bridges_pallet_owner.clone(), + ..Default::default() + }, + #[cfg(feature = "polkadot")] + bridge_polkadot_parachains: BridgePolkadotParachainsConfig { + owner: bridges_pallet_owner.clone(), + ..Default::default() + }, + #[cfg(feature = "polkadot")] + bridge_polkadot_messages: BridgePolkadotMessagesConfig { + owner: bridges_pallet_owner, opened_lanes: vec![XCM_LANE], ..Default::default() }, @@ -99,6 +129,8 @@ pub fn get_preset(id: &PresetId) -> Option> { sp_genesis_builder::DEV_RUNTIME_PRESET => testnet_genesis( // Initial PoA authorities vec![authority_keys_from_seed("Alice")], + // Bridges pallet owner + Some(get_account_id_from_seed::("Alice")), // Sudo account get_account_id_from_seed::("Alice"), ), @@ -110,6 +142,8 @@ pub fn get_preset(id: &PresetId) -> Option> { authority_keys_from_seed("Bob"), authority_keys_from_seed("Bob//stash"), ], + // Bridges pallet owner + Some(get_account_id_from_seed::("Alice")), // Sudo account get_account_id_from_seed::("Alice"), ), @@ -117,7 +151,7 @@ pub fn get_preset(id: &PresetId) -> Option> { }; Some( serde_json::to_string(&patch) - .expect("serialization to json is expected to work. qed.") + .expect("serialization to JSON is expected to work. qed.") .into_bytes(), ) } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 8d82f415..93459161 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -62,7 +62,13 @@ use sp_runtime::traits::transaction_extension::AsTransactionExtension; pub use sp_runtime::BuildStorage; pub use sp_runtime::{Perbill, Permill}; +#[cfg(feature = "rococo")] mod bridge_config; +#[cfg(feature = "polkadot")] +mod polkadot_bridge_config; +#[cfg(feature = "polkadot")] +use polkadot_bridge_config as bridge_config; + mod genesis_config_presets; mod weights; mod xcm_config; @@ -399,10 +405,16 @@ construct_runtime!( // Bridge RelayerSet: pallet_relayer_set = 50, + + #[cfg(feature = "rococo")] BridgeRococoGrandpa: pallet_bridge_grandpa = 51, + #[cfg(feature = "rococo")] BridgeRococoParachains: pallet_bridge_parachains = 52, + #[cfg(feature = "rococo")] BridgeRococoMessages: pallet_bridge_messages = 53, + // TODO: @antkve add here for Polkadot + // sudo Sudo: pallet_sudo = 255, } @@ -478,25 +490,60 @@ impl SignedExtension for ValidateSigned { _len: usize, ) -> Result { match call { - Self::Call::TransactionStorage(call) => - TransactionStorage::pre_dispatch_signed(who, call).map(|()| None), + // Transaction storage validation + Self::Call::TransactionStorage(inner_call) => + TransactionStorage::pre_dispatch_signed(who, inner_call).map(|()| None), + + // Sudo validation Self::Call::Sudo(_) => validate_sudo(who).map(|_| None), + + // Session key management Self::Call::Session(SessionCall::set_keys { .. }) => ValidatorSet::pre_dispatch_set_keys(who).map(|()| None), Self::Call::Session(SessionCall::purge_keys {}) => validate_purge_keys(who).map(|_| None), + + // Bridge-related calls + #[cfg(feature = "rococo")] Self::Call::BridgeRococoGrandpa(BridgeGrandpaCall::submit_finality_proof { .. }) | + Self::Call::BridgeRococoGrandpa(BridgeGrandpaCall::submit_finality_proof_ex { + .. + }) | Self::Call::BridgeRococoParachains(BridgeParachainsCall::submit_parachain_heads { .. }) | + Self::Call::BridgeRococoParachains( + BridgeParachainsCall::submit_parachain_heads_ex { .. }, + ) | Self::Call::BridgeRococoMessages(BridgeMessagesCall::receive_messages_proof { .. }) | Self::Call::BridgeRococoMessages( BridgeMessagesCall::receive_messages_delivery_proof { .. }, ) => RelayerSet::validate_bridge_tx(who).map(|()| Some(who.clone())), + #[cfg(feature = "polkadot")] + Self::Call::BridgePolkadotGrandpa(BridgeGrandpaCall::submit_finality_proof { + .. + }) | + Self::Call::BridgePolkadotGrandpa(BridgeGrandpaCall::submit_finality_proof_ex { + .. + }) | + Self::Call::BridgePolkadotParachains( + BridgeParachainsCall::submit_parachain_heads { .. }, + ) | + Self::Call::BridgePolkadotParachains( + BridgeParachainsCall::submit_parachain_heads_ex { .. }, + ) | + Self::Call::BridgePolkadotMessages(BridgeMessagesCall::receive_messages_proof { + .. + }) | + Self::Call::BridgePolkadotMessages( + BridgeMessagesCall::receive_messages_delivery_proof { .. }, + ) => RelayerSet::validate_bridge_tx(who).map(|()| Some(who.clone())), + + // All other calls are invalid _ => Err(InvalidTransaction::Call.into()), } } @@ -509,21 +556,37 @@ impl SignedExtension for ValidateSigned { _len: usize, ) -> TransactionValidity { match call { - Self::Call::TransactionStorage(call) => TransactionStorage::validate_signed(who, call), + // Transaction storage call + Self::Call::TransactionStorage(inner_call) => + TransactionStorage::validate_signed(who, inner_call), + + // Sudo call Self::Call::Sudo(_) => validate_sudo(who), + + // Session key management Self::Call::Session(SessionCall::set_keys { .. }) => ValidatorSet::validate_set_keys(who).map(|()| ValidTransaction { priority: SetPurgeKeysPriority::get(), longevity: SetPurgeKeysLongevity::get(), ..Default::default() }), + Self::Call::Session(SessionCall::purge_keys {}) => validate_purge_keys(who), + + // Bridge-related calls + #[cfg(feature = "rococo")] Self::Call::BridgeRococoGrandpa(BridgeGrandpaCall::submit_finality_proof { .. }) | + Self::Call::BridgeRococoGrandpa(BridgeGrandpaCall::submit_finality_proof_ex { + .. + }) | Self::Call::BridgeRococoParachains(BridgeParachainsCall::submit_parachain_heads { .. }) | + Self::Call::BridgeRococoParachains( + BridgeParachainsCall::submit_parachain_heads_ex { .. }, + ) | Self::Call::BridgeRococoMessages(BridgeMessagesCall::receive_messages_proof { .. }) | @@ -534,6 +597,31 @@ impl SignedExtension for ValidateSigned { longevity: BridgeTxLongevity::get(), ..Default::default() }), + #[cfg(feature = "polkadot")] + Self::Call::BridgePolkadotGrandpa(BridgeGrandpaCall::submit_finality_proof { + .. + }) | + Self::Call::BridgePolkadotGrandpa(BridgeGrandpaCall::submit_finality_proof_ex { + .. + }) | + Self::Call::BridgePolkadotParachains( + BridgeParachainsCall::submit_parachain_heads { .. }, + ) | + Self::Call::BridgePolkadotParachains( + BridgeParachainsCall::submit_parachain_heads_ex { .. }, + ) | + Self::Call::BridgePolkadotMessages(BridgeMessagesCall::receive_messages_proof { + .. + }) | + Self::Call::BridgePolkadotMessages( + BridgeMessagesCall::receive_messages_delivery_proof { .. }, + ) => RelayerSet::validate_bridge_tx(who).map(|()| ValidTransaction { + priority: BridgeTxPriority::get(), + longevity: BridgeTxLongevity::get(), + ..Default::default() + }), + + // All other calls are invalid _ => Err(InvalidTransaction::Call.into()), } } @@ -554,8 +642,9 @@ impl SignedExtension for ValidateSigned { } } -// it'll generate signed extensions to invalidate obsolete bridge transactions before -// they'll be included into block +// It'll generate signed extensions to invalidate obsolete bridge transactions before +// they'll be included in the block +#[cfg(feature = "rococo")] generate_bridge_reject_obsolete_headers_and_messages! { RuntimeCall, AccountId, // Grandpa @@ -565,6 +654,16 @@ generate_bridge_reject_obsolete_headers_and_messages! { // Messages BridgeRococoMessages } +#[cfg(feature = "polkadot")] +generate_bridge_reject_obsolete_headers_and_messages! { + RuntimeCall, AccountId, + // Grandpa + BridgePolkadotGrandpa, + // Parachains + BridgePolkadotParachains, + // Messages + BridgePolkadotMessages +} /// The SignedExtension to the basic transaction logic. pub type TxExtension = ( @@ -595,22 +694,39 @@ pub type Executive = frame_executive::Executive< #[cfg(feature = "runtime-benchmarks")] mod benches { - frame_benchmarking::define_benchmarks!( - [frame_benchmarking, BaselineBench::] - [frame_system, SystemBench::] - [pallet_timestamp, Timestamp] - [pallet_sudo, Sudo] - [pallet_transaction_storage, TransactionStorage] - [pallet_validator_set, ValidatorSet] - // TODO: Rococo vs Polkadot https://github.com/paritytech/polkadot-bulletin-chain/issues/22 - [pallet_bridge_grandpa, BridgeRococoGrandpa] - // [pallet_bridge_parachains, BridgeParachainsBench::] - // [pallet_bridge_messages, BridgeMessagesBench::] - // [pallet_bridge_grandpa, BridgePolkadotGrandpa] - // [pallet_bridge_parachains, BridgeParachainsBench::] - // [pallet_bridge_messages, BridgeMessagesBench::] - [pallet_relayer_set, RelayerSet] - ); + cfg_if::cfg_if! { + if #[cfg(feature = "rococo")] { + frame_benchmarking::define_benchmarks!( + [frame_benchmarking, BaselineBench::] + [frame_system, SystemBench::] + [pallet_timestamp, Timestamp] + [pallet_sudo, Sudo] + [pallet_transaction_storage, TransactionStorage] + [pallet_validator_set, ValidatorSet] + [pallet_relayer_set, RelayerSet] + + [pallet_bridge_grandpa, BridgeRococoGrandpa] + // TODO: finish benchmarking + // [pallet_bridge_parachains, BridgeParachainsBench::] + // [pallet_bridge_messages, BridgeMessagesBench::] + ); + } else if #[cfg(feature = "polkadot")] { + frame_benchmarking::define_benchmarks!( + [frame_benchmarking, BaselineBench::] + [frame_system, SystemBench::] + [pallet_timestamp, Timestamp] + [pallet_sudo, Sudo] + [pallet_transaction_storage, TransactionStorage] + [pallet_validator_set, ValidatorSet] + [pallet_relayer_set, RelayerSet] + + // TODO: finish benchmarking + [pallet_bridge_grandpa, BridgePolkadotGrandpa] + [pallet_bridge_parachains, BridgeParachainsBench::] + [pallet_bridge_messages, BridgeMessagesBench::] + ); + } + } } impl_runtime_apis! { @@ -776,6 +892,7 @@ impl_runtime_apis! { } } + #[cfg(feature = "rococo")] impl bp_rococo::RococoFinalityApi for Runtime { fn best_finalized() -> Option> { BridgeRococoGrandpa::best_finalized() @@ -793,6 +910,7 @@ impl_runtime_apis! { } } + #[cfg(feature = "rococo")] impl bp_bridge_hub_rococo::BridgeHubRococoFinalityApi for Runtime { fn best_finalized() -> Option> { BridgeRococoParachains::best_parachain_head_id::< @@ -806,6 +924,7 @@ impl_runtime_apis! { } } + #[cfg(feature = "rococo")] impl bp_bridge_hub_rococo::FromBridgeHubRococoInboundLaneApi for Runtime { fn message_details( lane: bp_messages::LegacyLaneId, @@ -818,6 +937,7 @@ impl_runtime_apis! { } } + #[cfg(feature = "rococo")] impl bp_bridge_hub_rococo::ToBridgeHubRococoOutboundLaneApi for Runtime { fn message_details( lane: bp_messages::LegacyLaneId, @@ -871,7 +991,7 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { - use sp_storage::TrackedStorageKey; + use sp_storage::TrackedStorageKey; use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch}; use frame_system_benchmarking::Pallet as SystemBench; diff --git a/runtime/src/xcm_config.rs b/runtime/src/xcm_config.rs index 32b40562..aeb1b667 100644 --- a/runtime/src/xcm_config.rs +++ b/runtime/src/xcm_config.rs @@ -17,7 +17,7 @@ //! XCM configuration for Polkadot Bulletin chain. use crate::{ - bridge_config::{BridgedNetwork, ToBridgeHubRococoHaulBlobExporter}, + bridge_config::{BridgedNetwork, ToBridgeHaulBlobExporter}, AllPalletsWithSystem, RuntimeCall, RuntimeOrigin, }; @@ -32,8 +32,8 @@ use sp_core::ConstU32; use sp_io::hashing::blake2_256; use xcm::{latest::prelude::*, VersionedInteriorLocation, VersionedXcm, MAX_XCM_DECODE_DEPTH}; use xcm_builder::{ - DispatchBlob, DispatchBlobError, FixedWeightBounds, FrameTransactionalProcessor, - TrailingSetTopicAsId, UnpaidLocalExporter, WithComputedOrigin, + DispatchBlob, DispatchBlobError, FixedWeightBounds, FrameTransactionalProcessor, LocalExporter, + TrailingSetTopicAsId, WithComputedOrigin, }; use xcm_executor::{ traits::{ConvertOrigin, ShouldExecute, WeightTrader, WithOriginFilter}, @@ -52,6 +52,7 @@ parameter_types! { /// Our location in the universe of consensus systems. pub UniversalLocation: InteriorLocation = ThisNetwork::get().into(); + /// TODO: (Kawabunga = People Chain) - rename somehow :) /// Location of the Kawabunga parachain, relative to this runtime. pub KawabungaLocation: Location = Location::new(1, [ GlobalConsensus(BridgedNetwork::get()), @@ -171,7 +172,7 @@ type LocalOriginConverter = ( ); /// Only bridged destination is supported. -pub type XcmRouter = UnpaidLocalExporter; +pub type XcmRouter = LocalExporter; /// The barriers one of which must be passed for an XCM message to be executed. pub type Barrier = TrailingSetTopicAsId< @@ -208,7 +209,7 @@ impl xcm_executor::Config for XcmConfig { type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = ConstU32<0>; type FeeManager = (); - type MessageExporter = ToBridgeHubRococoHaulBlobExporter; + type MessageExporter = ToBridgeHaulBlobExporter; type UniversalAliases = UniversalAliases; type CallDispatcher = WithOriginFilter; type SafeCallFilter = Everything; diff --git a/scripts/init.sh b/scripts/init.sh index f976f723..a14b5f26 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -9,4 +9,4 @@ if [ -z $CI_PROJECT_NAME ] ; then rustup update stable fi -rustup target add wasm32-unknown-unknown --toolchain nightly +rustup target add wasm32v1-none --toolchain nightly