Limit number of headers that are pruned within single import Call (#105)

* removeInMemoryStorage + extract Kovan stuff to runtime

* removed comment from the future

* limit number of headers that are pruned within single import Call

* verify that pruning range upper bottom is always-increasing

* Fix typo

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
This commit is contained in:
Svyatoslav Nikolsky
2020-06-03 01:17:16 +03:00
committed by Bastian Köcher
parent 3ebaf0548d
commit 944859319e
2 changed files with 295 additions and 43 deletions
+16 -4
View File
@@ -171,7 +171,7 @@ mod tests {
validator, validators, validators_addresses, TestRuntime,
};
use crate::validators::ValidatorsSource;
use crate::{BridgeStorage, Headers, OldestUnprunedBlock};
use crate::{BlocksToPrune, BridgeStorage, Headers, PruningRange};
use frame_support::{StorageMap, StorageValue};
#[test]
@@ -264,7 +264,7 @@ mod tests {
}
#[test]
fn headers_are_pruned() {
fn headers_are_pruned_during_import() {
custom_test_ext(genesis(), validators_addresses(3)).execute_with(|| {
let validators_config =
ValidatorsConfiguration::Single(ValidatorsSource::Contract([3; 20].into(), validators_addresses(3)));
@@ -354,7 +354,13 @@ mod tests {
latest_block_hash = rolling_last_block_hash;
step += 3;
}
assert_eq!(OldestUnprunedBlock::get(), 11);
assert_eq!(
BlocksToPrune::get(),
PruningRange {
oldest_unpruned_block: 11,
oldest_block_to_keep: 14,
},
);
// now let's insert block signed by validator 1
// => blocks 11..24 are finalized and blocks 11..14 are pruned
@@ -380,7 +386,13 @@ mod tests {
)
.unwrap();
assert_eq!(finalized_blocks, expected_blocks);
assert_eq!(OldestUnprunedBlock::get(), 15);
assert_eq!(
BlocksToPrune::get(),
PruningRange {
oldest_unpruned_block: 15,
oldest_block_to_keep: 15,
},
);
});
}
}