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:
Michael Sproul
2021-12-21 08:23:17 +00:00
parent a290a3c537
commit 3b61ac9cbf
26 changed files with 963 additions and 566 deletions
@@ -830,11 +830,7 @@ fn block_gossip_verification() {
fn verify_block_for_gossip_slashing_detection() {
let slasher_dir = tempdir().unwrap();
let slasher = Arc::new(
Slasher::open(
SlasherConfig::new(slasher_dir.path().into()).for_testing(),
test_logger(),
)
.unwrap(),
Slasher::open(SlasherConfig::new(slasher_dir.path().into()), test_logger()).unwrap(),
);
let inner_slasher = slasher.clone();
+9 -1
View File
@@ -515,12 +515,20 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
Arg::with_name("slasher-max-db-size")
.long("slasher-max-db-size")
.help(
"Maximum size of the LMDB database used by the slasher."
"Maximum size of the MDBX database used by the slasher."
)
.value_name("GIGABYTES")
.requires("slasher")
.takes_value(true)
)
.arg(
Arg::with_name("slasher-att-cache-size")
.long("slasher-att-cache-size")
.help("Set the maximum number of attestation roots for the slasher to cache")
.value_name("COUNT")
.requires("slasher")
.takes_value(true)
)
.arg(
Arg::with_name("slasher-chunk-size")
.long("slasher-chunk-size")
+6
View File
@@ -510,6 +510,12 @@ pub fn get_config<E: EthSpec>(
slasher_config.max_db_size_mbs = max_db_size_gbs * 1024;
}
if let Some(attestation_cache_size) =
clap_utils::parse_optional(cli_args, "slasher-att-cache-size")?
{
slasher_config.attestation_root_cache_size = attestation_cache_size;
}
if let Some(chunk_size) = clap_utils::parse_optional(cli_args, "slasher-chunk-size")? {
slasher_config.chunk_size = chunk_size;
}