diff --git a/beacon_node/client/src/builder.rs b/beacon_node/client/src/builder.rs index cbffed970..737cd072e 100644 --- a/beacon_node/client/src/builder.rs +++ b/beacon_node/client/src/builder.rs @@ -594,6 +594,8 @@ where eth1_service_from_genesis.drop_block_cache(); CachingEth1Backend::from_service(eth1_service_from_genesis) + } else if config.purge_cache { + CachingEth1Backend::new(config, context.log().clone(), spec) } else { beacon_chain_builder .get_persisted_eth1_backend()? diff --git a/beacon_node/eth1/src/service.rs b/beacon_node/eth1/src/service.rs index 6b23a43a4..faef1cf3e 100644 --- a/beacon_node/eth1/src/service.rs +++ b/beacon_node/eth1/src/service.rs @@ -343,6 +343,8 @@ pub struct Config { pub max_log_requests_per_update: Option, /// The maximum number of log requests per update. pub max_blocks_per_update: Option, + /// If set to true, the eth1 caches are wiped clean when the eth1 service starts. + pub purge_cache: bool, } impl Config { @@ -386,6 +388,7 @@ impl Default for Config { blocks_per_log_query: 1_000, max_log_requests_per_update: Some(100), max_blocks_per_update: Some(8_192), + purge_cache: false, } } } diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index c5d2cf4c6..f89579cf8 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -281,6 +281,13 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Defaults to http://127.0.0.1:8545.") .takes_value(true) ) + .arg( + Arg::with_name("eth1-purge-cache") + .long("eth1-purge-cache") + .value_name("PURGE-CACHE") + .help("Purges the eth1 block and deposit caches") + .takes_value(false) + ) .arg( Arg::with_name("eth1-blocks-per-log-query") .long("eth1-blocks-per-log-query") diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index 926ff54cc..d70ab8e46 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -183,6 +183,10 @@ pub fn get_config( .map_err(|_| "eth1-blocks-per-log-query is not a valid integer".to_string())?; } + if cli_args.is_present("eth1-purge-cache") { + client_config.eth1.purge_cache = true; + } + if let Some(freezer_dir) = cli_args.value_of("freezer-dir") { client_config.freezer_db_path = Some(PathBuf::from(freezer_dir)); }