mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
Optimise slasher DB layout and switch to MDBX (#2776)
## Issue Addressed Closes #2286 Closes #2538 Closes #2342 ## Proposed Changes Part II of major slasher optimisations after #2767 These changes will be backwards-incompatible due to the move to MDBX (and the schema change) 😱 * [x] Shrink attester keys from 16 bytes to 7 bytes. * [x] Shrink attester records from 64 bytes to 6 bytes. * [x] Separate `DiskConfig` from regular `Config`. * [x] Add configuration for the LRU cache size. * [x] Add a "migration" that deletes any legacy LMDB database.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
use logging::test_logger;
|
||||
use slasher::{test_utils::indexed_att, Config, Error, Slasher};
|
||||
use slasher::{test_utils::indexed_att, Config, Slasher};
|
||||
use tempfile::tempdir;
|
||||
use types::Epoch;
|
||||
|
||||
#[test]
|
||||
fn attestation_pruning_empty_wrap_around() {
|
||||
let tempdir = tempdir().unwrap();
|
||||
let mut config = Config::new(tempdir.path().into()).for_testing();
|
||||
let mut config = Config::new(tempdir.path().into());
|
||||
config.validator_chunk_size = 1;
|
||||
config.chunk_size = 16;
|
||||
config.history_length = 16;
|
||||
@@ -35,53 +35,3 @@ fn attestation_pruning_empty_wrap_around() {
|
||||
));
|
||||
slasher.process_queued(current_epoch).unwrap();
|
||||
}
|
||||
|
||||
// Test that pruning can recover from a `MapFull` error
|
||||
#[test]
|
||||
fn pruning_with_map_full() {
|
||||
let tempdir = tempdir().unwrap();
|
||||
let mut config = Config::new(tempdir.path().into()).for_testing();
|
||||
config.validator_chunk_size = 1;
|
||||
config.chunk_size = 16;
|
||||
config.history_length = 1024;
|
||||
config.max_db_size_mbs = 1;
|
||||
|
||||
let slasher = Slasher::open(config, test_logger()).unwrap();
|
||||
|
||||
let v = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
|
||||
let mut current_epoch = Epoch::new(0);
|
||||
|
||||
loop {
|
||||
slasher.accept_attestation(indexed_att(
|
||||
v.clone(),
|
||||
(current_epoch - 1).as_u64(),
|
||||
current_epoch.as_u64(),
|
||||
0,
|
||||
));
|
||||
if let Err(Error::DatabaseError(lmdb::Error::MapFull)) =
|
||||
slasher.process_queued(current_epoch)
|
||||
{
|
||||
break;
|
||||
}
|
||||
current_epoch += 1;
|
||||
}
|
||||
|
||||
loop {
|
||||
slasher.prune_database(current_epoch).unwrap();
|
||||
|
||||
slasher.accept_attestation(indexed_att(
|
||||
v.clone(),
|
||||
(current_epoch - 1).as_u64(),
|
||||
current_epoch.as_u64(),
|
||||
0,
|
||||
));
|
||||
match slasher.process_queued(current_epoch) {
|
||||
Ok(_) => break,
|
||||
Err(Error::DatabaseError(lmdb::Error::MapFull)) => {
|
||||
current_epoch += 1;
|
||||
}
|
||||
Err(e) => panic!("{:?}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user