This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
*: Disable authority discovery module #3914
Merged
gavofyork
merged 3 commits into
paritytech:master
from
mxinden:disable-authority-discovery
Oct 28, 2019
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ use node_primitives::{ | |
| AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, | ||
| Moment, Signature, | ||
| }; | ||
| use babe_primitives::{AuthorityId as BabeId, AuthoritySignature as BabeSignature}; | ||
| use babe_primitives::AuthorityId as BabeId; | ||
| use grandpa::fg_primitives; | ||
| use client::{ | ||
| block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult}, | ||
|
|
@@ -50,8 +50,6 @@ use version::NativeVersion; | |
| use primitives::OpaqueMetadata; | ||
| use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; | ||
| use im_online::sr25519::{AuthorityId as ImOnlineId}; | ||
| use authority_discovery_primitives::{AuthorityId as EncodedAuthorityId, Signature as EncodedSignature}; | ||
| use codec::{Encode, Decode}; | ||
| use system::offchain::TransactionSubmitter; | ||
|
|
||
| #[cfg(any(feature = "std", test))] | ||
|
|
@@ -83,8 +81,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { | |
| // and set impl_version to equal spec_version. If only runtime | ||
| // implementation changes and behavior does not, then leave spec_version as | ||
| // is and increment impl_version. | ||
| spec_version: 188, | ||
| impl_version: 188, | ||
| spec_version: 189, | ||
| impl_version: 189, | ||
| apis: RUNTIME_API_VERSIONS, | ||
| }; | ||
|
|
||
|
|
@@ -211,7 +209,10 @@ impl authorship::Trait for Runtime { | |
| type EventHandler = Staking; | ||
| } | ||
|
|
||
| type SessionHandlers = (Grandpa, Babe, ImOnline, AuthorityDiscovery); | ||
| // !!!!!!!!!!!!! | ||
| // WARNING!!!!!! SEE NOTE BELOW BEFORE TOUCHING THIS CODE | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice ;) |
||
| // !!!!!!!!!!!!! | ||
| type SessionHandlers = (Grandpa, Babe, ImOnline); | ||
|
|
||
| impl_opaque_keys! { | ||
| pub struct SessionKeys { | ||
|
|
@@ -439,10 +440,6 @@ impl offences::Trait for Runtime { | |
| type OnOffenceHandler = Staking; | ||
| } | ||
|
|
||
| impl authority_discovery::Trait for Runtime { | ||
| type AuthorityId = BabeId; | ||
| } | ||
|
|
||
| impl grandpa::Trait for Runtime { | ||
| type Event = Event; | ||
| } | ||
|
|
@@ -531,7 +528,6 @@ construct_runtime!( | |
| Contracts: contracts, | ||
| Sudo: sudo, | ||
| ImOnline: im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>}, | ||
| AuthorityDiscovery: authority_discovery::{Module, Call, Config<T>}, | ||
| Offences: offences::{Module, Call, Storage, Event}, | ||
| RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage}, | ||
| Nicks: nicks::{Module, Call, Storage, Event<T>}, | ||
|
|
@@ -646,35 +642,6 @@ impl_runtime_apis! { | |
| } | ||
| } | ||
|
|
||
| impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime { | ||
| fn authorities() -> Vec<EncodedAuthorityId> { | ||
| AuthorityDiscovery::authorities().into_iter() | ||
| .map(|id| id.encode()) | ||
| .map(EncodedAuthorityId) | ||
| .collect() | ||
| } | ||
|
|
||
| fn sign(payload: &Vec<u8>) -> Option<(EncodedSignature, EncodedAuthorityId)> { | ||
| AuthorityDiscovery::sign(payload).map(|(sig, id)| { | ||
| (EncodedSignature(sig.encode()), EncodedAuthorityId(id.encode())) | ||
| }) | ||
| } | ||
|
|
||
| fn verify(payload: &Vec<u8>, signature: &EncodedSignature, authority_id: &EncodedAuthorityId) -> bool { | ||
| let signature = match BabeSignature::decode(&mut &signature.0[..]) { | ||
| Ok(s) => s, | ||
| _ => return false, | ||
| }; | ||
|
|
||
| let authority_id = match BabeId::decode(&mut &authority_id.0[..]) { | ||
| Ok(id) => id, | ||
| _ => return false, | ||
| }; | ||
|
|
||
| AuthorityDiscovery::verify(payload, signature, authority_id) | ||
| } | ||
| } | ||
|
|
||
| impl system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime { | ||
| fn account_nonce(account: AccountId) -> Index { | ||
| System::account_nonce(account) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this unused now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is unused now @marcio-diaz. I kept it here with the following reasoning:
This commit is only temporary and will be reverted once the authority discovery refactoring is done.
As of my knowledge no one other than the authority discovery module is using Kademlia, thus no events are being produced. (Will check back with @montekki)
Given that no other module depends on the receiving side, this only affects the authority discovery module.
The receiver goes out of scope, thus the channel will be closed. Even if not the channel is bounded, thus we don't have a memory leak.
Even if events are produced, the network will drop them here: https://github.com/paritytech/substrate/blob/master/core/service/src/lib.rs#L449