Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
5161e16
Add basic BABE consensus type
Demi-Marie Apr 1, 2019
f2a7c7e
Merge branch 'master' into demi-babe
Demi-Marie Apr 2, 2019
99d8e29
Update core/consensus/babe/slots/Cargo.toml
gnunicorn Apr 2, 2019
bd0aed2
Fix parameterization and run `rustfmt`
Demi-Marie Apr 2, 2019
e7c8fe1
Merge branch 'demi-babe' of github.com:paritytech/substrate into demi…
Demi-Marie Apr 2, 2019
52308bb
Respond to review comments
Demi-Marie Apr 2, 2019
af53d76
Update various Cargo.lock files
Demi-Marie Apr 2, 2019
1458387
Revert "Update various Cargo.lock files"
Demi-Marie Apr 3, 2019
8d27f02
Merge branch 'master' into demi-babe
Demi-Marie Apr 3, 2019
f353f3b
`BabeSealSignature` → `BabeSeal`
Demi-Marie Apr 3, 2019
6702946
Move slot code to its own crate
Demi-Marie Apr 3, 2019
7e56f95
Remove redundancy between AuRa and BABE
Demi-Marie Apr 3, 2019
6ffc5be
Fix build error
Demi-Marie Apr 3, 2019
045e022
Avoid non-`#[doc(hidden)]` re-exports
Demi-Marie Apr 4, 2019
b1af553
Remove dead code in AuRa
Demi-Marie Apr 4, 2019
74ff043
Remove impl_slot macro
Demi-Marie Apr 5, 2019
c512fba
Use a custom struct for BABE configuration
Demi-Marie Apr 5, 2019
48a16d1
AuRa and BABE need different DB keys
Demi-Marie Apr 5, 2019
0eb29f6
Bring back `aura::Network`, but deprecate it.
Demi-Marie Apr 5, 2019
26595f6
Improve docs and add `slot_duration` inherent method
Demi-Marie Apr 5, 2019
6a1db59
Add docs to `substrate_consensus_aura::SlotDuration`
Demi-Marie Apr 6, 2019
d82e8a9
Add missing documentation and #![forbid(missing_docs, unsafe_code)]
Demi-Marie Apr 6, 2019
0907ca4
Add a #![forbid(missing_docs)]
Demi-Marie Apr 6, 2019
d395a53
Merge remote-tracking branch 'origin/master' into demi-babe
Demi-Marie Apr 6, 2019
d70c962
Remove dependency of `test-runtime` on `slots`
Demi-Marie Apr 7, 2019
38491e9
Update core/consensus/babe/src/lib.rs
bkchr Apr 8, 2019
83eee6f
Merge branch 'master' of github.com:paritytech/substrate into demi-babe
Demi-Marie Apr 8, 2019
1970c19
Remove wrongly added file
Demi-Marie Apr 8, 2019
791b86c
Fix copyright notice
bkchr Apr 8, 2019
0c4d5c9
Bump `impl_version` and `spec_version`
Demi-Marie Apr 8, 2019
d149ca3
Merge branch 'demi-babe' of github.com:paritytech/substrate into demi…
Demi-Marie Apr 8, 2019
f6dd177
Add more code to BABE
Demi-Marie Apr 8, 2019
dd09e84
Stuck on horrible compiler error message
Demi-Marie Apr 10, 2019
7e4167b
add missing files
Demi-Marie Apr 10, 2019
ffa9a0b
Spaces → tabs
Demi-Marie Apr 10, 2019
0242e0e
Simplify code
Demi-Marie Apr 10, 2019
0feab6b
Fix compilation
Demi-Marie Apr 10, 2019
0cf2152
Merge branch 'master' into demi-babe-progress
Demi-Marie Apr 10, 2019
e878b57
Merge branch 'master' into demi-babe
Demi-Marie Apr 10, 2019
ba31d70
Merge branch 'master' of github.com:paritytech/substrate into demi-ba…
Demi-Marie Apr 11, 2019
a78b4d7
More work on BABE
Demi-Marie Apr 11, 2019
0583b8c
Fix deprecation version
Demi-Marie Apr 11, 2019
29d1786
Fix deprecation version; remove spurious carets
Demi-Marie Apr 11, 2019
9cce1b4
Merge branch 'demi-babe' into demi-babe-progress
Demi-Marie Apr 11, 2019
423b928
Merge branch 'master' into demi-babe
Demi-Marie Apr 11, 2019
5f24589
Fix Cargo.toml
Demi-Marie Apr 11, 2019
7264750
Implement VRF signing logic
Demi-Marie Apr 11, 2019
fa66cab
The import queue code compiles, though it probably doesn’t work.
Demi-Marie Apr 12, 2019
90f208a
Add VRF verification
Demi-Marie Apr 12, 2019
fcf40ac
Merge branch 'master' into demi-babe
Demi-Marie Apr 12, 2019
08d9f7b
Merge branch 'demi-babe' of github.com:paritytech/substrate into demi…
Demi-Marie Apr 12, 2019
42c4139
Merge branch 'master' into demi-babe
Demi-Marie Apr 12, 2019
d1e383a
Update Cargo.lock
Demi-Marie Apr 12, 2019
ef170cf
Update dependencies
Demi-Marie Apr 12, 2019
2af6764
Merge branch 'demi-babe' into demi-babe-progress
Demi-Marie Apr 12, 2019
656cd2a
Merge branch 'master' into demi-babe-progress
Demi-Marie Apr 15, 2019
a2d5ac9
Move test network to sr25519 authority keys
Demi-Marie Apr 17, 2019
9a3819d
Merge branch 'master' into demi-babe-progress
Demi-Marie Apr 17, 2019
33fa14d
Fix accidental build bustage
Demi-Marie Apr 18, 2019
5801498
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 18, 2019
21ab9a0
Trying to get the tests to work
Demi-Marie Apr 19, 2019
bd5e402
Add logging messages and remove dead code
Demi-Marie Apr 21, 2019
ff3ac19
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 18, 2019
c3bb024
Trying to get the tests to work
Demi-Marie Apr 19, 2019
3577628
Add logging messages and remove dead code
Demi-Marie Apr 21, 2019
3b275f7
Merge branch 'master' into demi-another-try
Demi-Marie Apr 21, 2019
48341f2
Working testsuite at last!
Demi-Marie Apr 22, 2019
6f8890c
Merge branch 'demi-babe-progress' of github.com:paritytech/substrate …
Demi-Marie Apr 22, 2019
0e33988
Enable BabeSeal::Encode asserts in --release tests
Demi-Marie Apr 22, 2019
e918172
Bump runtime and dependency versions
Demi-Marie Apr 22, 2019
84775be
Fix wasm compilation
Demi-Marie Apr 22, 2019
6cdcaba
Merge branch 'master' into demi-babe-progress
Demi-Marie Apr 22, 2019
9a18966
Merge Cargo.lock
Demi-Marie Apr 22, 2019
e9a1630
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 22, 2019
640c2d2
Change expected JSON string
Demi-Marie Apr 22, 2019
ec6ff79
Responded to review
Demi-Marie Apr 23, 2019
099e75f
Remove hard-coded threshold from production code
Demi-Marie Apr 23, 2019
088a4d8
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 23, 2019
0dadb4e
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 23, 2019
f5e28ab
Initial work on inherent digests
Demi-Marie Apr 25, 2019
ad010fb
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 25, 2019
b01a2b9
Merge branch 'demi-babe-progress' into demi-inherent-digests
Demi-Marie Apr 25, 2019
9284087
Fix swapped doc comments
Demi-Marie Apr 25, 2019
fb87ea6
Fix unused import warnings
Demi-Marie Apr 25, 2019
b7f91c8
Revert excess verbosity and #![forbid(warnings)]
Demi-Marie Apr 25, 2019
fc4394f
Apply suggestions from code review
bkchr Apr 25, 2019
9614854
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 25, 2019
ec78278
fix ci error
Demi-Marie Apr 25, 2019
0536910
fix typo
Demi-Marie Apr 25, 2019
28af6ed
Merge branch 'demi-babe-progress' into demi-inherent-digests
Demi-Marie Apr 26, 2019
9b17da5
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 26, 2019
a90603a
Merge branch 'demi-babe-progress' into demi-inherent-digests
Demi-Marie Apr 26, 2019
8854a97
Fix spacing in docs
Demi-Marie Apr 26, 2019
65d88fa
Merge branch 'demi-babe-progress' into demi-inherent-digests
Demi-Marie Apr 26, 2019
bd1ec42
Minor changes suggested by @joepetrowski
Demi-Marie Apr 26, 2019
2823121
Merge branch 'demi-babe-progress' into demi-inherent-digests
Demi-Marie Apr 26, 2019
d961ef8
Remove unnecessary getters
Demi-Marie Apr 26, 2019
830b80d
fix compile error
Demi-Marie Apr 26, 2019
0c96ceb
Fix silly unused-variable error
Demi-Marie Apr 26, 2019
0ae9b02
Merge branch 'demi-babe-progress' into demi-inherent-digests
Demi-Marie Apr 26, 2019
a7f3b44
Switch to single spaces after sentences
Demi-Marie Apr 26, 2019
f4b9617
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 26, 2019
c279eab
Merge branch 'demi-babe-progress' into demi-inherent-digests
Demi-Marie Apr 26, 2019
9ea0a1e
Improve documentation formatting
joepetrowski Apr 26, 2019
f8b0870
Improve documentation formatting
joepetrowski Apr 26, 2019
68a9b06
Reformat some comments
Demi-Marie Apr 26, 2019
6d07186
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 29, 2019
470377b
Merge branch 'demi-babe-progress' into demi-inherent-digests
Demi-Marie Apr 29, 2019
3b4e80b
Merge remote-tracking branch 'origin/master' into demi-babe-progress
Demi-Marie Apr 29, 2019
e881e86
Merge branch 'master' into demi-babe-progress
Demi-Marie Apr 30, 2019
ae24490
Add issue links
Demi-Marie Apr 30, 2019
8900ab2
Merge branch 'master' into demi-babe-progress
Demi-Marie Apr 30, 2019
359b715
Merge branch 'demi-babe-progress' into demi-inherent-digests
Demi-Marie May 1, 2019
e700f2b
Merge branch 'demi-babe-progress' into demi-inherent-digests
Demi-Marie May 1, 2019
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
47 changes: 28 additions & 19 deletions Cargo.lock

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

