mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 19:35:43 +00:00
Snowbridge: Synchronize from Snowfork repository (#3761)
This PR includes the following 2 improvements: ## Ethereum Client Author: @yrong ### Original Upstream PRs - https://github.com/Snowfork/polkadot-sdk/pull/123 - https://github.com/Snowfork/polkadot-sdk/pull/125 ### Description The Ethereum client syncs beacon headers as they are finalized, and imports every execution header. When a message is received, it is verified against the import execution header. This is unnecessary, since the execution header can be sent with the message as proof. The recent Deneb Ethereum upgrade made it easier to locate the relevant beacon header from an execution header, and so this improvement was made possible. This resolves a concern @svyatonik had in our initial Rococo PR: https://github.com/paritytech/polkadot-sdk/pull/2522#discussion_r1431270691 ## Inbound Queue Author: @yrong ### Original Upstream PR - https://github.com/Snowfork/polkadot-sdk/pull/118 ### Description When the AH sovereign account (who pays relayer rewards) is depleted, the inbound message will not fail. The relayer just will not receive rewards. Both these changes were done by @yrong, many thanks. ❤️ --------- Co-authored-by: claravanstaden <Cats 4 life!> Co-authored-by: Ron <yrong1997@gmail.com> Co-authored-by: Vincent Geddes <vincent@snowfork.com> Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
This commit is contained in:
@@ -6,7 +6,7 @@ use frame_support::{assert_noop, assert_ok};
|
||||
use hex_literal::hex;
|
||||
use snowbridge_core::{inbound::Proof, ChannelId};
|
||||
use sp_keyring::AccountKeyring as Keyring;
|
||||
use sp_runtime::{DispatchError, TokenError};
|
||||
use sp_runtime::DispatchError;
|
||||
use sp_std::convert::From;
|
||||
|
||||
use crate::{Error, Event as InboundQueueEvent};
|
||||
@@ -25,9 +25,8 @@ fn test_submit_happy_path() {
|
||||
let message = Message {
|
||||
event_log: mock_event_log(),
|
||||
proof: Proof {
|
||||
block_hash: Default::default(),
|
||||
tx_index: Default::default(),
|
||||
data: Default::default(),
|
||||
receipt_proof: Default::default(),
|
||||
execution_proof: mock_execution_proof(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -77,9 +76,8 @@ fn test_submit_xcm_invalid_channel() {
|
||||
let message = Message {
|
||||
event_log: mock_event_log_invalid_channel(),
|
||||
proof: Proof {
|
||||
block_hash: Default::default(),
|
||||
tx_index: Default::default(),
|
||||
data: Default::default(),
|
||||
receipt_proof: Default::default(),
|
||||
execution_proof: mock_execution_proof(),
|
||||
},
|
||||
};
|
||||
assert_noop!(
|
||||
@@ -103,9 +101,8 @@ fn test_submit_with_invalid_gateway() {
|
||||
let message = Message {
|
||||
event_log: mock_event_log_invalid_gateway(),
|
||||
proof: Proof {
|
||||
block_hash: Default::default(),
|
||||
tx_index: Default::default(),
|
||||
data: Default::default(),
|
||||
receipt_proof: Default::default(),
|
||||
execution_proof: mock_execution_proof(),
|
||||
},
|
||||
};
|
||||
assert_noop!(
|
||||
@@ -129,9 +126,8 @@ fn test_submit_with_invalid_nonce() {
|
||||
let message = Message {
|
||||
event_log: mock_event_log(),
|
||||
proof: Proof {
|
||||
block_hash: Default::default(),
|
||||
tx_index: Default::default(),
|
||||
data: Default::default(),
|
||||
receipt_proof: Default::default(),
|
||||
execution_proof: mock_execution_proof(),
|
||||
},
|
||||
};
|
||||
assert_ok!(InboundQueue::submit(origin.clone(), message.clone()));
|
||||
@@ -150,12 +146,12 @@ fn test_submit_with_invalid_nonce() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_submit_no_funds_to_reward_relayers() {
|
||||
fn test_submit_no_funds_to_reward_relayers_just_ignore() {
|
||||
new_tester().execute_with(|| {
|
||||
let relayer: AccountId = Keyring::Bob.into();
|
||||
let origin = RuntimeOrigin::signed(relayer);
|
||||
|
||||
// Reset balance of sovereign_account to zero so to trigger the FundsUnavailable error
|
||||
// Reset balance of sovereign_account to zero first
|
||||
let sovereign_account = sibling_sovereign_account::<Test>(ASSET_HUB_PARAID.into());
|
||||
Balances::set_balance(&sovereign_account, 0);
|
||||
|
||||
@@ -163,15 +159,12 @@ fn test_submit_no_funds_to_reward_relayers() {
|
||||
let message = Message {
|
||||
event_log: mock_event_log(),
|
||||
proof: Proof {
|
||||
block_hash: Default::default(),
|
||||
tx_index: Default::default(),
|
||||
data: Default::default(),
|
||||
receipt_proof: Default::default(),
|
||||
execution_proof: mock_execution_proof(),
|
||||
},
|
||||
};
|
||||
assert_noop!(
|
||||
InboundQueue::submit(origin.clone(), message.clone()),
|
||||
TokenError::FundsUnavailable
|
||||
);
|
||||
// Check submit successfully in case no funds available
|
||||
assert_ok!(InboundQueue::submit(origin.clone(), message.clone()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -183,9 +176,8 @@ fn test_set_operating_mode() {
|
||||
let message = Message {
|
||||
event_log: mock_event_log(),
|
||||
proof: Proof {
|
||||
block_hash: Default::default(),
|
||||
tx_index: Default::default(),
|
||||
data: Default::default(),
|
||||
receipt_proof: Default::default(),
|
||||
execution_proof: mock_execution_proof(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -210,3 +202,44 @@ fn test_set_operating_mode_root_only() {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_submit_no_funds_to_reward_relayers_and_ed_preserved() {
|
||||
new_tester().execute_with(|| {
|
||||
let relayer: AccountId = Keyring::Bob.into();
|
||||
let origin = RuntimeOrigin::signed(relayer);
|
||||
|
||||
// Reset balance of sovereign account to (ED+1) first
|
||||
let sovereign_account = sibling_sovereign_account::<Test>(ASSET_HUB_PARAID.into());
|
||||
Balances::set_balance(&sovereign_account, ExistentialDeposit::get() + 1);
|
||||
|
||||
// Submit message successfully
|
||||
let message = Message {
|
||||
event_log: mock_event_log(),
|
||||
proof: Proof {
|
||||
receipt_proof: Default::default(),
|
||||
execution_proof: mock_execution_proof(),
|
||||
},
|
||||
};
|
||||
assert_ok!(InboundQueue::submit(origin.clone(), message.clone()));
|
||||
|
||||
// Check balance of sovereign account to ED
|
||||
let amount = Balances::balance(&sovereign_account);
|
||||
assert_eq!(amount, ExistentialDeposit::get());
|
||||
|
||||
// Submit another message with nonce set as 2
|
||||
let mut event_log = mock_event_log();
|
||||
event_log.data[31] = 2;
|
||||
let message = Message {
|
||||
event_log,
|
||||
proof: Proof {
|
||||
receipt_proof: Default::default(),
|
||||
execution_proof: mock_execution_proof(),
|
||||
},
|
||||
};
|
||||
assert_ok!(InboundQueue::submit(origin.clone(), message.clone()));
|
||||
// Check balance of sovereign account as ED does not change
|
||||
let amount = Balances::balance(&sovereign_account);
|
||||
assert_eq!(amount, ExistentialDeposit::get());
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user