mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
Misc changes for merge testnets (#2667)
* Thread eth1_block_hash into interop genesis state * Add merge-fork-epoch flag * Build LH with minimal spec by default * Add verbose logs to execution_layer * Add --http-allow-sync-stalled flag * Update lcli new-testnet to create genesis state * Fix http test * Fix compile errors in tests
This commit is contained in:
@@ -97,6 +97,7 @@ pub struct Config {
|
||||
pub allow_origin: Option<String>,
|
||||
pub serve_legacy_spec: bool,
|
||||
pub tls_config: Option<TlsConfig>,
|
||||
pub allow_sync_stalled: bool,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -108,6 +109,7 @@ impl Default for Config {
|
||||
allow_origin: None,
|
||||
serve_legacy_spec: true,
|
||||
tls_config: None,
|
||||
allow_sync_stalled: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,6 +239,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
shutdown: impl Future<Output = ()> + Send + Sync + 'static,
|
||||
) -> Result<HttpServer, Error> {
|
||||
let config = ctx.config.clone();
|
||||
let allow_sync_stalled = config.allow_sync_stalled;
|
||||
let log = ctx.log.clone();
|
||||
|
||||
// Configure CORS.
|
||||
@@ -338,44 +341,49 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
});
|
||||
|
||||
// Create a `warp` filter that rejects request whilst the node is syncing.
|
||||
let not_while_syncing_filter = warp::any()
|
||||
.and(network_globals.clone())
|
||||
.and(chain_filter.clone())
|
||||
.and_then(
|
||||
|network_globals: Arc<NetworkGlobals<T::EthSpec>>, chain: Arc<BeaconChain<T>>| async move {
|
||||
match *network_globals.sync_state.read() {
|
||||
SyncState::SyncingFinalized { .. } => {
|
||||
let head_slot = chain.best_slot().map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
let not_while_syncing_filter =
|
||||
warp::any()
|
||||
.and(network_globals.clone())
|
||||
.and(chain_filter.clone())
|
||||
.and_then(
|
||||
move |network_globals: Arc<NetworkGlobals<T::EthSpec>>,
|
||||
chain: Arc<BeaconChain<T>>| async move {
|
||||
match *network_globals.sync_state.read() {
|
||||
SyncState::SyncingFinalized { .. } => {
|
||||
let head_slot = chain
|
||||
.best_slot()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
|
||||
let current_slot = chain
|
||||
.slot_clock
|
||||
.now_or_genesis()
|
||||
.ok_or_else(|| {
|
||||
warp_utils::reject::custom_server_error(
|
||||
"unable to read slot clock".to_string(),
|
||||
)
|
||||
})?;
|
||||
let current_slot =
|
||||
chain.slot_clock.now_or_genesis().ok_or_else(|| {
|
||||
warp_utils::reject::custom_server_error(
|
||||
"unable to read slot clock".to_string(),
|
||||
)
|
||||
})?;
|
||||
|
||||
let tolerance = SYNC_TOLERANCE_EPOCHS * T::EthSpec::slots_per_epoch();
|
||||
let tolerance = SYNC_TOLERANCE_EPOCHS * T::EthSpec::slots_per_epoch();
|
||||
|
||||
if head_slot + tolerance >= current_slot {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(warp_utils::reject::not_synced(format!(
|
||||
"head slot is {}, current slot is {}",
|
||||
head_slot, current_slot
|
||||
)))
|
||||
if head_slot + tolerance >= current_slot {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(warp_utils::reject::not_synced(format!(
|
||||
"head slot is {}, current slot is {}",
|
||||
head_slot, current_slot
|
||||
)))
|
||||
}
|
||||
}
|
||||
SyncState::SyncingHead { .. }
|
||||
| SyncState::SyncTransition
|
||||
| SyncState::BackFillSyncing { .. } => Ok(()),
|
||||
SyncState::Synced => Ok(()),
|
||||
SyncState::Stalled if allow_sync_stalled => Ok(()),
|
||||
SyncState::Stalled => Err(warp_utils::reject::not_synced(
|
||||
"sync is stalled".to_string(),
|
||||
)),
|
||||
}
|
||||
SyncState::SyncingHead { .. } | SyncState::SyncTransition | SyncState::BackFillSyncing { .. } => Ok(()),
|
||||
SyncState::Synced => Ok(()),
|
||||
SyncState::Stalled => Err(warp_utils::reject::not_synced(
|
||||
"sync is stalled".to_string(),
|
||||
)),
|
||||
}
|
||||
},
|
||||
)
|
||||
.untuple_one();
|
||||
},
|
||||
)
|
||||
.untuple_one();
|
||||
|
||||
// Create a `warp` filter that provides access to the logger.
|
||||
let inner_ctx = ctx.clone();
|
||||
|
||||
Reference in New Issue
Block a user