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:
Clara van Staden
2024-04-02 15:53:05 +02:00
committed by GitHub
parent e54279699b
commit 5d9826c262
35 changed files with 1123 additions and 1307 deletions
@@ -286,8 +286,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
match call {
RuntimeCall::System(frame_system::Call::set_storage { items })
if items.iter().all(|(k, _)| {
k.eq(&bridging::XcmBridgeHubRouterByteFee::key()) |
k.eq(&bridging::XcmBridgeHubRouterBaseFee::key()) |
k.eq(&bridging::XcmBridgeHubRouterByteFee::key()) ||
k.eq(&bridging::XcmBridgeHubRouterBaseFee::key()) ||
k.eq(&bridging::to_ethereum::BridgeHubEthereumBaseFee::key())
}) =>
return true,
@@ -100,8 +100,6 @@ use parachains_common::{
AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO,
};
use polkadot_runtime_common::prod_or_fast;
#[cfg(feature = "runtime-benchmarks")]
use benchmark_helpers::DoNothingRouter;
@@ -515,14 +513,14 @@ parameter_types! {
pub mod benchmark_helpers {
use crate::{EthereumBeaconClient, Runtime, RuntimeOrigin};
use codec::Encode;
use snowbridge_beacon_primitives::CompactExecutionHeader;
use snowbridge_beacon_primitives::BeaconHeader;
use snowbridge_pallet_inbound_queue::BenchmarkHelper;
use sp_core::H256;
use xcm::latest::{Assets, Location, SendError, SendResult, SendXcm, Xcm, XcmHash};
impl<T: snowbridge_pallet_ethereum_client::Config> BenchmarkHelper<T> for Runtime {
fn initialize_storage(block_hash: H256, header: CompactExecutionHeader) {
EthereumBeaconClient::store_execution_header(block_hash, header, 0, H256::default())
fn initialize_storage(beacon_header: BeaconHeader, block_roots_root: H256) {
EthereumBeaconClient::store_finalized_header(beacon_header, block_roots_root).unwrap();
}
}
@@ -643,14 +641,9 @@ parameter_types! {
};
}
parameter_types! {
pub const MaxExecutionHeadersToKeep: u32 = prod_or_fast!(8192 * 2, 1000);
}
impl snowbridge_pallet_ethereum_client::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ForkVersions = ChainForkVersions;
type MaxExecutionHeadersToKeep = MaxExecutionHeadersToKeep;
type WeightInfo = weights::snowbridge_pallet_ethereum_client::WeightInfo<Runtime>;
}
@@ -126,26 +126,4 @@ impl<T: frame_system::Config> snowbridge_pallet_ethereum_client::WeightInfo for
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(1))
}
/// 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: EthereumBeaconClient LatestExecutionState (r:1 w:1)
/// Proof: EthereumBeaconClient LatestExecutionState (max_values: Some(1), max_size: Some(80), added: 575, mode: MaxEncodedLen)
/// Storage: EthereumBeaconClient ExecutionHeaderIndex (r:1 w:1)
/// Proof: EthereumBeaconClient ExecutionHeaderIndex (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: EthereumBeaconClient ExecutionHeaderMapping (r:1 w:1)
/// Proof: EthereumBeaconClient ExecutionHeaderMapping (max_values: None, max_size: Some(36), added: 2511, mode: MaxEncodedLen)
/// Storage: EthereumBeaconClient ExecutionHeaders (r:0 w:1)
/// Proof: EthereumBeaconClient ExecutionHeaders (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen)
fn submit_execution_header() -> Weight {
// Proof Size summary in bytes:
// Measured: `386`
// Estimated: `3537`
// Minimum execution time: 108_761_000 picoseconds.
Weight::from_parts(113_158_000, 0)
.saturating_add(Weight::from_parts(0, 3537))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(4))
}
}
@@ -58,12 +58,12 @@ impl<T: frame_system::Config> snowbridge_pallet_inbound_queue::WeightInfo for We
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn submit() -> Weight {
// Proof Size summary in bytes:
// Measured: `457`
// Estimated: `3601`
// Minimum execution time: 69_000_000 picoseconds.
Weight::from_parts(70_000_000, 0)
.saturating_add(Weight::from_parts(0, 3601))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
// Measured: `800`
// Estimated: `7200`
// Minimum execution time: 200_000_000 picoseconds.
Weight::from_parts(200_000_000, 0)
.saturating_add(Weight::from_parts(0, 7200))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(6))
}
}