mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-14 03:55:53 +00:00
5d9826c262
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>
130 lines
3.7 KiB
Rust
130 lines
3.7 KiB
Rust
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
|
|
use super::*;
|
|
mod util;
|
|
|
|
use crate::Pallet as EthereumBeaconClient;
|
|
use frame_benchmarking::v2::*;
|
|
use frame_system::RawOrigin;
|
|
|
|
use snowbridge_pallet_ethereum_client_fixtures::*;
|
|
|
|
use primitives::{
|
|
fast_aggregate_verify, prepare_aggregate_pubkey, prepare_aggregate_signature,
|
|
verify_merkle_branch,
|
|
};
|
|
use util::*;
|
|
|
|
#[benchmarks]
|
|
mod benchmarks {
|
|
use super::*;
|
|
|
|
#[benchmark]
|
|
fn force_checkpoint() -> Result<(), BenchmarkError> {
|
|
let checkpoint_update = make_checkpoint();
|
|
let block_root: H256 = checkpoint_update.header.hash_tree_root().unwrap();
|
|
|
|
#[extrinsic_call]
|
|
_(RawOrigin::Root, Box::new(*checkpoint_update));
|
|
|
|
assert!(<LatestFinalizedBlockRoot<T>>::get() == block_root);
|
|
assert!(<FinalizedBeaconState<T>>::get(block_root).is_some());
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[benchmark]
|
|
fn submit() -> Result<(), BenchmarkError> {
|
|
let caller: T::AccountId = whitelisted_caller();
|
|
let checkpoint_update = make_checkpoint();
|
|
let finalized_header_update = make_finalized_header_update();
|
|
let block_root: H256 = finalized_header_update.finalized_header.hash_tree_root().unwrap();
|
|
EthereumBeaconClient::<T>::process_checkpoint_update(&checkpoint_update)?;
|
|
|
|
#[extrinsic_call]
|
|
submit(RawOrigin::Signed(caller.clone()), Box::new(*finalized_header_update));
|
|
|
|
assert!(<LatestFinalizedBlockRoot<T>>::get() == block_root);
|
|
assert!(<FinalizedBeaconState<T>>::get(block_root).is_some());
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[benchmark]
|
|
fn submit_with_sync_committee() -> Result<(), BenchmarkError> {
|
|
let caller: T::AccountId = whitelisted_caller();
|
|
let checkpoint_update = make_checkpoint();
|
|
let sync_committee_update = make_sync_committee_update();
|
|
EthereumBeaconClient::<T>::process_checkpoint_update(&checkpoint_update)?;
|
|
|
|
#[extrinsic_call]
|
|
submit(RawOrigin::Signed(caller.clone()), Box::new(*sync_committee_update));
|
|
|
|
assert!(<NextSyncCommittee<T>>::exists());
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[benchmark(extra)]
|
|
fn bls_fast_aggregate_verify_pre_aggregated() -> Result<(), BenchmarkError> {
|
|
EthereumBeaconClient::<T>::process_checkpoint_update(&make_checkpoint())?;
|
|
let update = make_sync_committee_update();
|
|
let participant_pubkeys = participant_pubkeys::<T>(&update)?;
|
|
let signing_root = signing_root::<T>(&update)?;
|
|
let agg_sig =
|
|
prepare_aggregate_signature(&update.sync_aggregate.sync_committee_signature).unwrap();
|
|
let agg_pub_key = prepare_aggregate_pubkey(&participant_pubkeys).unwrap();
|
|
|
|
#[block]
|
|
{
|
|
agg_sig.fast_aggregate_verify_pre_aggregated(signing_root.as_bytes(), &agg_pub_key);
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[benchmark(extra)]
|
|
fn bls_fast_aggregate_verify() -> Result<(), BenchmarkError> {
|
|
EthereumBeaconClient::<T>::process_checkpoint_update(&make_checkpoint())?;
|
|
let update = make_sync_committee_update();
|
|
let current_sync_committee = <CurrentSyncCommittee<T>>::get();
|
|
let absent_pubkeys = absent_pubkeys::<T>(&update)?;
|
|
let signing_root = signing_root::<T>(&update)?;
|
|
|
|
#[block]
|
|
{
|
|
fast_aggregate_verify(
|
|
¤t_sync_committee.aggregate_pubkey,
|
|
&absent_pubkeys,
|
|
signing_root,
|
|
&update.sync_aggregate.sync_committee_signature,
|
|
)
|
|
.unwrap();
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[benchmark(extra)]
|
|
fn verify_merkle_proof() -> Result<(), BenchmarkError> {
|
|
EthereumBeaconClient::<T>::process_checkpoint_update(&make_checkpoint())?;
|
|
let update = make_sync_committee_update();
|
|
let block_root: H256 = update.finalized_header.hash_tree_root().unwrap();
|
|
|
|
#[block]
|
|
{
|
|
verify_merkle_branch(
|
|
block_root,
|
|
&update.finality_branch,
|
|
config::FINALIZED_ROOT_SUBTREE_INDEX,
|
|
config::FINALIZED_ROOT_DEPTH,
|
|
update.attested_header.state_root,
|
|
);
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
impl_benchmark_test_suite!(EthereumBeaconClient, crate::mock::new_tester(), crate::mock::Test);
|
|
}
|