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
@@ -1,11 +1,15 @@
[package]
name = "snowbridge-ethereum-beacon-client"
description = "Snowbridge Beacon Client Pallet"
version = "0.0.1"
edition = "2021"
name = "snowbridge-pallet-ethereum-client"
description = "Snowbridge Ethereum Client Pallet"
version = "0.9.0"
authors = ["Snowfork <contact@snowfork.com>"]
repository = "https://github.com/Snowfork/snowbridge"
edition.workspace = true
repository.workspace = true
license = "Apache-2.0"
categories = ["cryptography::cryptocurrencies"]
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
@@ -0,0 +1,3 @@
# Ethereum Beacon Client
The Ethereum Beacon Client is an on-chain light client that tracks Ethereum consensus using the beacon chain.
@@ -7,15 +7,15 @@ for it is super helpful.
# Benchmark
We add several benchmarks
[here](https://github.com/Snowfork/snowbridge/blob/8891ca3cdcf2e04d8118c206588c956541ae4710/parachain/pallets/ethereum-beacon-client/src/benchmarking/mod.rs#L98-L124)
[here](https://github.com/Snowfork/snowbridge/blob/8891ca3cdcf2e04d8118c206588c956541ae4710/parachain/pallets/ethereum-client/src/benchmarking/mod.rs#L98-L124)
as following to demonstrate
[bls_fast_aggregate_verify](https://github.com/Snowfork/snowbridge/blob/8891ca3cdcf2e04d8118c206588c956541ae4710/parachain/pallets/ethereum-beacon-client/src/lib.rs#L764)
[bls_fast_aggregate_verify](https://github.com/Snowfork/snowbridge/blob/8891ca3cdcf2e04d8118c206588c956541ae4710/parachain/pallets/ethereum-client/src/lib.rs#L764)
is the main bottleneck. Test data
[here](https://github.com/Snowfork/snowbridge/blob/8891ca3cdcf2e04d8118c206588c956541ae4710/parachain/pallets/ethereum-beacon-client/src/benchmarking/data_mainnet.rs#L553-L1120)
[here](https://github.com/Snowfork/snowbridge/blob/8891ca3cdcf2e04d8118c206588c956541ae4710/parachain/pallets/ethereum-client/src/benchmarking/data_mainnet.rs#L553-L1120)
is real from goerli network which contains 512 public keys from sync committee.
## sync_committee_period_update
Base line benchmark for extrinsic [sync_committee_period_update](https://github.com/Snowfork/snowbridge/blob/8891ca3cdcf2e04d8118c206588c956541ae4710/parachain/pallets/ethereum-beacon-client/src/lib.rs#L233)
Base line benchmark for extrinsic [sync_committee_period_update](https://github.com/Snowfork/snowbridge/blob/8891ca3cdcf2e04d8118c206588c956541ae4710/parachain/pallets/ethereum-client/src/lib.rs#L233)
## bls_fast_aggregate_verify
Subfunction of extrinsic `sync_committee_period_update` which does what
@@ -59,14 +59,14 @@ cargo run --release --bin polkadot-parachain \
benchmark pallet \
--base-path /mnt/scratch/benchmark \
--chain=bridge-hub-rococo-dev \
--pallet=snowbridge_ethereum_beacon_client \
--pallet=snowbridge_pallet_ethereum_client \
--extrinsic="*" \
--execution=wasm --wasm-execution=compiled \
--steps 50 --repeat 20 \
--output ./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_ethereum_beacon_client.rs
--output ./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_pallet_ethereum_client.rs
```
### [Weights](https://github.com/Snowfork/cumulus/blob/ron/benchmark-beacon-bridge/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_ethereum_beacon_client.rs)
### [Weights](https://github.com/Snowfork/cumulus/blob/ron/benchmark-beacon-bridge/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_pallet_ethereum_client.rs)
|extrinsic | minimum execution time benchmarked(us) |
| --------------------------------------- |----------------------------------------|
@@ -84,5 +84,5 @@ benchmark pallet \
# Conclusion
A high level host function specific for
[bls_fast_aggregate_verify](https://github.com/Snowfork/snowbridge/blob/8891ca3cdcf2e04d8118c206588c956541ae4710/parachain/pallets/ethereum-beacon-client/src/lib.rs#L764)
[bls_fast_aggregate_verify](https://github.com/Snowfork/snowbridge/blob/8891ca3cdcf2e04d8118c206588c956541ae4710/parachain/pallets/ethereum-client/src/lib.rs#L764)
is super helpful.
@@ -15,7 +15,7 @@ impl<T: Config> Verifier for Pallet<T> {
/// ancestor of a finalized beacon block.
fn verify(event_log: &Log, proof: &Proof) -> Result<(), VerificationError> {
log::info!(
target: "ethereum-beacon-client",
target: "ethereum-client",
"💫 Verifying message with block hash {}",
proof.block_hash,
);
@@ -26,7 +26,7 @@ impl<T: Config> Verifier for Pallet<T> {
Ok(receipt) => receipt,
Err(err) => {
log::error!(
target: "ethereum-beacon-client",
target: "ethereum-client",
"💫 Verification of receipt inclusion failed for block {}: {:?}",
proof.block_hash,
err
@@ -36,7 +36,7 @@ impl<T: Config> Verifier for Pallet<T> {
};
log::trace!(
target: "ethereum-beacon-client",
target: "ethereum-client",
"💫 Verified receipt inclusion for transaction at index {} in block {}",
proof.tx_index, proof.block_hash,
);
@@ -52,7 +52,7 @@ impl<T: Config> Verifier for Pallet<T> {
if !receipt.contains_log(&event_log) {
log::error!(
target: "ethereum-beacon-client",
target: "ethereum-client",
"💫 Event log not found in receipt for transaction at index {} in block {}",
proof.tx_index, proof.block_hash,
);
@@ -60,7 +60,7 @@ impl<T: Config> Verifier for Pallet<T> {
}
log::info!(
target: "ethereum-beacon-client",
target: "ethereum-client",
"💫 Receipt verification successful for {}",
proof.block_hash,
);
@@ -82,7 +82,7 @@ impl<T: Config> Pallet<T> {
Ok(receipt) => Ok(receipt),
Err(err) => {
log::trace!(
target: "ethereum-beacon-client",
target: "ethereum-client",
"💫 Failed to decode transaction receipt: {}",
err
);
@@ -61,7 +61,7 @@ pub use pallet::*;
pub use config::SLOTS_PER_HISTORICAL_ROOT;
pub const LOG_TARGET: &str = "ethereum-beacon-client";
pub const LOG_TARGET: &str = "ethereum-client";
#[frame_support::pallet]
pub mod pallet {
@@ -692,7 +692,7 @@ pub mod pallet {
/// Stores the provided execution header in pallet storage. The header is stored
/// in a ring buffer map, with the block hash as map key. The last imported execution
/// header is also kept in storage, for the relayer to check import progress.
pub(crate) fn store_execution_header(
pub fn store_execution_header(
block_hash: H256,
header: CompactExecutionHeader,
beacon_slot: u64,
@@ -11,6 +11,11 @@ use sp_core::H256;
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
use std::{fs::File, path::PathBuf};
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
fn load_fixture<T>(basename: String) -> Result<T, serde_json::Error>
where
T: for<'de> serde::Deserialize<'de>,
@@ -21,60 +26,36 @@ where
}
pub fn load_execution_header_update_fixture() -> primitives::ExecutionHeaderUpdate {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("execution-header-update.{}.json", SPEC);
load_fixture(basename).unwrap()
}
pub fn load_checkpoint_update_fixture(
) -> primitives::CheckpointUpdate<{ config::SYNC_COMMITTEE_SIZE }> {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("initial-checkpoint.{}.json", SPEC);
load_fixture(basename).unwrap()
}
pub fn load_sync_committee_update_fixture(
) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("sync-committee-update.{}.json", SPEC);
load_fixture(basename).unwrap()
}
pub fn load_finalized_header_update_fixture(
) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("finalized-header-update.{}.json", SPEC);
load_fixture(basename).unwrap()
}
pub fn load_next_sync_committee_update_fixture(
) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("next-sync-committee-update.{}.json", SPEC);
load_fixture(basename).unwrap()
}
pub fn load_next_finalized_header_update_fixture(
) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("next-finalized-header-update.{}.json", SPEC);
load_fixture(basename).unwrap()
}
@@ -20,7 +20,7 @@
// --repeat
// 10
// --output
// pallets/ethereum-beacon-client/src/weights.rs
// pallets/ethereum-client/src/weights.rs
// --template
// templates/module-weight-template.hbs
@@ -1,11 +1,15 @@
[package]
name = "snowbridge-inbound-queue"
description = "Snowbridge Inbound Queue"
version = "0.1.1"
edition = "2021"
name = "snowbridge-pallet-inbound-queue"
description = "Snowbridge Inbound Queue Pallet"
version = "0.9.0"
authors = ["Snowfork <contact@snowfork.com>"]
repository = "https://github.com/Snowfork/snowbridge"
edition.workspace = true
repository.workspace = true
license = "Apache-2.0"
categories = ["cryptography::cryptocurrencies"]
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
@@ -32,6 +36,7 @@ sp-runtime = { path = "../../../../../substrate/primitives/runtime", default-fea
xcm = { package = "staging-xcm", path = "../../../../../polkadot/xcm", default-features = false }
xcm-builder = { package = "staging-xcm-builder", path = "../../../../../polkadot/xcm/xcm-builder", default-features = false }
xcm-executor = { package = "staging-xcm-executor", path = "../../../../../polkadot/xcm/xcm-executor", default-features = false }
snowbridge-core = { path = "../../primitives/core", default-features = false }
snowbridge-ethereum = { path = "../../primitives/ethereum", default-features = false }
@@ -42,7 +47,7 @@ snowbridge-beacon-primitives = { path = "../../primitives/beacon", default-featu
frame-benchmarking = { path = "../../../../../substrate/frame/benchmarking" }
sp-keyring = { path = "../../../../../substrate/primitives/keyring" }
snowbridge-beacon-primitives = { path = "../../primitives/beacon" }
snowbridge-ethereum-beacon-client = { path = "../../pallets/ethereum-beacon-client" }
snowbridge-pallet-ethereum-client = { path = "../../pallets/ethereum-client" }
hex-literal = { version = "0.4.1" }
[features]
@@ -68,6 +73,7 @@ std = [
"sp-runtime/std",
"sp-std/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
]
runtime-benchmarks = [
@@ -79,15 +85,16 @@ runtime-benchmarks = [
"pallet-balances/runtime-benchmarks",
"snowbridge-beacon-primitives",
"snowbridge-core/runtime-benchmarks",
"snowbridge-ethereum-beacon-client/runtime-benchmarks",
"snowbridge-pallet-ethereum-client/runtime-benchmarks",
"snowbridge-router-primitives/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"snowbridge-ethereum-beacon-client/try-runtime",
"snowbridge-pallet-ethereum-client/try-runtime",
"sp-runtime/try-runtime",
]
@@ -0,0 +1,3 @@
# Ethereum Inbound Queue
Reads messages from Ethereum and sends it to intended destination on Polkadot, using XCM.
@@ -44,7 +44,7 @@ use envelope::Envelope;
use frame_support::{
traits::{
fungible::{Inspect, Mutate},
tokens::{Fortitude, Precision, Preservation},
tokens::Preservation,
},
weights::WeightToFee,
PalletError,
@@ -55,18 +55,20 @@ use sp_core::{H160, H256};
use sp_std::{convert::TryFrom, vec};
use xcm::prelude::{
send_xcm, Instruction::SetTopic, Junction::*, Junctions::*, MultiLocation,
SendError as XcmpSendError, SendXcm, Xcm, XcmHash,
SendError as XcmpSendError, SendXcm, Xcm, XcmContext, XcmHash,
};
use xcm_executor::traits::TransactAsset;
use snowbridge_core::{
inbound::{Message, VerificationError, Verifier},
sibling_sovereign_account, BasicOperatingMode, Channel, ChannelId, ParaId, StaticLookup,
sibling_sovereign_account, BasicOperatingMode, Channel, ChannelId, ParaId, PricingParameters,
StaticLookup,
};
use snowbridge_router_primitives::{
inbound,
inbound::{ConvertMessage, ConvertMessageError},
};
use sp_runtime::traits::Saturating;
use sp_runtime::{traits::Saturating, SaturatedConversion, TokenError};
pub use weights::WeightInfo;
@@ -83,7 +85,6 @@ pub mod pallet {
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use snowbridge_core::PricingParameters;
#[pallet::pallet]
pub struct Pallet<T>(_);
@@ -135,6 +136,9 @@ pub mod pallet {
/// The upper limit here only used to estimate delivery cost
type MaxMessageSize: Get<u32>;
/// To withdraw and deposit an asset.
type AssetTransactor: TransactAsset;
}
#[pallet::hooks]
@@ -142,7 +146,7 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T> {
pub enum Event<T: Config> {
/// A message was received from Ethereum
MessageReceived {
/// The message channel
@@ -151,6 +155,8 @@ pub mod pallet {
nonce: u64,
/// ID of the XCM message which was forwarded to the final destination parachain
message_id: [u8; 32],
/// Fee burned for the teleport
fee_burned: BalanceOf<T>,
},
/// Set OperatingMode
OperatingModeChanged { mode: BasicOperatingMode },
@@ -268,17 +274,16 @@ pub mod pallet {
Err(_) => return Err(Error::<T>::InvalidPayload.into()),
};
// We embed fees for xcm execution inside the xcm program using teleports
// so we must burn the amount of the fee embedded into the XCM script.
T::Token::burn_from(&sovereign_account, fee, Precision::Exact, Fortitude::Polite)?;
log::info!(
target: LOG_TARGET,
"💫 xcm {:?} sent with fee {:?}",
"💫 xcm decoded as {:?} with fee {:?}",
xcm,
fee
);
// Burning fees for teleport
Self::burn_fees(channel.para_id, fee)?;
// Attempt to send XCM to a dest parachain
let message_id = Self::send_xcm(xcm, channel.para_id)?;
@@ -286,6 +291,7 @@ pub mod pallet {
channel_id: envelope.channel_id,
nonce: envelope.nonce,
message_id,
fee_burned: fee,
});
Ok(())
@@ -330,6 +336,30 @@ pub mod pallet {
.saturating_add(len_fee)
.saturating_add(T::PricingParameters::get().rewards.local)
}
/// Burn the amount of the fee embedded into the XCM for teleports
pub fn burn_fees(para_id: ParaId, fee: BalanceOf<T>) -> DispatchResult {
let dummy_context =
XcmContext { origin: None, message_id: Default::default(), topic: None };
let dest = MultiLocation { parents: 1, interior: X1(Parachain(para_id.into())) };
let fees = (MultiLocation::parent(), fee.saturated_into::<u128>()).into();
T::AssetTransactor::can_check_out(&dest, &fees, &dummy_context).map_err(|error| {
log::error!(
target: LOG_TARGET,
"XCM asset check out failed with error {:?}", error
);
TokenError::FundsUnavailable
})?;
T::AssetTransactor::check_out(&dest, &fees, &dummy_context);
T::AssetTransactor::withdraw_asset(&fees, &dest, None).map_err(|error| {
log::error!(
target: LOG_TARGET,
"XCM asset withdraw failed with error {:?}", error
);
TokenError::FundsUnavailable
})?;
Ok(())
}
}
/// API for accessing the delivery cost of a message
@@ -22,6 +22,7 @@ use sp_runtime::{
};
use sp_std::convert::From;
use xcm::v3::{prelude::*, MultiAssets, SendXcm};
use xcm_executor::Assets;
use crate::{self as inbound_queue};
@@ -32,7 +33,7 @@ frame_support::construct_runtime!(
{
System: frame_system::{Pallet, Call, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
EthereumBeaconClient: snowbridge_ethereum_beacon_client::{Pallet, Call, Storage, Event<T>},
EthereumBeaconClient: snowbridge_pallet_ethereum_client::{Pallet, Call, Storage, Event<T>},
InboundQueue: inbound_queue::{Pallet, Call, Storage, Event<T>},
}
);
@@ -112,7 +113,7 @@ parameter_types! {
};
}
impl snowbridge_ethereum_beacon_client::Config for Test {
impl snowbridge_pallet_ethereum_client::Config for Test {
type RuntimeEvent = RuntimeEvent;
type ForkVersions = ChainForkVersions;
type MaxExecutionHeadersToKeep = ExecutionHeadersPruneThreshold;
@@ -142,7 +143,7 @@ parameter_types! {
}
#[cfg(feature = "runtime-benchmarks")]
impl<T: snowbridge_ethereum_beacon_client::Config> BenchmarkHelper<T> for Test {
impl<T: snowbridge_pallet_ethereum_client::Config> BenchmarkHelper<T> for Test {
// not implemented since the MockVerifier is used for tests
fn initialize_storage(_: H256, _: CompactExecutionHeader) {}
}
@@ -200,6 +201,50 @@ impl StaticLookup for MockChannelLookup {
}
}
pub struct SuccessfulTransactor;
impl TransactAsset for SuccessfulTransactor {
fn can_check_in(
_origin: &MultiLocation,
_what: &MultiAsset,
_context: &XcmContext,
) -> XcmResult {
Ok(())
}
fn can_check_out(
_dest: &MultiLocation,
_what: &MultiAsset,
_context: &XcmContext,
) -> XcmResult {
Ok(())
}
fn deposit_asset(
_what: &MultiAsset,
_who: &MultiLocation,
_context: Option<&XcmContext>,
) -> XcmResult {
Ok(())
}
fn withdraw_asset(
_what: &MultiAsset,
_who: &MultiLocation,
_context: Option<&XcmContext>,
) -> Result<Assets, XcmError> {
Ok(Assets::default())
}
fn internal_transfer_asset(
_what: &MultiAsset,
_from: &MultiLocation,
_to: &MultiLocation,
_context: &XcmContext,
) -> Result<Assets, XcmError> {
Ok(Assets::default())
}
}
impl inbound_queue::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Verifier = MockVerifier;
@@ -221,6 +266,7 @@ impl inbound_queue::Config for Test {
type WeightToFee = IdentityFee<u128>;
type LengthToFee = IdentityFee<u128>;
type MaxMessageSize = ConstU32<1024>;
type AssetTransactor = SuccessfulTransactor;
}
pub fn last_events(n: usize) -> Vec<RuntimeEvent> {
@@ -44,6 +44,7 @@ fn test_submit_happy_path() {
27, 217, 88, 127, 46, 143, 199, 70, 236, 66, 212, 244, 85, 221, 153, 104, 175, 37,
224, 20, 140, 95, 140, 7, 27, 74, 182, 199, 77, 12, 194, 236,
],
fee_burned: 110000000000,
}
.into()]);
@@ -1,11 +1,15 @@
[package]
name = "snowbridge-outbound-queue"
description = "Snowbridge Outbound Queue"
version = "0.1.1"
edition = "2021"
name = "snowbridge-pallet-outbound-queue"
description = "Snowbridge Outbound Queue Pallet"
version = "0.9.0"
authors = ["Snowfork <contact@snowfork.com>"]
repository = "https://github.com/Snowfork/snowbridge"
edition.workspace = true
repository.workspace = true
license = "Apache-2.0"
categories = ["cryptography::cryptocurrencies"]
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
@@ -0,0 +1,3 @@
# Ethereum Outbound Queue
Sends messages from an origin in the Polkadot ecosystem to Ethereum.
@@ -1,11 +1,15 @@
[package]
name = "snowbridge-outbound-queue-merkle-tree"
description = "Snowbridge Outbound Queue Merkle Tree"
version = "0.1.1"
edition = "2021"
version = "0.9.0"
authors = ["Snowfork <contact@snowfork.com>"]
repository = "https://github.com/Snowfork/snowbridge"
edition.workspace = true
repository.workspace = true
license = "Apache-2.0"
categories = ["cryptography::cryptocurrencies"]
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
@@ -0,0 +1,4 @@
# Snowbridge Outbound Queue Merkle Tree
This crate implements a simple binary Merkle Tree utilities required for inter-op with Ethereum
bridge & Solidity contract.
@@ -1,11 +1,15 @@
[package]
name = "snowbridge-outbound-queue-runtime-api"
description = "Snowbridge Outbound Queue Runtime API"
version = "0.1.0"
edition = "2021"
version = "0.9.0"
authors = ["Snowfork <contact@snowfork.com>"]
repository = "https://github.com/Snowfork/snowbridge"
edition.workspace = true
repository.workspace = true
license = "Apache-2.0"
categories = ["cryptography::cryptocurrencies"]
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
@@ -0,0 +1,6 @@
# Ethereum Outbound Queue Runtime API
Provides an API:
- to generate merkle proofs for outbound messages
- calculate delivery fee for delivering messages to Ethereum
@@ -5,10 +5,10 @@
//! # Overview
//!
//! Messages come either from sibling parachains via XCM, or BridgeHub itself
//! via the `snowbridge-system` pallet:
//! via the `snowbridge-pallet-system`:
//!
//! 1. `snowbridge_router_primitives::outbound::EthereumBlobExporter::deliver`
//! 2. `snowbridge_system::Pallet::send`
//! 2. `snowbridge_pallet_system::Pallet::send`
//!
//! The message submission pipeline works like this:
//! 1. The message is first validated via the implementation for
@@ -110,7 +110,7 @@ fn process_message_fails_on_max_nonce_reached() {
channel_id,
command: mock_message(sibling_id).command,
};
let versioned_queued_message: VersionedQueuedMessage = message.into();
let versioned_queued_message: VersionedQueuedMessage = message.try_into().unwrap();
let encoded = versioned_queued_message.encode();
let mut meter = WeightMeter::with_limit(Weight::MAX);
@@ -134,7 +134,7 @@ fn process_message_fails_on_overweight_message() {
channel_id,
command: mock_message(sibling_id).command,
};
let versioned_queued_message: VersionedQueuedMessage = message.into();
let versioned_queued_message: VersionedQueuedMessage = message.try_into().unwrap();
let encoded = versioned_queued_message.encode();
let mut meter = WeightMeter::with_limit(Weight::from_parts(1, 1));
assert_noop!(
@@ -1,5 +1,5 @@
//! Autogenerated weights for `snowbridge_outbound_queue`
//! Autogenerated weights for `snowbridge-pallet-outbound-queue`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-10-19, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]`
@@ -12,7 +12,7 @@
// benchmark
// pallet
// --chain=bridge-hub-rococo-dev
// --pallet=snowbridge_outbound_queue
// --pallet=snowbridge-pallet-outbound-queue
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
@@ -29,7 +29,7 @@
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weight functions needed for `snowbridge_outbound_queue`.
/// Weight functions needed for `snowbridge-pallet-outbound-queue`.
pub trait WeightInfo {
fn do_process_message() -> Weight;
fn commit() -> Weight;
@@ -1,11 +1,15 @@
[package]
name = "snowbridge-system"
description = "Snowbridge System"
version = "0.1.1"
name = "snowbridge-pallet-system"
description = "Snowbridge System Pallet"
version = "0.9.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition = "2021"
repository = "https://github.com/Snowfork/snowbridge"
edition.workspace = true
repository.workspace = true
license = "Apache-2.0"
categories = ["cryptography::cryptocurrencies"]
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
@@ -39,7 +43,7 @@ pallet-balances = { path = "../../../../../substrate/frame/balances" }
sp-keyring = { path = "../../../../../substrate/primitives/keyring" }
polkadot-primitives = { path = "../../../../../polkadot/primitives" }
pallet-message-queue = { path = "../../../../../substrate/frame/message-queue" }
snowbridge-outbound-queue = { path = "../outbound-queue" }
snowbridge-pallet-outbound-queue = { path = "../outbound-queue" }
[features]
default = ["std"]
@@ -68,7 +72,7 @@ runtime-benchmarks = [
"pallet-message-queue/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"snowbridge-core/runtime-benchmarks",
"snowbridge-outbound-queue/runtime-benchmarks",
"snowbridge-pallet-outbound-queue/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
@@ -78,6 +82,6 @@ try-runtime = [
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"pallet-message-queue/try-runtime",
"snowbridge-outbound-queue/try-runtime",
"snowbridge-pallet-outbound-queue/try-runtime",
"sp-runtime/try-runtime",
]
@@ -1 +1,3 @@
License: MIT-0
# Ethereum System
Contains management functions to manage functions on Ethereum. For example, creating agents and channels.
@@ -1,11 +1,15 @@
[package]
name = "snowbridge-system-runtime-api"
description = "Snowbridge System Runtime API"
version = "0.1.0"
edition = "2021"
version = "0.9.0"
authors = ["Snowfork <contact@snowfork.com>"]
repository = "https://github.com/Snowfork/snowbridge"
edition.workspace = true
repository.workspace = true
license = "Apache-2.0"
categories = ["cryptography::cryptocurrencies"]
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
@@ -0,0 +1,3 @@
# Ethereum System Runtime API
Provides an API for looking up an agent ID on Ethereum.
@@ -79,6 +79,8 @@ use xcm_executor::traits::ConvertLocation;
#[cfg(feature = "runtime-benchmarks")]
use frame_support::traits::OriginTrait;
pub use pallet::*;
pub type BalanceOf<T> =
<<T as pallet::Config>::Token as Inspect<<T as frame_system::Config>::AccountId>>::Balance;
pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
@@ -89,7 +89,7 @@ frame_support::construct_runtime!(
System: frame_system,
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
XcmOrigin: pallet_xcm_origin::{Pallet, Origin},
OutboundQueue: snowbridge_outbound_queue::{Pallet, Call, Storage, Event<T>},
OutboundQueue: snowbridge_pallet_outbound_queue::{Pallet, Call, Storage, Event<T>},
EthereumSystem: snowbridge_system,
MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>}
}
@@ -167,7 +167,7 @@ parameter_types! {
pub const OwnParaId: ParaId = ParaId::new(1013);
}
impl snowbridge_outbound_queue::Config for Test {
impl snowbridge_pallet_outbound_queue::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Hashing = Keccak256;
type MessageQueue = MessageQueue;