mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 01:41:03 +00:00
Update Snowbridge versions and prep for publishing (#2894)
- updates snowbridge crates to `0.9.0` - updates Cargo.toml files in preparation for publishing to crates.io - adds Kusama and Polkadot Snowbridge runtime config crates - moves runtime tests from the Snowbridge subtree into the bridge hub tests dir --------- Co-authored-by: claravanstaden <Cats 4 life!> Co-authored-by: Ron <yrong1997@gmail.com>
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
[package]
|
||||
name = "snowbridge-rococo-common"
|
||||
description = "Snowbridge Rococo Common"
|
||||
version = "0.0.1"
|
||||
authors = ["Snowfork <contact@snowfork.com>"]
|
||||
edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
log = { version = "0.4.20", default-features = false }
|
||||
|
||||
frame-support = { path = "../../../../../substrate/frame/support", default-features = false }
|
||||
xcm = { package = "staging-xcm", path = "../../../../../polkadot/xcm", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"frame-support/std",
|
||||
"log/std",
|
||||
"xcm/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"frame-support/runtime-benchmarks",
|
||||
]
|
||||
@@ -1,16 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
|
||||
//! # Rococo Common
|
||||
//!
|
||||
//! Config used for the Rococo asset hub and bridge hub runtimes.
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use frame_support::parameter_types;
|
||||
use xcm::opaque::lts::NetworkId;
|
||||
|
||||
pub const INBOUND_QUEUE_MESSAGES_PALLET_INDEX: u8 = 80;
|
||||
|
||||
parameter_types! {
|
||||
// Network and location for the Ethereum chain.
|
||||
pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 11155111 };
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
[package]
|
||||
name = "snowbridge-runtime-common"
|
||||
description = "Snowbridge Runtime Common"
|
||||
version = "0.1.1"
|
||||
version = "0.9.0"
|
||||
authors = ["Snowfork <contact@snowfork.com>"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
repository.workspace = true
|
||||
license = "Apache-2.0"
|
||||
categories = ["cryptography::cryptocurrencies"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
log = { version = "0.4.20", default-features = false }
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# Snowbridge Runtime Common
|
||||
|
||||
Common crate to contain runtime related structs and implementations for Snowbridge.
|
||||
+18
-63
@@ -1,10 +1,14 @@
|
||||
[package]
|
||||
name = "snowbridge-runtime-tests"
|
||||
name = "snowbridge-runtime-test-common"
|
||||
description = "Snowbridge Runtime Tests"
|
||||
version = "0.1.0"
|
||||
version = "0.9.0"
|
||||
authors = ["Snowfork <contact@snowfork.com>"]
|
||||
edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
categories = ["cryptography::cryptocurrencies"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
||||
@@ -48,7 +52,6 @@ sp-transaction-pool = { path = "../../../../../substrate/primitives/transaction-
|
||||
sp-version = { path = "../../../../../substrate/primitives/version", default-features = false }
|
||||
|
||||
# Polkadot
|
||||
rococo-runtime-constants = { path = "../../../../../polkadot/runtime/rococo/constants", default-features = false }
|
||||
pallet-xcm = { path = "../../../../../polkadot/xcm/pallet-xcm", default-features = false }
|
||||
pallet-xcm-benchmarks = { path = "../../../../../polkadot/xcm/pallet-xcm-benchmarks", default-features = false, optional = true }
|
||||
polkadot-core-primitives = { path = "../../../../../polkadot/core-primitives", default-features = false }
|
||||
@@ -71,19 +74,17 @@ pallet-collator-selection = { path = "../../../../../cumulus/pallets/collator-se
|
||||
parachain-info = { package = "staging-parachain-info", path = "../../../../../cumulus/parachains/pallets/parachain-info", default-features = false }
|
||||
parachains-common = { path = "../../../../../cumulus/parachains/common", default-features = false }
|
||||
parachains-runtimes-test-utils = { path = "../../../../../cumulus/parachains/runtimes/test-utils", default-features = false }
|
||||
bridge-hub-rococo-runtime = { path = "../../../../../cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo", default-features = false }
|
||||
asset-hub-rococo-runtime = { path = "../../../../../cumulus/parachains/runtimes/assets/asset-hub-rococo", default-features = false }
|
||||
assets-common = { path = "../../../../../cumulus/parachains/runtimes/assets/common", default-features = false }
|
||||
|
||||
# Ethereum Bridge (Snowbridge)
|
||||
snowbridge-core = { path = "../../primitives/core", default-features = false }
|
||||
snowbridge-beacon-primitives = { path = "../../primitives/beacon", default-features = false }
|
||||
snowbridge-router-primitives = { path = "../../primitives/router", default-features = false }
|
||||
snowbridge-ethereum-beacon-client = { path = "../../pallets/ethereum-beacon-client", default-features = false }
|
||||
snowbridge-inbound-queue = { path = "../../pallets/inbound-queue", default-features = false }
|
||||
snowbridge-outbound-queue = { path = "../../pallets/outbound-queue", default-features = false }
|
||||
snowbridge-pallet-ethereum-client = { path = "../../pallets/ethereum-client", default-features = false }
|
||||
snowbridge-pallet-inbound-queue = { path = "../../pallets/inbound-queue", default-features = false }
|
||||
snowbridge-pallet-outbound-queue = { path = "../../pallets/outbound-queue", default-features = false }
|
||||
snowbridge-outbound-queue-runtime-api = { path = "../../pallets/outbound-queue/runtime-api", default-features = false }
|
||||
snowbridge-system = { path = "../../pallets/system", default-features = false }
|
||||
snowbridge-pallet-system = { path = "../../pallets/system", default-features = false }
|
||||
snowbridge-system-runtime-api = { path = "../../pallets/system/runtime-api", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
@@ -95,9 +96,7 @@ sp-keyring = { path = "../../../../../substrate/primitives/keyring" }
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"asset-hub-rococo-runtime/std",
|
||||
"assets-common/std",
|
||||
"bridge-hub-rococo-runtime/std",
|
||||
"codec/std",
|
||||
"cumulus-pallet-aura-ext/std",
|
||||
"cumulus-pallet-dmp-queue/std",
|
||||
@@ -134,18 +133,17 @@ std = [
|
||||
"polkadot-core-primitives/std",
|
||||
"polkadot-parachain-primitives/std",
|
||||
"polkadot-runtime-common/std",
|
||||
"rococo-runtime-constants/std",
|
||||
"scale-info/std",
|
||||
"serde",
|
||||
"snowbridge-beacon-primitives/std",
|
||||
"snowbridge-core/std",
|
||||
"snowbridge-ethereum-beacon-client/std",
|
||||
"snowbridge-inbound-queue/std",
|
||||
"snowbridge-outbound-queue-runtime-api/std",
|
||||
"snowbridge-outbound-queue/std",
|
||||
"snowbridge-pallet-ethereum-client/std",
|
||||
"snowbridge-pallet-inbound-queue/std",
|
||||
"snowbridge-pallet-outbound-queue/std",
|
||||
"snowbridge-pallet-system/std",
|
||||
"snowbridge-router-primitives/std",
|
||||
"snowbridge-system-runtime-api/std",
|
||||
"snowbridge-system/std",
|
||||
"sp-api/std",
|
||||
"sp-block-builder/std",
|
||||
"sp-consensus-aura/std",
|
||||
@@ -166,9 +164,7 @@ std = [
|
||||
]
|
||||
|
||||
runtime-benchmarks = [
|
||||
"asset-hub-rococo-runtime/runtime-benchmarks",
|
||||
"assets-common/runtime-benchmarks",
|
||||
"bridge-hub-rococo-runtime/runtime-benchmarks",
|
||||
"bridge-runtime-common/runtime-benchmarks",
|
||||
"cumulus-pallet-dmp-queue/runtime-benchmarks",
|
||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||
@@ -192,53 +188,12 @@ runtime-benchmarks = [
|
||||
"polkadot-parachain-primitives/runtime-benchmarks",
|
||||
"polkadot-runtime-common/runtime-benchmarks",
|
||||
"snowbridge-core/runtime-benchmarks",
|
||||
"snowbridge-ethereum-beacon-client/runtime-benchmarks",
|
||||
"snowbridge-inbound-queue/runtime-benchmarks",
|
||||
"snowbridge-outbound-queue/runtime-benchmarks",
|
||||
"snowbridge-pallet-ethereum-client/runtime-benchmarks",
|
||||
"snowbridge-pallet-inbound-queue/runtime-benchmarks",
|
||||
"snowbridge-pallet-outbound-queue/runtime-benchmarks",
|
||||
"snowbridge-pallet-system/runtime-benchmarks",
|
||||
"snowbridge-router-primitives/runtime-benchmarks",
|
||||
"snowbridge-system/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"xcm-executor/runtime-benchmarks",
|
||||
]
|
||||
|
||||
try-runtime = [
|
||||
"asset-hub-rococo-runtime/try-runtime",
|
||||
"bridge-hub-rococo-runtime/try-runtime",
|
||||
"cumulus-pallet-aura-ext/try-runtime",
|
||||
"cumulus-pallet-dmp-queue/try-runtime",
|
||||
"cumulus-pallet-parachain-system/try-runtime",
|
||||
"cumulus-pallet-xcm/try-runtime",
|
||||
"cumulus-pallet-xcmp-queue/try-runtime",
|
||||
"frame-executive/try-runtime",
|
||||
"frame-support/try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
"frame-try-runtime/try-runtime",
|
||||
"pallet-aura/try-runtime",
|
||||
"pallet-authorship/try-runtime",
|
||||
"pallet-balances/try-runtime",
|
||||
"pallet-collator-selection/try-runtime",
|
||||
"pallet-message-queue/try-runtime",
|
||||
"pallet-multisig/try-runtime",
|
||||
"pallet-session/try-runtime",
|
||||
"pallet-timestamp/try-runtime",
|
||||
"pallet-transaction-payment/try-runtime",
|
||||
"pallet-utility/try-runtime",
|
||||
"pallet-xcm/try-runtime",
|
||||
"parachain-info/try-runtime",
|
||||
"polkadot-runtime-common/try-runtime",
|
||||
"snowbridge-ethereum-beacon-client/try-runtime",
|
||||
"snowbridge-inbound-queue/try-runtime",
|
||||
"snowbridge-outbound-queue/try-runtime",
|
||||
"snowbridge-system/try-runtime",
|
||||
"sp-runtime/try-runtime",
|
||||
]
|
||||
fast-runtime = [
|
||||
"bridge-hub-rococo-runtime/fast-runtime",
|
||||
]
|
||||
experimental = ["pallet-aura/experimental"]
|
||||
|
||||
# A feature that should be enabled when the runtime should be built for on-chain
|
||||
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
|
||||
# to make it smaller like logging for example.
|
||||
on-chain-release-build = ["sp-api/disable-logging"]
|
||||
@@ -0,0 +1,3 @@
|
||||
# Runtime Tests
|
||||
|
||||
Tests runtime config and bridge functionality in the boundaries of a runtime.
|
||||
+25
-24
@@ -1,12 +1,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
|
||||
|
||||
//! Module contains predefined test-case scenarios for `Runtime` with bridging capabilities.
|
||||
|
||||
use asset_hub_rococo_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
|
||||
use bridge_hub_rococo_runtime::EthereumSystem;
|
||||
use codec::Encode;
|
||||
use frame_support::{assert_err, assert_ok, traits::fungible::Mutate};
|
||||
pub use parachains_runtimes_test_utils::test_cases::change_storage_constant_by_governance_works;
|
||||
use parachains_runtimes_test_utils::{
|
||||
AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, ValidatorIdOf, XcmReceivedFrom,
|
||||
};
|
||||
@@ -49,7 +46,7 @@ where
|
||||
+ parachain_info::Config
|
||||
+ pallet_collator_selection::Config
|
||||
+ cumulus_pallet_parachain_system::Config
|
||||
+ snowbridge_outbound_queue::Config,
|
||||
+ snowbridge_pallet_outbound_queue::Config,
|
||||
XcmConfig: xcm_executor::Config,
|
||||
{
|
||||
let assethub_parachain_location = MultiLocation::new(1, Parachain(assethub_parachain_id));
|
||||
@@ -109,8 +106,8 @@ pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
|
||||
weth_contract_address: H160,
|
||||
destination_address: H160,
|
||||
fee_amount: u128,
|
||||
snowbridge_outbound_queue: Box<
|
||||
dyn Fn(Vec<u8>) -> Option<snowbridge_outbound_queue::Event<Runtime>>,
|
||||
snowbridge_pallet_outbound_queue: Box<
|
||||
dyn Fn(Vec<u8>) -> Option<snowbridge_pallet_outbound_queue::Event<Runtime>>,
|
||||
>,
|
||||
) where
|
||||
Runtime: frame_system::Config
|
||||
@@ -120,8 +117,8 @@ pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
|
||||
+ parachain_info::Config
|
||||
+ pallet_collator_selection::Config
|
||||
+ cumulus_pallet_parachain_system::Config
|
||||
+ snowbridge_outbound_queue::Config
|
||||
+ snowbridge_system::Config,
|
||||
+ snowbridge_pallet_outbound_queue::Config
|
||||
+ snowbridge_pallet_system::Config,
|
||||
XcmConfig: xcm_executor::Config,
|
||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
||||
{
|
||||
@@ -132,14 +129,14 @@ pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
|
||||
.with_tracing()
|
||||
.build()
|
||||
.execute_with(|| {
|
||||
EthereumSystem::initialize(runtime_para_id.into(), assethub_parachain_id.into())
|
||||
.unwrap();
|
||||
<snowbridge_pallet_system::Pallet<Runtime>>::initialize(
|
||||
runtime_para_id.into(),
|
||||
assethub_parachain_id.into(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// fund asset hub sovereign account enough so it can pay fees
|
||||
initial_fund::<Runtime>(
|
||||
assethub_parachain_id,
|
||||
DefaultBridgeHubEthereumBaseFee::get() + 1_000_000_000,
|
||||
);
|
||||
initial_fund::<Runtime>(assethub_parachain_id, 5_000_000_000_000);
|
||||
|
||||
let outcome = send_transfer_token_message::<Runtime, XcmConfig>(
|
||||
assethub_parachain_id,
|
||||
@@ -153,10 +150,11 @@ pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
|
||||
// check events
|
||||
let mut events = <frame_system::Pallet<Runtime>>::events()
|
||||
.into_iter()
|
||||
.filter_map(|e| snowbridge_outbound_queue(e.event.encode()));
|
||||
assert!(
|
||||
events.any(|e| matches!(e, snowbridge_outbound_queue::Event::MessageQueued { .. }))
|
||||
);
|
||||
.filter_map(|e| snowbridge_pallet_outbound_queue(e.event.encode()));
|
||||
assert!(events.any(|e| matches!(
|
||||
e,
|
||||
snowbridge_pallet_outbound_queue::Event::MessageQueued { .. }
|
||||
)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -174,7 +172,7 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
|
||||
+ parachain_info::Config
|
||||
+ pallet_collator_selection::Config
|
||||
+ cumulus_pallet_parachain_system::Config
|
||||
+ snowbridge_outbound_queue::Config,
|
||||
+ snowbridge_pallet_outbound_queue::Config,
|
||||
XcmConfig: xcm_executor::Config,
|
||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
||||
{
|
||||
@@ -263,8 +261,8 @@ pub fn send_transfer_token_message_failure<Runtime, XcmConfig>(
|
||||
+ parachain_info::Config
|
||||
+ pallet_collator_selection::Config
|
||||
+ cumulus_pallet_parachain_system::Config
|
||||
+ snowbridge_outbound_queue::Config
|
||||
+ snowbridge_system::Config,
|
||||
+ snowbridge_pallet_outbound_queue::Config
|
||||
+ snowbridge_pallet_system::Config,
|
||||
XcmConfig: xcm_executor::Config,
|
||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
||||
{
|
||||
@@ -275,8 +273,11 @@ pub fn send_transfer_token_message_failure<Runtime, XcmConfig>(
|
||||
.with_tracing()
|
||||
.build()
|
||||
.execute_with(|| {
|
||||
EthereumSystem::initialize(runtime_para_id.into(), assethub_parachain_id.into())
|
||||
.unwrap();
|
||||
<snowbridge_pallet_system::Pallet<Runtime>>::initialize(
|
||||
runtime_para_id.into(),
|
||||
assethub_parachain_id.into(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// fund asset hub sovereign account enough so it can pay fees
|
||||
initial_fund::<Runtime>(assethub_parachain_id, initial_amount);
|
||||
@@ -1,94 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
mod test_cases;
|
||||
|
||||
use asset_hub_rococo_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
|
||||
use bridge_hub_rococo_runtime::{
|
||||
xcm_config::XcmConfig, MessageQueueServiceWeight, Runtime, RuntimeEvent, SessionKeys,
|
||||
};
|
||||
use codec::Decode;
|
||||
use cumulus_primitives_core::XcmError::{FailedToTransactAsset, NotHoldingFees};
|
||||
use parachains_common::{AccountId, AuraId};
|
||||
use snowbridge_ethereum_beacon_client::WeightInfo;
|
||||
use sp_core::H160;
|
||||
use sp_keyring::AccountKeyring::Alice;
|
||||
|
||||
pub fn collator_session_keys() -> bridge_hub_test_utils::CollatorSessionKeys<Runtime> {
|
||||
bridge_hub_test_utils::CollatorSessionKeys::new(
|
||||
AccountId::from(Alice),
|
||||
AccountId::from(Alice),
|
||||
SessionKeys { aura: AuraId::from(Alice.public()) },
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn transfer_token_to_ethereum_works() {
|
||||
test_cases::send_transfer_token_message_success::<Runtime, XcmConfig>(
|
||||
collator_session_keys(),
|
||||
1013,
|
||||
1000,
|
||||
H160::random(),
|
||||
H160::random(),
|
||||
DefaultBridgeHubEthereumBaseFee::get(),
|
||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||
Ok(RuntimeEvent::EthereumOutboundQueue(event)) => Some(event),
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn unpaid_transfer_token_to_ethereum_fails_with_barrier() {
|
||||
test_cases::send_unpaid_transfer_token_message::<Runtime, XcmConfig>(
|
||||
collator_session_keys(),
|
||||
1013,
|
||||
1000,
|
||||
H160::random(),
|
||||
H160::random(),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn transfer_token_to_ethereum_fee_not_enough() {
|
||||
test_cases::send_transfer_token_message_failure::<Runtime, XcmConfig>(
|
||||
collator_session_keys(),
|
||||
1013,
|
||||
1000,
|
||||
DefaultBridgeHubEthereumBaseFee::get() + 1_000_000_000,
|
||||
H160::random(),
|
||||
H160::random(),
|
||||
// fee not enough
|
||||
1_000_000_000,
|
||||
NotHoldingFees,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn transfer_token_to_ethereum_insufficient_fund() {
|
||||
test_cases::send_transfer_token_message_failure::<Runtime, XcmConfig>(
|
||||
collator_session_keys(),
|
||||
1013,
|
||||
1000,
|
||||
1_000_000_000,
|
||||
H160::random(),
|
||||
H160::random(),
|
||||
DefaultBridgeHubEthereumBaseFee::get(),
|
||||
FailedToTransactAsset("InsufficientBalance"),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn max_message_queue_service_weight_is_more_than_beacon_extrinsic_weights() {
|
||||
let max_message_queue_weight = MessageQueueServiceWeight::get();
|
||||
let force_checkpoint =
|
||||
<Runtime as snowbridge_ethereum_beacon_client::Config>::WeightInfo::force_checkpoint();
|
||||
let submit_checkpoint =
|
||||
<Runtime as snowbridge_ethereum_beacon_client::Config>::WeightInfo::submit();
|
||||
max_message_queue_weight.all_gt(force_checkpoint);
|
||||
max_message_queue_weight.all_gt(submit_checkpoint);
|
||||
}
|
||||
Reference in New Issue
Block a user