Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix signature and public tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
seerscode committed Aug 6, 2019
1 parent 8862d30 commit 3b9c38d
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 110 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

102 changes: 0 additions & 102 deletions core/consensus/babe/primitives/src/equivocation.rs

This file was deleted.

10 changes: 9 additions & 1 deletion core/consensus/babe/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@ impl slots::SlotData for BabeConfiguration {
}

/// Represents an Babe equivocation proof.
#[derive(Clone, Encode, Decode, PartialEq)]
#[derive(Debug, Clone, Encode, Decode, PartialEq)]
pub struct BabeEquivocationProof<H> {
identity: AuthorityId,
identity_proof: Proof,
slot: u64,
first_header: H,
second_header: H,
Expand All @@ -160,6 +161,7 @@ where
/// Create a new Babe equivocation proof.
fn new(
identity: Self::Identity,
identity_proof: Proof,
slot: u64,
first_header: H,
second_header: H,
Expand All @@ -168,6 +170,7 @@ where
) -> Self {
BabeEquivocationProof {
identity,
identity_proof,
slot,
first_header,
second_header,
Expand All @@ -186,6 +189,11 @@ where
&self.identity
}

/// Get the identity of the suspect of equivocating.
fn identity_proof(&self) -> &Proof {
&self.identity_proof
}

/// Get the first header involved in the equivocation.
fn first_header(&self) -> &H {
&self.first_header
Expand Down
2 changes: 1 addition & 1 deletion core/consensus/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ fn check_header<B: BlockT + Sized, C: AuxStore, T>(
}

if let Some(equivocation_proof) = check_equivocation::<
_, _, BabeEquivocationProof<B::Header>, _, _
_, _, BabeEquivocationProof<B::Header>, _
>(
client,
slot_now,
Expand Down
1 change: 1 addition & 0 deletions core/consensus/common/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sr-primitives = { path = "../../../sr-primitives", default-features = false }
rstd = { package = "sr-std", path = "../../../sr-std", default-features = false }
serde = { version = "1.0", optional = true, features = ["derive"] }
primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false }
srml-session = { path = "../../../../srml/session", default-features = false }

[features]
default = ["std"]
Expand Down
6 changes: 5 additions & 1 deletion core/consensus/common/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use parity_codec::Codec;
#[cfg(feature = "std")]
use serde::Serialize;
use sr_primitives::{traits::{Header, Verify}};

use srml_session::historical::Proof;

decl_runtime_apis! {
/// Common consensus runtime api.
Expand All @@ -42,6 +42,7 @@ pub trait AuthorshipEquivocationProof {
/// Create an equivocation proof for AuRa or Babe.
fn new(
identity: Self::Identity,
identity_proof: Proof,
slot: u64,
first_header: Self::Header,
second_header: Self::Header,
Expand All @@ -52,6 +53,9 @@ pub trait AuthorshipEquivocationProof {
/// Get the slot where the equivocation happened.
fn slot(&self) -> u64;

/// Get the identity proof of the suspect of equivocating.
fn identity_proof(&self) -> &Proof;

/// Get the identity of the suspect of equivocating.
fn identity(&self) -> &Self::Identity;

Expand Down
1 change: 1 addition & 0 deletions core/consensus/slots/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ sr-primitives = { path = "../../sr-primitives" }
consensus_common = { package = "substrate-consensus-common", path = "../common" }
consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../common/primitives" }
inherents = { package = "substrate-inherents", path = "../../inherents" }
srml-session = { path = "../../../srml/session", default-features = false }
futures-preview = "0.3.0-alpha.17"
futures-timer = "0.2.1"
parking_lot = "0.8.0"
Expand Down
7 changes: 4 additions & 3 deletions core/consensus/slots/src/aux_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

//! Schema for slots in the aux-db.
use std::ops::Deref;
use codec::{Encode, Decode, Codec};
use client::backend::AuxStore;
use client::error::{Result as ClientResult, Error as ClientError};
use sr_primitives::traits::{Header, Verify};
use consensus_common_primitives::AuthorshipEquivocationProof;
use std::ops::Deref;
use srml_session::historical::Proof;

const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map";
const SLOT_HEADER_START: &[u8] = b"slot_header_start";
Expand Down Expand Up @@ -57,7 +58,7 @@ pub struct EquivocationProof<H> {
/// Checks if the header is an equivocation and returns the proof in that case.
///
/// Note: it detects equivocations only when slot_now - slot <= MAX_SLOT_CAPACITY.
pub fn check_equivocation<C, H, E, V, P>(
pub fn check_equivocation<C, H, E, V>(
backend: &C,
slot_now: u64,
slot: u64,
Expand All @@ -68,7 +69,6 @@ pub fn check_equivocation<C, H, E, V, P>(
where
H: Header,
C: AuxStore,
P: Clone + Encode + Decode + PartialEq,
V: Verify + Codec + Clone,
<V as Verify>::Signer: Clone + Codec + PartialEq,
E: AuthorshipEquivocationProof<
Expand Down Expand Up @@ -106,6 +106,7 @@ pub fn check_equivocation<C, H, E, V, P>(
if header.hash() != prev_header.hash() {
return Ok(Some(AuthorshipEquivocationProof::new(
signer.clone(),
Proof::default(),
slot,
prev_header.clone(),
header.clone(),
Expand Down
14 changes: 14 additions & 0 deletions core/primitives/src/sr25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ impl ::std::fmt::Debug for Public {
}
}

#[cfg(not(feature = "std"))]
impl ::core::fmt::Debug for Public {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
write!(f, "")
}
}

#[cfg(not(feature = "std"))]
impl ::core::fmt::Debug for Signature {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
write!(f, "")
}
}

#[cfg(feature = "std")]
impl Serialize for Public {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer {
Expand Down
4 changes: 2 additions & 2 deletions srml/session/src/historical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ impl<T: Trait> ProvingTrie<T> {
}

/// Proof of ownership of a specific key.
#[cfg_attr(feature = "std", derive(Serialize, Debug))]
#[derive(Encode, Decode, Clone, PartialEq, Eq, Default)]
#[cfg_attr(feature = "std", derive(Serialize))]
#[derive(Encode, Decode, Clone, PartialEq, Eq, Default, Debug)]
pub struct Proof {
session: SessionIndex,
trie_nodes: Vec<Vec<u8>>,
Expand Down

0 comments on commit 3b9c38d

Please sign in to comment.