Skip to content

Commit

Permalink
Update Snowbridge versions and prep for publishing (paritytech#2894)
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
2 people authored and serban300 committed Jan 18, 2024
1 parent e542f4b commit b17b01e
Show file tree
Hide file tree
Showing 67 changed files with 336 additions and 348 deletions.
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
3 changes: 3 additions & 0 deletions snowbridge/parachain/pallets/ethereum-client/README.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) |
| --------------------------------------- |----------------------------------------|
Expand All @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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
Expand All @@ -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,
);
Expand All @@ -52,15 +52,15 @@ 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,
);
return Err(LogNotFound)
}

log::info!(
target: "ethereum-beacon-client",
target: "ethereum-client",
"💫 Receipt verification successful for {}",
proof.block_hash,
);
Expand All @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand All @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 15 additions & 8 deletions snowbridge/parachain/pallets/inbound-queue/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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 }
Expand All @@ -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]
Expand All @@ -68,6 +73,7 @@ std = [
"sp-runtime/std",
"sp-std/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
]
runtime-benchmarks = [
Expand All @@ -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",
]
3 changes: 3 additions & 0 deletions snowbridge/parachain/pallets/inbound-queue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ethereum Inbound Queue

Reads messages from Ethereum and sends it to intended destination on Polkadot, using XCM.
Loading

0 comments on commit b17b01e

Please sign in to comment.