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:
Clara van Staden
2024-01-10 18:51:27 +02:00
committed by GitHub
parent 6a80c10a6f
commit bab0348372
88 changed files with 579 additions and 490 deletions
+16
View File
@@ -117,3 +117,19 @@ pub mod consensus {
/// Relay chain slot duration, in milliseconds.
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
}
pub mod snowbridge {
use frame_support::parameter_types;
use xcm::opaque::lts::NetworkId;
/// The pallet index of the Ethereum inbound queue pallet in the bridge hub runtime.
pub const INBOUND_QUEUE_PALLET_INDEX: u8 = 80;
parameter_types! {
/// Network and location for the Ethereum chain. On Rococo, the Ethereum chain bridged
/// to is the Sepolia Ethereum testnet, with chain ID 11155111.
/// <https://chainlist.org/chain/11155111>
/// <https://ethereum.org/en/developers/docs/apis/json-rpc/#net_version>
pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 11155111 };
}
}
@@ -30,6 +30,6 @@ bridge-hub-common = { path = "../../../../../../runtimes/bridge-hubs/common", de
# Snowbridge
snowbridge-core = { path = "../../../../../../../../bridges/snowbridge/parachain/primitives/core", default-features = false }
snowbridge-router-primitives = { path = "../../../../../../../../bridges/snowbridge/parachain/primitives/router", default-features = false }
snowbridge-system = { path = "../../../../../../../../bridges/snowbridge/parachain/pallets/system", default-features = false }
snowbridge-inbound-queue = { path = "../../../../../../../../bridges/snowbridge/parachain/pallets/inbound-queue", default-features = false }
snowbridge-outbound-queue = { path = "../../../../../../../../bridges/snowbridge/parachain/pallets/outbound-queue", default-features = false }
snowbridge-pallet-system = { path = "../../../../../../../../bridges/snowbridge/parachain/pallets/system", default-features = false }
snowbridge-pallet-inbound-queue = { path = "../../../../../../../../bridges/snowbridge/parachain/pallets/inbound-queue", default-features = false }
snowbridge-pallet-outbound-queue = { path = "../../../../../../../../bridges/snowbridge/parachain/pallets/outbound-queue", default-features = false }
@@ -48,7 +48,6 @@ asset-hub-rococo-runtime = { path = "../../../../../runtimes/assets/asset-hub-ro
# Snowbridge
snowbridge-core = { path = "../../../../../../../bridges/snowbridge/parachain/primitives/core", default-features = false }
snowbridge-router-primitives = { path = "../../../../../../../bridges/snowbridge/parachain/primitives/router", default-features = false }
snowbridge-system = { path = "../../../../../../../bridges/snowbridge/parachain/pallets/system", default-features = false }
snowbridge-inbound-queue = { path = "../../../../../../../bridges/snowbridge/parachain/pallets/inbound-queue", default-features = false }
snowbridge-outbound-queue = { path = "../../../../../../../bridges/snowbridge/parachain/pallets/outbound-queue", default-features = false }
snowbridge-rococo-common = { path = "../../../../../../../bridges/snowbridge/parachain/runtime/rococo-common", default-features = false }
snowbridge-pallet-system = { path = "../../../../../../../bridges/snowbridge/parachain/pallets/system", default-features = false }
snowbridge-pallet-inbound-queue = { path = "../../../../../../../bridges/snowbridge/parachain/pallets/inbound-queue", default-features = false }
snowbridge-pallet-outbound-queue = { path = "../../../../../../../bridges/snowbridge/parachain/pallets/outbound-queue", default-features = false }
@@ -17,12 +17,12 @@ use codec::{Decode, Encode};
use emulated_integration_tests_common::xcm_emulator::ConvertLocation;
use frame_support::pallet_prelude::TypeInfo;
use hex_literal::hex;
use parachains_common::rococo::snowbridge::EthereumNetwork;
use snowbridge_core::outbound::OperatingMode;
use snowbridge_rococo_common::EthereumNetwork;
use snowbridge_pallet_system;
use snowbridge_router_primitives::inbound::{
Command, Destination, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage,
};
use snowbridge_system;
use sp_core::H256;
const INITIAL_FUND: u128 = 5_000_000_000 * ROCOCO_ED;
@@ -94,7 +94,7 @@ fn create_agent() {
assert_expected_events!(
BridgeHubRococo,
vec![
RuntimeEvent::EthereumSystem(snowbridge_system::Event::CreateAgent {
RuntimeEvent::EthereumSystem(snowbridge_pallet_system::Event::CreateAgent {
..
}) => {},
]
@@ -168,7 +168,7 @@ fn create_channel() {
assert_expected_events!(
BridgeHubRococo,
vec![
RuntimeEvent::EthereumSystem(snowbridge_system::Event::CreateChannel {
RuntimeEvent::EthereumSystem(snowbridge_pallet_system::Event::CreateChannel {
..
}) => {},
]
@@ -190,7 +190,10 @@ fn register_weth_token_from_ethereum_to_asset_hub() {
chain_id: CHAIN_ID,
command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE },
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
let (xcm, fee) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
assert_ok!(EthereumInboundQueue::burn_fees(AssetHubRococo::para_id().into(), fee));
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into()).unwrap();
assert_expected_events!(
@@ -481,7 +484,7 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {
assert_expected_events!(
BridgeHubRococo,
vec![
RuntimeEvent::EthereumOutboundQueue(snowbridge_outbound_queue::Event::MessageQueued {..}) => {},
RuntimeEvent::EthereumOutboundQueue(snowbridge_pallet_outbound_queue::Event::MessageQueued {..}) => {},
]
);
let events = BridgeHubRococo::events();
@@ -91,7 +91,6 @@ bp-asset-hub-westend = { path = "../../../../../bridges/primitives/chain-asset-h
bp-bridge-hub-rococo = { path = "../../../../../bridges/primitives/chain-bridge-hub-rococo", default-features = false }
bp-bridge-hub-westend = { path = "../../../../../bridges/primitives/chain-bridge-hub-westend", default-features = false }
snowbridge-router-primitives = { path = "../../../../../bridges/snowbridge/parachain/primitives/router", default-features = false }
snowbridge-rococo-common = { path = "../../../../../bridges/snowbridge/parachain/runtime/rococo-common", default-features = false }
[dev-dependencies]
asset-test-utils = { path = "../test-utils" }
@@ -139,7 +138,6 @@ runtime-benchmarks = [
"parachains-common/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"snowbridge-rococo-common/runtime-benchmarks",
"snowbridge-router-primitives/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
@@ -231,7 +229,6 @@ std = [
"primitive-types/std",
"rococo-runtime-constants/std",
"scale-info/std",
"snowbridge-rococo-common/std",
"snowbridge-router-primitives/std",
"sp-api/std",
"sp-block-builder/std",
@@ -35,7 +35,7 @@ use assets_common::{
};
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::AggregateMessageOrigin;
use snowbridge_rococo_common::EthereumNetwork;
use parachains_common::rococo::snowbridge::EthereumNetwork;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
@@ -31,6 +31,7 @@ use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
rococo::snowbridge::EthereumNetwork,
xcm_config::{
AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier,
ConcreteAssetFromSystem, ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains,
@@ -39,7 +40,6 @@ use parachains_common::{
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use snowbridge_rococo_common::EthereumNetwork;
use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor;
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
use xcm::latest::prelude::*;
@@ -817,7 +817,7 @@ pub mod bridging {
1,
X2(
Parachain(SiblingBridgeHubParaId::get()),
PalletInstance(snowbridge_rococo_common::INBOUND_QUEUE_MESSAGES_PALLET_INDEX)
PalletInstance(parachains_common::rococo::snowbridge::INBOUND_QUEUE_PALLET_INDEX)
)
);
@@ -108,16 +108,15 @@ bridge-runtime-common = { path = "../../../../../bridges/bin/runtime-common", de
# Ethereum Bridge (Snowbridge)
snowbridge-beacon-primitives = { path = "../../../../../bridges/snowbridge/parachain/primitives/beacon", default-features = false }
snowbridge-system = { path = "../../../../../bridges/snowbridge/parachain/pallets/system", default-features = false }
snowbridge-pallet-system = { path = "../../../../../bridges/snowbridge/parachain/pallets/system", default-features = false }
snowbridge-system-runtime-api = { path = "../../../../../bridges/snowbridge/parachain/pallets/system/runtime-api", default-features = false }
snowbridge-core = { path = "../../../../../bridges/snowbridge/parachain/primitives/core", default-features = false }
snowbridge-ethereum-beacon-client = { path = "../../../../../bridges/snowbridge/parachain/pallets/ethereum-beacon-client", default-features = false }
snowbridge-inbound-queue = { path = "../../../../../bridges/snowbridge/parachain/pallets/inbound-queue", default-features = false }
snowbridge-outbound-queue = { path = "../../../../../bridges/snowbridge/parachain/pallets/outbound-queue", default-features = false }
snowbridge-pallet-ethereum-client = { path = "../../../../../bridges/snowbridge/parachain/pallets/ethereum-client", default-features = false }
snowbridge-pallet-inbound-queue = { path = "../../../../../bridges/snowbridge/parachain/pallets/inbound-queue", default-features = false }
snowbridge-pallet-outbound-queue = { path = "../../../../../bridges/snowbridge/parachain/pallets/outbound-queue", default-features = false }
snowbridge-outbound-queue-runtime-api = { path = "../../../../../bridges/snowbridge/parachain/pallets/outbound-queue/runtime-api", default-features = false }
snowbridge-router-primitives = { path = "../../../../../bridges/snowbridge/parachain/primitives/router", default-features = false }
snowbridge-runtime-common = { path = "../../../../../bridges/snowbridge/parachain/runtime/runtime-common", default-features = false }
snowbridge-rococo-common = { path = "../../../../../bridges/snowbridge/parachain/runtime/rococo-common", default-features = false }
bridge-hub-common = { path = "../common", default-features = false }
@@ -128,6 +127,7 @@ bridge-runtime-common = { path = "../../../../../bridges/bin/runtime-common", fe
"integrity-test",
] }
sp-keyring = { path = "../../../../../substrate/primitives/keyring" }
snowbridge-runtime-test-common = { path = "../../../../../bridges/snowbridge/parachain/runtime/test-common" }
[features]
default = ["std"]
@@ -192,15 +192,14 @@ 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-rococo-common/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-runtime-common/std",
"snowbridge-system-runtime-api/std",
"snowbridge-system/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
@@ -251,13 +250,13 @@ 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-rococo-common/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-runtime-common/runtime-benchmarks",
"snowbridge-system/runtime-benchmarks",
"snowbridge-runtime-test-common/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
@@ -290,16 +289,16 @@ 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",
"snowbridge-pallet-ethereum-client/try-runtime",
"snowbridge-pallet-inbound-queue/try-runtime",
"snowbridge-pallet-outbound-queue/try-runtime",
"snowbridge-pallet-system/try-runtime",
"sp-runtime/try-runtime",
]
experimental = ["pallet-aura/experimental"]
fast-runtime = [
"snowbridge-ethereum-beacon-client/beacon-spec-minimal",
"snowbridge-pallet-ethereum-client/beacon-spec-minimal",
]
# A feature that should be enabled when the runtime should be built for on-chain
@@ -15,13 +15,13 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::{xcm_config::UniversalLocation, Runtime};
use snowbridge_rococo_common::EthereumNetwork;
use parachains_common::rococo::snowbridge::EthereumNetwork;
use snowbridge_router_primitives::outbound::EthereumBlobExporter;
/// Exports message to the Ethereum Gateway contract.
pub type SnowbridgeExporter = EthereumBlobExporter<
UniversalLocation,
EthereumNetwork,
snowbridge_outbound_queue::Pallet<Runtime>,
snowbridge_pallet_outbound_queue::Pallet<Runtime>,
snowbridge_core::AgentIdOf,
>;
@@ -71,8 +71,6 @@ use frame_system::{
};
use bp_runtime::HeaderId;
#[cfg(not(feature = "runtime-benchmarks"))]
use bridge_hub_common::BridgeHubMessageRouter;
use bridge_hub_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AggregateMessageOrigin,
@@ -102,17 +100,9 @@ use parachains_common::{
use polkadot_runtime_common::prod_or_fast;
#[cfg(feature = "runtime-benchmarks")]
use crate::xcm_config::benchmark_helpers::DoNothingRouter;
#[cfg(feature = "runtime-benchmarks")]
use snowbridge_beacon_primitives::CompactExecutionHeader;
#[cfg(feature = "runtime-benchmarks")]
use snowbridge_core::RingBufferMap;
#[cfg(feature = "runtime-benchmarks")]
pub use snowbridge_ethereum_beacon_client::ExecutionHeaderBuffer;
#[cfg(feature = "runtime-benchmarks")]
use snowbridge_inbound_queue::BenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
use sp_core::H256;
use benchmark_helpers::DoNothingRouter;
#[cfg(not(feature = "runtime-benchmarks"))]
use bridge_hub_common::BridgeHubMessageRouter;
/// The address format for describing accounts.
pub type Address = MultiAddress<AccountId, ()>;
@@ -154,7 +144,7 @@ pub type Migrations = (
InitStorageVersions,
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
// unreleased
snowbridge_system::migration::v0::InitializeOnUpgrade<
snowbridge_pallet_system::migration::v0::InitializeOnUpgrade<
Runtime,
ConstU32<BRIDGE_HUB_ID>,
ConstU32<ASSET_HUB_ID>,
@@ -512,7 +502,7 @@ parameter_types! {
parameter_types! {
pub const CreateAssetCall: [u8;2] = [53, 0];
pub const CreateAssetDeposit: u128 = (UNITS / 10) + EXISTENTIAL_DEPOSIT;
pub const InboundQueuePalletInstance: u8 = snowbridge_rococo_common::INBOUND_QUEUE_MESSAGES_PALLET_INDEX;
pub const InboundQueuePalletInstance: u8 = parachains_common::rococo::snowbridge::INBOUND_QUEUE_PALLET_INDEX;
pub Parameters: PricingParameters<u128> = PricingParameters {
exchange_rate: FixedU128::from_rational(1, 400),
fee_per_gas: gwei(20),
@@ -521,15 +511,46 @@ parameter_types! {
}
#[cfg(feature = "runtime-benchmarks")]
impl<T: snowbridge_ethereum_beacon_client::Config> BenchmarkHelper<T> for Runtime {
fn initialize_storage(block_hash: H256, header: CompactExecutionHeader) {
<ExecutionHeaderBuffer<T>>::insert(block_hash, header);
pub mod benchmark_helpers {
use crate::{EthereumBeaconClient, Runtime, RuntimeOrigin};
use codec::Encode;
use snowbridge_beacon_primitives::CompactExecutionHeader;
use snowbridge_pallet_inbound_queue::BenchmarkHelper;
use sp_core::H256;
use xcm::latest::{MultiAssets, MultiLocation, SendError, SendResult, SendXcm, Xcm, XcmHash};
impl<T: snowbridge_pallet_ethereum_client::Config> BenchmarkHelper<T> for Runtime {
fn initialize_storage(block_hash: H256, header: CompactExecutionHeader) {
EthereumBeaconClient::store_execution_header(block_hash, header, 0, H256::default())
}
}
pub struct DoNothingRouter;
impl SendXcm for DoNothingRouter {
type Ticket = Xcm<()>;
fn validate(
_dest: &mut Option<MultiLocation>,
xcm: &mut Option<Xcm<()>>,
) -> SendResult<Self::Ticket> {
Ok((xcm.clone().unwrap(), MultiAssets::new()))
}
fn deliver(xcm: Xcm<()>) -> Result<XcmHash, SendError> {
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
Ok(hash)
}
}
impl snowbridge_pallet_system::BenchmarkHelper<RuntimeOrigin> for () {
fn make_xcm_origin(location: MultiLocation) -> RuntimeOrigin {
RuntimeOrigin::from(pallet_xcm::Origin::Xcm(location))
}
}
}
impl snowbridge_inbound_queue::Config for Runtime {
impl snowbridge_pallet_inbound_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Verifier = snowbridge_ethereum_beacon_client::Pallet<Runtime>;
type Verifier = snowbridge_pallet_ethereum_client::Pallet<Runtime>;
type Token = Balances;
#[cfg(not(feature = "runtime-benchmarks"))]
type XcmSender = XcmRouter;
@@ -549,11 +570,12 @@ impl snowbridge_inbound_queue::Config for Runtime {
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type MaxMessageSize = ConstU32<2048>;
type WeightInfo = weights::snowbridge_inbound_queue::WeightInfo<Runtime>;
type WeightInfo = weights::snowbridge_pallet_inbound_queue::WeightInfo<Runtime>;
type PricingParameters = EthereumSystem;
type AssetTransactor = <xcm_config::XcmConfig as xcm_executor::Config>::AssetTransactor;
}
impl snowbridge_outbound_queue::Config for Runtime {
impl snowbridge_pallet_outbound_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Hashing = Keccak256;
type MessageQueue = MessageQueue;
@@ -563,7 +585,7 @@ impl snowbridge_outbound_queue::Config for Runtime {
type GasMeter = snowbridge_core::outbound::ConstantGasMeter;
type Balance = Balance;
type WeightToFee = WeightToFee;
type WeightInfo = weights::snowbridge_outbound_queue::WeightInfo<Runtime>;
type WeightInfo = weights::snowbridge_pallet_outbound_queue::WeightInfo<Runtime>;
type PricingParameters = EthereumSystem;
type Channels = EthereumSystem;
}
@@ -616,28 +638,21 @@ parameter_types! {
pub const MaxExecutionHeadersToKeep: u32 = prod_or_fast!(8192 * 2, 1000);
}
impl snowbridge_ethereum_beacon_client::Config for Runtime {
impl snowbridge_pallet_ethereum_client::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ForkVersions = ChainForkVersions;
type MaxExecutionHeadersToKeep = MaxExecutionHeadersToKeep;
type WeightInfo = weights::snowbridge_ethereum_beacon_client::WeightInfo<Runtime>;
type WeightInfo = weights::snowbridge_pallet_ethereum_client::WeightInfo<Runtime>;
}
#[cfg(feature = "runtime-benchmarks")]
impl snowbridge_system::BenchmarkHelper<RuntimeOrigin> for () {
fn make_xcm_origin(location: xcm::latest::MultiLocation) -> RuntimeOrigin {
RuntimeOrigin::from(pallet_xcm::Origin::Xcm(location))
}
}
impl snowbridge_system::Config for Runtime {
impl snowbridge_pallet_system::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OutboundQueue = EthereumOutboundQueue;
type SiblingOrigin = EnsureXcm<AllowSiblingsOnly>;
type AgentIdOf = snowbridge_core::AgentIdOf;
type TreasuryAccount = TreasuryAccount;
type Token = Balances;
type WeightInfo = weights::snowbridge_system::WeightInfo<Runtime>;
type WeightInfo = weights::snowbridge_pallet_system::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
type DefaultPricingParameters = Parameters;
@@ -703,10 +718,10 @@ construct_runtime!(
// With-Rococo Bulletin bridge hub pallet.
XcmOverPolkadotBulletin: pallet_xcm_bridge_hub::<Instance2>::{Pallet} = 62,
EthereumInboundQueue: snowbridge_inbound_queue::{Pallet, Call, Storage, Event<T>} = 80,
EthereumOutboundQueue: snowbridge_outbound_queue::{Pallet, Call, Storage, Event<T>} = 81,
EthereumBeaconClient: snowbridge_ethereum_beacon_client::{Pallet, Call, Storage, Event<T>} = 82,
EthereumSystem: snowbridge_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 83,
EthereumInboundQueue: snowbridge_pallet_inbound_queue::{Pallet, Call, Storage, Event<T>} = 80,
EthereumOutboundQueue: snowbridge_pallet_outbound_queue::{Pallet, Call, Storage, Event<T>} = 81,
EthereumBeaconClient: snowbridge_pallet_ethereum_client::{Pallet, Call, Storage, Event<T>} = 82,
EthereumSystem: snowbridge_pallet_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 83,
// Message Queue. Importantly, is registered last so that messages are processed after
// the `on_initialize` hooks of bridging pallets.
@@ -758,10 +773,10 @@ mod benches {
[pallet_bridge_messages, RococoToRococoBulletin]
[pallet_bridge_relayers, BridgeRelayersBench::<Runtime>]
// Ethereum Bridge
[snowbridge_inbound_queue, EthereumInboundQueue]
[snowbridge_outbound_queue, EthereumOutboundQueue]
[snowbridge_system, EthereumSystem]
[snowbridge_ethereum_beacon_client, EthereumBeaconClient]
[snowbridge_pallet_inbound_queue, EthereumInboundQueue]
[snowbridge_pallet_outbound_queue, EthereumOutboundQueue]
[snowbridge_pallet_system, EthereumSystem]
[snowbridge_pallet_ethereum_client, EthereumBeaconClient]
);
}
@@ -991,18 +1006,18 @@ impl_runtime_apis! {
}
impl snowbridge_outbound_queue_runtime_api::OutboundQueueApi<Block, Balance> for Runtime {
fn prove_message(leaf_index: u64) -> Option<snowbridge_outbound_queue::MerkleProof> {
snowbridge_outbound_queue::api::prove_message::<Runtime>(leaf_index)
fn prove_message(leaf_index: u64) -> Option<snowbridge_pallet_outbound_queue::MerkleProof> {
snowbridge_pallet_outbound_queue::api::prove_message::<Runtime>(leaf_index)
}
fn calculate_fee(message: Message) -> Option<Balance> {
snowbridge_outbound_queue::api::calculate_fee::<Runtime>(message)
snowbridge_pallet_outbound_queue::api::calculate_fee::<Runtime>(message)
}
}
impl snowbridge_system_runtime_api::ControlApi<Block> for Runtime {
fn agent_id(location: VersionedMultiLocation) -> Option<AgentId> {
snowbridge_system::api::agent_id::<Runtime>(location)
snowbridge_pallet_system::api::agent_id::<Runtime>(location)
}
}
@@ -40,10 +40,10 @@ pub mod pallet_utility;
pub mod pallet_xcm;
pub mod paritydb_weights;
pub mod rocksdb_weights;
pub mod snowbridge_ethereum_beacon_client;
pub mod snowbridge_inbound_queue;
pub mod snowbridge_outbound_queue;
pub mod snowbridge_system;
pub mod snowbridge_pallet_ethereum_client;
pub mod snowbridge_pallet_inbound_queue;
pub mod snowbridge_pallet_outbound_queue;
pub mod snowbridge_pallet_system;
pub mod xcm;
pub use block_weights::constants::BlockExecutionWeight;
@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `snowbridge_ethereum_beacon_client`
//! Autogenerated weights for `snowbridge_pallet_ethereum_client`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-06-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
@@ -47,9 +47,9 @@
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `snowbridge_ethereum_beacon_client`.
/// Weight functions for `snowbridge_pallet_ethereum_client`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> snowbridge_ethereum_beacon_client::WeightInfo for WeightInfo<T> {
impl<T: frame_system::Config> snowbridge_pallet_ethereum_client::WeightInfo for WeightInfo<T> {
/// Storage: EthereumBeaconClient FinalizedBeaconStateIndex (r:1 w:1)
/// Proof: EthereumBeaconClient FinalizedBeaconStateIndex (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: EthereumBeaconClient FinalizedBeaconStateMapping (r:1 w:1)
@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `snowbridge_inbound_queue`
//! Autogenerated weights for `snowbridge_pallet_inbound_queue`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-09-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
@@ -45,9 +45,9 @@
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `snowbridge_inbound_queue`.
/// Weight functions for `snowbridge_pallet_inbound_queue`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> snowbridge_inbound_queue::WeightInfo for WeightInfo<T> {
impl<T: frame_system::Config> snowbridge_pallet_inbound_queue::WeightInfo for WeightInfo<T> {
/// Storage: EthereumInboundQueue PalletOperatingMode (r:1 w:0)
/// Proof: EthereumInboundQueue PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen)
/// Storage: EthereumBeaconClient ExecutionHeaders (r:1 w:0)
@@ -43,7 +43,7 @@ use core::marker::PhantomData;
/// Weight functions for `snowbridge_outbound_queue`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> snowbridge_outbound_queue::WeightInfo for WeightInfo<T> {
impl<T: frame_system::Config> snowbridge_pallet_outbound_queue::WeightInfo for WeightInfo<T> {
/// Storage: EthereumOutboundQueue MessageLeaves (r:1 w:1)
/// Proof Skipped: EthereumOutboundQueue MessageLeaves (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: EthereumOutboundQueue PendingHighPriorityMessageCount (r:1 w:1)
@@ -27,12 +27,12 @@
// pallet
// --chain
// bridge-hub-rococo-dev
// --pallet=snowbridge_system
// --pallet=snowbridge_pallet_system
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --output
// parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_system.rs
// parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_pallet_system.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -44,7 +44,7 @@ use core::marker::PhantomData;
/// Weight functions for `snowbridge_system`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> snowbridge_system::WeightInfo for WeightInfo<T> {
impl<T: frame_system::Config> snowbridge_pallet_system::WeightInfo for WeightInfo<T> {
/// Storage: ParachainInfo ParachainId (r:1 w:0)
/// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: EthereumOutboundQueue PalletOperatingMode (r:1 w:0)
@@ -39,6 +39,7 @@ use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
rococo::snowbridge::EthereumNetwork,
xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
RelayOrOtherSystemParachains,
@@ -47,7 +48,6 @@ use parachains_common::{
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use snowbridge_rococo_common::EthereumNetwork;
use snowbridge_runtime_common::XcmExportFeeToSibling;
use sp_core::Get;
use sp_runtime::traits::AccountIdConversion;
@@ -216,12 +216,12 @@ impl Contains<RuntimeCall> for SafeCallFilter {
WithRococoBulletinMessagesInstance,
>::set_operating_mode { .. }) |
RuntimeCall::EthereumBeaconClient(
snowbridge_ethereum_beacon_client::Call::force_checkpoint { .. } |
snowbridge_ethereum_beacon_client::Call::set_operating_mode { .. },
snowbridge_pallet_ethereum_client::Call::force_checkpoint { .. } |
snowbridge_pallet_ethereum_client::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumInboundQueue(
snowbridge_inbound_queue::Call::set_operating_mode { .. },
snowbridge_pallet_inbound_queue::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumOutboundQueue(
snowbridge_outbound_queue::Call::set_operating_mode { .. },
snowbridge_pallet_outbound_queue::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumSystem(..)
)
}
@@ -492,22 +492,3 @@ impl<WaivedLocations: Contains<MultiLocation>, FeeHandler: HandleFee> FeeManager
FeeHandler::handle_fee(fee, context, reason);
}
}
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmark_helpers {
use crate::{MultiAssets, MultiLocation, SendError, SendResult, SendXcm, Xcm, XcmHash};
pub struct DoNothingRouter;
impl SendXcm for DoNothingRouter {
type Ticket = ();
fn validate(
_dest: &mut Option<MultiLocation>,
_msg: &mut Option<Xcm<()>>,
) -> SendResult<()> {
Ok(((), MultiAssets::new()))
}
fn deliver(_: ()) -> Result<XcmHash, SendError> {
Ok([0; 32])
}
}
}
@@ -0,0 +1,109 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
#![cfg(test)]
use bridge_hub_rococo_runtime::{
xcm_config::XcmConfig, MessageQueueServiceWeight, Runtime, RuntimeEvent, SessionKeys,
};
use codec::Decode;
use cumulus_primitives_core::XcmError::{FailedToTransactAsset, NotHoldingFees};
use frame_support::parameter_types;
use parachains_common::{AccountId, AuraId, Balance};
use snowbridge_pallet_ethereum_client::WeightInfo;
use sp_core::H160;
use sp_keyring::AccountKeyring::Alice;
parameter_types! {
pub const DefaultBridgeHubEthereumBaseFee: Balance = 2_750_872_500_000;
}
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() {
snowbridge_runtime_test_common::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() {
snowbridge_runtime_test_common::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() {
snowbridge_runtime_test_common::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() {
snowbridge_runtime_test_common::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_pallet_ethereum_client::Config>::WeightInfo::force_checkpoint();
let submit_checkpoint =
<Runtime as snowbridge_pallet_ethereum_client::Config>::WeightInfo::submit();
max_message_queue_weight.all_gt(force_checkpoint);
max_message_queue_weight.all_gt(submit_checkpoint);
}
@@ -26,7 +26,7 @@ use sp_std::{marker::PhantomData, prelude::*};
use xcm::v3::{Junction, MultiLocation};
/// The aggregate origin of an inbound message.
/// This is specialized for BridgeHub, as the snowbridge-outbound-queue pallet is also using
/// This is specialized for BridgeHub, as the snowbridge-outbound-queue-pallet is also using
/// the shared MessageQueue pallet.
#[derive(Encode, Decode, Copy, MaxEncodedLen, Clone, Eq, PartialEq, TypeInfo, Debug)]
pub enum AggregateMessageOrigin {
@@ -79,7 +79,6 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d
parachain-info = { package = "staging-parachain-info", path = "../../../pallets/parachain-info", default-features = false }
parachains-common = { path = "../../../common", default-features = false }
assets-common = { path = "../../assets/common", default-features = false }
snowbridge-rococo-common = { path = "../../../../../bridges/snowbridge/parachain/runtime/rococo-common", default-features = false }
[features]
default = ["std"]
@@ -121,7 +120,6 @@ std = [
"polkadot-primitives/std",
"polkadot-runtime-common/std",
"scale-info/std",
"snowbridge-rococo-common/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
@@ -166,7 +164,6 @@ runtime-benchmarks = [
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"snowbridge-rococo-common/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
@@ -40,9 +40,9 @@ use frame_system::EnsureRoot;
use pallet_asset_tx_payment::HandleCredit;
use pallet_assets::Instance1;
use pallet_xcm::XcmPassthrough;
use parachains_common::rococo::snowbridge::EthereumNetwork;
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::impls::ToAuthor;
use snowbridge_rococo_common::EthereumNetwork;
use sp_runtime::traits::Zero;
use xcm::latest::prelude::*;
#[allow(deprecated)]