[frame/im-online] remove network state from heartbeats (#14251)

* [frame/im-online] remove `external_addresses` from heartbeats

Users should use DHT for discovering new nodes. The reason for adding external addresses was
unstable work of authority discovery (see https://github.com/paritytech/substrate/issues/2719),
which is now stable. Hence we can safely remove `external_addresses`.

Refs https://github.com/paritytech/polkadot/issues/7181

* remove unused import

* run benchmark

* remove external_addresses from offchain NetworkState

* add missing fn to TestNetwork

* Revert "run benchmark"

This reverts commit a282042c2d6bf8bae2c383f6e2699c3fe2970a3d.

* update weights

* address @bkchr comments

* remove duplicate fn

* cleanup benchmarking.rs

* fix executor tests

* remove peer_id from hearbeat as well

https://github.com/paritytech/substrate/pull/14251#discussion_r1210887220

* remove MaxPeerDataEncodingSize

* change storage value type to `()`

https://github.com/paritytech/substrate/pull/14251#discussion_r1214268931

* scaffold storage migration

* no need to check the type actually

* remove unnecessary types from v0 mod

* add a test for migration

* expose Config types

+ pre_upgrade and post_upgrade working fn

* fix test

* replace dummy type with ConstU32

* add some comments to migration test

* fix comment

* respond to @bkchr comments

* use BoundedOpaqueNetworkState::default

intead of using default for each field
This commit is contained in:
Anton
2023-06-15 13:42:36 +04:00
committed by GitHub
parent 4057ef1554
commit 6cd2c8b395
10 changed files with 226 additions and 198 deletions
+22 -29
View File
@@ -18,9 +18,9 @@
//! Autogenerated weights for pallet_im_online
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-05-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! HOSTNAME: `build-host`, CPU: `AMD EPYC 7601 32-Core Processor`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
@@ -37,18 +37,19 @@
// --heap-pages=4096
// --output=./frame/im-online/src/weights.rs
// --header=./HEADER-APACHE2
// --template=./.maintain/frame-weight-template.hbs
// --template=./frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;
use core::marker::PhantomData;
/// Weight functions needed for pallet_im_online.
pub trait WeightInfo {
fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight;
fn validate_unsigned_and_then_heartbeat(k: u32, ) -> Weight;
}
/// Weights for pallet_im_online using the Substrate node and recommended hardware.
@@ -61,25 +62,21 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Storage: ImOnline Keys (r:1 w:0)
/// Proof: ImOnline Keys (max_values: Some(1), max_size: Some(320002), added: 320497, mode: MaxEncodedLen)
/// Storage: ImOnline ReceivedHeartbeats (r:1 w:1)
/// Proof: ImOnline ReceivedHeartbeats (max_values: None, max_size: Some(10021032), added: 10023507, mode: MaxEncodedLen)
/// Proof: ImOnline ReceivedHeartbeats (max_values: None, max_size: Some(1028), added: 3503, mode: MaxEncodedLen)
/// Storage: ImOnline AuthoredBlocks (r:1 w:0)
/// Proof: ImOnline AuthoredBlocks (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen)
/// The range of component `k` is `[1, 1000]`.
/// The range of component `e` is `[1, 100]`.
fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight {
fn validate_unsigned_and_then_heartbeat(k: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `295 + k * (32 ±0)`
// Estimated: `10024497 + e * (35 ±0) + k * (32 ±0)`
// Minimum execution time: 95_573_000 picoseconds.
Weight::from_parts(78_856_572, 10024497)
// Standard Error: 315
.saturating_add(Weight::from_parts(22_926, 0).saturating_mul(k.into()))
// Standard Error: 3_181
.saturating_add(Weight::from_parts(362_093, 0).saturating_mul(e.into()))
// Estimated: `321487 + k * (1761 ±0)`
// Minimum execution time: 120_818_000 picoseconds.
Weight::from_parts(121_396_296, 321487)
// Standard Error: 2_183
.saturating_add(Weight::from_parts(58_710, 0).saturating_mul(k.into()))
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
.saturating_add(Weight::from_parts(0, 35).saturating_mul(e.into()))
.saturating_add(Weight::from_parts(0, 32).saturating_mul(k.into()))
.saturating_add(Weight::from_parts(0, 1761).saturating_mul(k.into()))
}
}
@@ -92,24 +89,20 @@ impl WeightInfo for () {
/// Storage: ImOnline Keys (r:1 w:0)
/// Proof: ImOnline Keys (max_values: Some(1), max_size: Some(320002), added: 320497, mode: MaxEncodedLen)
/// Storage: ImOnline ReceivedHeartbeats (r:1 w:1)
/// Proof: ImOnline ReceivedHeartbeats (max_values: None, max_size: Some(10021032), added: 10023507, mode: MaxEncodedLen)
/// Proof: ImOnline ReceivedHeartbeats (max_values: None, max_size: Some(1028), added: 3503, mode: MaxEncodedLen)
/// Storage: ImOnline AuthoredBlocks (r:1 w:0)
/// Proof: ImOnline AuthoredBlocks (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen)
/// The range of component `k` is `[1, 1000]`.
/// The range of component `e` is `[1, 100]`.
fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight {
fn validate_unsigned_and_then_heartbeat(k: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `295 + k * (32 ±0)`
// Estimated: `10024497 + e * (35 ±0) + k * (32 ±0)`
// Minimum execution time: 95_573_000 picoseconds.
Weight::from_parts(78_856_572, 10024497)
// Standard Error: 315
.saturating_add(Weight::from_parts(22_926, 0).saturating_mul(k.into()))
// Standard Error: 3_181
.saturating_add(Weight::from_parts(362_093, 0).saturating_mul(e.into()))
// Estimated: `321487 + k * (1761 ±0)`
// Minimum execution time: 120_818_000 picoseconds.
Weight::from_parts(121_396_296, 321487)
// Standard Error: 2_183
.saturating_add(Weight::from_parts(58_710, 0).saturating_mul(k.into()))
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
.saturating_add(Weight::from_parts(0, 35).saturating_mul(e.into()))
.saturating_add(Weight::from_parts(0, 32).saturating_mul(k.into()))
.saturating_add(Weight::from_parts(0, 1761).saturating_mul(k.into()))
}
}