epoch-changes: separate epoch header with epoch data (#4881)

* fork-tree: prune returns all pruned node data

* epoch-changes: split EpochHeader vs epoch data

* EpochChanges::viable_epoch and add missing comments

* Incoperate the new epoch_changes interface for BABE

* Fix BABE tests

* Fix fork-tree pruning issue

* Fix tests

* Fix pruning algorithm

* fork-tree: implement map function for mapping one value type to another

* Add migration script for new epoch changes scheme

* Update utils/fork-tree/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Update client/consensus/slots/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Remove authorities_len.is_none check, which is duplicate of unwrap_or(false)

* Update client/consensus/epochs/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Update client/consensus/epochs/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* No trailing ; for return statement

* Use VERSION_KEY for migration

* Fix issues that removed nodes are not properly added into removed list

* Add comments indicating end_slot is non-inclusive

* fork-tree: use &mut F for map type declaration

* Add tests for v0 epoch_changes migration

* Fix babe RPC tests

Co-authored-by: André Silva <andre.beat@gmail.com>
This commit is contained in:
Wei Tang
2020-03-16 22:06:13 +01:00
committed by GitHub
parent abe391a0a7
commit 846a9ce8c6
10 changed files with 764 additions and 212 deletions
+2 -3
View File
@@ -509,12 +509,11 @@ mod tests {
service.transaction_pool()
);
let epoch = babe_link.epoch_changes().lock().epoch_for_child_of(
let epoch_descriptor = babe_link.epoch_changes().lock().epoch_descriptor_for_child_of(
descendent_query(&*service.client()),
&parent_hash,
parent_number,
slot_num,
|slot| babe_link.config().genesis_epoch(slot)
).unwrap().unwrap();
let mut digest = Digest::<H256>::default();
@@ -564,7 +563,7 @@ mod tests {
params.body = Some(new_body);
params.intermediates.insert(
Cow::from(INTERMEDIATE_KEY),
Box::new(BabeIntermediate { epoch }) as Box<dyn Any>,
Box::new(BabeIntermediate::<Block> { epoch_descriptor }) as Box<dyn Any>,
);
params.fork_choice = Some(ForkChoiceStrategy::LongestChain);