[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
+4 -24
View File
@@ -22,12 +22,9 @@
use super::*;
use crate::mock::*;
use frame_support::{assert_noop, dispatch};
use sp_core::{
offchain::{
testing::{TestOffchainExt, TestTransactionPoolExt},
OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
},
OpaquePeerId,
use sp_core::offchain::{
testing::{TestOffchainExt, TestTransactionPoolExt},
OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
};
use sp_runtime::{
testing::UintAuthorityId,
@@ -121,14 +118,8 @@ fn heartbeat(
id: UintAuthorityId,
validators: Vec<u64>,
) -> dispatch::DispatchResult {
use frame_support::unsigned::ValidateUnsigned;
let heartbeat = Heartbeat {
block_number,
network_state: OpaqueNetworkState {
peer_id: OpaquePeerId(vec![1]),
external_addresses: vec![],
},
session_index,
authority_index,
validators_len: validators.len() as u32,
@@ -212,8 +203,6 @@ fn late_heartbeat_and_invalid_keys_len_should_fail() {
#[test]
fn should_generate_heartbeats() {
use frame_support::traits::OffchainWorker;
let mut ext = new_test_ext();
let (offchain, _state) = TestOffchainExt::new();
let (pool, state) = TestTransactionPoolExt::new();
@@ -252,7 +241,6 @@ fn should_generate_heartbeats() {
heartbeat,
Heartbeat {
block_number: block,
network_state: sp_io::offchain::network_state().unwrap(),
session_index: 2,
authority_index: 2,
validators_len: 3,
@@ -365,21 +353,13 @@ fn should_not_send_a_report_if_already_online() {
assert_eq!(
heartbeat,
Heartbeat {
block_number: 4,
network_state: sp_io::offchain::network_state().unwrap(),
session_index: 2,
authority_index: 0,
validators_len: 3,
}
Heartbeat { block_number: 4, session_index: 2, authority_index: 0, validators_len: 3 }
);
});
}
#[test]
fn should_handle_missing_progress_estimates() {
use frame_support::traits::OffchainWorker;
let mut ext = new_test_ext();
let (offchain, _state) = TestOffchainExt::new();
let (pool, state) = TestTransactionPoolExt::new();