mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Improve UX whilst VC is waiting for genesis (#1915)
## Issue Addressed - Resolves #1424 ## Proposed Changes Add a `GET lighthouse/staking` that returns 200 if the node is ready to stake (i.e., `--eth1` flag is present) or a 404 otherwise. Whilst the VC is waiting for the genesis time to start (i.e., when the genesis state is known), check the `lighthouse/staking` endpoint and log an error if the node isn't configured for staking. ## Additional Info NA
This commit is contained in:
@@ -2147,7 +2147,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.and(warp::path::param::<StateId>())
|
||||
.and(warp::path("ssz"))
|
||||
.and(warp::path::end())
|
||||
.and(chain_filter)
|
||||
.and(chain_filter.clone())
|
||||
.and_then(|state_id: StateId, chain: Arc<BeaconChain<T>>| {
|
||||
blocking_task(move || {
|
||||
let state = state_id.state(&chain)?;
|
||||
@@ -2164,6 +2164,25 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
})
|
||||
});
|
||||
|
||||
// GET lighthouse/staking
|
||||
let get_lighthouse_staking = warp::path("lighthouse")
|
||||
.and(warp::path("staking"))
|
||||
.and(warp::path::end())
|
||||
.and(chain_filter)
|
||||
.and_then(|chain: Arc<BeaconChain<T>>| {
|
||||
blocking_json_task(move || {
|
||||
if chain.eth1_chain.is_some() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(warp_utils::reject::custom_not_found(
|
||||
"staking is not enabled, \
|
||||
see the --staking CLI flag"
|
||||
.to_string(),
|
||||
))
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// Define the ultimate set of routes that will be provided to the server.
|
||||
let routes = warp::get()
|
||||
.and(
|
||||
@@ -2211,7 +2230,8 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.or(get_lighthouse_eth1_syncing.boxed())
|
||||
.or(get_lighthouse_eth1_block_cache.boxed())
|
||||
.or(get_lighthouse_eth1_deposit_cache.boxed())
|
||||
.or(get_lighthouse_beacon_states_ssz.boxed()),
|
||||
.or(get_lighthouse_beacon_states_ssz.boxed())
|
||||
.or(get_lighthouse_staking.boxed()),
|
||||
)
|
||||
.or(warp::post().and(
|
||||
post_beacon_blocks
|
||||
|
||||
Reference in New Issue
Block a user