diff --git a/crates/btc-relay/src/benchmarking.rs b/crates/btc-relay/src/benchmarking.rs index e22b02865d..88a00449f9 100644 --- a/crates/btc-relay/src/benchmarking.rs +++ b/crates/btc-relay/src/benchmarking.rs @@ -81,7 +81,7 @@ pub mod benchmarks { } #[benchmark] - pub fn store_block_header_when_updating_chainwork_mandatory() { + pub fn store_block_header_when_adding_chainwork() { let caller: T::AccountId = whitelisted_caller(); let init_block = initialize_relay::(caller.clone()); @@ -206,5 +206,55 @@ pub mod benchmarks { assert_eq!(rich_header.chain_id, MAIN_CHAIN_ID); } + #[benchmark] + pub fn store_block_header_reorganize_chains_based_on_chainwork(f: Linear<3, 6>) { + let caller: T::AccountId = whitelisted_caller(); + StableBitcoinConfirmations::::put(SECURE_BITCOIN_CONFIRMATIONS); + + let init_block = initialize_relay::(caller.clone()); + let mut init_block_hash = init_block.header.hash; + + migration::v1::migrate_from_v0_to_v1::(); + + for i in 1..f { + let mut block_hash = init_block_hash; + for _ in 0..SECURE_BITCOIN_CONFIRMATIONS { + let block = add_new_block_to_relay::(caller.clone(), block_hash, i as usize); + block_hash = block.header.hash; + } + } + + // new fork up to block before swapping the main chain + for _ in 1..(BestBlockHeight::::get() + SECURE_BITCOIN_CONFIRMATIONS) { + let block = add_new_block_to_relay::(caller.clone(), init_block_hash, f as usize); + init_block_hash = block.header.hash; + } + + let prev_best_block_height = BestBlockHeight::::get(); + assert_eq!(prev_best_block_height, SECURE_BITCOIN_CONFIRMATIONS); + assert_eq!(ChainsIndex::::iter().collect::>().len(), f as usize); + + let mut last_entered_block = BtcRelay::::get_block_header_from_hash(init_block_hash).unwrap(); + last_entered_block.block_header.target = U256::max_value(); + BlockHeaders::::insert(last_entered_block.block_header.hash, last_entered_block); + + // we can benchmark the worst-case complexity for swapping + // since we know how many blocks are required + let mut block = new_block::(init_block_hash, f as usize); + block.header.target = U256::max_value(); + block.header.update_hash().unwrap(); + + #[extrinsic_call] + store_block_header(RawOrigin::Signed(caller), block.header, u32::MAX); + + // make sure reorg occurred + assert_eq!( + BestBlockHeight::::get(), + prev_best_block_height + SECURE_BITCOIN_CONFIRMATIONS + ); + let rich_header = BtcRelay::::get_block_header_from_hash(block.header.hash).unwrap(); + assert_eq!(rich_header.chain_id, MAIN_CHAIN_ID); + } + impl_benchmark_test_suite!(BtcRelay, crate::mock::ExtBuilder::build(), crate::mock::Test); } diff --git a/crates/btc-relay/src/default_weights.rs b/crates/btc-relay/src/default_weights.rs index d325c64756..97d5b3b167 100644 --- a/crates/btc-relay/src/default_weights.rs +++ b/crates/btc-relay/src/default_weights.rs @@ -43,13 +43,15 @@ pub trait WeightInfo { fn store_block_header_new_fork_unsorted(f: u32, ) -> Weight; fn store_block_header_reorganize_chains(f: u32, ) -> Weight; fn set_chainwork_for_block() -> Weight; - fn store_block_header_when_updating_chainwork_mandatory () -> Weight; + fn store_block_header_when_adding_chainwork () -> Weight; + fn store_block_header_reorganize_chains_based_on_chainwork(f: u32, ) -> Weight; } /// Weights for btc_relay using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + /// Storage: `BTCRelay::BestBlock` (r:1 w:1) /// Proof: `BTCRelay::BestBlock` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Storage: `BTCRelay::DisableDifficultyCheck` (r:1 w:0) @@ -76,8 +78,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `403` // Estimated: `3545` - // Minimum execution time: 80_000_000 picoseconds. - Weight::from_parts(80_000_000, 3545) + // Minimum execution time: 44_000_000 picoseconds. + Weight::from_parts(44_000_000, 3545) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -89,8 +91,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1049` // Estimated: `6340` - // Minimum execution time: 39_000_000 picoseconds. - Weight::from_parts(39_000_000, 6340) + // Minimum execution time: 27_000_000 picoseconds. + Weight::from_parts(27_000_000, 6340) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -112,12 +114,12 @@ impl WeightInfo for SubstrateWeight { /// Proof: `BTCRelay::BestBlock` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Storage: `BTCRelay::BestBlockHeight` (r:0 w:1) /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - fn store_block_header_when_updating_chainwork_mandatory () -> Weight { + fn store_block_header_when_adding_chainwork () -> Weight { // Proof Size summary in bytes: // Measured: `979` // Estimated: `6340` - // Minimum execution time: 83_000_000 picoseconds. - Weight::from_parts(83_000_000, 6340) + // Minimum execution time: 52_000_000 picoseconds. + Weight::from_parts(52_000_000, 6340) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -143,8 +145,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `874` // Estimated: `6340` - // Minimum execution time: 73_000_000 picoseconds. - Weight::from_parts(73_000_000, 6340) + // Minimum execution time: 47_000_000 picoseconds. + Weight::from_parts(47_000_000, 6340) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -171,8 +173,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `796 + f * (110 ±0)` // Estimated: `18483` - // Minimum execution time: 85_000_000 picoseconds. - Weight::from_parts(140_000_000, 18483) + // Minimum execution time: 71_000_000 picoseconds. + Weight::from_parts(93_000_000, 18483) .saturating_add(T::DbWeight::get().reads(20_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -199,8 +201,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `832 + f * (108 ±0)` // Estimated: `18483` - // Minimum execution time: 85_000_000 picoseconds. - Weight::from_parts(149_000_000, 18483) + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(94_000_000, 18483) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -231,16 +233,47 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4754 + f * (235 ±0)` // Estimated: `54490` - // Minimum execution time: 509_000_000 picoseconds. - Weight::from_parts(533_000_000, 54490) + // Minimum execution time: 322_000_000 picoseconds. + Weight::from_parts(345_000_000, 54490) .saturating_add(T::DbWeight::get().reads(49_u64)) .saturating_add(T::DbWeight::get().writes(46_u64)) } + /// Storage: `BTCRelay::ChainCounter` (r:1 w:0) + /// Proof: `BTCRelay::ChainCounter` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BlockHeaders` (r:20 w:18) + /// Proof: `BTCRelay::BlockHeaders` (`max_values`: None, `max_size`: Some(200), added: 2675, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainsIndex` (r:3 w:2) + /// Proof: `BTCRelay::ChainsIndex` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::DisableDifficultyCheck` (r:1 w:0) + /// Proof: `BTCRelay::DisableDifficultyCheck` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainsHashes` (r:13 w:24) + /// Proof: `BTCRelay::ChainsHashes` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainWork` (r:2 w:1) + /// Proof: `BTCRelay::ChainWork` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::Chains` (r:6 w:0) + /// Proof: `BTCRelay::Chains` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlock` (r:0 w:1) + /// Proof: `BTCRelay::BestBlock` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:0 w:1) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// The range of component `f` is `[3, 6]`. + fn store_block_header_reorganize_chains_based_on_chainwork (_f: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `5196 + f * (298 ±0)` + // Estimated: `54490` + // Minimum execution time: 328_000_000 picoseconds. + Weight::from_parts(358_000_000, 54490) + .saturating_add(T::DbWeight::get().reads(47_u64)) + .saturating_add(T::DbWeight::get().writes(47_u64)) + } } // For backwards compatibility and tests impl WeightInfo for () { + /// Storage: `BTCRelay::BestBlock` (r:1 w:1) /// Proof: `BTCRelay::BestBlock` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Storage: `BTCRelay::DisableDifficultyCheck` (r:1 w:0) @@ -267,8 +300,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `403` // Estimated: `3545` - // Minimum execution time: 80_000_000 picoseconds. - Weight::from_parts(80_000_000, 3545) + // Minimum execution time: 44_000_000 picoseconds. + Weight::from_parts(44_000_000, 3545) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(8_u64)) } @@ -280,8 +313,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1049` // Estimated: `6340` - // Minimum execution time: 39_000_000 picoseconds. - Weight::from_parts(39_000_000, 6340) + // Minimum execution time: 27_000_000 picoseconds. + Weight::from_parts(27_000_000, 6340) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -303,12 +336,12 @@ impl WeightInfo for () { /// Proof: `BTCRelay::BestBlock` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Storage: `BTCRelay::BestBlockHeight` (r:0 w:1) /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - fn store_block_header_when_updating_chainwork_mandatory () -> Weight { + fn store_block_header_when_adding_chainwork () -> Weight { // Proof Size summary in bytes: // Measured: `979` // Estimated: `6340` - // Minimum execution time: 83_000_000 picoseconds. - Weight::from_parts(83_000_000, 6340) + // Minimum execution time: 52_000_000 picoseconds. + Weight::from_parts(52_000_000, 6340) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -334,8 +367,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `874` // Estimated: `6340` - // Minimum execution time: 73_000_000 picoseconds. - Weight::from_parts(73_000_000, 6340) + // Minimum execution time: 47_000_000 picoseconds. + Weight::from_parts(47_000_000, 6340) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -362,8 +395,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `796 + f * (110 ±0)` // Estimated: `18483` - // Minimum execution time: 85_000_000 picoseconds. - Weight::from_parts(140_000_000, 18483) + // Minimum execution time: 71_000_000 picoseconds. + Weight::from_parts(93_000_000, 18483) .saturating_add(RocksDbWeight::get().reads(20_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -390,8 +423,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `832 + f * (108 ±0)` // Estimated: `18483` - // Minimum execution time: 85_000_000 picoseconds. - Weight::from_parts(149_000_000, 18483) + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(94_000_000, 18483) .saturating_add(RocksDbWeight::get().reads(16_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } @@ -422,9 +455,39 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4754 + f * (235 ±0)` // Estimated: `54490` - // Minimum execution time: 509_000_000 picoseconds. - Weight::from_parts(533_000_000, 54490) + // Minimum execution time: 322_000_000 picoseconds. + Weight::from_parts(345_000_000, 54490) .saturating_add(RocksDbWeight::get().reads(49_u64)) .saturating_add(RocksDbWeight::get().writes(46_u64)) } + /// Storage: `BTCRelay::ChainCounter` (r:1 w:0) + /// Proof: `BTCRelay::ChainCounter` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BlockHeaders` (r:20 w:18) + /// Proof: `BTCRelay::BlockHeaders` (`max_values`: None, `max_size`: Some(200), added: 2675, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainsIndex` (r:3 w:2) + /// Proof: `BTCRelay::ChainsIndex` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::DisableDifficultyCheck` (r:1 w:0) + /// Proof: `BTCRelay::DisableDifficultyCheck` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainsHashes` (r:13 w:24) + /// Proof: `BTCRelay::ChainsHashes` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainWork` (r:2 w:1) + /// Proof: `BTCRelay::ChainWork` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::Chains` (r:6 w:0) + /// Proof: `BTCRelay::Chains` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlock` (r:0 w:1) + /// Proof: `BTCRelay::BestBlock` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:0 w:1) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// The range of component `f` is `[3, 6]`. + fn store_block_header_reorganize_chains_based_on_chainwork (_f: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `5196 + f * (298 ±0)` + // Estimated: `54490` + // Minimum execution time: 328_000_000 picoseconds. + Weight::from_parts(358_000_000, 54490) + .saturating_add(RocksDbWeight::get().reads(47_u64)) + .saturating_add(RocksDbWeight::get().writes(47_u64)) + } } diff --git a/crates/btc-relay/src/lib.rs b/crates/btc-relay/src/lib.rs index 8081c3c94b..71b9731196 100644 --- a/crates/btc-relay/src/lib.rs +++ b/crates/btc-relay/src/lib.rs @@ -162,7 +162,8 @@ pub mod pallet { .max(::WeightInfo::store_block_header_new_fork_sorted(f)) .max(::WeightInfo::store_block_header_new_fork_unsorted(f)) .max(::WeightInfo::store_block_header_reorganize_chains(f)) - .max(::WeightInfo::store_block_header_when_updating_chainwork_mandatory()) + .max(::WeightInfo::store_block_header_reorganize_chains_based_on_chainwork(f)) + .max(::WeightInfo::store_block_header_when_adding_chainwork()) }, DispatchClass::Operational ))] diff --git a/parachain/runtime/interlay/src/weights/btc_relay.rs b/parachain/runtime/interlay/src/weights/btc_relay.rs index 497e8f764a..9d435dc726 100644 --- a/parachain/runtime/interlay/src/weights/btc_relay.rs +++ b/parachain/runtime/interlay/src/weights/btc_relay.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for btc_relay //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-09-26, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-09-27, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Nakuls-MacBook-Pro.local`, CPU: `` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("interlay-dev"), DB CACHE: 1024 @@ -25,7 +25,7 @@ // --chain // interlay-dev // --output -// int_bench.rs +// interlay_bench.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -65,8 +65,8 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `403` // Estimated: `3545` - // Minimum execution time: 80_000_000 picoseconds. - Weight::from_parts(80_000_000, 3545) + // Minimum execution time: 44_000_000 picoseconds. + Weight::from_parts(44_000_000, 3545) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -78,8 +78,8 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1049` // Estimated: `6340` - // Minimum execution time: 39_000_000 picoseconds. - Weight::from_parts(39_000_000, 6340) + // Minimum execution time: 27_000_000 picoseconds. + Weight::from_parts(27_000_000, 6340) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -101,12 +101,12 @@ impl btc_relay::WeightInfo for WeightInfo { /// Proof: `BTCRelay::BestBlock` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Storage: `BTCRelay::BestBlockHeight` (r:0 w:1) /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - fn store_block_header_when_updating_chainwork_mandatory () -> Weight { + fn store_block_header_when_adding_chainwork () -> Weight { // Proof Size summary in bytes: // Measured: `979` // Estimated: `6340` - // Minimum execution time: 83_000_000 picoseconds. - Weight::from_parts(83_000_000, 6340) + // Minimum execution time: 52_000_000 picoseconds. + Weight::from_parts(52_000_000, 6340) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -132,8 +132,8 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `874` // Estimated: `6340` - // Minimum execution time: 73_000_000 picoseconds. - Weight::from_parts(73_000_000, 6340) + // Minimum execution time: 47_000_000 picoseconds. + Weight::from_parts(47_000_000, 6340) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -160,8 +160,8 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `796 + f * (110 ±0)` // Estimated: `18483` - // Minimum execution time: 85_000_000 picoseconds. - Weight::from_parts(140_000_000, 18483) + // Minimum execution time: 71_000_000 picoseconds. + Weight::from_parts(93_000_000, 18483) .saturating_add(T::DbWeight::get().reads(20_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -188,8 +188,8 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `832 + f * (108 ±0)` // Estimated: `18483` - // Minimum execution time: 85_000_000 picoseconds. - Weight::from_parts(149_000_000, 18483) + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(94_000_000, 18483) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -220,9 +220,39 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `4754 + f * (235 ±0)` // Estimated: `54490` - // Minimum execution time: 509_000_000 picoseconds. - Weight::from_parts(533_000_000, 54490) + // Minimum execution time: 322_000_000 picoseconds. + Weight::from_parts(345_000_000, 54490) .saturating_add(T::DbWeight::get().reads(49_u64)) .saturating_add(T::DbWeight::get().writes(46_u64)) } + /// Storage: `BTCRelay::ChainCounter` (r:1 w:0) + /// Proof: `BTCRelay::ChainCounter` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BlockHeaders` (r:20 w:18) + /// Proof: `BTCRelay::BlockHeaders` (`max_values`: None, `max_size`: Some(200), added: 2675, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainsIndex` (r:3 w:2) + /// Proof: `BTCRelay::ChainsIndex` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::DisableDifficultyCheck` (r:1 w:0) + /// Proof: `BTCRelay::DisableDifficultyCheck` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainsHashes` (r:13 w:24) + /// Proof: `BTCRelay::ChainsHashes` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainWork` (r:2 w:1) + /// Proof: `BTCRelay::ChainWork` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::Chains` (r:6 w:0) + /// Proof: `BTCRelay::Chains` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlock` (r:0 w:1) + /// Proof: `BTCRelay::BestBlock` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:0 w:1) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// The range of component `f` is `[3, 6]`. + fn store_block_header_reorganize_chains_based_on_chainwork (_f: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `5196 + f * (298 ±0)` + // Estimated: `54490` + // Minimum execution time: 328_000_000 picoseconds. + Weight::from_parts(358_000_000, 54490) + .saturating_add(T::DbWeight::get().reads(47_u64)) + .saturating_add(T::DbWeight::get().writes(47_u64)) + } } \ No newline at end of file diff --git a/parachain/runtime/kintsugi/src/weights/btc_relay.rs b/parachain/runtime/kintsugi/src/weights/btc_relay.rs index 1667eee791..5ebbc61aed 100644 --- a/parachain/runtime/kintsugi/src/weights/btc_relay.rs +++ b/parachain/runtime/kintsugi/src/weights/btc_relay.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for btc_relay //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-09-26, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-09-27, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Nakuls-MacBook-Pro.local`, CPU: `` //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("kintsugi-dev"), DB CACHE: 1024 @@ -25,7 +25,7 @@ // --chain // kintsugi-dev // --output -// kint_bench.rs +// kintsugi_bench.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -65,8 +65,8 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `423` // Estimated: `3545` - // Minimum execution time: 113_000_000 picoseconds. - Weight::from_parts(113_000_000, 3545) + // Minimum execution time: 40_000_000 picoseconds. + Weight::from_parts(40_000_000, 3545) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -78,8 +78,8 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1049` // Estimated: `6340` - // Minimum execution time: 45_000_000 picoseconds. - Weight::from_parts(45_000_000, 6340) + // Minimum execution time: 22_000_000 picoseconds. + Weight::from_parts(22_000_000, 6340) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -101,12 +101,12 @@ impl btc_relay::WeightInfo for WeightInfo { /// Proof: `BTCRelay::BestBlock` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Storage: `BTCRelay::BestBlockHeight` (r:0 w:1) /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - fn store_block_header_when_updating_chainwork_mandatory () -> Weight { + fn store_block_header_when_adding_chainwork () -> Weight { // Proof Size summary in bytes: // Measured: `999` // Estimated: `6340` - // Minimum execution time: 100_000_000 picoseconds. - Weight::from_parts(100_000_000, 6340) + // Minimum execution time: 48_000_000 picoseconds. + Weight::from_parts(48_000_000, 6340) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -132,8 +132,8 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `894` // Estimated: `6340` - // Minimum execution time: 87_000_000 picoseconds. - Weight::from_parts(87_000_000, 6340) + // Minimum execution time: 44_000_000 picoseconds. + Weight::from_parts(44_000_000, 6340) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -160,8 +160,8 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `816 + f * (110 ±0)` // Estimated: `18483` - // Minimum execution time: 89_000_000 picoseconds. - Weight::from_parts(139_000_000, 18483) + // Minimum execution time: 50_000_000 picoseconds. + Weight::from_parts(81_000_000, 18483) .saturating_add(T::DbWeight::get().reads(20_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -188,8 +188,8 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `852 + f * (108 ±0)` // Estimated: `18483` - // Minimum execution time: 113_000_000 picoseconds. - Weight::from_parts(151_000_000, 18483) + // Minimum execution time: 58_000_000 picoseconds. + Weight::from_parts(90_000_000, 18483) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -220,9 +220,39 @@ impl btc_relay::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `4774 + f * (235 ±0)` // Estimated: `54490` - // Minimum execution time: 494_000_000 picoseconds. - Weight::from_parts(523_000_000, 54490) + // Minimum execution time: 311_000_000 picoseconds. + Weight::from_parts(323_000_000, 54490) .saturating_add(T::DbWeight::get().reads(49_u64)) .saturating_add(T::DbWeight::get().writes(46_u64)) } + /// Storage: `BTCRelay::ChainCounter` (r:1 w:0) + /// Proof: `BTCRelay::ChainCounter` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BlockHeaders` (r:20 w:18) + /// Proof: `BTCRelay::BlockHeaders` (`max_values`: None, `max_size`: Some(200), added: 2675, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainsIndex` (r:3 w:2) + /// Proof: `BTCRelay::ChainsIndex` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::DisableDifficultyCheck` (r:1 w:0) + /// Proof: `BTCRelay::DisableDifficultyCheck` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainsHashes` (r:13 w:24) + /// Proof: `BTCRelay::ChainsHashes` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::ChainWork` (r:2 w:1) + /// Proof: `BTCRelay::ChainWork` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::Chains` (r:6 w:0) + /// Proof: `BTCRelay::Chains` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlock` (r:0 w:1) + /// Proof: `BTCRelay::BestBlock` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:0 w:1) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// The range of component `f` is `[3, 6]`. + fn store_block_header_reorganize_chains_based_on_chainwork (_f: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `5216 + f * (298 ±0)` + // Estimated: `54490` + // Minimum execution time: 297_000_000 picoseconds. + Weight::from_parts(329_000_000, 54490) + .saturating_add(T::DbWeight::get().reads(47_u64)) + .saturating_add(T::DbWeight::get().writes(47_u64)) + } } \ No newline at end of file