Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions core/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ client = { package = "substrate-client", path = "../../core/client" }
client_db = { package = "substrate-client-db", path = "../../core/client/db", features = ["kvdb-rocksdb"] }
codec = { package = "parity-scale-codec", version = "1.0.0" }
substrate-executor = { path = "../../core/executor" }
substrate-authority-discovery = { path = "../../core/authority-discovery"}
transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" }
rpc-servers = { package = "substrate-rpc-servers", path = "../../core/rpc-servers" }
rpc = { package = "substrate-rpc", path = "../../core/rpc" }
tel = { package = "substrate-telemetry", path = "../../core/telemetry" }
offchain = { package = "substrate-offchain", path = "../../core/offchain" }
parity-multiaddr = { package = "parity-multiaddr", version = "0.5.0" }
authority-discovery-primitives = { package = "substrate-authority-discovery-primitives", path = "../authority-discovery/primitives", default-features = false }

[dev-dependencies]
substrate-test-runtime-client = { path = "../test-runtime/client" }
Expand Down
2 changes: 0 additions & 2 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ balances = { package = "srml-balances", path = "../../srml/balances" }
transaction-payment = { package = "srml-transaction-payment", path = "../../srml/transaction-payment" }
support = { package = "srml-support", path = "../../srml/support", default-features = false }
im_online = { package = "srml-im-online", path = "../../srml/im-online", default-features = false }
sr-authority-discovery = { package = "srml-authority-discovery", path = "../../srml/authority-discovery", default-features = false }
authority-discovery = { package = "substrate-authority-discovery", path = "../../core/authority-discovery"}
serde = { version = "1.0.101", features = [ "derive" ] }
client_db = { package = "substrate-client-db", path = "../../core/client/db", features = ["kvdb-rocksdb"] }
offchain = { package = "substrate-offchain", path = "../../core/offchain" }
Expand Down
9 changes: 3 additions & 6 deletions node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use chain_spec::ChainSpecExtension;
use primitives::{Pair, Public, crypto::UncheckedInto, sr25519};
use serde::{Serialize, Deserialize};
use node_runtime::{
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, DemocracyConfig,
ElectionsConfig, GrandpaConfig, ImOnlineConfig, IndicesConfig, SessionConfig, SessionKeys, StakerStatus,
StakingConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, WASM_BINARY,
BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, DemocracyConfig, ElectionsConfig, GrandpaConfig,
ImOnlineConfig, IndicesConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig, SudoConfig, SystemConfig,
TechnicalCommitteeConfig, WASM_BINARY,
};
use node_runtime::Block;
use node_runtime::constants::{time::*, currency::*};
Expand Down Expand Up @@ -265,9 +265,6 @@ pub fn testnet_genesis(
im_online: Some(ImOnlineConfig {
keys: vec![],
}),
authority_discovery: Some(AuthorityDiscoveryConfig{
keys: vec![],
}),
grandpa: Some(GrandpaConfig {
authorities: vec![],
}),
Expand Down
12 changes: 2 additions & 10 deletions node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ macro_rules! new_full {
// back-pressure. Authority discovery is triggering one event per authority within the current authority set.
// This estimates the authority set size to be somewhere below 10 000 thereby setting the channel buffer size to
// 10 000.
let (dht_event_tx, dht_event_rx) =
mpsc::channel::<DhtEvent>(10000);
let (dht_event_tx, _dht_event_rx) =
mpsc::channel::<DhtEvent>(10_000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this unused now?

Copy link
Contributor Author

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


let service = builder.with_network_protocol(|_| Ok(crate::service::NodeProtocol::new()))?
.with_finality_proof_provider(|client, backend|
Expand Down Expand Up @@ -169,14 +169,6 @@ macro_rules! new_full {

let babe = babe::start_babe(babe_config)?;
service.spawn_essential_task(babe);

let authority_discovery = authority_discovery::AuthorityDiscovery::new(
service.client(),
service.network(),
dht_event_rx,
);

service.spawn_task(authority_discovery);
}

let config = grandpa::Config {
Expand Down
4 changes: 0 additions & 4 deletions node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ rustc-hex = { version = "2.0", optional = true }
safe-mix = { version = "1.0", default-features = false }
serde = { version = "1.0.101", optional = true }

authority-discovery-primitives = { package = "substrate-authority-discovery-primitives", path = "../../core/authority-discovery/primitives", default-features = false }
babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../core/consensus/babe/primitives", default-features = false }
client = { package = "substrate-client", path = "../../core/client", default-features = false }
node-primitives = { path = "../primitives", default-features = false }
Expand All @@ -25,7 +24,6 @@ substrate-keyring = { path = "../../core/keyring", optional = true }
substrate-session = { path = "../../core/session", default-features = false }
version = { package = "sr-version", path = "../../core/sr-version", default-features = false }

authority-discovery = { package = "srml-authority-discovery", path = "../../srml/authority-discovery", default-features = false }
authorship = { package = "srml-authorship", path = "../../srml/authorship", default-features = false }
babe = { package = "srml-babe", path = "../../srml/babe", default-features = false }
balances = { package = "srml-balances", path = "../../srml/balances", default-features = false }
Expand Down Expand Up @@ -64,8 +62,6 @@ runtime_io = { package = "sr-io", path = "../../core/sr-io" }
[features]
default = ["std"]
std = [
"authority-discovery-primitives/std",
"authority-discovery/std",
"authorship/std",
"babe-primitives/std",
"babe/std",
Expand Down
47 changes: 7 additions & 40 deletions node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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))]
Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice ;)

// !!!!!!!!!!!!!
type SessionHandlers = (Grandpa, Babe, ImOnline);

impl_opaque_keys! {
pub struct SessionKeys {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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>},
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion node/testing/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig
authorities: vec![],
}),
im_online: Some(Default::default()),
authority_discovery: Some(Default::default()),
democracy: Some(Default::default()),
collective_Instance1: Some(Default::default()),
collective_Instance2: Some(Default::default()),
Expand Down