diff --git a/parachain/Cargo.lock b/parachain/Cargo.lock index 8c3bd4f406..fd0cdc6780 100644 --- a/parachain/Cargo.lock +++ b/parachain/Cargo.lock @@ -5299,6 +5299,7 @@ dependencies = [ "snowbridge-beacon-primitives", "snowbridge-core", "snowbridge-ethereum", + "snowbridge-pallet-ethereum-client-fixtures", "sp-core", "sp-io", "sp-keyring", @@ -5309,6 +5310,20 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "snowbridge-pallet-ethereum-client-fixtures" +version = "0.9.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "hex-literal", + "snowbridge-beacon-primitives", + "snowbridge-core", + "sp-core", + "sp-std 8.0.0", +] + [[package]] name = "snowbridge-pallet-inbound-queue" version = "0.9.0" @@ -5483,6 +5498,7 @@ dependencies = [ "snowbridge-core", "snowbridge-outbound-queue-runtime-api", "snowbridge-pallet-ethereum-client", + "snowbridge-pallet-ethereum-client-fixtures", "snowbridge-pallet-inbound-queue", "snowbridge-pallet-outbound-queue", "snowbridge-pallet-system", diff --git a/parachain/pallets/ethereum-client/fixtures/src/lib.rs b/parachain/pallets/ethereum-client/fixtures/src/lib.rs index e13d81696f..573481e2c4 100644 --- a/parachain/pallets/ethereum-client/fixtures/src/lib.rs +++ b/parachain/pallets/ethereum-client/fixtures/src/lib.rs @@ -4,15 +4,19 @@ // See README.md for instructions to generate #![cfg_attr(not(feature = "std"), no_std)] -use crate::{CheckpointUpdate, ExecutionHeaderUpdate, Update}; use hex_literal::hex; -use primitives::{ - types::deneb, updates::AncestryProof, BeaconHeader, NextSyncCommitteeUpdate, SyncAggregate, - SyncCommittee, VersionedExecutionPayloadHeader, +use snowbridge_beacon_primitives::{ + types::deneb, updates::AncestryProof, BeaconHeader, ExecutionHeaderUpdate, + NextSyncCommitteeUpdate, SyncAggregate, SyncCommittee, VersionedExecutionPayloadHeader, }; use sp_core::U256; use sp_std::{boxed::Box, vec}; +const SC_SIZE: usize = 512; +const SC_BITS_SIZE: usize = 64; +type CheckpointUpdate = snowbridge_beacon_primitives::CheckpointUpdate; +type Update = snowbridge_beacon_primitives::Update; + pub fn make_checkpoint() -> Box { Box::new(CheckpointUpdate { header: BeaconHeader { diff --git a/parachain/runtime/test-common/Cargo.toml b/parachain/runtime/test-common/Cargo.toml index 5b5a79b563..2453708860 100644 --- a/parachain/runtime/test-common/Cargo.toml +++ b/parachain/runtime/test-common/Cargo.toml @@ -82,6 +82,7 @@ snowbridge-core = { path = "../../primitives/core", default-features = false } snowbridge-beacon-primitives = { path = "../../primitives/beacon", default-features = false } snowbridge-router-primitives = { path = "../../primitives/router", default-features = false } snowbridge-pallet-ethereum-client = { path = "../../pallets/ethereum-client", default-features = false } +snowbridge-pallet-ethereum-client-fixtures = { path = "../../pallets/ethereum-client/fixtures", default-features = false } snowbridge-pallet-inbound-queue = { path = "../../pallets/inbound-queue", default-features = false } snowbridge-pallet-outbound-queue = { path = "../../pallets/outbound-queue", default-features = false } snowbridge-outbound-queue-runtime-api = { path = "../../pallets/outbound-queue/runtime-api", default-features = false } @@ -140,6 +141,7 @@ std = [ "snowbridge-core/std", "snowbridge-outbound-queue-runtime-api/std", "snowbridge-pallet-ethereum-client/std", + "snowbridge-pallet-ethereum-client-fixtures/std", "snowbridge-pallet-inbound-queue/std", "snowbridge-pallet-outbound-queue/std", "snowbridge-pallet-system/std", @@ -190,6 +192,7 @@ runtime-benchmarks = [ "polkadot-runtime-common/runtime-benchmarks", "snowbridge-core/runtime-benchmarks", "snowbridge-pallet-ethereum-client/runtime-benchmarks", + "snowbridge-pallet-ethereum-client-fixtures/runtime-benchmarks", "snowbridge-pallet-inbound-queue/runtime-benchmarks", "snowbridge-pallet-outbound-queue/runtime-benchmarks", "snowbridge-pallet-system/runtime-benchmarks", diff --git a/parachain/runtime/test-common/src/lib.rs b/parachain/runtime/test-common/src/lib.rs index fa1d95437e..e13e33ff16 100644 --- a/parachain/runtime/test-common/src/lib.rs +++ b/parachain/runtime/test-common/src/lib.rs @@ -2,13 +2,11 @@ // SPDX-FileCopyrightText: 2023 Snowfork use codec::Encode; -use snowbridge_core::RingBufferMap; use frame_support::{assert_err, assert_ok, traits::fungible::Mutate}; pub use parachains_runtimes_test_utils::test_cases::change_storage_constant_by_governance_works; use parachains_runtimes_test_utils::{ AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, ValidatorIdOf, XcmReceivedFrom, }; -use snowbridge_pallet_ethereum_client::ExecutionHeaderBuffer; use sp_core::H160; use sp_runtime::SaturatedConversion; use xcm::{ @@ -18,6 +16,7 @@ use xcm::{ use xcm_executor::XcmExecutor; use sp_keyring::AccountKeyring::*; use sp_runtime::AccountId32; +use snowbridge_pallet_ethereum_client_fixtures::*; type RuntimeHelper = parachains_runtimes_test_utils::RuntimeHelper; @@ -325,10 +324,10 @@ where .with_tracing() .build() .execute_with(|| { - let initial_checkpoint = fixtures::make_checkpoint(); - let update = fixtures::make_finalized_header_update(); - let sync_committee_update = fixtures::make_sync_committee_update(); - let execution_header_update = fixtures::make_execution_header_update(); + let initial_checkpoint = make_checkpoint(); + let update = make_finalized_header_update(); + let sync_committee_update = make_sync_committee_update(); + let execution_header_update = make_execution_header_update(); let alice = Alice; let alice_account = alice.to_account_id(); @@ -400,10 +399,9 @@ pub fn ethereum_to_polkadot_message_extrinsics_work( .with_tracing() .build() .execute_with(|| { - let initial_checkpoint = fixtures::make_checkpoint_for_inbound(); - let sync_committee_update = fixtures::make_sync_committee_update_for_inbound(); - let sync_committee_update_for_next_period = fixtures::make_sync_committee_update_for_inbound_next_period(); - let execution_header_update = fixtures::make_execution_header_update_for_inbound(); + let initial_checkpoint = make_checkpoint(); + let sync_committee_update = make_sync_committee_update(); + let execution_header_update = make_execution_header_update(); let alice = Alice; let alice_account = alice.to_account_id(); @@ -424,10 +422,6 @@ pub fn ethereum_to_polkadot_message_extrinsics_work( update: Box::new(*sync_committee_update), }.into(); - let update_sync_committee_call_for_next_period: ::RuntimeCall = snowbridge_pallet_ethereum_client::Call::::submit { - update: Box::new(*sync_committee_update_for_next_period), - }.into(); - let execution_header_call: ::RuntimeCall = snowbridge_pallet_ethereum_client::Call::::submit_execution_header { update: Box::new(*execution_header_update), }.into(); @@ -435,9 +429,6 @@ pub fn ethereum_to_polkadot_message_extrinsics_work( let sync_committee_outcome = construct_and_apply_extrinsic(alice, update_sync_committee_call.into()); assert_ok!(sync_committee_outcome); - let sync_committee_outcome_next_period_outcome = construct_and_apply_extrinsic(alice, update_sync_committee_call_for_next_period.into()); - assert_ok!(sync_committee_outcome_next_period_outcome); - let execution_header_outcome = construct_and_apply_extrinsic(alice, execution_header_call.into()); assert_ok!(execution_header_outcome); });