diff --git a/Cargo.lock b/Cargo.lock index cb65ff175b8..022c658a685 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,6 +164,11 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf688625d06217d5b1bb0ea9d9c44a1635fd0ee3534466388d18203174f4d11" +[[package]] +name = "amcl" +version = "0.3.0" +source = "git+https://github.com/Snowfork/milagro_bls#bc2b5b5e8d48b7e2e1bfaa56dc2d93e13cb32095" + [[package]] name = "anes" version = "0.1.6" @@ -1073,6 +1078,11 @@ dependencies = [ "scale-info", "serde", "smallvec", + "snowbridge-basic-channel", + "snowbridge-beacon-primitives", + "snowbridge-core", + "snowbridge-dispatch", + "snowbridge-ethereum-beacon-client", "sp-api", "sp-block-builder", "sp-consensus-aura", @@ -3374,6 +3384,24 @@ dependencies = [ "libc", ] +[[package]] +name = "ethabi-decode" +version = "1.3.3" +source = "git+https://github.com/Snowfork/ethabi-decode.git?branch=master#6f63405bb33ef4365a1c62b72d499fa0f448118e" +dependencies = [ + "ethereum-types", + "tiny-keccak 1.5.0", +] + +[[package]] +name = "ethabi-decode" +version = "1.3.3" +source = "git+https://github.com/snowfork/ethabi-decode.git?rev=6f63405bb33ef4365a1c62b72d499fa0f448118e#6f63405bb33ef4365a1c62b72d499fa0f448118e" +dependencies = [ + "ethereum-types", + "tiny-keccak 1.5.0", +] + [[package]] name = "ethbloom" version = "0.13.0" @@ -3382,9 +3410,11 @@ checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ "crunchy", "fixed-hash", + "impl-codec", "impl-rlp", "impl-serde", - "tiny-keccak", + "scale-info", + "tiny-keccak 2.0.2", ] [[package]] @@ -3395,9 +3425,11 @@ checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ "ethbloom", "fixed-hash", + "impl-codec", "impl-rlp", "impl-serde", "primitive-types", + "scale-info", "uint", ] @@ -5768,6 +5800,18 @@ dependencies = [ "thrift", ] +[[package]] +name = "milagro_bls" +version = "1.5.0" +source = "git+https://github.com/Snowfork/milagro_bls#bc2b5b5e8d48b7e2e1bfaa56dc2d93e13cb32095" +dependencies = [ + "amcl", + "hex", + "lazy_static", + "rand 0.8.5", + "zeroize", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -7711,6 +7755,12 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "parity-bytes" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b56e3a2420138bdb970f84dfb9c774aea80fa0e7371549eedec0d80c209c67" + [[package]] name = "parity-db" version = "0.4.6" @@ -8911,6 +8961,7 @@ dependencies = [ "seedling-runtime", "serde", "shell-runtime", + "snowbridge-basic-channel-rpc", "sp-api", "sp-block-builder", "sp-blockchain", @@ -11914,6 +11965,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-big-array" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd31f59f6fe2b0c055371bb2f16d7f0aa7d8881676c04a55b1596d1a17cd10a4" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.156" @@ -12172,6 +12232,146 @@ dependencies = [ "subtle", ] +[[package]] +name = "snowbridge-basic-channel" +version = "0.1.1" +dependencies = [ + "ethabi-decode 1.3.3 (git+https://github.com/Snowfork/ethabi-decode.git?branch=master)", + "frame-benchmarking", + "frame-support", + "frame-system", + "hex-literal", + "parity-scale-codec", + "rlp", + "scale-info", + "serde", + "snowbridge-basic-channel-merkle-proof", + "snowbridge-core", + "snowbridge-ethereum", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "snowbridge-basic-channel-merkle-proof" +version = "0.1.1" +dependencies = [ + "parity-scale-codec", + "sp-core", + "sp-runtime", +] + +[[package]] +name = "snowbridge-basic-channel-rpc" +version = "0.1.0" +dependencies = [ + "jsonrpsee", + "parity-scale-codec", + "parking_lot 0.11.2", + "snowbridge-basic-channel-merkle-proof", + "sp-core", + "sp-offchain", + "sp-runtime", +] + +[[package]] +name = "snowbridge-beacon-primitives" +version = "0.0.1" +dependencies = [ + "frame-support", + "frame-system", + "hex", + "parity-scale-codec", + "rlp", + "scale-info", + "serde", + "snowbridge-ethereum", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "snowbridge-core" +version = "0.1.1" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "snowbridge-ethereum", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "snowbridge-dispatch" +version = "0.1.1" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "snowbridge-core", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "snowbridge-ethereum" +version = "0.1.0" +dependencies = [ + "ethabi-decode 1.3.3 (git+https://github.com/snowfork/ethabi-decode.git?rev=6f63405bb33ef4365a1c62b72d499fa0f448118e)", + "ethbloom", + "ethereum-types", + "hex-literal", + "parity-bytes", + "parity-scale-codec", + "rlp", + "rustc-hex", + "scale-info", + "serde", + "serde-big-array", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "snowbridge-ethereum-beacon-client" +version = "0.0.1" +dependencies = [ + "byte-slice-cast", + "frame-benchmarking", + "frame-support", + "frame-system", + "hex-literal", + "milagro_bls", + "parity-scale-codec", + "rlp", + "scale-info", + "serde", + "snowbridge-beacon-primitives", + "snowbridge-core", + "snowbridge-ethereum", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "ssz-rs", + "ssz-rs-derive", +] + [[package]] name = "socket2" version = "0.4.4" @@ -12959,6 +13159,28 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "ssz-rs" +version = "0.8.0" +source = "git+https://github.com/ralexstokes/ssz-rs?rev=d18af912abacbf84219be37ab3b42a9abcf10d2a#d18af912abacbf84219be37ab3b42a9abcf10d2a" +dependencies = [ + "bitvec", + "num-bigint", + "sha2 0.9.8", + "ssz-rs-derive", + "thiserror", +] + +[[package]] +name = "ssz-rs-derive" +version = "0.8.0" +source = "git+https://github.com/ralexstokes/ssz-rs?rev=d18af912abacbf84219be37ab3b42a9abcf10d2a#d18af912abacbf84219be37ab3b42a9abcf10d2a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -13622,6 +13844,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "tiny-keccak" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" +dependencies = [ + "crunchy", +] + [[package]] name = "tiny-keccak" version = "2.0.2" diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 9dcc30e3e1a..b26a2748be3 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -87,6 +87,13 @@ pallet-bridge-parachains = { path = "../../../../bridges/modules/parachains", de pallet-bridge-relayers = { path = "../../../../bridges/modules/relayers", default-features = false } bridge-runtime-common = { path = "../../../../bridges/bin/runtime-common", default-features = false } +# Ethereum Bridge (Snowbridge) +snowbridge-core = { path = "../../../../../parachain/primitives/core", default-features = false } +snowbridge-beacon-primitives = { path = "../../../../../parachain/primitives/beacon", default-features = false } +snowbridge-basic-channel = { path = "../../../../../parachain/pallets/basic-channel", default-features = false } +snowbridge-dispatch = { path = "../../../../../parachain/pallets/dispatch", default-features = false } +snowbridge-ethereum-beacon-client = { path = "../../../../../parachain/pallets/ethereum-beacon-client", default-features = false, features=["minimal"]} + [dev-dependencies] static_assertions = "1.1" bridge-hub-test-utils = { path = "../test-utils"} @@ -160,6 +167,11 @@ std = [ "xcm-executor/std", "xcm/std", "substrate-wasm-builder", + "snowbridge-basic-channel/std", + "snowbridge-core/std", + "snowbridge-dispatch/std", + "snowbridge-ethereum-beacon-client/std", + "snowbridge-beacon-primitives/std", ] runtime-benchmarks = [ @@ -184,6 +196,10 @@ runtime-benchmarks = [ "cumulus-pallet-session-benchmarking/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", "pallet-xcm-benchmarks/runtime-benchmarks", + "snowbridge-basic-channel/runtime-benchmarks", + "snowbridge-core/runtime-benchmarks", + "snowbridge-dispatch/runtime-benchmarks", + "snowbridge-ethereum-beacon-client/runtime-benchmarks", ] try-runtime = [ diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index f465378bb5b..7838949f3b9 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -30,11 +30,12 @@ pub mod xcm_config; use constants::currency::*; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; +use snowbridge_beacon_primitives::{Fork, ForkVersions}; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdLookup, BlakeTwo256, Block as BlockT}, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, Keccak256}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; @@ -66,6 +67,8 @@ use bp_runtime::HeaderId; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; +pub use snowbridge_core::MessageId; + use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; @@ -540,6 +543,89 @@ impl pallet_bridge_relayers::Config for Runtime { type WeightInfo = weights::pallet_bridge_relayers::WeightInfo; } +// Ethereum Bridge + +impl snowbridge_dispatch::Config for Runtime { + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; + type MessageId = MessageId; + type RuntimeCall = RuntimeCall; + type CallFilter = Everything; +} + +use snowbridge_basic_channel::{ + inbound as basic_channel_inbound, outbound as basic_channel_outbound, +}; + +impl basic_channel_inbound::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Verifier = snowbridge_ethereum_beacon_client::Pallet; + type MessageDispatch = snowbridge_dispatch::Pallet; + type WeightInfo = (); +} + +parameter_types! { + pub const MaxMessagePayloadSize: u32 = 256; + pub const MaxMessagesPerCommit: u32 = 20; +} + +impl basic_channel_outbound::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Hashing = Keccak256; + type SourceId = ::AccountId; + type MaxMessagePayloadSize = MaxMessagePayloadSize; + type MaxMessagesPerCommit = MaxMessagesPerCommit; + type WeightInfo = weights::snowbridge_basic_channel_outbound::WeightInfo; +} + +parameter_types! { + pub const MaxSyncCommitteeSize: u32 = 32; + pub const MaxProofBranchSize: u32 = 20; + pub const MaxExtraDataSize: u32 = 32; + pub const MaxLogsBloomSize: u32 = 256; + pub const MaxFeeRecipientSize: u32 = 20; + pub const MaxPublicKeySize: u32 = 48; + pub const MaxSignatureSize: u32 = 96; + pub const MaxSlotsPerHistoricalRoot: u64 = 64; + pub const MaxFinalizedHeaderSlotArray: u32 = 1000; + pub const WeakSubjectivityPeriodSeconds: u32 = 97200; + pub const ChainForkVersions: ForkVersions = ForkVersions{ + genesis: Fork { + version: [0, 0, 0, 1], // 0x00000001 + epoch: 0, + }, + altair: Fork { + version: [1, 0, 0, 1], // 0x01000001 + epoch: 0, + }, + bellatrix: Fork { + version: [2, 0, 0, 1], // 0x02000001 + epoch: 0, + }, + capella: Fork { + version: [3, 0, 0, 1], // 0x03000001 + epoch: 0, + }, + }; +} + +impl snowbridge_ethereum_beacon_client::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type TimeProvider = pallet_timestamp::Pallet; + type MaxSyncCommitteeSize = MaxSyncCommitteeSize; + type MaxProofBranchSize = MaxProofBranchSize; + type MaxExtraDataSize = MaxExtraDataSize; + type MaxLogsBloomSize = MaxLogsBloomSize; + type MaxFeeRecipientSize = MaxFeeRecipientSize; + type MaxPublicKeySize = MaxPublicKeySize; + type MaxSignatureSize = MaxSignatureSize; + type MaxSlotsPerHistoricalRoot = MaxSlotsPerHistoricalRoot; + type MaxFinalizedHeaderSlotArray = MaxFinalizedHeaderSlotArray; + type ForkVersions = ChainForkVersions; + type WeakSubjectivityPeriodSeconds = WeakSubjectivityPeriodSeconds; + type WeightInfo = weights::snowbridge_ethereum_beacon_client::WeightInfo; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -592,6 +678,12 @@ construct_runtime!( BridgeRococoMessages: pallet_bridge_messages::::{Pallet, Call, Storage, Event, Config} = 45, BridgeRelayers: pallet_bridge_relayers::{Pallet, Call, Storage, Event} = 47, + + // Ethereum Bridge + BasicInboundChannel: basic_channel_inbound::{Pallet, Call, Config, Storage, Event} = 50, + BasicOutboundChannel: basic_channel_outbound::{Pallet, Config, Storage, Event} = 51, + Dispatch: snowbridge_dispatch::{Pallet, Call, Storage, Event, Origin} = 52, + EthereumBeaconClient: snowbridge_ethereum_beacon_client::{Pallet, Call, Config, Storage, Event} = 53, } ); @@ -636,6 +728,11 @@ mod benches { [pallet_bridge_messages, BridgeMessagesBench::] // Bridge relayer pallets [pallet_bridge_relayers, BridgeRelayersBench::] + // Ethereum Bridge + //[snowbridge_basic_channel::inbound, BasicInboundChannel] + [snowbridge_basic_channel::outbound, BasicOutboundChannel] + //[snowbridge_dispatch, Dispatch] + [snowbridge_ethereum_beacon_client, EthereumBeaconClient] ); } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs index 59f3932ad2b..9b6fb98afc8 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs @@ -37,6 +37,8 @@ pub mod pallet_utility; pub mod pallet_xcm; pub mod paritydb_weights; pub mod rocksdb_weights; +pub mod snowbridge_basic_channel_outbound; +pub mod snowbridge_ethereum_beacon_client; pub mod xcm; pub use block_weights::constants::BlockExecutionWeight; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_basic_channel_outbound.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_basic_channel_outbound.rs new file mode 100644 index 00000000000..0110cd7dc45 --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_basic_channel_outbound.rs @@ -0,0 +1,80 @@ +// Copyright 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 . + +//! Autogenerated weights for `snowbridge_basic_channel::outbound` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-03-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `ip-172-31-4-183`, CPU: `Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./artifacts/polkadot-parachain +// benchmark +// pallet +// --chain=bridge-hub-rococo-dev +// --execution=wasm +// --wasm-execution=compiled +// --pallet=snowbridge_basic_channel::outbound +// --extrinsic=* +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_basic_channel_outbound.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `snowbridge_basic_channel::outbound`. +pub struct WeightInfo(PhantomData); +impl snowbridge_basic_channel::outbound::WeightInfo for WeightInfo { + /// Storage: BasicOutboundChannel MessageQueue (r:1 w:1) + /// Proof: BasicOutboundChannel MessageQueue (max_values: Some(1), max_size: Some(5961), added: 6456, mode: MaxEncodedLen) + /// Storage: System Digest (r:1 w:1) + /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) + /// The range of component `m` is `[1, 20]`. + /// The range of component `p` is `[0, 255]`. + fn on_commit(m: u32, p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + m * (290 ±0) + p * (20 ±0)` + // Estimated: `9314 + m * (114 ±2) + p * (7 ±0)` + // Minimum execution time: 46_170_000 picoseconds. + Weight::from_parts(46_620_000, 0) + .saturating_add(Weight::from_parts(0, 9314)) + // Standard Error: 70_228 + .saturating_add(Weight::from_parts(13_877_868, 0).saturating_mul(m.into())) + // Standard Error: 5_497 + .saturating_add(Weight::from_parts(107_283, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 114).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 7).saturating_mul(p.into())) + } + fn on_commit_no_messages() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 429_000 picoseconds. + Weight::from_parts(454_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_ethereum_beacon_client.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_ethereum_beacon_client.rs new file mode 100644 index 00000000000..823cdb9f35e --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_ethereum_beacon_client.rs @@ -0,0 +1,128 @@ +// Copyright 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 . + +//! Autogenerated weights for `snowbridge_ethereum_beacon_client` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-03-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `ip-172-31-4-183`, CPU: `Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./artifacts/polkadot-parachain +// benchmark +// pallet +// --chain=bridge-hub-rococo-dev +// --execution=wasm +// --wasm-execution=compiled +// --pallet=snowbridge_ethereum_beacon_client +// --extrinsic=* +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_ethereum_beacon_client.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `snowbridge_ethereum_beacon_client`. +pub struct WeightInfo(PhantomData); +impl snowbridge_ethereum_beacon_client::WeightInfo for WeightInfo { + /// Storage: EthereumBeaconClient Blocked (r:1 w:0) + /// Proof: EthereumBeaconClient Blocked (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient LatestSyncCommitteePeriod (r:1 w:1) + /// Proof: EthereumBeaconClient LatestSyncCommitteePeriod (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient SyncCommittees (r:2 w:1) + /// Proof: EthereumBeaconClient SyncCommittees (max_values: None, max_size: Some(1593), added: 4068, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient ValidatorsRoot (r:1 w:0) + /// Proof: EthereumBeaconClient ValidatorsRoot (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient FinalizedBeaconHeaderSlots (r:1 w:1) + /// Proof: EthereumBeaconClient FinalizedBeaconHeaderSlots (max_values: Some(1), max_size: Some(8002), added: 8497, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient LatestFinalizedHeaderState (r:1 w:1) + /// Proof: EthereumBeaconClient LatestFinalizedHeaderState (max_values: Some(1), max_size: Some(48), added: 543, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient FinalizedBeaconHeaders (r:0 w:1) + /// Proof: EthereumBeaconClient FinalizedBeaconHeaders (max_values: None, max_size: Some(144), added: 2619, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient FinalizedBeaconHeadersBlockRoot (r:0 w:1) + /// Proof: EthereumBeaconClient FinalizedBeaconHeadersBlockRoot (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + fn sync_committee_period_update() -> Weight { + // Proof Size summary in bytes: + // Measured: `1921` + // Estimated: `26135` + // Minimum execution time: 47_657_897_000 picoseconds. + Weight::from_parts(47_722_703_000, 0) + .saturating_add(Weight::from_parts(0, 26135)) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(6)) + } + /// Storage: EthereumBeaconClient Blocked (r:1 w:0) + /// Proof: EthereumBeaconClient Blocked (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient LatestFinalizedHeaderState (r:1 w:1) + /// Proof: EthereumBeaconClient LatestFinalizedHeaderState (max_values: Some(1), max_size: Some(48), added: 543, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient SyncCommittees (r:1 w:0) + /// Proof: EthereumBeaconClient SyncCommittees (max_values: None, max_size: Some(1593), added: 4068, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient ValidatorsRoot (r:1 w:0) + /// Proof: EthereumBeaconClient ValidatorsRoot (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient FinalizedBeaconHeaderSlots (r:1 w:1) + /// Proof: EthereumBeaconClient FinalizedBeaconHeaderSlots (max_values: Some(1), max_size: Some(8002), added: 8497, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient FinalizedBeaconHeaders (r:0 w:1) + /// Proof: EthereumBeaconClient FinalizedBeaconHeaders (max_values: None, max_size: Some(144), added: 2619, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient FinalizedBeaconHeadersBlockRoot (r:0 w:1) + /// Proof: EthereumBeaconClient FinalizedBeaconHeadersBlockRoot (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + fn import_finalized_header() -> Weight { + // Proof Size summary in bytes: + // Measured: `1921` + // Estimated: `20574` + // Minimum execution time: 47_461_268_000 picoseconds. + Weight::from_parts(47_502_607_000, 0) + .saturating_add(Weight::from_parts(0, 20574)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: EthereumBeaconClient Blocked (r:1 w:0) + /// Proof: EthereumBeaconClient Blocked (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient LatestFinalizedHeaderState (r:1 w:0) + /// Proof: EthereumBeaconClient LatestFinalizedHeaderState (max_values: Some(1), max_size: Some(48), added: 543, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient LatestExecutionHeaderState (r:1 w:1) + /// Proof: EthereumBeaconClient LatestExecutionHeaderState (max_values: Some(1), max_size: Some(80), added: 575, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient FinalizedBeaconHeadersBlockRoot (r:1 w:0) + /// Proof: EthereumBeaconClient FinalizedBeaconHeadersBlockRoot (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient SyncCommittees (r:1 w:0) + /// Proof: EthereumBeaconClient SyncCommittees (max_values: None, max_size: Some(1593), added: 4068, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient ValidatorsRoot (r:1 w:0) + /// Proof: EthereumBeaconClient ValidatorsRoot (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: EthereumBeaconClient ExecutionHeaders (r:0 w:1) + /// Proof: EthereumBeaconClient ExecutionHeaders (max_values: None, max_size: Some(188), added: 2663, mode: MaxEncodedLen) + fn import_execution_header() -> Weight { + // Proof Size summary in bytes: + // Measured: `1965` + // Estimated: `14688` + // Minimum execution time: 47_535_909_000 picoseconds. + Weight::from_parts(47_607_054_000, 0) + .saturating_add(Weight::from_parts(0, 14688)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } +} diff --git a/polkadot-parachain/Cargo.toml b/polkadot-parachain/Cargo.toml index 80de13097f2..bbf7207c551 100644 --- a/polkadot-parachain/Cargo.toml +++ b/polkadot-parachain/Cargo.toml @@ -88,6 +88,9 @@ cumulus-primitives-core = { path = "../primitives/core" } cumulus-primitives-parachain-inherent = { path = "../primitives/parachain-inherent" } cumulus-relay-chain-interface = { path = "../client/relay-chain-interface" } +# Ethereum Bridge +snowbridge-basic-channel-rpc = { path = "../../parachain/pallets/basic-channel/rpc" } + [build-dependencies] substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/polkadot-parachain/src/chain_spec/bridge_hubs.rs index d0ded6ad1f7..77fdcffbb8a 100644 --- a/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -268,6 +268,9 @@ pub mod rococo { get_account_id_from_seed::("Dave//stash"), get_account_id_from_seed::("Eve//stash"), get_account_id_from_seed::("Ferdie//stash"), + // Ethereum Bridge Relayer Accounts + get_account_id_from_seed::("BeaconRelay"), + get_account_id_from_seed::("ExecutionRelay"), ], para_id, bridges_pallet_owner_seed @@ -339,6 +342,16 @@ pub mod rococo { owner: bridges_pallet_owner, ..Default::default() }, + // Ethereum Bridge + basic_inbound_channel: bridge_hub_rococo_runtime::BasicInboundChannelConfig { + source_channel: Default::default(), + }, + basic_outbound_channel: bridge_hub_rococo_runtime::BasicOutboundChannelConfig { + interval: 1, + }, + ethereum_beacon_client: bridge_hub_rococo_runtime::EthereumBeaconClientConfig { + initial_sync: Default::default(), + }, } } } diff --git a/polkadot-parachain/src/rpc.rs b/polkadot-parachain/src/rpc.rs index 43752fd8d12..90bb53144e7 100644 --- a/polkadot-parachain/src/rpc.rs +++ b/polkadot-parachain/src/rpc.rs @@ -63,6 +63,7 @@ where { use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; + use snowbridge_basic_channel_rpc::{BasicChannel, BasicChannelApiServer}; use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut module = RpcExtension::new(()); @@ -70,7 +71,14 @@ where module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?; - module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; + module.merge(StateMigration::new(client.clone(), backend.clone(), deny_unsafe).into_rpc())?; + + if let Some(basic_channel_rpc) = backend + .offchain_storage() + .map(|storage| BasicChannel::::new(storage).into_rpc()) + { + module.merge(basic_channel_rpc)?; + } Ok(module) }