Refactoring Checkpoint: (WIP)
This commit is contained in:
@@ -7,8 +7,8 @@ use pezframe_support::{
|
||||
traits::{fungible::Mutate, OnFinalize, OnInitialize},
|
||||
};
|
||||
use pezframe_system::pezpallet_prelude::BlockNumberFor;
|
||||
use snowbridge_core::{ChannelId, ParaId};
|
||||
use snowbridge_pallet_ethereum_client_fixtures::*;
|
||||
use pezsnowbridge_core::{ChannelId, ParaId};
|
||||
use snowbridge_pezpallet_ethereum_client_fixtures::*;
|
||||
use pezsp_core::{Get, H160, U256};
|
||||
use pezsp_keyring::Sr25519Keyring::*;
|
||||
use pezsp_runtime::{traits::Header, AccountId32, DigestItem, SaturatedConversion, Saturating};
|
||||
@@ -27,7 +27,7 @@ where
|
||||
{
|
||||
// fund asset hub sovereign account enough so it can pay fees
|
||||
let asset_hub_sovereign_account =
|
||||
snowbridge_core::sibling_sovereign_account::<Runtime>(assethub_teyrchain_id.into());
|
||||
pezsnowbridge_core::sibling_sovereign_account::<Runtime>(assethub_teyrchain_id.into());
|
||||
<pezpallet_balances::Pallet<Runtime>>::mint_into(
|
||||
&asset_hub_sovereign_account,
|
||||
initial_amount.saturated_into::<BalanceOf<Runtime>>(),
|
||||
@@ -49,8 +49,8 @@ where
|
||||
+ pezpallet_xcm::Config
|
||||
+ teyrchain_info::Config
|
||||
+ pezpallet_collator_selection::Config
|
||||
+ pezcumulus_pallet_teyrchain_system::Config
|
||||
+ snowbridge_pallet_outbound_queue::Config
|
||||
+ pezcumulus_pezpallet_teyrchain_system::Config
|
||||
+ snowbridge_pezpallet_outbound_queue::Config
|
||||
+ pezpallet_timestamp::Config,
|
||||
XcmConfig: xcm_executor::Config,
|
||||
{
|
||||
@@ -111,8 +111,8 @@ pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
|
||||
weth_contract_address: H160,
|
||||
destination_address: H160,
|
||||
fee_amount: u128,
|
||||
snowbridge_pallet_outbound_queue: Box<
|
||||
dyn Fn(Vec<u8>) -> Option<snowbridge_pallet_outbound_queue::Event<Runtime>>,
|
||||
snowbridge_pezpallet_outbound_queue: Box<
|
||||
dyn Fn(Vec<u8>) -> Option<snowbridge_pezpallet_outbound_queue::Event<Runtime>>,
|
||||
>,
|
||||
) where
|
||||
Runtime: pezframe_system::Config
|
||||
@@ -122,9 +122,9 @@ pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
|
||||
+ teyrchain_info::Config
|
||||
+ pezpallet_collator_selection::Config
|
||||
+ pezpallet_message_queue::Config
|
||||
+ pezcumulus_pallet_teyrchain_system::Config
|
||||
+ snowbridge_pallet_outbound_queue::Config
|
||||
+ snowbridge_pallet_system::Config
|
||||
+ pezcumulus_pezpallet_teyrchain_system::Config
|
||||
+ snowbridge_pezpallet_outbound_queue::Config
|
||||
+ snowbridge_pezpallet_system::Config
|
||||
+ pezpallet_timestamp::Config,
|
||||
XcmConfig: xcm_executor::Config,
|
||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
||||
@@ -137,7 +137,7 @@ pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
|
||||
.with_tracing()
|
||||
.build()
|
||||
.execute_with(|| {
|
||||
<snowbridge_pallet_system::Pallet<Runtime>>::initialize(
|
||||
<snowbridge_pezpallet_system::Pallet<Runtime>>::initialize(
|
||||
runtime_para_id.into(),
|
||||
assethub_teyrchain_id.into(),
|
||||
)
|
||||
@@ -159,10 +159,10 @@ pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
|
||||
// check events
|
||||
let mut events = <pezframe_system::Pallet<Runtime>>::events()
|
||||
.into_iter()
|
||||
.filter_map(|e| snowbridge_pallet_outbound_queue(e.event.encode()));
|
||||
.filter_map(|e| snowbridge_pezpallet_outbound_queue(e.event.encode()));
|
||||
assert!(events.any(|e| matches!(
|
||||
e,
|
||||
snowbridge_pallet_outbound_queue::Event::MessageQueued { .. }
|
||||
snowbridge_pezpallet_outbound_queue::Event::MessageQueued { .. }
|
||||
)));
|
||||
|
||||
let block_number = <pezframe_system::Pallet<Runtime>>::block_number();
|
||||
@@ -171,24 +171,24 @@ pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
|
||||
|
||||
// finish current block
|
||||
<pezpallet_message_queue::Pallet<Runtime>>::on_finalize(block_number);
|
||||
<snowbridge_pallet_outbound_queue::Pallet<Runtime>>::on_finalize(block_number);
|
||||
<snowbridge_pezpallet_outbound_queue::Pallet<Runtime>>::on_finalize(block_number);
|
||||
<pezframe_system::Pallet<Runtime>>::on_finalize(block_number);
|
||||
|
||||
// start next block
|
||||
<pezframe_system::Pallet<Runtime>>::set_block_number(next_block_number);
|
||||
<pezframe_system::Pallet<Runtime>>::on_initialize(next_block_number);
|
||||
<snowbridge_pallet_outbound_queue::Pallet<Runtime>>::on_initialize(next_block_number);
|
||||
<snowbridge_pezpallet_outbound_queue::Pallet<Runtime>>::on_initialize(next_block_number);
|
||||
<pezpallet_message_queue::Pallet<Runtime>>::on_initialize(next_block_number);
|
||||
|
||||
// finish next block
|
||||
<pezpallet_message_queue::Pallet<Runtime>>::on_finalize(next_block_number);
|
||||
<snowbridge_pallet_outbound_queue::Pallet<Runtime>>::on_finalize(next_block_number);
|
||||
<snowbridge_pezpallet_outbound_queue::Pallet<Runtime>>::on_finalize(next_block_number);
|
||||
let included_head = <pezframe_system::Pallet<Runtime>>::finalize();
|
||||
|
||||
let origin: ParaId = assethub_teyrchain_id.into();
|
||||
let channel_id: ChannelId = origin.into();
|
||||
|
||||
let nonce = snowbridge_pallet_outbound_queue::Nonce::<Runtime>::try_get(channel_id);
|
||||
let nonce = snowbridge_pezpallet_outbound_queue::Nonce::<Runtime>::try_get(channel_id);
|
||||
assert_ok!(nonce);
|
||||
assert_eq!(nonce.unwrap(), 1);
|
||||
|
||||
@@ -211,8 +211,8 @@ pub fn ethereum_outbound_queue_processes_messages_before_message_queue_works<
|
||||
weth_contract_address: H160,
|
||||
destination_address: H160,
|
||||
fee_amount: u128,
|
||||
snowbridge_pallet_outbound_queue: Box<
|
||||
dyn Fn(Vec<u8>) -> Option<snowbridge_pallet_outbound_queue::Event<Runtime>>,
|
||||
snowbridge_pezpallet_outbound_queue: Box<
|
||||
dyn Fn(Vec<u8>) -> Option<snowbridge_pezpallet_outbound_queue::Event<Runtime>>,
|
||||
>,
|
||||
) where
|
||||
Runtime: pezframe_system::Config
|
||||
@@ -222,9 +222,9 @@ pub fn ethereum_outbound_queue_processes_messages_before_message_queue_works<
|
||||
+ teyrchain_info::Config
|
||||
+ pezpallet_collator_selection::Config
|
||||
+ pezpallet_message_queue::Config
|
||||
+ pezcumulus_pallet_teyrchain_system::Config
|
||||
+ snowbridge_pallet_outbound_queue::Config
|
||||
+ snowbridge_pallet_system::Config
|
||||
+ pezcumulus_pezpallet_teyrchain_system::Config
|
||||
+ snowbridge_pezpallet_outbound_queue::Config
|
||||
+ snowbridge_pezpallet_system::Config
|
||||
+ pezpallet_timestamp::Config,
|
||||
XcmConfig: xcm_executor::Config,
|
||||
AllPalletsWithoutSystem:
|
||||
@@ -239,7 +239,7 @@ pub fn ethereum_outbound_queue_processes_messages_before_message_queue_works<
|
||||
.with_tracing()
|
||||
.build()
|
||||
.execute_with(|| {
|
||||
<snowbridge_pallet_system::Pallet<Runtime>>::initialize(
|
||||
<snowbridge_pezpallet_system::Pallet<Runtime>>::initialize(
|
||||
runtime_para_id.into(),
|
||||
assethub_teyrchain_id.into(),
|
||||
)
|
||||
@@ -261,10 +261,10 @@ pub fn ethereum_outbound_queue_processes_messages_before_message_queue_works<
|
||||
// check events
|
||||
let mut events = <pezframe_system::Pallet<Runtime>>::events()
|
||||
.into_iter()
|
||||
.filter_map(|e| snowbridge_pallet_outbound_queue(e.event.encode()));
|
||||
.filter_map(|e| snowbridge_pezpallet_outbound_queue(e.event.encode()));
|
||||
assert!(events.any(|e| matches!(
|
||||
e,
|
||||
snowbridge_pallet_outbound_queue::Event::MessageQueued { .. }
|
||||
snowbridge_pezpallet_outbound_queue::Event::MessageQueued { .. }
|
||||
)));
|
||||
|
||||
let next_block_number: U256 = <pezframe_system::Pallet<Runtime>>::block_number()
|
||||
@@ -304,9 +304,9 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
|
||||
+ pezpallet_xcm::Config
|
||||
+ teyrchain_info::Config
|
||||
+ pezpallet_collator_selection::Config
|
||||
+ pezcumulus_pallet_teyrchain_system::Config
|
||||
+ snowbridge_pallet_outbound_queue::Config
|
||||
+ snowbridge_pallet_system::Config
|
||||
+ pezcumulus_pezpallet_teyrchain_system::Config
|
||||
+ snowbridge_pezpallet_outbound_queue::Config
|
||||
+ snowbridge_pezpallet_system::Config
|
||||
+ pezpallet_timestamp::Config,
|
||||
XcmConfig: xcm_executor::Config,
|
||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
||||
@@ -320,7 +320,7 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
|
||||
.with_tracing()
|
||||
.build()
|
||||
.execute_with(|| {
|
||||
<snowbridge_pallet_system::Pallet<Runtime>>::initialize(
|
||||
<snowbridge_pezpallet_system::Pallet<Runtime>>::initialize(
|
||||
runtime_para_id.into(),
|
||||
assethub_teyrchain_id.into(),
|
||||
)
|
||||
@@ -390,9 +390,9 @@ pub fn send_transfer_token_message_failure<Runtime, XcmConfig>(
|
||||
+ pezpallet_xcm::Config
|
||||
+ teyrchain_info::Config
|
||||
+ pezpallet_collator_selection::Config
|
||||
+ pezcumulus_pallet_teyrchain_system::Config
|
||||
+ snowbridge_pallet_outbound_queue::Config
|
||||
+ snowbridge_pallet_system::Config
|
||||
+ pezcumulus_pezpallet_teyrchain_system::Config
|
||||
+ snowbridge_pezpallet_outbound_queue::Config
|
||||
+ snowbridge_pezpallet_system::Config
|
||||
+ pezpallet_timestamp::Config,
|
||||
XcmConfig: xcm_executor::Config,
|
||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
||||
@@ -404,7 +404,7 @@ pub fn send_transfer_token_message_failure<Runtime, XcmConfig>(
|
||||
.with_tracing()
|
||||
.build()
|
||||
.execute_with(|| {
|
||||
<snowbridge_pallet_system::Pallet<Runtime>>::initialize(
|
||||
<snowbridge_pezpallet_system::Pallet<Runtime>>::initialize(
|
||||
runtime_para_id.into(),
|
||||
assethub_teyrchain_id.into(),
|
||||
)
|
||||
@@ -442,14 +442,14 @@ pub fn ethereum_extrinsic<Runtime>(
|
||||
+ pezpallet_utility::Config
|
||||
+ teyrchain_info::Config
|
||||
+ pezpallet_collator_selection::Config
|
||||
+ pezcumulus_pallet_teyrchain_system::Config
|
||||
+ snowbridge_pallet_outbound_queue::Config
|
||||
+ snowbridge_pallet_system::Config
|
||||
+ snowbridge_pallet_ethereum_client::Config
|
||||
+ pezcumulus_pezpallet_teyrchain_system::Config
|
||||
+ snowbridge_pezpallet_outbound_queue::Config
|
||||
+ snowbridge_pezpallet_system::Config
|
||||
+ snowbridge_pezpallet_ethereum_client::Config
|
||||
+ pezpallet_timestamp::Config,
|
||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
||||
<Runtime as pezpallet_utility::Config>::RuntimeCall:
|
||||
From<snowbridge_pallet_ethereum_client::Call<Runtime>>,
|
||||
From<snowbridge_pezpallet_ethereum_client::Call<Runtime>>,
|
||||
<Runtime as pezframe_system::Config>::RuntimeCall: From<pezpallet_utility::Call<Runtime>>,
|
||||
AccountIdOf<Runtime>: From<AccountId32>,
|
||||
{
|
||||
@@ -478,7 +478,7 @@ pub fn ethereum_extrinsic<Runtime>(
|
||||
let balance_before =
|
||||
<pezpallet_balances::Pallet<Runtime>>::free_balance(&alice_account.clone().into());
|
||||
|
||||
assert_ok!(<snowbridge_pallet_ethereum_client::Pallet<Runtime>>::force_checkpoint(
|
||||
assert_ok!(<snowbridge_pezpallet_ethereum_client::Pallet<Runtime>>::force_checkpoint(
|
||||
RuntimeHelper::<Runtime>::root_origin(),
|
||||
initial_checkpoint.clone(),
|
||||
));
|
||||
@@ -486,25 +486,25 @@ pub fn ethereum_extrinsic<Runtime>(
|
||||
<pezpallet_balances::Pallet<Runtime>>::free_balance(&alice_account.clone().into());
|
||||
|
||||
let update_call: <Runtime as pezpallet_utility::Config>::RuntimeCall =
|
||||
snowbridge_pallet_ethereum_client::Call::<Runtime>::submit {
|
||||
snowbridge_pezpallet_ethereum_client::Call::<Runtime>::submit {
|
||||
update: Box::new(*update.clone()),
|
||||
}
|
||||
.into();
|
||||
|
||||
let invalid_update_call: <Runtime as pezpallet_utility::Config>::RuntimeCall =
|
||||
snowbridge_pallet_ethereum_client::Call::<Runtime>::submit {
|
||||
snowbridge_pezpallet_ethereum_client::Call::<Runtime>::submit {
|
||||
update: Box::new(*invalid_update),
|
||||
}
|
||||
.into();
|
||||
|
||||
let update_sync_committee_call: <Runtime as pezpallet_utility::Config>::RuntimeCall =
|
||||
snowbridge_pallet_ethereum_client::Call::<Runtime>::submit {
|
||||
snowbridge_pezpallet_ethereum_client::Call::<Runtime>::submit {
|
||||
update: Box::new(*sync_committee_update),
|
||||
}
|
||||
.into();
|
||||
|
||||
let invalid_update_sync_committee_call: <Runtime as pezpallet_utility::Config>::RuntimeCall =
|
||||
snowbridge_pallet_ethereum_client::Call::<Runtime>::submit {
|
||||
snowbridge_pezpallet_ethereum_client::Call::<Runtime>::submit {
|
||||
update: Box::new(*invalid_sync_committee_update),
|
||||
}
|
||||
.into();
|
||||
@@ -523,7 +523,7 @@ pub fn ethereum_extrinsic<Runtime>(
|
||||
construct_and_apply_extrinsic(alice, invalid_update_call.into());
|
||||
assert_err!(
|
||||
invalid_update_outcome,
|
||||
snowbridge_pallet_ethereum_client::Error::<Runtime>::InvalidUpdateSlot
|
||||
snowbridge_pezpallet_ethereum_client::Error::<Runtime>::InvalidUpdateSlot
|
||||
);
|
||||
let balance_after_invalid_update =
|
||||
<pezpallet_balances::Pallet<Runtime>>::free_balance(&alice_account.clone().into());
|
||||
@@ -540,7 +540,7 @@ pub fn ethereum_extrinsic<Runtime>(
|
||||
construct_and_apply_extrinsic(alice, invalid_update_sync_committee_call.into());
|
||||
assert_err!(
|
||||
invalid_sync_committee_outcome,
|
||||
snowbridge_pallet_ethereum_client::Error::<Runtime>::InvalidUpdateSlot
|
||||
snowbridge_pezpallet_ethereum_client::Error::<Runtime>::InvalidUpdateSlot
|
||||
);
|
||||
let balance_after_invalid_sync_com_update =
|
||||
<pezpallet_balances::Pallet<Runtime>>::free_balance(&alice_account.clone().into());
|
||||
@@ -549,7 +549,7 @@ pub fn ethereum_extrinsic<Runtime>(
|
||||
// Checkpoint is a free operation
|
||||
assert!(balance_before == balance_after_checkpoint);
|
||||
let gap =
|
||||
<Runtime as snowbridge_pallet_ethereum_client::Config>::FreeHeadersInterval::get();
|
||||
<Runtime as snowbridge_pezpallet_ethereum_client::Config>::FreeHeadersInterval::get();
|
||||
// Large enough header gap is free
|
||||
if update.finalized_header.slot >= initial_checkpoint.header.slot + gap as u64 {
|
||||
assert!(balance_after_checkpoint == balance_after_update);
|
||||
@@ -581,14 +581,14 @@ pub fn ethereum_to_pezkuwi_message_extrinsics_work<Runtime>(
|
||||
+ pezpallet_utility::Config
|
||||
+ teyrchain_info::Config
|
||||
+ pezpallet_collator_selection::Config
|
||||
+ pezcumulus_pallet_teyrchain_system::Config
|
||||
+ snowbridge_pallet_outbound_queue::Config
|
||||
+ snowbridge_pallet_system::Config
|
||||
+ snowbridge_pallet_ethereum_client::Config
|
||||
+ pezcumulus_pezpallet_teyrchain_system::Config
|
||||
+ snowbridge_pezpallet_outbound_queue::Config
|
||||
+ snowbridge_pezpallet_system::Config
|
||||
+ snowbridge_pezpallet_ethereum_client::Config
|
||||
+ pezpallet_timestamp::Config,
|
||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
||||
<Runtime as pezpallet_utility::Config>::RuntimeCall:
|
||||
From<snowbridge_pallet_ethereum_client::Call<Runtime>>,
|
||||
From<snowbridge_pezpallet_ethereum_client::Call<Runtime>>,
|
||||
<Runtime as pezframe_system::Config>::RuntimeCall: From<pezpallet_utility::Call<Runtime>>,
|
||||
AccountIdOf<Runtime>: From<AccountId32>,
|
||||
{
|
||||
@@ -610,13 +610,13 @@ pub fn ethereum_to_pezkuwi_message_extrinsics_work<Runtime>(
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_ok!(<snowbridge_pallet_ethereum_client::Pallet<Runtime>>::force_checkpoint(
|
||||
assert_ok!(<snowbridge_pezpallet_ethereum_client::Pallet<Runtime>>::force_checkpoint(
|
||||
RuntimeHelper::<Runtime>::root_origin(),
|
||||
initial_checkpoint,
|
||||
));
|
||||
|
||||
let update_sync_committee_call: <Runtime as pezpallet_utility::Config>::RuntimeCall =
|
||||
snowbridge_pallet_ethereum_client::Call::<Runtime>::submit {
|
||||
snowbridge_pezpallet_ethereum_client::Call::<Runtime>::submit {
|
||||
update: Box::new(*sync_committee_update),
|
||||
}
|
||||
.into();
|
||||
|
||||
Reference in New Issue
Block a user