session-info: add new fields + migration (#4545)

* session_info: v2 + migration

* use primitives::v2

* use polkadot_primitives::v2

* impl primitives::v2

* fix approval-voting tests

* fix other tests

* hook storage migration up

* backwards compat (1)

* backwards compat (2)

* fmt

* fix tests

* FMT

* do not reexport v1 in v2

* fmt

* set storage version to 1

Co-authored-by: Javier Viola <javier@parity.io>
This commit is contained in:
Andronik Ordian
2021-12-27 09:01:30 +01:00
committed by GitHub
parent 2e360f0aac
commit b342ae11d3
38 changed files with 542 additions and 299 deletions
@@ -22,10 +22,13 @@ use sp_keyring::Sr25519Keyring;
use polkadot_erasure_coding::{branches, obtain_chunks_v1 as obtain_chunks};
use polkadot_node_primitives::{AvailableData, BlockData, ErasureChunk, PoV, Proof};
use polkadot_primitives::v1::{
CandidateCommitments, CandidateDescriptor, CandidateHash, CommittedCandidateReceipt,
GroupIndex, Hash, HeadData, Id as ParaId, OccupiedCore, PersistedValidationData, SessionInfo,
ValidatorIndex,
use polkadot_primitives::{
v1::{
CandidateCommitments, CandidateDescriptor, CandidateHash, CommittedCandidateReceipt,
GroupIndex, Hash, HeadData, Id as ParaId, OccupiedCore, PersistedValidationData,
ValidatorIndex,
},
v2::SessionInfo,
};
use polkadot_primitives_test_helpers::{
dummy_collator, dummy_collator_signature, dummy_hash, dummy_validation_code,
@@ -61,6 +64,7 @@ pub fn make_session_info() -> SessionInfo {
n_delay_tranches: 0,
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: Vec::new(),
}
}
@@ -39,9 +39,9 @@ use polkadot_node_network_protocol::{
request_response::{v1, IncomingRequest, OutgoingRequest, Requests},
};
use polkadot_node_primitives::ErasureChunk;
use polkadot_primitives::v1::{
CandidateHash, CoreState, GroupIndex, Hash, Id as ParaId, ScheduledCore, SessionInfo,
ValidatorIndex,
use polkadot_primitives::{
v1::{CandidateHash, CoreState, GroupIndex, Hash, Id as ParaId, ScheduledCore, ValidatorIndex},
v2::SessionInfo,
};
use polkadot_subsystem::{
messages::{
@@ -48,9 +48,12 @@ use polkadot_node_network_protocol::{
};
use polkadot_node_primitives::{AvailableData, ErasureChunk};
use polkadot_node_subsystem_util::request_session_info;
use polkadot_primitives::v1::{
AuthorityDiscoveryId, BlakeTwo256, BlockNumber, CandidateHash, CandidateReceipt, GroupIndex,
Hash, HashT, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex,
use polkadot_primitives::{
v1::{
AuthorityDiscoveryId, BlakeTwo256, BlockNumber, CandidateHash, CandidateReceipt,
GroupIndex, Hash, HashT, SessionIndex, ValidatorId, ValidatorIndex,
},
v2::SessionInfo,
};
use polkadot_subsystem::{
errors::RecoveryError,
@@ -220,6 +220,7 @@ impl TestState {
n_delay_tranches: 0,
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: vec![],
}))).unwrap();
}
);
@@ -32,9 +32,12 @@ use sp_runtime::traits::AppVerify;
use polkadot_node_network_protocol::{our_view, request_response::IncomingRequest, view};
use polkadot_node_primitives::BlockData;
use polkadot_node_subsystem_util::TimeoutExt;
use polkadot_primitives::v1::{
AuthorityDiscoveryId, CollatorPair, GroupRotationInfo, ScheduledCore, SessionIndex,
SessionInfo, ValidatorId, ValidatorIndex,
use polkadot_primitives::{
v1::{
AuthorityDiscoveryId, CollatorPair, GroupRotationInfo, ScheduledCore, SessionIndex,
ValidatorId, ValidatorIndex,
},
v2::SessionInfo,
};
use polkadot_primitives_test_helpers::TestCandidateBuilder;
use polkadot_subsystem::{
@@ -110,6 +113,7 @@ impl Default for TestState {
n_delay_tranches: 0,
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: vec![],
},
group_rotation_info,
validator_peer_id,
@@ -32,9 +32,12 @@ use sp_keyring::Sr25519Keyring;
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
use polkadot_node_primitives::{DisputeMessage, SignedDisputeStatement};
use polkadot_primitives::v1::{
AuthorityDiscoveryId, CandidateHash, CandidateReceipt, Hash, SessionIndex, SessionInfo,
ValidatorId, ValidatorIndex,
use polkadot_primitives::{
v1::{
AuthorityDiscoveryId, CandidateHash, CandidateReceipt, Hash, SessionIndex, ValidatorId,
ValidatorIndex,
},
v2::SessionInfo,
};
use polkadot_primitives_test_helpers::dummy_candidate_descriptor;
@@ -86,6 +89,7 @@ pub static ref MOCK_SESSION_INFO: SessionInfo =
n_delay_tranches: 0,
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: vec![],
};
/// `SessionInfo` for the second session. (No more validators, but two more authorities.
@@ -105,6 +109,7 @@ pub static ref MOCK_NEXT_SESSION_INFO: SessionInfo =
n_delay_tranches: 0,
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: vec![],
};
}
@@ -41,8 +41,9 @@ use polkadot_node_network_protocol::{
IfDisconnected,
};
use polkadot_node_primitives::{CandidateVotes, UncheckedDisputeMessage};
use polkadot_primitives::v1::{
AuthorityDiscoveryId, CandidateHash, Hash, SessionIndex, SessionInfo,
use polkadot_primitives::{
v1::{AuthorityDiscoveryId, CandidateHash, Hash, SessionIndex},
v2::SessionInfo,
};
use polkadot_subsystem::{
messages::{
@@ -28,7 +28,7 @@ use polkadot_node_network_protocol::{
};
use polkadot_node_primitives::Statement;
use polkadot_node_subsystem_test_helpers::mock::make_ferdie_keystore;
use polkadot_primitives::v1::{SessionInfo, ValidationCode};
use polkadot_primitives::{v1::ValidationCode, v2::SessionInfo};
use polkadot_primitives_test_helpers::{dummy_committed_candidate_receipt, dummy_hash};
use polkadot_subsystem::{
jaeger,
@@ -1851,5 +1851,6 @@ fn make_session_info(validators: Vec<Pair>, groups: Vec<Vec<u32>>) -> SessionInf
n_delay_tranches: 0,
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: Vec::new(),
}
}