Use BABE instead of AuRa in node (#3171)

* babe: add babe module trait

* babe: track current slot and epoch start slot

* babe: implement ShouldEndSession based on epochs

* babe: rename weight type to avoid ambiguities

* babe: expose epoch start slot in Epoch digest

* babe: use epoch start for validating epoch transitions

* babe: make the epoch duration a parameter type

* babe: remove unused fields from config

* node: update runtime to use babe instead of aura

* node: use babe instead of aura

* core: generate sr25519 keys from seed and add to keystore

* core: remove AuthorityKeyring

* node: remove unused primitive types related to babe crypto

* uniform babe primitives crate import name

* wrap long lines

* babe: fix find_epoch_digest

* fork-tree: fix find_node_where

* node: set babe epoch duration to "10 minutes"

* babe: cleanup import key cache if authorities don't change

* node: make integration test compile (but fail)

* node: bump spec_version

* node: fix import

* babe: don't use constants in storage fields array sizes

* babe: account for first epoch slot way in the past

* babe: signal next epoch change (not current)

* babe: calculate next epoch randomness with next epoch index

* babe: track next epoch in node

* babe: cache current epoch and authorities separately

* babe: generate valid babe vrf proofs in integration test

* babe: cleanup claim_slot

* babe: perform threshold calculation according to spec

* babe: compute relative weight in threshold

* babe: more precise threshold calculation

* babe: use floats for threshold exponent calculation

* babe: update constant c
This commit is contained in:
André Silva
2019-07-24 20:53:04 +01:00
committed by DemiMarie-parity
parent 407970406d
commit 9f50c8fce4
33 changed files with 784 additions and 429 deletions
+13 -5
View File
@@ -64,7 +64,12 @@ impl Proposer<TestBlock> for DummyProposer {
type Error = Error;
type Create = Result<TestBlock, Error>;
fn propose(&self, _: InherentData, digests: DigestFor<TestBlock>, _: Duration) -> Result<TestBlock, Error> {
fn propose(
&self,
_: InherentData,
digests: DigestFor<TestBlock>,
_: Duration,
) -> Result<TestBlock, Error> {
self.1.new_block(digests).unwrap().bake().map_err(|e| e.into())
}
}
@@ -232,7 +237,10 @@ fn run_one_test() {
// wait for all finalized on each.
let wait_for = futures::future::join_all(import_notifications);
let drive_to_completion = futures::future::poll_fn(|| { net.lock().poll(); Ok(Async::NotReady) });
let drive_to_completion = futures::future::poll_fn(|| {
net.lock().poll();
Ok(Async::NotReady)
});
let _ = runtime.block_on(wait_for.select(drive_to_completion).map_err(|_| ())).unwrap();
}
@@ -306,17 +314,17 @@ fn sig_is_not_pre_digest() {
#[test]
fn can_author_block() {
let _ = env_logger::try_init();
let randomness = &[];
let (pair, _) = sr25519::Pair::generate();
let mut i = 0;
let epoch = Epoch {
authorities: vec![(pair.public(), 0)],
start_slot: 0,
authorities: vec![(pair.public(), 1)],
randomness: [0; 32],
epoch_index: 1,
duration: 100,
};
loop {
match claim_slot(randomness, i, 0, epoch.clone(), &pair, u64::MAX / 10) {
match claim_slot(i, epoch.clone(), &pair, (3, 10)) {
None => i += 1,
Some(s) => {
debug!(target: "babe", "Authored block {:?}", s);