Skip to content

Commit

Permalink
Limit number of headers that are pruned within single import Call (pa…
Browse files Browse the repository at this point in the history
…ritytech#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 <[email protected]>
  • Loading branch information
2 people authored and serban300 committed Apr 8, 2024
1 parent de524c8 commit cd68df1
Show file tree
Hide file tree
Showing 2 changed files with 295 additions and 43 deletions.
20 changes: 16 additions & 4 deletions bridges/modules/ethereum/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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
Expand All @@ -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,
},
);
});
}
}
Loading

0 comments on commit cd68df1

Please sign in to comment.