diff --git a/Cargo.lock b/Cargo.lock index 208bbc2f2c5d4..0d91222982b2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21694,15 +21694,14 @@ dependencies = [ "log", "pallet-timestamp", "parity-scale-codec", - "rand 0.8.5", "scale-info", "serde", "serde_json", "snowbridge-beacon-primitives", "snowbridge-core", "snowbridge-ethereum", - "snowbridge-inbound-queue-primitives", "snowbridge-pallet-ethereum-client-fixtures", + "snowbridge-verification-primitives", "sp-core 28.0.0", "sp-io 30.0.0", "sp-runtime 31.0.1", @@ -21717,7 +21716,7 @@ dependencies = [ "hex-literal", "snowbridge-beacon-primitives", "snowbridge-core", - "snowbridge-inbound-queue-primitives", + "snowbridge-verification-primitives", "sp-core 28.0.0", "sp-std 14.0.0", ] @@ -21781,7 +21780,6 @@ dependencies = [ "snowbridge-beacon-primitives", "snowbridge-core", "snowbridge-inbound-queue-primitives", - "snowbridge-pallet-ethereum-client", "snowbridge-pallet-inbound-queue-v2-fixtures", "snowbridge-test-utils", "sp-core 28.0.0", @@ -21846,13 +21844,14 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", + "snowbridge-beacon-primitives", "snowbridge-core", "snowbridge-merkle-tree", "snowbridge-outbound-queue-primitives", + "snowbridge-verification-primitives", "sp-arithmetic 23.0.0", "sp-core 28.0.0", "sp-io 30.0.0", - "sp-keyring", "sp-runtime 31.0.1", "sp-std 14.0.0", "staging-xcm", diff --git a/bridges/snowbridge/pallets/ethereum-client/Cargo.toml b/bridges/snowbridge/pallets/ethereum-client/Cargo.toml index 9e33cd28e4050..cae796835f268 100644 --- a/bridges/snowbridge/pallets/ethereum-client/Cargo.toml +++ b/bridges/snowbridge/pallets/ethereum-client/Cargo.toml @@ -37,14 +37,13 @@ pallet-timestamp = { optional = true, workspace = true } snowbridge-beacon-primitives = { workspace = true } snowbridge-core = { workspace = true } snowbridge-ethereum = { workspace = true } -snowbridge-inbound-queue-primitives = { workspace = true } snowbridge-pallet-ethereum-client-fixtures = { optional = true, workspace = true } +snowbridge-verification-primitives = { workspace = true } static_assertions = { workspace = true } [dev-dependencies] hex-literal = { workspace = true, default-features = true } pallet-timestamp = { workspace = true, default-features = true } -rand = { workspace = true, default-features = true } serde = { workspace = true, default-features = true } serde_json = { workspace = true, default-features = true } snowbridge-pallet-ethereum-client-fixtures = { workspace = true, default-features = true } @@ -64,8 +63,8 @@ std = [ "snowbridge-beacon-primitives/std", "snowbridge-core/std", "snowbridge-ethereum/std", - "snowbridge-inbound-queue-primitives/std", "snowbridge-pallet-ethereum-client-fixtures/std", + "snowbridge-verification-primitives/std", "sp-core/std", "sp-io/std", "sp-runtime/std", @@ -79,7 +78,6 @@ runtime-benchmarks = [ "hex-literal", "pallet-timestamp?/runtime-benchmarks", "snowbridge-core/runtime-benchmarks", - "snowbridge-inbound-queue-primitives/runtime-benchmarks", "snowbridge-pallet-ethereum-client-fixtures/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] diff --git a/bridges/snowbridge/pallets/ethereum-client/fixtures/Cargo.toml b/bridges/snowbridge/pallets/ethereum-client/fixtures/Cargo.toml index d3e3c5ade9dc9..e97d847a4b172 100644 --- a/bridges/snowbridge/pallets/ethereum-client/fixtures/Cargo.toml +++ b/bridges/snowbridge/pallets/ethereum-client/fixtures/Cargo.toml @@ -21,7 +21,7 @@ exclude-from-umbrella = true hex-literal = { workspace = true, default-features = true } snowbridge-beacon-primitives = { workspace = true } snowbridge-core = { workspace = true } -snowbridge-inbound-queue-primitives = { workspace = true } +snowbridge-verification-primitives = { workspace = true } sp-core = { workspace = true } sp-std = { workspace = true } @@ -30,11 +30,10 @@ default = ["std"] std = [ "snowbridge-beacon-primitives/std", "snowbridge-core/std", - "snowbridge-inbound-queue-primitives/std", + "snowbridge-verification-primitives/std", "sp-core/std", "sp-std/std", ] runtime-benchmarks = [ "snowbridge-core/runtime-benchmarks", - "snowbridge-inbound-queue-primitives/runtime-benchmarks", ] diff --git a/bridges/snowbridge/pallets/ethereum-client/fixtures/src/lib.rs b/bridges/snowbridge/pallets/ethereum-client/fixtures/src/lib.rs index 01b0f025c5ad9..aa612e59007a5 100644 --- a/bridges/snowbridge/pallets/ethereum-client/fixtures/src/lib.rs +++ b/bridges/snowbridge/pallets/ethereum-client/fixtures/src/lib.rs @@ -9,7 +9,7 @@ use snowbridge_beacon_primitives::{ types::deneb, AncestryProof, BeaconHeader, ExecutionProof, NextSyncCommitteeUpdate, SyncAggregate, SyncCommittee, VersionedExecutionPayloadHeader, }; -use snowbridge_inbound_queue_primitives::{EventProof, InboundQueueFixture, Log, Proof}; +use snowbridge_verification_primitives::{EventFixture, EventProof, Log, Proof}; use sp_core::U256; use sp_std::{boxed::Box, vec}; @@ -1225,8 +1225,8 @@ pub fn make_execution_proof() -> Box { }) } -pub fn make_inbound_fixture() -> InboundQueueFixture { - InboundQueueFixture { +pub fn make_inbound_fixture() -> EventFixture { + EventFixture { event: EventProof { event_log: Log { address: hex!("eda338e4dc46038493b885327842fd3e301cab39").into(), diff --git a/bridges/snowbridge/pallets/ethereum-client/src/impls.rs b/bridges/snowbridge/pallets/ethereum-client/src/impls.rs index 7eda86b06a5c6..8cb959bb174de 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/impls.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/impls.rs @@ -6,9 +6,9 @@ use snowbridge_beacon_primitives::ExecutionProof; use snowbridge_beacon_primitives::merkle_proof::{generalized_index_length, subtree_index}; use snowbridge_ethereum::Receipt; -use snowbridge_inbound_queue_primitives::{ +use snowbridge_verification_primitives::{ VerificationError::{self, *}, - *, + Verifier, *, }; impl Verifier for Pallet { diff --git a/bridges/snowbridge/pallets/ethereum-client/src/mock.rs b/bridges/snowbridge/pallets/ethereum-client/src/mock.rs index 1385e0cacd980..9eec93f98c855 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/mock.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/mock.rs @@ -5,7 +5,7 @@ use crate::config; use frame_support::{derive_impl, dispatch::DispatchResult, parameter_types}; use pallet_timestamp; use snowbridge_beacon_primitives::{Fork, ForkVersions}; -use snowbridge_inbound_queue_primitives::{Log, Proof}; +use snowbridge_verification_primitives::{Log, Proof}; use sp_std::default::Default; use std::{fs::File, path::PathBuf}; diff --git a/bridges/snowbridge/pallets/ethereum-client/src/mock_electra.rs b/bridges/snowbridge/pallets/ethereum-client/src/mock_electra.rs index 140e9d502034e..d0c9f5bd9eaef 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/mock_electra.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/mock_electra.rs @@ -5,7 +5,7 @@ use crate::config; use frame_support::{derive_impl, dispatch::DispatchResult, parameter_types}; use pallet_timestamp; use snowbridge_beacon_primitives::{Fork, ForkVersions}; -use snowbridge_inbound_queue_primitives::{Log, Proof}; +use snowbridge_verification_primitives::{Log, Proof}; use sp_std::default::Default; use std::{fs::File, path::PathBuf}; diff --git a/bridges/snowbridge/pallets/ethereum-client/src/tests.rs b/bridges/snowbridge/pallets/ethereum-client/src/tests.rs index ec43017a95e76..fd27505a547c1 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/tests.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/tests.rs @@ -20,7 +20,7 @@ use snowbridge_beacon_primitives::{ types::deneb, Fork, ForkVersions, NextSyncCommitteeUpdate, VersionedExecutionPayloadHeader, }; -use snowbridge_inbound_queue_primitives::{VerificationError, Verifier}; +use snowbridge_verification_primitives::{VerificationError, Verifier}; use sp_core::H256; use sp_runtime::DispatchError; diff --git a/bridges/snowbridge/pallets/ethereum-client/src/tests_electra.rs b/bridges/snowbridge/pallets/ethereum-client/src/tests_electra.rs index 4bac31f0bff3c..2feddf528b4ca 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/tests_electra.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/tests_electra.rs @@ -19,7 +19,7 @@ use snowbridge_beacon_primitives::{ types::deneb, Fork, ForkVersions, NextSyncCommitteeUpdate, VersionedExecutionPayloadHeader, }; -use snowbridge_inbound_queue_primitives::{VerificationError, Verifier}; +use snowbridge_verification_primitives::{VerificationError, Verifier}; use sp_core::H256; use sp_runtime::DispatchError; diff --git a/bridges/snowbridge/pallets/inbound-queue-v2/Cargo.toml b/bridges/snowbridge/pallets/inbound-queue-v2/Cargo.toml index fe52c823b9b2d..727cc62dbef7c 100644 --- a/bridges/snowbridge/pallets/inbound-queue-v2/Cargo.toml +++ b/bridges/snowbridge/pallets/inbound-queue-v2/Cargo.toml @@ -50,7 +50,6 @@ bp-relayers = { workspace = true } frame-benchmarking = { workspace = true, default-features = true } hex = { workspace = true, default-features = true } hex-literal = { workspace = true, default-features = true } -snowbridge-pallet-ethereum-client = { workspace = true, default-features = true } snowbridge-test-utils = { workspace = true } sp-keyring = { workspace = true, default-features = true } @@ -89,7 +88,6 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "snowbridge-core/runtime-benchmarks", "snowbridge-inbound-queue-primitives/runtime-benchmarks", - "snowbridge-pallet-ethereum-client/runtime-benchmarks", "snowbridge-pallet-inbound-queue-v2-fixtures/runtime-benchmarks", "snowbridge-test-utils/runtime-benchmarks", "sp-runtime/runtime-benchmarks", @@ -101,6 +99,5 @@ try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "pallet-balances/try-runtime", - "snowbridge-pallet-ethereum-client/try-runtime", "sp-runtime/try-runtime", ] diff --git a/bridges/snowbridge/pallets/inbound-queue-v2/fixtures/src/register_token.rs b/bridges/snowbridge/pallets/inbound-queue-v2/fixtures/src/register_token.rs index d42899bf8da61..aa13e78542721 100644 --- a/bridges/snowbridge/pallets/inbound-queue-v2/fixtures/src/register_token.rs +++ b/bridges/snowbridge/pallets/inbound-queue-v2/fixtures/src/register_token.rs @@ -7,12 +7,12 @@ use hex_literal::hex; use snowbridge_beacon_primitives::{ types::deneb, AncestryProof, BeaconHeader, ExecutionProof, VersionedExecutionPayloadHeader, }; -use snowbridge_inbound_queue_primitives::{EventProof, InboundQueueFixture, Log, Proof}; +use snowbridge_inbound_queue_primitives::{EventFixture, EventProof, Log, Proof}; use sp_core::U256; use sp_std::vec; -pub fn make_register_token_message() -> InboundQueueFixture { - InboundQueueFixture { +pub fn make_register_token_message() -> EventFixture { + EventFixture { event: EventProof { event_log: Log { address: hex!("b1185ede04202fe62d38f5db72f71e38ff3e8305").into(), diff --git a/bridges/snowbridge/pallets/inbound-queue-v2/src/mock.rs b/bridges/snowbridge/pallets/inbound-queue-v2/src/mock.rs index 05666a3dcb63b..39a1787155049 100644 --- a/bridges/snowbridge/pallets/inbound-queue-v2/src/mock.rs +++ b/bridges/snowbridge/pallets/inbound-queue-v2/src/mock.rs @@ -8,7 +8,7 @@ use frame_support::{derive_impl, parameter_types, traits::ConstU32, weights::Ide use hex_literal::hex; use scale_info::TypeInfo; use snowbridge_beacon_primitives::{ - types::deneb, BeaconHeader, ExecutionProof, Fork, ForkVersions, VersionedExecutionPayloadHeader, + types::deneb, BeaconHeader, ExecutionProof, VersionedExecutionPayloadHeader, }; use snowbridge_core::TokenId; use snowbridge_inbound_queue_primitives::{v2::MessageToXcm, Log, Proof, VerificationError}; @@ -27,7 +27,6 @@ frame_support::construct_runtime!( { System: frame_system::{Pallet, Call, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - EthereumBeaconClient: snowbridge_pallet_ethereum_client::{Pallet, Call, Storage, Event}, InboundQueue: inbound_queue_v2::{Pallet, Call, Storage, Event}, } ); @@ -56,42 +55,6 @@ impl pallet_balances::Config for Test { type AccountStore = System; } -parameter_types! { - 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, - }, - deneb: Fork { - version: [4, 0, 0, 1], // 0x04000001 - epoch: 0, - }, - electra: Fork { - version: [5, 0, 0, 0], // 0x05000000 - epoch: 80000000000, - } - }; -} - -impl snowbridge_pallet_ethereum_client::Config for Test { - type RuntimeEvent = RuntimeEvent; - type ForkVersions = ChainForkVersions; - type FreeHeadersInterval = ConstU32<32>; - type WeightInfo = (); -} - // Mock verifier pub struct MockVerifier; @@ -107,7 +70,7 @@ impl Verifier for MockVerifier { const GATEWAY_ADDRESS: [u8; 20] = hex!["b1185ede04202fe62d38f5db72f71e38ff3e8305"]; #[cfg(feature = "runtime-benchmarks")] -impl BenchmarkHelper for Test { +impl BenchmarkHelper for Test { // not implemented since the MockVerifier is used for tests fn initialize_storage(_: BeaconHeader, _: H256) {} } diff --git a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/register_token.rs b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/register_token.rs index 12ce83e305c6c..63868f36f0997 100644 --- a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/register_token.rs +++ b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/register_token.rs @@ -7,12 +7,12 @@ use hex_literal::hex; use snowbridge_beacon_primitives::{ types::deneb, AncestryProof, BeaconHeader, ExecutionProof, VersionedExecutionPayloadHeader, }; -use snowbridge_inbound_queue_primitives::{EventProof, InboundQueueFixture, Log, Proof}; +use snowbridge_inbound_queue_primitives::{EventFixture, EventProof, Log, Proof}; use sp_core::U256; use sp_std::vec; -pub fn make_register_token_message() -> InboundQueueFixture { - InboundQueueFixture { +pub fn make_register_token_message() -> EventFixture { + EventFixture { event: EventProof { event_log: Log { address: hex!("eda338e4dc46038493b885327842fd3e301cab39").into(), diff --git a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_native_eth.rs b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_native_eth.rs index 61b8209668f84..e277f27166e08 100755 --- a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_native_eth.rs +++ b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_native_eth.rs @@ -7,12 +7,12 @@ use hex_literal::hex; use snowbridge_beacon_primitives::{ types::deneb, AncestryProof, BeaconHeader, ExecutionProof, VersionedExecutionPayloadHeader, }; -use snowbridge_inbound_queue_primitives::{EventProof, InboundQueueFixture, Log, Proof}; +use snowbridge_inbound_queue_primitives::{EventFixture, EventProof, Log, Proof}; use sp_core::U256; use sp_std::vec; -pub fn make_send_native_eth_message() -> InboundQueueFixture { - InboundQueueFixture { +pub fn make_send_native_eth_message() -> EventFixture { + EventFixture { event: EventProof { event_log: Log { address: hex!("87d1f7fdfee7f651fabc8bfcb6e086c278b77a7d").into(), diff --git a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_token.rs b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_token.rs index 588c67088c3e9..bd72afc13e2b7 100755 --- a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_token.rs +++ b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_token.rs @@ -7,12 +7,12 @@ use hex_literal::hex; use snowbridge_beacon_primitives::{ types::deneb, AncestryProof, BeaconHeader, ExecutionProof, VersionedExecutionPayloadHeader, }; -use snowbridge_inbound_queue_primitives::{EventProof, InboundQueueFixture, Log, Proof}; +use snowbridge_inbound_queue_primitives::{EventFixture, EventProof, Log, Proof}; use sp_core::U256; use sp_std::vec; -pub fn make_send_token_message() -> InboundQueueFixture { - InboundQueueFixture { +pub fn make_send_token_message() -> EventFixture { + EventFixture { event: EventProof { event_log: Log { address: hex!("eda338e4dc46038493b885327842fd3e301cab39").into(), diff --git a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_token_to_penpal.rs b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_token_to_penpal.rs index cba96a79fd0ab..a61b13f9582a9 100755 --- a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_token_to_penpal.rs +++ b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_token_to_penpal.rs @@ -7,12 +7,12 @@ use hex_literal::hex; use snowbridge_beacon_primitives::{ types::deneb, AncestryProof, BeaconHeader, ExecutionProof, VersionedExecutionPayloadHeader, }; -use snowbridge_inbound_queue_primitives::{EventProof, InboundQueueFixture, Log, Proof}; +use snowbridge_inbound_queue_primitives::{EventFixture, EventProof, Log, Proof}; use sp_core::U256; use sp_std::vec; -pub fn make_send_token_to_penpal_message() -> InboundQueueFixture { - InboundQueueFixture { +pub fn make_send_token_to_penpal_message() -> EventFixture { + EventFixture { event: EventProof { event_log: Log { address: hex!("eda338e4dc46038493b885327842fd3e301cab39").into(), diff --git a/bridges/snowbridge/pallets/outbound-queue-v2/Cargo.toml b/bridges/snowbridge/pallets/outbound-queue-v2/Cargo.toml index d895e8aba1497..b39dd07b8d376 100644 --- a/bridges/snowbridge/pallets/outbound-queue-v2/Cargo.toml +++ b/bridges/snowbridge/pallets/outbound-queue-v2/Cargo.toml @@ -37,9 +37,11 @@ sp-std = { workspace = true } bp-relayers = { workspace = true } bridge-hub-common = { workspace = true } +snowbridge-beacon-primitives = { workspace = true } snowbridge-core = { workspace = true } snowbridge-merkle-tree = { workspace = true } snowbridge-outbound-queue-primitives = { workspace = true } +snowbridge-verification-primitives = { workspace = true } xcm = { workspace = true } xcm-builder = { workspace = true } @@ -47,7 +49,6 @@ xcm-executor = { workspace = true } [dev-dependencies] pallet-message-queue = { workspace = true } -sp-keyring = { workspace = true, default-features = true } [features] default = ["std"] @@ -63,9 +64,11 @@ std = [ "pallet-message-queue/std", "scale-info/std", "serde/std", + "snowbridge-beacon-primitives/std", "snowbridge-core/std", "snowbridge-merkle-tree/std", "snowbridge-outbound-queue-primitives/std", + "snowbridge-verification-primitives/std", "sp-arithmetic/std", "sp-core/std", "sp-io/std", diff --git a/bridges/snowbridge/pallets/outbound-queue-v2/src/benchmarking.rs b/bridges/snowbridge/pallets/outbound-queue-v2/src/benchmarking.rs index b4ce4d2106564..1af38457a528f 100644 --- a/bridges/snowbridge/pallets/outbound-queue-v2/src/benchmarking.rs +++ b/bridges/snowbridge/pallets/outbound-queue-v2/src/benchmarking.rs @@ -2,10 +2,12 @@ // SPDX-FileCopyrightText: 2023 Snowfork use super::*; +use crate::fixture::make_submit_delivery_receipt_message; use bridge_hub_common::AggregateMessageOrigin; use codec::Encode; use frame_benchmarking::v2::*; use frame_support::{traits::Hooks, BoundedVec}; +use frame_system::RawOrigin; use snowbridge_outbound_queue_primitives::v2::{Command, Initializer, Message}; use sp_core::{H160, H256}; @@ -18,6 +20,7 @@ use crate::Pallet as OutboundQueue; )] mod benchmarks { use super::*; + use frame_support::assert_ok; /// Build `Upgrade` message with `MaxMessagePayloadSize`, in the worst-case. fn build_message() -> (Message, OutboundMessage) { @@ -147,5 +150,33 @@ mod benchmarks { Ok(()) } + #[benchmark] + fn submit_delivery_receipt() -> Result<(), BenchmarkError> { + let caller: T::AccountId = whitelisted_caller(); + + let message = make_submit_delivery_receipt_message(); + + T::Helper::initialize_storage(message.finalized_header, message.block_roots_root); + + let receipt = DeliveryReceipt::try_from(&message.event.event_log).unwrap(); + + let order = PendingOrder { + nonce: receipt.nonce, + fee: 0, + block_number: frame_system::Pallet::::current_block_number(), + }; + >::insert(receipt.nonce, order); + + #[block] + { + assert_ok!(OutboundQueue::::submit_delivery_receipt( + RawOrigin::Signed(caller.clone()).into(), + Box::new(message.event), + )); + } + + Ok(()) + } + impl_benchmark_test_suite!(OutboundQueue, crate::mock::new_tester(), crate::mock::Test,); } diff --git a/bridges/snowbridge/pallets/outbound-queue-v2/src/fixture.rs b/bridges/snowbridge/pallets/outbound-queue-v2/src/fixture.rs new file mode 100644 index 0000000000000..b6c4a9d998265 --- /dev/null +++ b/bridges/snowbridge/pallets/outbound-queue-v2/src/fixture.rs @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2023 Snowfork +// Generated, do not edit! +// See ethereum client README.md for instructions to generate + +use hex_literal::hex; +use snowbridge_beacon_primitives::{ + types::deneb, AncestryProof, BeaconHeader, ExecutionProof, VersionedExecutionPayloadHeader, +}; +use snowbridge_verification_primitives::{EventFixture, EventProof, Log, Proof}; +use sp_core::U256; +use sp_std::vec; + +pub fn make_submit_delivery_receipt_message() -> EventFixture { + EventFixture { + event: EventProof { + event_log: Log { + address: hex!("b1185ede04202fe62d38f5db72f71e38ff3e8305").into(), + topics: vec![ + hex!("8856ab63954e6c2938803a4654fb704c8779757e7bfdbe94a578e341ec637a95").into(), + hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + ], + data: hex!("907b6ec7bf3f2496ef79238e0fb19e032bfe444c7ffe906bd340c6c4ffe8511f0000000000000000000000000000000000000000000000000000000000000001d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").into(), + }, + proof: Proof { + receipt_proof: (vec![ + hex!("8a40611a32af2ad0ad63bf32e8c633ff209e6f701645b8f25e492327cd95d4e0").to_vec(), + ], vec![ + hex!("f9024e822080b9024802f9024401830d716eb9010000200000000000000000000000000000080000000000000000000000000000000000000000000004000000000000000000000000000000000000000000008000000000000000000801000000000000000000000000000000000000000000000000000000020000000008000000000800000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000800000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000020000000000200000000000000000000000000000000000000000000000000000000f90139f87a94b1185ede04202fe62d38f5db72f71e38ff3e8305f842a057f58171b8777633d03aff1e7408b96a3d910c93a7ce433a8cb7fb837dc306a6a09441dceeeffa7e032eedaccf9b7632e60e86711551a82ffbbb0dda8afd9e4ef7a0000000000000000000000000de45448ca2d57797c0bec0ee15a1e42334744219f8bb94b1185ede04202fe62d38f5db72f71e38ff3e8305f842a08856ab63954e6c2938803a4654fb704c8779757e7bfdbe94a578e341ec637a95a00000000000000000000000000000000000000000000000000000000000000000b860907b6ec7bf3f2496ef79238e0fb19e032bfe444c7ffe906bd340c6c4ffe8511f0000000000000000000000000000000000000000000000000000000000000001d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec(), + ]), + execution_proof: ExecutionProof { + header: BeaconHeader { + slot: 663, + proposer_index: 4, + parent_root: hex!("478651896411faa949cd0882bb6a82595b71d3eba74cbeb87b5eb8162c7e00f1").into(), + state_root: hex!("4191b7c2a622b8cfa31684e5e06de3b36834e403a6ded2acd32156a488f829b0").into(), + body_root: hex!("72765c81bbad6cd083314506936528719e03d33ee65927167a372febe1fbf734").into(), + }, + ancestry_proof: Some(AncestryProof { + header_branch: vec![ + hex!("478651896411faa949cd0882bb6a82595b71d3eba74cbeb87b5eb8162c7e00f1").into(), + hex!("87314a5200d3a22749bd98ba32af7d0546d25d47cf012dfcc85adc19ad7adfe3").into(), + hex!("e794355aa5b1743ea691e3f051f44a66956892621c0110a12980e66f70dc3d74").into(), + hex!("fe0a3f7035e5d4cc83412939c9d343caa34889bd9655a05e9cc53a09e3aa7e8c").into(), + hex!("0f472e1a66d039197fbe378845e848ec11d5bcde60ac650da812fa1f4461c603").into(), + hex!("018f388291fbd20c15691e4b118a17b870eec7beb837e91fcc839adcb5fb21fc").into(), + hex!("8a016b0d65b61e5026b9357df092bf82b52fa61af3e10d11ba7b24ae30b457ec").into(), + hex!("73af6cacce9735d5576d1defc7fc39061776004ac7d3aba3abf6dfad7b1a3a36").into(), + hex!("6116f4b671f0f26c224ab10c6c330d56c9b5e48fa6e2204035f333bc142f55d2").into(), + hex!("a08d24b9120c5faeb98654664c4a324aaa509031193dbd74930acf26285b26a6").into(), + hex!("ffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b").into(), + hex!("6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220").into(), + hex!("b7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f").into(), + ], + finalized_block_root: hex!("d5793913dc57d9f5b9d50fb8c693504201d6926649834ac90337b673e66f98e0").into(), + }), + execution_header: VersionedExecutionPayloadHeader::Deneb(deneb::ExecutionPayloadHeader { + parent_hash: hex!("35f64f37bea4538092ba578f4851d52375f7f3b2a52c1cb16f22fe512aead95d").into(), + fee_recipient: hex!("0000000000000000000000000000000000000000").into(), + state_root: hex!("dfa305877e67ab0caa827b15d573b58dfe360fe8d484d37228f8ae55ccced61c").into(), + receipts_root: hex!("8a40611a32af2ad0ad63bf32e8c633ff209e6f701645b8f25e492327cd95d4e0").into(), + logs_bloom: hex!("00200000000000000000000000000000080000000000000000000000000000000000000000000004000000000000000000000000000000000000000000008000000000000000000801000000000000000000000000000000000000000000000000000000020000000008000000000800000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000800000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000020000000000200000000000000000000000000000000000000000000000000000000").into(), + prev_randao: hex!("ebdade0d95216bdba380fce14fad97c870d8553fcf0ca37df22331b3ed498db2").into(), + block_number: 663, + gas_limit: 41857321, + gas_used: 881006, + timestamp: 1742914413, + extra_data: hex!("d983010e0c846765746888676f312e32332e348664617277696e").into(), + base_fee_per_gas: U256::from(7u64), + block_hash: hex!("c70c7e5b0a03fa9509e0b4598d65e6e0b6a2477f25064aa3221b39eee17583d4").into(), + transactions_root: hex!("065ecaa208638c4a43d080cd78a1451e406895caaa254b1ad0585c6a9e3c7ac6").into(), + withdrawals_root: hex!("792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535").into(), + blob_gas_used: 0, + excess_blob_gas: 0, + }), + execution_branch: vec![ + hex!("ef46bf5d8bd654162c1a7f44949fe1f9cb2a3f356d593587a3f1f3f8da14b790").into(), + hex!("b46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb").into(), + hex!("db56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71").into(), + hex!("b4e39d31736a4064a84ca49c4d372696e92e7c5c7bcbb7219671c24df1dfcafa").into(), + ], + } + }, + }, + finalized_header: BeaconHeader { + slot: 864, + proposer_index: 4, + parent_root: hex!("2839d32d7b5a1dbb9139c5fd11ea549abaac1ead425c79553b8424550fddd389").into(), + state_root: hex!("452daf2471437939f4d65af921a1cfee860b11111771fd55164b37fe25d610de").into(), + body_root: hex!("0bbd0377987d0984e7495bf61219342941e31a0b6fe790453fbc87ec92319097").into(), + }, + block_roots_root: hex!("aca108d3e77ec6b010ca03df025e3b2e84f754d4642e5d8bf0ba9bdf58f42848").into(), + } +} diff --git a/bridges/snowbridge/pallets/outbound-queue-v2/src/lib.rs b/bridges/snowbridge/pallets/outbound-queue-v2/src/lib.rs index 92d53d536c1c4..682c2f94ab317 100644 --- a/bridges/snowbridge/pallets/outbound-queue-v2/src/lib.rs +++ b/bridges/snowbridge/pallets/outbound-queue-v2/src/lib.rs @@ -64,6 +64,9 @@ mod mock; #[cfg(test)] mod test; +#[cfg(feature = "runtime-benchmarks")] +mod fixture; + use alloy_core::{ primitives::{Bytes, FixedBytes}, sol_types::SolValue, @@ -76,7 +79,7 @@ use frame_support::{ traits::{tokens::Balance, EnqueueMessage, Get, ProcessMessageError}, weights::{Weight, WeightToFee}, }; -use snowbridge_core::{BasicOperatingMode, TokenId}; +use snowbridge_core::BasicOperatingMode; use snowbridge_merkle_tree::merkle_root; use snowbridge_outbound_queue_primitives::{ v2::{ @@ -87,14 +90,16 @@ use snowbridge_outbound_queue_primitives::{ }; use sp_core::{H160, H256}; use sp_runtime::{ - traits::{BlockNumberProvider, Hash, MaybeEquivalence}, + traits::{BlockNumberProvider, Hash}, DigestItem, }; use sp_std::prelude::*; pub use types::{PendingOrder, ProcessMessageOriginOf}; pub use weights::WeightInfo; -use xcm::latest::{Location, NetworkId}; -type DeliveryReceiptOf = DeliveryReceipt<::AccountId>; +use xcm::prelude::NetworkId; + +#[cfg(feature = "runtime-benchmarks")] +use snowbridge_beacon_primitives::BeaconHeader; pub use pallet::*; @@ -149,7 +154,8 @@ pub mod pallet { type RewardPayment: RewardLedger; /// Ethereum NetworkId type EthereumNetwork: Get; - type ConvertAssetId: MaybeEquivalence; + #[cfg(feature = "runtime-benchmarks")] + type Helper: BenchmarkHelper; } #[pallet::event] @@ -244,11 +250,13 @@ pub mod pallet { } } + #[cfg(feature = "runtime-benchmarks")] + pub trait BenchmarkHelper { + fn initialize_storage(beacon_header: BeaconHeader, block_roots_root: H256); + } + #[pallet::call] - impl Pallet - where - T::AccountId: From<[u8; 32]>, - { + impl Pallet { #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::submit_delivery_receipt())] pub fn submit_delivery_receipt( @@ -261,7 +269,7 @@ pub mod pallet { T::Verifier::verify(&event.event_log, &event.proof) .map_err(|e| Error::::Verification(e))?; - let receipt = DeliveryReceiptOf::::try_from(&event.event_log) + let receipt = DeliveryReceipt::try_from(&event.event_log) .map_err(|_| Error::::InvalidEnvelope)?; Self::process_delivery_receipt(relayer, receipt) @@ -368,11 +376,8 @@ pub mod pallet { /// Process a delivery receipt from a relayer, to allocate the relayer reward. pub fn process_delivery_receipt( relayer: ::AccountId, - receipt: DeliveryReceiptOf, - ) -> DispatchResult - where - ::AccountId: From<[u8; 32]>, - { + receipt: DeliveryReceipt, + ) -> DispatchResult { // Verify that the message was submitted from the known Gateway contract ensure!(T::GatewayAddress::get() == receipt.gateway, Error::::InvalidGateway); diff --git a/bridges/snowbridge/pallets/outbound-queue-v2/src/mock.rs b/bridges/snowbridge/pallets/outbound-queue-v2/src/mock.rs index 0263b30bbfe04..f14332cc45a14 100644 --- a/bridges/snowbridge/pallets/outbound-queue-v2/src/mock.rs +++ b/bridges/snowbridge/pallets/outbound-queue-v2/src/mock.rs @@ -83,7 +83,7 @@ impl Verifier for MockVerifier { } } -const GATEWAY_ADDRESS: [u8; 20] = hex!["eda338e4dc46038493b885327842fd3e301cab39"]; +const GATEWAY_ADDRESS: [u8; 20] = hex!["b1185ede04202fe62d38f5db72f71e38ff3e8305"]; const WETH: [u8; 20] = hex!["C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"]; parameter_types! { @@ -141,10 +141,11 @@ impl crate::Config for Test { type WeightToFee = IdentityFee; type WeightInfo = (); type RewardPayment = (); - type ConvertAssetId = (); type EthereumNetwork = EthereumNetwork; type RewardKind = BridgeReward; type DefaultRewardKind = DefaultMyRewardKind; + #[cfg(feature = "runtime-benchmarks")] + type Helper = Test; } fn setup() { @@ -251,3 +252,9 @@ pub fn mock_register_token_message(sibling_para_id: u32) -> Message { .unwrap(), } } + +#[cfg(feature = "runtime-benchmarks")] +impl BenchmarkHelper for Test { + // not implemented since the MockVerifier is used for tests + fn initialize_storage(_: BeaconHeader, _: H256) {} +} diff --git a/bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs b/bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs index b3651b64b0124..92bd0e5d66169 100644 --- a/bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs +++ b/bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs @@ -257,7 +257,7 @@ fn encode_unlock_message() { let message: Message = mock_message(1000); let message_abi_encoded = encode_mock_message(message); println!("{}", HexDisplay::from(&message_abi_encoded)); - assert_eq!(hex!("000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000eda338e4dc46038493b885327842fd3e301cab3900000000000000000000000000000000000000000000000000000000000f4240").to_vec(), message_abi_encoded) + assert_eq!(hex!("000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000b1185ede04202fe62d38f5db72f71e38ff3e830500000000000000000000000000000000000000000000000000000000000f4240").to_vec(), message_abi_encoded) } #[test] diff --git a/bridges/snowbridge/primitives/inbound-queue/src/lib.rs b/bridges/snowbridge/primitives/inbound-queue/src/lib.rs index ea7323e30acb5..e44d98b698048 100644 --- a/bridges/snowbridge/primitives/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/primitives/inbound-queue/src/lib.rs @@ -5,21 +5,13 @@ pub mod v1; pub mod v2; use codec::Encode; -use snowbridge_beacon_primitives::BeaconHeader; -use sp_core::{blake2_256, RuntimeDebug, H256}; +use sp_core::blake2_256; use sp_std::marker::PhantomData; use xcm::prelude::{AccountKey20, Ethereum, GlobalConsensus, Location}; use xcm_executor::traits::ConvertLocation; pub use snowbridge_verification_primitives::*; -#[derive(Clone, RuntimeDebug)] -pub struct InboundQueueFixture { - pub event: EventProof, - pub finalized_header: BeaconHeader, - pub block_roots_root: H256, -} - /// DEPRECATED in favor of [xcm_builder::ExternalConsensusLocationsConverterFor] pub struct EthereumLocationsConverterFor(PhantomData); impl ConvertLocation for EthereumLocationsConverterFor diff --git a/bridges/snowbridge/primitives/outbound-queue/src/v2/delivery_receipt.rs b/bridges/snowbridge/primitives/outbound-queue/src/v2/delivery_receipt.rs index 98410eef3493c..852de849177b1 100644 --- a/bridges/snowbridge/primitives/outbound-queue/src/v2/delivery_receipt.rs +++ b/bridges/snowbridge/primitives/outbound-queue/src/v2/delivery_receipt.rs @@ -13,10 +13,7 @@ sol! { /// Delivery receipt #[derive(Clone, RuntimeDebug)] -pub struct DeliveryReceipt -where - AccountId: From<[u8; 32]> + Clone, -{ +pub struct DeliveryReceipt { /// The address of the outbound queue on Ethereum that emitted this message as an event log pub gateway: H160, /// The nonce of the dispatched message @@ -26,7 +23,7 @@ where /// Delivery status pub success: bool, /// The reward address - pub reward_address: AccountId, + pub reward_address: [u8; 32], } #[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] @@ -35,10 +32,7 @@ pub enum DeliveryReceiptDecodeError { DecodeAccountFailed, } -impl TryFrom<&Log> for DeliveryReceipt -where - AccountId: From<[u8; 32]> + Clone, -{ +impl TryFrom<&Log> for DeliveryReceipt { type Error = DeliveryReceiptDecodeError; fn try_from(log: &Log) -> Result { @@ -47,14 +41,12 @@ where let event = InboundMessageDispatched::decode_raw_log(topics, &log.data, true) .map_err(|_| DeliveryReceiptDecodeError::DecodeLogFailed)?; - let account: AccountId = AccountId::from(event.reward_address.0); - Ok(Self { gateway: log.address, nonce: event.nonce, topic: H256::from_slice(event.topic.as_ref()), success: event.success, - reward_address: account, + reward_address: event.reward_address.0, }) } } diff --git a/bridges/snowbridge/primitives/verification/src/lib.rs b/bridges/snowbridge/primitives/verification/src/lib.rs index f8414398af327..1e508f48da437 100644 --- a/bridges/snowbridge/primitives/verification/src/lib.rs +++ b/bridges/snowbridge/primitives/verification/src/lib.rs @@ -5,7 +5,7 @@ use codec::{Decode, DecodeWithMemTracking, Encode}; use frame_support::PalletError; use scale_info::TypeInfo; -use snowbridge_beacon_primitives::ExecutionProof; +use snowbridge_beacon_primitives::{BeaconHeader, ExecutionProof}; use sp_core::{RuntimeDebug, H160, H256}; use sp_std::prelude::*; @@ -70,3 +70,10 @@ pub struct Proof { // Proof that an execution header was finalized by the beacon chain pub execution_proof: ExecutionProof, } + +#[derive(Clone, RuntimeDebug)] +pub struct EventFixture { + pub event: EventProof, + pub finalized_header: BeaconHeader, + pub block_roots_root: H256, +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 06a16443f59f7..6a8271524155c 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -21,7 +21,7 @@ use hex_literal::hex; use rococo_westend_system_emulated_network::BridgeHubRococoParaSender as BridgeHubRococoSender; use snowbridge_inbound_queue_primitives::{ v1::{Command, Destination, MessageV1, VersionedMessage}, - InboundQueueFixture, + EventFixture, }; use snowbridge_outbound_queue_primitives::OperatingMode; use snowbridge_pallet_inbound_queue_fixtures::{ @@ -57,7 +57,7 @@ pub enum SnowbridgeControl { Control(ControlCall), } -pub fn send_inbound_message(fixture: InboundQueueFixture) -> DispatchResult { +pub fn send_inbound_message(fixture: EventFixture) -> DispatchResult { EthereumBeaconClient::store_finalized_header( fixture.finalized_header, fixture.block_roots_root, diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge.rs index 724444a3f7101..eef3081f5a8c2 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge.rs @@ -31,7 +31,7 @@ use rococo_westend_system_emulated_network::{ use snowbridge_core::{AssetMetadata, TokenIdOf}; use snowbridge_inbound_queue_primitives::{ v1::{Command, Destination, MessageV1, VersionedMessage}, - InboundQueueFixture, + EventFixture, }; use snowbridge_pallet_inbound_queue_fixtures::send_native_eth::make_send_native_eth_message; use sp_core::H256; @@ -61,7 +61,7 @@ pub enum SnowbridgeControl { Control(ControlCall), } -pub fn send_inbound_message(fixture: InboundQueueFixture) -> DispatchResult { +pub fn send_inbound_message(fixture: EventFixture) -> DispatchResult { EthereumBeaconClient::store_finalized_header( fixture.finalized_header, fixture.block_roots_root, diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge_v2_outbound.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge_v2_outbound.rs index ec25a499290d5..7ef387692bcd2 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge_v2_outbound.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge_v2_outbound.rs @@ -106,8 +106,8 @@ fn send_weth_from_asset_hub_to_ethereum() { let receipt = DeliveryReceipt { gateway: EthereumGatewayAddress::get(), nonce: 0, + reward_address: reward_account.into(), topic: H256::zero(), - reward_address: reward_account, success: true, }; @@ -262,8 +262,8 @@ fn transfer_relay_token_from_ah() { let receipt = DeliveryReceipt { gateway: EthereumGatewayAddress::get(), nonce: 0, + reward_address: reward_account.into(), topic: H256::zero(), - reward_address: reward_account, success: true, }; @@ -349,8 +349,8 @@ fn send_weth_and_dot_from_asset_hub_to_ethereum() { let receipt = DeliveryReceipt { gateway: EthereumGatewayAddress::get(), nonce: 0, + reward_address: reward_account.into(), topic: H256::zero(), - reward_address: reward_account, success: true, }; @@ -445,8 +445,8 @@ fn transact_with_agent_from_asset_hub() { let receipt = DeliveryReceipt { gateway: EthereumGatewayAddress::get(), nonce: 0, + reward_address: reward_account.into(), topic: H256::zero(), - reward_address: reward_account, success: true, }; @@ -562,8 +562,8 @@ fn register_token_from_penpal() { let receipt = DeliveryReceipt { gateway: EthereumGatewayAddress::get(), nonce: 0, + reward_address: reward_account.into(), topic: H256::zero(), - reward_address: reward_account, success: true, }; @@ -727,8 +727,8 @@ fn invalid_nonce_for_delivery_receipt_fails() { let receipt = DeliveryReceipt { gateway: EthereumGatewayAddress::get(), nonce: 0, + reward_address: reward_account.into(), topic: H256::zero(), - reward_address: reward_account, success: true, }; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_ethereum_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_ethereum_config.rs index 6428b08598ae4..1845281c0d332 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_ethereum_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_ethereum_config.rs @@ -191,12 +191,12 @@ impl snowbridge_pallet_outbound_queue_v2::Config for Runtime { type Verifier = snowbridge_pallet_ethereum_client::Pallet; type GatewayAddress = EthereumGatewayAddress; type WeightInfo = crate::weights::snowbridge_pallet_outbound_queue_v2::WeightInfo; - type ConvertAssetId = EthereumSystem; type EthereumNetwork = EthereumNetwork; type RewardKind = BridgeReward; - type DefaultRewardKind = SnowbridgeReward; type RewardPayment = BridgeRelayers; + #[cfg(feature = "runtime-benchmarks")] + type Helper = Runtime; } #[cfg(any(feature = "std", feature = "fast-runtime", feature = "runtime-benchmarks", test))] @@ -313,7 +313,8 @@ pub mod benchmark_helpers { use hex_literal::hex; use snowbridge_beacon_primitives::BeaconHeader; use snowbridge_pallet_inbound_queue::BenchmarkHelper; - use snowbridge_pallet_inbound_queue_v2::BenchmarkHelper as BenchmarkHelperV2; + use snowbridge_pallet_inbound_queue_v2::BenchmarkHelper as InboundQueueBenchmarkHelperV2; + use snowbridge_pallet_outbound_queue_v2::BenchmarkHelper as OutboundQueueBenchmarkHelperV2; use sp_core::H256; use xcm::latest::{Assets, Location, SendError, SendResult, SendXcm, Xcm, XcmHash}; @@ -331,7 +332,13 @@ pub mod benchmark_helpers { } } - impl BenchmarkHelperV2 for Runtime { + impl InboundQueueBenchmarkHelperV2 for Runtime { + fn initialize_storage(beacon_header: BeaconHeader, block_roots_root: H256) { + EthereumBeaconClient::store_finalized_header(beacon_header, block_roots_root).unwrap(); + } + } + + impl OutboundQueueBenchmarkHelperV2 for Runtime { fn initialize_storage(beacon_header: BeaconHeader, block_roots_root: H256) { EthereumBeaconClient::store_finalized_header(beacon_header, block_roots_root).unwrap(); } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/snowbridge_pallet_outbound_queue_v2.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/snowbridge_pallet_outbound_queue_v2.rs index 24533f9e871d3..0f1a9d360e714 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/snowbridge_pallet_outbound_queue_v2.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/snowbridge_pallet_outbound_queue_v2.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `snowbridge_pallet_outbound_queue_v2` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-03-18, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-03-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `yangdebijibendiannao.local`, CPU: `` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 @@ -71,8 +71,8 @@ impl snowbridge_pallet_outbound_queue_v2::WeightInfo fo // Proof Size summary in bytes: // Measured: `1128` // Estimated: `2613` - // Minimum execution time: 24_000_000 picoseconds. - Weight::from_parts(25_000_000, 0) + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(26_000_000, 0) .saturating_add(Weight::from_parts(0, 2613)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -82,8 +82,8 @@ impl snowbridge_pallet_outbound_queue_v2::WeightInfo fo // Proof Size summary in bytes: // Measured: `135` // Estimated: `1620` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(9_000_000, 0) + // Minimum execution time: 9_000_000 picoseconds. + Weight::from_parts(10_000_000, 0) .saturating_add(Weight::from_parts(0, 1620)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -100,29 +100,6 @@ impl snowbridge_pallet_outbound_queue_v2::WeightInfo fo .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(2)) } - - /// Storage: `EthereumBeaconClient::LatestFinalizedBlockRoot` (r:1 w:0) - /// Proof: `EthereumBeaconClient::LatestFinalizedBlockRoot` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::FinalizedBeaconState` (r:1 w:0) - /// Proof: `EthereumBeaconClient::FinalizedBeaconState` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// Storage: UNKNOWN KEY `0xaed97c7854d601808b98ae43079dafb3` (r:1 w:0) - /// Proof: UNKNOWN KEY `0xaed97c7854d601808b98ae43079dafb3` (r:1 w:0) - /// Storage: `EthereumOutboundQueueV2::PendingOrders` (r:1 w:1) - /// Proof: `EthereumOutboundQueueV2::PendingOrders` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) - /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) - /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `BridgeRelayers::RelayerRewards` (r:1 w:1) - /// Proof: `BridgeRelayers::RelayerRewards` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) - fn submit_delivery_receipt() -> Weight { - // Proof Size summary in bytes: - // Measured: `309` - // Estimated: `3774` - // Minimum execution time: 59_000_000 picoseconds. - Weight::from_parts(60_000_000, 0) - .saturating_add(Weight::from_parts(0, 3774)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(2)) - } /// Storage: `EthereumOutboundQueueV2::Nonce` (r:1 w:1) /// Proof: `EthereumOutboundQueueV2::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) /// Storage: `EthereumOutboundQueueV2::PendingOrders` (r:0 w:32) @@ -135,10 +112,28 @@ impl snowbridge_pallet_outbound_queue_v2::WeightInfo fo // Proof Size summary in bytes: // Measured: `113` // Estimated: `1493` - // Minimum execution time: 500_000_000 picoseconds. - Weight::from_parts(506_000_000, 0) + // Minimum execution time: 502_000_000 picoseconds. + Weight::from_parts(521_000_000, 0) .saturating_add(Weight::from_parts(0, 1493)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(35)) } + /// Storage: `EthereumBeaconClient::LatestFinalizedBlockRoot` (r:1 w:0) + /// Proof: `EthereumBeaconClient::LatestFinalizedBlockRoot` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `EthereumBeaconClient::FinalizedBeaconState` (r:1 w:0) + /// Proof: `EthereumBeaconClient::FinalizedBeaconState` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// Storage: UNKNOWN KEY `0xaed97c7854d601808b98ae43079dafb3` (r:1 w:0) + /// Proof: UNKNOWN KEY `0xaed97c7854d601808b98ae43079dafb3` (r:1 w:0) + /// Storage: `EthereumOutboundQueueV2::PendingOrders` (r:1 w:1) + /// Proof: `EthereumOutboundQueueV2::PendingOrders` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + fn submit_delivery_receipt() -> Weight { + // Proof Size summary in bytes: + // Measured: `320` + // Estimated: `3785` + // Minimum execution time: 67_000_000 picoseconds. + Weight::from_parts(68_000_000, 0) + .saturating_add(Weight::from_parts(0, 3785)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } } diff --git a/prdoc/pr_8026.prdoc b/prdoc/pr_8026.prdoc new file mode 100644 index 0000000000000..e117dcc2e4627 --- /dev/null +++ b/prdoc/pr_8026.prdoc @@ -0,0 +1,29 @@ +title: Benchmark the extrinsic `submit_delivery_receipt` +doc: +- audience: [Runtime Dev, Node Dev] + description: |- + To benchmark the extrinsic `submit_delivery_receipt`, which is missed in #7402. + There are also some other refactoring and improvements for the benchmark. +crates: +- name: snowbridge-inbound-queue-primitives + bump: minor +- name: snowbridge-outbound-queue-primitives + bump: minor +- name: snowbridge-verification-primitives + bump: minor +- name: snowbridge-pallet-ethereum-client-fixtures + bump: minor +- name: snowbridge-pallet-inbound-queue-v2 + bump: minor +- name: snowbridge-pallet-inbound-queue-v2-fixtures + bump: minor +- name: snowbridge-pallet-outbound-queue-v2 + bump: minor +- name: bridge-hub-westend-runtime + bump: minor +- name: bridge-hub-westend-integration-tests + bump: minor +- name: bridge-hub-rococo-integration-tests + bump: minor + +