mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 15:05:40 +00:00
Refactor key management (#3296)
* Add Call type to extensible transactions. Cleanup some naming * Merge Resource and BlockExhausted into just Exhausted * Fix * Another fix * Call * Some fixes * Fix srml tests. * Fix all tests. * Refactor crypto so each application of it has its own type. * Introduce new AuthorityProvider API into Aura This will eventually allow for dynamic determination of authority keys and avoid having to set them directly on CLI. * Introduce authority determinator for Babe. Experiment with modular consensus API. * Work in progress to introduce KeyTypeId and avoid polluting API with validator IDs * Finish up drafting imonline * Rework offchain workers API. * Rework API implementation. * Make it compile for wasm, simplify app_crypto. * Fix compilation of im-online. * Fix compilation of im-online. * Fix more compilation errors. * Make it compile. * Fixing tests. * Rewrite `keystore` * Fix session tests * Bring back `TryFrom`'s' * Fix `srml-grandpa` * Fix `srml-aura` * Fix consensus babe * More fixes * Make service generate keys from dev_seed * Build fixes * Remove offchain tests * More fixes and cleanups * Fixes finality grandpa * Fix `consensus-aura` * Fix cli * Fix `node-cli` * Fix chain_spec builder * Fix doc tests * Add authority getter for grandpa. * Test fix * Fixes * Make keystore accessible from the runtime * Move app crypto to its own crate * Update `Cargo.lock` * Make the crypto stuff usable from the runtime * Adds some runtime crypto tests * Use last finalized block for grandpa authority * Fix warning * Adds `SessionKeys` runtime api * Remove `FinalityPair` and `ConsensusPair` * Minor governance tweaks to get it inline with docs. * Make the governance be up to date with the docs. * Build fixes. * Generate the inital session keys * Failing keystore is a hard error * Make babe work again * Fix grandpa * Fix tests * Disable `keystore` in consensus critical stuff * Build fix. * ImOnline supports multiple authorities at once. * Update core/application-crypto/src/ed25519.rs * Merge branch 'master' into gav-in-progress * Remove unneeded code for now. * Some `session` testing * Support querying the public keys * Cleanup offchain * Remove warnings * More cleanup * Apply suggestions from code review Co-Authored-By: Benjamin Kampmann <ben.kampmann@googlemail.com> * More cleanups * JSONRPC API for setting keys. Also, rename traits::KeyStore* -> traits::BareCryptoStore* * Bad merge * Fix integration tests * Fix test build * Test fix * Fixes * Warnings * Another warning * Bump version.
This commit is contained in:
@@ -100,9 +100,9 @@ impl<T: Trait> Module<T> {
|
||||
/// Specialization of the crate-level `OnSessionEnding` which returns the old
|
||||
/// set of full identification when changing the validator set.
|
||||
pub trait OnSessionEnding<ValidatorId, FullIdentification>: crate::OnSessionEnding<ValidatorId> {
|
||||
/// Returns the set of new validators, if any, along with the old validators
|
||||
/// and their full identifications.
|
||||
fn on_session_ending(ending: SessionIndex, applied_at: SessionIndex)
|
||||
/// If there was a validator set change, its returns the set of new validators along with the
|
||||
/// old validators and their full identifications.
|
||||
fn on_session_ending(ending: SessionIndex, will_apply_at: SessionIndex)
|
||||
-> Option<(Vec<ValidatorId>, Vec<(ValidatorId, FullIdentification)>)>;
|
||||
}
|
||||
|
||||
@@ -312,11 +312,8 @@ impl<T: Trait, D: AsRef<[u8]>> srml_support::traits::KeyOwnerProofSystem<(KeyTyp
|
||||
mod tests {
|
||||
use super::*;
|
||||
use runtime_io::with_externalities;
|
||||
use primitives::Blake2Hasher;
|
||||
use sr_primitives::{
|
||||
traits::OnInitialize,
|
||||
testing::{UintAuthorityId, UINT_DUMMY_KEY},
|
||||
};
|
||||
use primitives::{Blake2Hasher, crypto::key_types::DUMMY};
|
||||
use sr_primitives::{traits::OnInitialize, testing::UintAuthorityId};
|
||||
use crate::mock::{
|
||||
NEXT_VALIDATORS, force_new_session,
|
||||
set_next_validators, Test, System, Session,
|
||||
@@ -329,7 +326,7 @@ mod tests {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
|
||||
let (storage, _child_storage) = crate::GenesisConfig::<Test> {
|
||||
keys: NEXT_VALIDATORS.with(|l|
|
||||
l.borrow().iter().cloned().map(|i| (i, UintAuthorityId(i))).collect()
|
||||
l.borrow().iter().cloned().map(|i| (i, UintAuthorityId(i).into())).collect()
|
||||
),
|
||||
}.build_storage().unwrap();
|
||||
t.extend(storage);
|
||||
@@ -346,15 +343,10 @@ mod tests {
|
||||
Session::on_initialize(1);
|
||||
|
||||
let encoded_key_1 = UintAuthorityId(1).encode();
|
||||
let proof = Historical::prove((UINT_DUMMY_KEY, &encoded_key_1[..])).unwrap();
|
||||
let proof = Historical::prove((DUMMY, &encoded_key_1[..])).unwrap();
|
||||
|
||||
// proof-checking in the same session is OK.
|
||||
assert!(
|
||||
Historical::check_proof(
|
||||
(UINT_DUMMY_KEY, &encoded_key_1[..]),
|
||||
proof.clone(),
|
||||
).is_some()
|
||||
);
|
||||
assert!(Historical::check_proof((DUMMY, &encoded_key_1[..]), proof.clone()).is_some());
|
||||
|
||||
set_next_validators(vec![1, 2, 4]);
|
||||
force_new_session();
|
||||
@@ -370,12 +362,7 @@ mod tests {
|
||||
assert!(Session::current_index() > proof.session);
|
||||
|
||||
// proof-checking in the next session is also OK.
|
||||
assert!(
|
||||
Historical::check_proof(
|
||||
(UINT_DUMMY_KEY, &encoded_key_1[..]),
|
||||
proof.clone(),
|
||||
).is_some()
|
||||
);
|
||||
assert!(Historical::check_proof((DUMMY, &encoded_key_1[..]), proof.clone()).is_some());
|
||||
|
||||
set_next_validators(vec![1, 2, 5]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user