14 changes: 11 additions & 3 deletions core/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,15 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
origin,
header,
justification,
pre_digests,
post_digests,
body,
finalized,
auxiliary,
fork_choice,
} = import_block;

assert!(justification.is_some() && finalized || justification.is_none());
assert!(justification.is_none() || finalized);

let parent_hash = header.parent_hash().clone();

Expand Down Expand Up @@ -740,6 +741,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
operation,
origin,
hash,
pre_digests.0,
import_headers,
justification,
body,
Expand All @@ -763,6 +765,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
operation: &mut ClientImportOperation<Block, Blake2Hasher, B>,
origin: BlockOrigin,
hash: Block::Hash,
pre_digests: Vec<u8>,
import_headers: PrePostHeader<Block::Header>,
justification: Option<Justification>,
body: Option<Vec<Block::Extrinsic>>,
Expand Down Expand Up @@ -801,7 +804,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
}

// FIXME #1232: correct path logic for when to execute this function
let (storage_update,changes_update,storage_changes) = self.block_execution(&operation.op, &import_headers, origin, hash, body.clone())?;
let (storage_update,changes_update,storage_changes) = self.block_execution(&operation.op, pre_digests, &import_headers, origin, hash, body.clone())?;

let is_new_best = finalized || match fork_choice {
ForkChoiceStrategy::LongestChain => import_headers.post().number() > &last_best_number,
Expand Down Expand Up @@ -851,6 +854,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
fn block_execution(
&self,
transaction: &B::BlockImportOperation,
pre_digest: Vec<u8>,
import_headers: &PrePostHeader<Block::Header>,
origin: BlockOrigin,
hash: Block::Hash,
Expand Down Expand Up @@ -890,7 +894,11 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
transaction_state,
&mut overlay,
"Core_execute_block",
&<Block as BlockT>::new(import_headers.pre().clone(), body.unwrap_or_default()).encode(),
&{
let mut the_block = <Block as BlockT>::new(import_headers.pre().clone(), body.unwrap_or_default());
the_block.set_pre_digest(pre_digest);
the_block.encode()
},
match origin {
BlockOrigin::NetworkInitialSync => get_execution_manager(self.execution_strategies().syncing),
_ => get_execution_manager(self.execution_strategies().importing),
Expand Down
1 change: 1 addition & 0 deletions core/consensus/aura/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ runtime_primitives = { package = "sr-primitives", path = "../../../sr-primitives
[features]
default = ["std"]
std = [
"runtime_primitives/std",
"substrate-client/std",
]
34 changes: 11 additions & 23 deletions core/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ use srml_aura::{
};
use substrate_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO};

use slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible};
use slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible, slot_now};

pub use aura_primitives::*;
pub use consensus_common::SyncOracle;
pub use consensus_common::{SyncOracle, PreDigest};

type AuthorityId<P> = <P as Pair>::Public;
type Signature<P> = <P as Pair>::Signature;
Expand Down Expand Up @@ -120,20 +120,6 @@ fn slot_author<P: Pair>(slot_num: u64, authorities: &[AuthorityId<P>]) -> Option
Some(current_author)
}

