Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
1 change: 1 addition & 0 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions core/application-crypto/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use primitives::crypto::{KeyTypeId, CryptoType, IsWrappedBy, Public};
#[cfg(feature = "std")]
use primitives::crypto::Pair;
use codec::Codec;

/// An application-specific key.
pub trait AppKey: 'static + Send + Sync + Sized + CryptoType + Clone {
Expand Down Expand Up @@ -72,7 +73,7 @@ pub trait AppSignature: AppKey + Eq + PartialEq + MaybeDebugHash {
/// A runtime interface for a public key.
pub trait RuntimePublic: Sized {
/// The signature that will be generated when signing with the corresponding private key.
type Signature;
type Signature: Codec + MaybeDebugHash + Eq + PartialEq + Clone;

/// Returns all public keys for the given key type in the keystore.
fn all(key_type: KeyTypeId) -> crate::Vec<Self>;
Expand All @@ -97,7 +98,7 @@ pub trait RuntimePublic: Sized {
/// A runtime interface for an application's public key.
pub trait RuntimeAppPublic: Sized {
/// The signature that will be generated when signing with the corresponding private key.
type Signature;
type Signature: Codec + MaybeDebugHash + Eq + PartialEq + Clone;

/// Returns all public keys for this application in the keystore.
fn all() -> crate::Vec<Self>;
Expand Down
32 changes: 16 additions & 16 deletions core/consensus/aura/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,38 @@ use substrate_client::decl_runtime_apis;
use rstd::vec::Vec;
use sr_primitives::ConsensusEngineId;

mod app_sr25519 {
use app_crypto::{app_crypto, key_types::AURA, sr25519};
app_crypto!(sr25519, AURA);
}

pub mod sr25519 {
mod app_sr25519 {
use app_crypto::{app_crypto, key_types::AURA, sr25519};
app_crypto!(sr25519, AURA);
}

/// An Aura authority keypair using S/R 25519 as its crypto.
#[cfg(feature = "std")]
pub type AuthorityPair = super::app_sr25519::Pair;
pub type AuthorityPair = app_sr25519::Pair;

/// An Aura authority signature using S/R 25519 as its crypto.
pub type AuthoritySignature = super::app_sr25519::Signature;
pub type AuthoritySignature = app_sr25519::Signature;

/// An Aura authority identifier using S/R 25519 as its crypto.
pub type AuthorityId = super::app_sr25519::Public;
}

mod app_ed25519 {
use app_crypto::{app_crypto, key_types::AURA, ed25519};
app_crypto!(ed25519, AURA);
pub type AuthorityId = app_sr25519::Public;
}

pub mod ed25519 {
mod app_ed25519 {
use app_crypto::{app_crypto, key_types::AURA, ed25519};
app_crypto!(ed25519, AURA);
}

/// An Aura authority keypair using Ed25519 as its crypto.
#[cfg(feature = "std")]
pub type AuthorityPair = super::app_ed25519::Pair;
pub type AuthorityPair = app_ed25519::Pair;

/// An Aura authority signature using Ed25519 as its crypto.
pub type AuthoritySignature = super::app_ed25519::Signature;
pub type AuthoritySignature = app_ed25519::Signature;

/// An Aura authority identifier using Ed25519 as its crypto.
pub type AuthorityId = super::app_ed25519::Public;
pub type AuthorityId = app_ed25519::Public;
}

/// The `ConsensusEngineId` of AuRa.
Expand Down
2 changes: 1 addition & 1 deletion core/rpc/src/author/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl<B, E, P, RA> AuthorApi<ExHash<P>, BlockHash<P>> for Author<B, E, P, RA> whe
Some(public) => public.0,
None => {
let maybe_public = match key_type {
key_types::BABE | key_types::IM_ONLINE | key_types::SR25519 =>
key_types::BABE | key_types::SR25519 =>
sr25519::Pair::from_string(&suri, maybe_password)
.map(|pair| pair.public().to_raw_vec()),
key_types::GRANDPA | key_types::ED25519 =>
Expand Down
2 changes: 1 addition & 1 deletion node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use hex_literal::hex;
use substrate_telemetry::TelemetryEndpoints;
use grandpa_primitives::{AuthorityId as GrandpaId};
use babe_primitives::{AuthorityId as BabeId};
use im_online::AuthorityId as ImOnlineId;
use im_online::sr25519::{AuthorityId as ImOnlineId};
use sr_primitives::Perbill;

const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
Expand Down
19 changes: 10 additions & 9 deletions node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use elections::VoteIndex;
use version::NativeVersion;
use primitives::OpaqueMetadata;
use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight};
use im_online::{AuthorityId as ImOnlineId};
use im_online::sr25519::{AuthorityId as ImOnlineId};

#[cfg(any(feature = "std", test))]
pub use sr_primitives::BuildStorage;
Expand Down Expand Up @@ -79,7 +79,7 @@ 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: 153,
spec_version: 154,
impl_version: 154,
apis: RUNTIME_API_VERSIONS,
};
Expand Down Expand Up @@ -393,6 +393,7 @@ impl sudo::Trait for Runtime {
}

impl im_online::Trait for Runtime {
type AuthorityId = ImOnlineId;
type Call = Call;
type Event = Event;
type UncheckedExtrinsic = UncheckedExtrinsic;
Expand Down Expand Up @@ -447,8 +448,8 @@ construct_runtime!(
Treasury: treasury::{Module, Call, Storage, Event<T>},
Contracts: contracts,
Sudo: sudo,
ImOnline: im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config},
AuthorityDiscovery: authority_discovery::{Module, Call, Config},
ImOnline: im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
AuthorityDiscovery: authority_discovery::{Module, Call, Config<T>},
Offences: offences::{Module, Call, Storage, Event},
}
);
Expand Down Expand Up @@ -578,19 +579,19 @@ impl_runtime_apis! {
}
}

impl authority_discovery_primitives::AuthorityDiscoveryApi<Block, im_online::AuthorityId> for Runtime {
fn authority_id() -> Option<im_online::AuthorityId> {
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block, ImOnlineId> for Runtime {
fn authority_id() -> Option<ImOnlineId> {
AuthorityDiscovery::authority_id()
}
fn authorities() -> Vec<im_online::AuthorityId> {
fn authorities() -> Vec<ImOnlineId> {
AuthorityDiscovery::authorities()
}

fn sign(payload: Vec<u8>, authority_id: im_online::AuthorityId) -> Option<Vec<u8>> {
fn sign(payload: Vec<u8>, authority_id: ImOnlineId) -> Option<Vec<u8>> {
AuthorityDiscovery::sign(payload, authority_id)
}

fn verify(payload: Vec<u8>, signature: Vec<u8>, public_key: im_online::AuthorityId) -> bool {
fn verify(payload: Vec<u8>, signature: Vec<u8>, public_key: ImOnlineId) -> bool {
AuthorityDiscovery::verify(payload, signature, public_key)
}
}
Expand Down
3 changes: 3 additions & 0 deletions srml/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ srml-support = { path = "../support", default-features = false }
sr-io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
system = { package = "srml-system", path = "../system", default-features = false }

[dev-dependencies]
sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false }

[features]
default = ["std"]
std = [
Expand Down
Loading