Skip to content

Commit

Permalink
Development feature flag - Disable backfill (#4537)
Browse files Browse the repository at this point in the history
Often when testing I have to create a hack which is annoying to maintain. 

I think it might be handy to add a custom compile-time flag that developers can use if they want to test things locally without having to backfill a bunch of blocks.

There is probably an argument to have a feature called "backfill" which is enabled by default and can be disabled. I didn't go this route because I think it's counter-intuitive to have a feature that enables a core and necessary behaviour.
  • Loading branch information
AgeManning committed Jul 31, 2023
1 parent 117802c commit 8654f20
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion beacon_node/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ operation_pool = { path = "../operation_pool" }
execution_layer = { path = "../execution_layer" }
beacon_processor = { path = "../beacon_processor" }
parking_lot = "0.12.0"
environment = { path = "../../lighthouse/environment" }
environment = { path = "../../lighthouse/environment" }

[features]
# NOTE: This can be run via cargo build --bin lighthouse --features network/disable-backfill
disable-backfill = []
6 changes: 6 additions & 0 deletions beacon_node/network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ impl<T: BeaconChainTypes> NetworkService<T> {
// build the channels for external comms
let (network_senders, network_recievers) = NetworkSenders::new();

#[cfg(feature = "disable-backfill")]
warn!(
network_log,
"Backfill is disabled. DO NOT RUN IN PRODUCTION"
);

// try and construct UPnP port mappings if required.
if let Some(upnp_config) = crate::nat::UPnPConfig::from_config(config) {
let upnp_log = network_log.new(o!("service" => "UPnP"));
Expand Down
3 changes: 3 additions & 0 deletions beacon_node/network/src/sync/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {

// If we would otherwise be synced, first check if we need to perform or
// complete a backfill sync.
#[cfg(not(feature = "disable_backfill"))]
if matches!(sync_state, SyncState::Synced) {
// Determine if we need to start/resume/restart a backfill sync.
match self.backfill_sync.start(&mut self.network) {
Expand All @@ -419,6 +420,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
}
Some((RangeSyncType::Finalized, start_slot, target_slot)) => {
// If there is a backfill sync in progress pause it.
#[cfg(not(feature = "disable_backfill"))]
self.backfill_sync.pause();

SyncState::SyncingFinalized {
Expand All @@ -428,6 +430,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
}
Some((RangeSyncType::Head, start_slot, target_slot)) => {
// If there is a backfill sync in progress pause it.
#[cfg(not(feature = "disable_backfill"))]
self.backfill_sync.pause();

SyncState::SyncingHead {
Expand Down

0 comments on commit 8654f20

Please sign in to comment.