fn duration_now() -> Option<Duration> {
use std::time::SystemTime;

let now = SystemTime::now();
now.duration_since(SystemTime::UNIX_EPOCH).map_err(|e| {
warn!("Current time {:?} is before unix epoch. Something is wrong: {:?}", now, e);
}).ok()
}

/// Get the slot for now.
fn slot_now(slot_duration: u64) -> Option<u64> {
duration_now().map(|s| s.as_secs() / slot_duration)
}

fn inherent_to_common_error(err: RuntimeString) -> consensus_common::Error {
consensus_common::ErrorKind::InherentData(err.into()).into()
}
Expand Down Expand Up @@ -429,6 +415,7 @@ impl<B: Block, C, E, I, P, Error, SO> SlotWorker<B> for AuraWorker<C, E, I, P, S
let import_block: ImportBlock<B> = ImportBlock {
origin: BlockOrigin::Own,
header,
pre_digests: PreDigest::new(),
justification: None,
post_digests: vec![item],
body: Some(body),
Expand Down Expand Up @@ -467,7 +454,6 @@ impl<B: Block, C, E, I, P, Error, SO> SlotWorker<B> for AuraWorker<C, E, I, P, S
/// This digest item will always return `Some` when used with `as_aura_seal`.
//
// FIXME #1018 needs misbehavior types
#[forbid(deprecated)]
fn check_header<B: Block, P: Pair>(
slot_now: u64,
mut header: B::Header,
Expand Down Expand Up @@ -680,6 +666,7 @@ impl<B: Block, C, E, P> Verifier<B> for AuraVerifier<C, E, P> where

let import_block = ImportBlock {
origin,
pre_digests: PreDigest::new(),
header: pre_header,
post_digests: vec![seal],
body,
Expand Down Expand Up @@ -785,7 +772,8 @@ pub fn import_queue<B, C, E, P>(

/// Start an import queue for the Aura consensus algorithm with backwards compatibility.
#[deprecated(
note = "should not be used unless backwards compatibility with an older chain is needed."
since = "1.0.1",
note = "should not be used unless backwards compatibility with an older chain is needed.",
)]
pub fn import_queue_accept_old_seals<B, C, E, P>(
slot_duration: SlotDuration,
Expand Down Expand Up @@ -828,8 +816,8 @@ mod tests {
use network::config::ProtocolConfig;
use parking_lot::Mutex;
use tokio::runtime::current_thread;
use keyring::ed25519::Keyring;
use primitives::ed25519;
use keyring::sr25519::Keyring;
use primitives::sr25519;
use client::BlockchainEvents;
use test_client;

Expand All @@ -844,7 +832,7 @@ mod tests {
type Proposer = DummyProposer;
type Error = Error;

fn init(&self, parent_header: &<TestBlock as BlockT>::Header, _authorities: &[AuthorityId<ed25519::Pair>])
fn init(&self, parent_header: &<TestBlock as BlockT>::Header, _authorities: &[AuthorityId<sr25519::Pair>])
-> Result<DummyProposer, Error>
{
Ok(DummyProposer(parent_header.number + 1, self.0.clone()))
Expand All @@ -870,7 +858,7 @@ mod tests {

impl TestNetFactory for AuraTestNet {
type Specialization = DummySpecialization;
type Verifier = AuraVerifier<PeersClient, NothingExtra, ed25519::Pair>;
type Verifier = AuraVerifier<PeersClient, NothingExtra, sr25519::Pair>;
type PeerData = ();

/// Create new test network with peers and given config.
Expand Down Expand Up @@ -957,7 +945,7 @@ mod tests {
&inherent_data_providers, slot_duration.get()
).expect("Registers aura inherent data provider");

let aura = start_aura::<_, _, _, _, ed25519::Pair, _, _, _>(
let aura = start_aura::<_, _, _, _, sr25519::Pair, _, _, _>(
slot_duration,
Arc::new(key.clone().into()),
client.clone(),
Expand Down
8 changes: 4 additions & 4 deletions core/consensus/babe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ runtime_io = { package = "sr-io", path = "../../sr-io" }
inherents = { package = "substrate-inherents", path = "../../inherents" }
srml-consensus = { path = "../../../srml/consensus" }
substrate-telemetry = { path = "../../telemetry" }
srml-babe = { path = "../../../srml/babe" }
client = { package = "substrate-client", path = "../../client" }
consensus_common = { package = "substrate-consensus-common", path = "../common" }
authorities = { package = "substrate-consensus-authorities", path = "../authorities" }
Expand All @@ -26,10 +27,9 @@ tokio = "0.1.18"
parking_lot = "0.7.1"
error-chain = "0.12.0"
log = "0.4.6"

[dependencies.schnorrkel]
git = "https://github.com/paritytech/schnorrkel"
branch = "master"
schnorrkel = "0.1.1"
rand = "0.6.5"
merlin = "1.0.3"

[dev-dependencies]
keyring = { package = "substrate-keyring", path = "../../keyring" }
Expand Down
4 changes: 3 additions & 1 deletion core/consensus/babe/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ edition = "2018"
substrate-client = { path = "../../../client", default-features = false }
runtime_primitives = { package = "sr-primitives", path = "../../../sr-primitives", default-features = false }
slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true }
parity-codec = "^3.4.0"
parity-codec = { version = "3.5.1", default-features = false }

[features]
default = ["std"]
std = [
"runtime_primitives/std",
"substrate-client/std",
"parity-codec/std",
"slots",
]
29 changes: 13 additions & 16 deletions core/consensus/babe/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,28 @@ pub const BABE_ENGINE_ID: ConsensusEngineId = [b'b', b'a', b'b', b'e'];
/// Configuration data used by the BABE consensus engine.
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug, Encode, Decode)]
pub struct BabeConfiguration {
slot_duration: u64,
expected_block_time: u64,
}
/// The slot duration in milliseconds for BABE. Currently, only
/// the value provided by this type at genesis will be used.
///
/// Dynamic slot duration may be supported in the future.
pub slot_duration: u64,

impl BabeConfiguration {
/// Return the expected block time in milliseconds for BABE. Currently,
/// The expected block time in milliseconds for BABE. Currently,
/// only the value provided by this type at genesis will be used.
///
/// Dynamic expected block time may be supported in the future.
pub fn expected_block_time(&self) -> u64 {
self.expected_block_time
}
pub expected_block_time: u64,

/// Return the slot duration in milliseconds for BABE. Currently, only
/// the value provided by this type at genesis will be used.
/// The maximum permitted VRF output, or *threshold*, for BABE. Currently,
/// only the value provided by this type at genesis will be used.
///
/// Dynamic slot duration may be supported in the future.
pub fn slot_duration(&self) -> u64 {
self.slot_duration
}
/// Dynamic thresholds may be supported in the future.
pub threshold: u64,
}

#[cfg(feature = "std")]
impl slots::SlotData for BabeConfiguration {
/// Return the slot duration in milliseconds for BABE. Currently, only
/// Return the slot duration in milliseconds for BABE. Currently, only
/// the value provided by this type at genesis will be used.
///
/// Dynamic slot duration may be supported in the future.
Expand All @@ -67,7 +64,7 @@ impl slots::SlotData for BabeConfiguration {
decl_runtime_apis! {
/// API necessary for block authorship with BABE.
pub trait BabeApi {
/// Return the configuration for BABE. Currently,
/// Return the configuration for BABE. Currently,
/// only the value provided by this type at genesis will be used.
///
/// Dynamic configuration may be supported in the future.
Expand Down
Loading