mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-16 12:28:24 +00:00
Anchor pre-PR: Dependency cleanup (#6769)
* remove ensure_dir_exists (2 deps saved) * group UNHANDLED_ERRORs into a generic (2 deps saved) * Introduce separate `health_metrics` crate * separate health_metrics crate * remove metrics from warp_utils * move ProcessHealth::observe and SystemHealth::observe to health_metrics * fix errors * nitpick `Cargo.toml`s --------- Co-authored-by: Daniel Knopik <daniel@dknopik.de> --------- Co-authored-by: ThreeHrSleep <151536303+ThreeHrSleep@users.noreply.github.com>
This commit is contained in:
@@ -690,9 +690,9 @@ impl<T: BeaconChainTypes> BeaconBlockStreamer<T> {
|
||||
async fn send_errors<E: EthSpec>(
|
||||
block_roots: Vec<Hash256>,
|
||||
sender: UnboundedSender<(Hash256, Arc<BlockResult<E>>)>,
|
||||
beacon_chain_error: BeaconChainError,
|
||||
unhandled_error: BeaconChainError,
|
||||
) {
|
||||
let result = Arc::new(Err(beacon_chain_error));
|
||||
let result = Arc::new(Err(unhandled_error));
|
||||
for root in block_roots {
|
||||
if sender.send((root, result.clone())).is_err() {
|
||||
break;
|
||||
|
||||
@@ -17,6 +17,7 @@ ethereum_serde_utils = { workspace = true }
|
||||
ethereum_ssz = { workspace = true }
|
||||
execution_layer = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
health_metrics = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
lighthouse_network = { workspace = true }
|
||||
lighthouse_version = { workspace = true }
|
||||
|
||||
@@ -7,7 +7,7 @@ use state_processing::{
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use types::{BeaconState, BeaconStateError, EthSpec, Hash256};
|
||||
use warp_utils::reject::{beacon_chain_error, custom_bad_request, custom_server_error};
|
||||
use warp_utils::reject::{custom_bad_request, custom_server_error, unhandled_error};
|
||||
|
||||
const MAX_REQUEST_RANGE_EPOCHS: usize = 100;
|
||||
const BLOCK_ROOT_CHUNK_SIZE: usize = 100;
|
||||
@@ -50,7 +50,7 @@ pub fn get_attestation_performance<T: BeaconChainTypes>(
|
||||
let end_slot = end_epoch.end_slot(T::EthSpec::slots_per_epoch());
|
||||
|
||||
// Ensure end_epoch is smaller than the current epoch - 1.
|
||||
let current_epoch = chain.epoch().map_err(beacon_chain_error)?;
|
||||
let current_epoch = chain.epoch().map_err(unhandled_error)?;
|
||||
if query.end_epoch >= current_epoch - 1 {
|
||||
return Err(custom_bad_request(format!(
|
||||
"end_epoch must be less than the current epoch - 1. current: {}, end: {}",
|
||||
@@ -83,7 +83,7 @@ pub fn get_attestation_performance<T: BeaconChainTypes>(
|
||||
let index_range = if target.to_lowercase() == "global" {
|
||||
chain
|
||||
.with_head(|head| Ok((0..head.beacon_state.validators().len() as u64).collect()))
|
||||
.map_err(beacon_chain_error)?
|
||||
.map_err(unhandled_error::<BeaconChainError>)?
|
||||
} else {
|
||||
vec![target.parse::<u64>().map_err(|_| {
|
||||
custom_bad_request(format!(
|
||||
@@ -96,10 +96,10 @@ pub fn get_attestation_performance<T: BeaconChainTypes>(
|
||||
// Load block roots.
|
||||
let mut block_roots: Vec<Hash256> = chain
|
||||
.forwards_iter_block_roots_until(start_slot, end_slot)
|
||||
.map_err(beacon_chain_error)?
|
||||
.map_err(unhandled_error)?
|
||||
.map(|res| res.map(|(root, _)| root))
|
||||
.collect::<Result<Vec<Hash256>, _>>()
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
block_roots.dedup();
|
||||
|
||||
// Load first block so we can get its parent.
|
||||
@@ -113,7 +113,7 @@ pub fn get_attestation_performance<T: BeaconChainTypes>(
|
||||
.and_then(|maybe_block| {
|
||||
maybe_block.ok_or(BeaconChainError::MissingBeaconBlock(*first_block_root))
|
||||
})
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
|
||||
// Load the block of the prior slot which will be used to build the starting state.
|
||||
let prior_block = chain
|
||||
@@ -122,14 +122,14 @@ pub fn get_attestation_performance<T: BeaconChainTypes>(
|
||||
maybe_block
|
||||
.ok_or_else(|| BeaconChainError::MissingBeaconBlock(first_block.parent_root()))
|
||||
})
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
|
||||
// Load state for block replay.
|
||||
let state_root = prior_block.state_root();
|
||||
let state = chain
|
||||
.get_state(&state_root, Some(prior_slot))
|
||||
.and_then(|maybe_state| maybe_state.ok_or(BeaconChainError::MissingBeaconState(state_root)))
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
|
||||
// Allocate an AttestationPerformance vector for each validator in the range.
|
||||
let mut perfs: Vec<AttestationPerformance> =
|
||||
@@ -198,7 +198,7 @@ pub fn get_attestation_performance<T: BeaconChainTypes>(
|
||||
.and_then(|maybe_block| {
|
||||
maybe_block.ok_or(BeaconChainError::MissingBeaconBlock(*root))
|
||||
})
|
||||
.map_err(beacon_chain_error)
|
||||
.map_err(unhandled_error)
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
|
||||
@@ -16,9 +16,7 @@ pub fn attester_duties<T: BeaconChainTypes>(
|
||||
request_indices: &[u64],
|
||||
chain: &BeaconChain<T>,
|
||||
) -> Result<ApiDuties, warp::reject::Rejection> {
|
||||
let current_epoch = chain
|
||||
.epoch()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
let current_epoch = chain.epoch().map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
// Determine what the current epoch would be if we fast-forward our system clock by
|
||||
// `MAXIMUM_GOSSIP_CLOCK_DISPARITY`.
|
||||
@@ -57,7 +55,7 @@ fn cached_attestation_duties<T: BeaconChainTypes>(
|
||||
|
||||
let (duties, dependent_root, execution_status) = chain
|
||||
.validator_attestation_duties(request_indices, request_epoch, head_block_root)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
convert_to_api_response(
|
||||
duties,
|
||||
@@ -82,7 +80,7 @@ fn compute_historic_attester_duties<T: BeaconChainTypes>(
|
||||
let (cached_head, execution_status) = chain
|
||||
.canonical_head
|
||||
.head_and_execution_status()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
let head = &cached_head.snapshot;
|
||||
|
||||
if head.beacon_state.current_epoch() <= request_epoch {
|
||||
@@ -131,13 +129,13 @@ fn compute_historic_attester_duties<T: BeaconChainTypes>(
|
||||
state
|
||||
.build_committee_cache(relative_epoch, &chain.spec)
|
||||
.map_err(BeaconChainError::from)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
let dependent_root = state
|
||||
// The only block which decides its own shuffling is the genesis block.
|
||||
.attester_shuffling_decision_root(chain.genesis_block_root, relative_epoch)
|
||||
.map_err(BeaconChainError::from)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
let duties = request_indices
|
||||
.iter()
|
||||
@@ -147,7 +145,7 @@ fn compute_historic_attester_duties<T: BeaconChainTypes>(
|
||||
.map_err(BeaconChainError::from)
|
||||
})
|
||||
.collect::<Result<_, _>>()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
convert_to_api_response(
|
||||
duties,
|
||||
@@ -181,7 +179,7 @@ fn ensure_state_knows_attester_duties_for_epoch<E: EthSpec>(
|
||||
// A "partial" state advance is adequate since attester duties don't rely on state roots.
|
||||
partial_state_advance(state, Some(state_root), target_slot, spec)
|
||||
.map_err(BeaconChainError::from)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -208,7 +206,7 @@ fn convert_to_api_response<T: BeaconChainTypes>(
|
||||
let usize_indices = indices.iter().map(|i| *i as usize).collect::<Vec<_>>();
|
||||
let index_to_pubkey_map = chain
|
||||
.validator_pubkey_bytes_many(&usize_indices)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
let data = duties
|
||||
.into_iter()
|
||||
|
||||
@@ -38,7 +38,7 @@ impl BlockId {
|
||||
let (cached_head, execution_status) = chain
|
||||
.canonical_head
|
||||
.head_and_execution_status()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
Ok((
|
||||
cached_head.head_block_root(),
|
||||
execution_status.is_optimistic_or_invalid(),
|
||||
@@ -63,10 +63,10 @@ impl BlockId {
|
||||
CoreBlockId::Slot(slot) => {
|
||||
let execution_optimistic = chain
|
||||
.is_optimistic_or_invalid_head()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
let root = chain
|
||||
.block_root_at_slot(*slot, WhenSlotSkipped::None)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)
|
||||
.map_err(warp_utils::reject::unhandled_error)
|
||||
.and_then(|root_opt| {
|
||||
root_opt.ok_or_else(|| {
|
||||
warp_utils::reject::custom_not_found(format!(
|
||||
@@ -96,17 +96,17 @@ impl BlockId {
|
||||
.store
|
||||
.block_exists(root)
|
||||
.map_err(BeaconChainError::DBError)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.map_err(warp_utils::reject::unhandled_error)?
|
||||
{
|
||||
let execution_optimistic = chain
|
||||
.canonical_head
|
||||
.fork_choice_read_lock()
|
||||
.is_optimistic_or_invalid_block(root)
|
||||
.map_err(BeaconChainError::ForkChoiceError)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
let blinded_block = chain
|
||||
.get_blinded_block(root)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.map_err(warp_utils::reject::unhandled_error)?
|
||||
.ok_or_else(|| {
|
||||
warp_utils::reject::custom_not_found(format!(
|
||||
"beacon block with root {}",
|
||||
@@ -116,7 +116,7 @@ impl BlockId {
|
||||
let block_slot = blinded_block.slot();
|
||||
let finalized = chain
|
||||
.is_finalized_block(root, block_slot)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
Ok((*root, execution_optimistic, finalized))
|
||||
} else {
|
||||
Err(warp_utils::reject::custom_not_found(format!(
|
||||
@@ -134,7 +134,7 @@ impl BlockId {
|
||||
) -> Result<Option<SignedBlindedBeaconBlock<T::EthSpec>>, warp::Rejection> {
|
||||
chain
|
||||
.get_blinded_block(root)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)
|
||||
.map_err(warp_utils::reject::unhandled_error)
|
||||
}
|
||||
|
||||
/// Return the `SignedBeaconBlock` identified by `self`.
|
||||
@@ -154,7 +154,7 @@ impl BlockId {
|
||||
let (cached_head, execution_status) = chain
|
||||
.canonical_head
|
||||
.head_and_execution_status()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
Ok((
|
||||
cached_head.snapshot.beacon_block.clone_as_blinded(),
|
||||
execution_status.is_optimistic_or_invalid(),
|
||||
@@ -211,7 +211,7 @@ impl BlockId {
|
||||
let (cached_head, execution_status) = chain
|
||||
.canonical_head
|
||||
.head_and_execution_status()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
Ok((
|
||||
cached_head.snapshot.beacon_block.clone(),
|
||||
execution_status.is_optimistic_or_invalid(),
|
||||
@@ -223,7 +223,7 @@ impl BlockId {
|
||||
chain
|
||||
.get_block(&root)
|
||||
.await
|
||||
.map_err(warp_utils::reject::beacon_chain_error)
|
||||
.map_err(warp_utils::reject::unhandled_error)
|
||||
.and_then(|block_opt| match block_opt {
|
||||
Some(block) => {
|
||||
if block.slot() != *slot {
|
||||
@@ -245,7 +245,7 @@ impl BlockId {
|
||||
chain
|
||||
.get_block(&root)
|
||||
.await
|
||||
.map_err(warp_utils::reject::beacon_chain_error)
|
||||
.map_err(warp_utils::reject::unhandled_error)
|
||||
.and_then(|block_opt| {
|
||||
block_opt
|
||||
.map(|block| (Arc::new(block), execution_optimistic, finalized))
|
||||
@@ -308,7 +308,7 @@ impl BlockId {
|
||||
let blob_sidecar_list = chain
|
||||
.store
|
||||
.get_blobs(&root)
|
||||
.map_err(|e| warp_utils::reject::beacon_chain_error(e.into()))?
|
||||
.map_err(|e| warp_utils::reject::unhandled_error(BeaconChainError::from(e)))?
|
||||
.ok_or_else(|| {
|
||||
warp_utils::reject::custom_not_found(format!("no blobs stored for block {root}"))
|
||||
})?;
|
||||
@@ -351,7 +351,7 @@ impl BlockId {
|
||||
|column_index| match chain.get_data_column(&root, &column_index) {
|
||||
Ok(Some(data_column)) => Some(Ok(data_column)),
|
||||
Ok(None) => None,
|
||||
Err(e) => Some(Err(warp_utils::reject::beacon_chain_error(e))),
|
||||
Err(e) => Some(Err(warp_utils::reject::unhandled_error(e))),
|
||||
},
|
||||
)
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
@@ -13,7 +13,7 @@ use types::{
|
||||
AttestationRef, BeaconCommittee, BeaconState, BeaconStateError, BlindedPayload, ChainSpec,
|
||||
Epoch, EthSpec, Hash256, OwnedBeaconCommittee, RelativeEpoch, SignedBeaconBlock, Slot,
|
||||
};
|
||||
use warp_utils::reject::{beacon_chain_error, custom_bad_request, custom_server_error};
|
||||
use warp_utils::reject::{custom_bad_request, custom_server_error, unhandled_error};
|
||||
|
||||
/// Load blocks from block roots in chunks to reduce load on memory.
|
||||
const BLOCK_ROOT_CHUNK_SIZE: usize = 100;
|
||||
@@ -263,9 +263,9 @@ pub fn get_block_packing_efficiency<T: BeaconChainTypes>(
|
||||
// Load block roots.
|
||||
let mut block_roots: Vec<Hash256> = chain
|
||||
.forwards_iter_block_roots_until(start_slot_of_prior_epoch, end_slot)
|
||||
.map_err(beacon_chain_error)?
|
||||
.map_err(unhandled_error)?
|
||||
.collect::<Result<Vec<(Hash256, Slot)>, _>>()
|
||||
.map_err(beacon_chain_error)?
|
||||
.map_err(unhandled_error)?
|
||||
.iter()
|
||||
.map(|(root, _)| *root)
|
||||
.collect();
|
||||
@@ -280,7 +280,7 @@ pub fn get_block_packing_efficiency<T: BeaconChainTypes>(
|
||||
.and_then(|maybe_block| {
|
||||
maybe_block.ok_or(BeaconChainError::MissingBeaconBlock(*first_block_root))
|
||||
})
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
|
||||
// Load state for block replay.
|
||||
let starting_state_root = first_block.state_root();
|
||||
@@ -290,7 +290,7 @@ pub fn get_block_packing_efficiency<T: BeaconChainTypes>(
|
||||
.and_then(|maybe_state| {
|
||||
maybe_state.ok_or(BeaconChainError::MissingBeaconState(starting_state_root))
|
||||
})
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
|
||||
// Initialize response vector.
|
||||
let mut response = Vec::new();
|
||||
@@ -392,7 +392,7 @@ pub fn get_block_packing_efficiency<T: BeaconChainTypes>(
|
||||
.and_then(|maybe_block| {
|
||||
maybe_block.ok_or(BeaconChainError::MissingBeaconBlock(*root))
|
||||
})
|
||||
.map_err(beacon_chain_error)
|
||||
.map_err(unhandled_error)
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::num::NonZeroUsize;
|
||||
use std::sync::Arc;
|
||||
use types::beacon_block::BlindedBeaconBlock;
|
||||
use types::non_zero_usize::new_non_zero_usize;
|
||||
use warp_utils::reject::{beacon_chain_error, beacon_state_error, custom_bad_request};
|
||||
use warp_utils::reject::{beacon_state_error, custom_bad_request, unhandled_error};
|
||||
|
||||
const STATE_CACHE_SIZE: NonZeroUsize = new_non_zero_usize(2);
|
||||
|
||||
@@ -30,23 +30,23 @@ pub fn get_block_rewards<T: BeaconChainTypes>(
|
||||
|
||||
let end_block_root = chain
|
||||
.block_root_at_slot(end_slot, WhenSlotSkipped::Prev)
|
||||
.map_err(beacon_chain_error)?
|
||||
.map_err(unhandled_error)?
|
||||
.ok_or_else(|| custom_bad_request(format!("block at end slot {} unknown", end_slot)))?;
|
||||
|
||||
let blocks = chain
|
||||
.store
|
||||
.load_blocks_to_replay(start_slot, end_slot, end_block_root)
|
||||
.map_err(|e| beacon_chain_error(e.into()))?;
|
||||
.map_err(|e| unhandled_error(BeaconChainError::from(e)))?;
|
||||
|
||||
let state_root = chain
|
||||
.state_root_at_slot(prior_slot)
|
||||
.map_err(beacon_chain_error)?
|
||||
.map_err(unhandled_error)?
|
||||
.ok_or_else(|| custom_bad_request(format!("prior state at slot {} unknown", prior_slot)))?;
|
||||
|
||||
let mut state = chain
|
||||
.get_state(&state_root, Some(prior_slot))
|
||||
.and_then(|maybe_state| maybe_state.ok_or(BeaconChainError::MissingBeaconState(state_root)))
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
|
||||
state
|
||||
.build_caches(&chain.spec)
|
||||
@@ -73,12 +73,12 @@ pub fn get_block_rewards<T: BeaconChainTypes>(
|
||||
.state_root_iter(
|
||||
chain
|
||||
.forwards_iter_state_roots_until(prior_slot, end_slot)
|
||||
.map_err(beacon_chain_error)?,
|
||||
.map_err(unhandled_error)?,
|
||||
)
|
||||
.no_signature_verification()
|
||||
.minimal_block_root_verification()
|
||||
.apply_blocks(blocks, None)
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
|
||||
if block_replayer.state_root_miss() {
|
||||
warn!(
|
||||
@@ -125,7 +125,7 @@ pub fn compute_block_rewards<T: BeaconChainTypes>(
|
||||
);
|
||||
let parent_block = chain
|
||||
.get_blinded_block(&parent_root)
|
||||
.map_err(beacon_chain_error)?
|
||||
.map_err(unhandled_error)?
|
||||
.ok_or_else(|| {
|
||||
custom_bad_request(format!(
|
||||
"parent block not known or not canonical: {:?}",
|
||||
@@ -135,7 +135,7 @@ pub fn compute_block_rewards<T: BeaconChainTypes>(
|
||||
|
||||
let parent_state = chain
|
||||
.get_state(&parent_block.state_root(), Some(parent_block.slot()))
|
||||
.map_err(beacon_chain_error)?
|
||||
.map_err(unhandled_error)?
|
||||
.ok_or_else(|| {
|
||||
custom_bad_request(format!(
|
||||
"no state known for parent block: {:?}",
|
||||
@@ -148,7 +148,7 @@ pub fn compute_block_rewards<T: BeaconChainTypes>(
|
||||
.state_root_iter([Ok((parent_block.state_root(), parent_block.slot()))].into_iter())
|
||||
.minimal_block_root_verification()
|
||||
.apply_blocks(vec![], Some(block.slot()))
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error::<BeaconChainError>)?;
|
||||
|
||||
if block_replayer.state_root_miss() {
|
||||
warn!(
|
||||
@@ -176,7 +176,7 @@ pub fn compute_block_rewards<T: BeaconChainTypes>(
|
||||
&mut reward_cache,
|
||||
true,
|
||||
)
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
block_rewards.push(block_reward);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ pub fn build_block_contents<E: EthSpec>(
|
||||
} = block;
|
||||
|
||||
let Some((kzg_proofs, blobs)) = blob_items else {
|
||||
return Err(warp_utils::reject::block_production_error(
|
||||
return Err(warp_utils::reject::unhandled_error(
|
||||
BlockProductionError::MissingBlobs,
|
||||
));
|
||||
};
|
||||
|
||||
@@ -50,6 +50,7 @@ use eth2::types::{
|
||||
ValidatorStatus, ValidatorsRequestBody,
|
||||
};
|
||||
use eth2::{CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER};
|
||||
use health_metrics::observe::Observe;
|
||||
use lighthouse_network::{types::SyncState, EnrExt, NetworkGlobals, PeerId, PubsubMessage};
|
||||
use lighthouse_version::version_with_platform;
|
||||
use logging::SSELoggingComponents;
|
||||
@@ -938,9 +939,9 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
)
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
warp_utils::reject::beacon_chain_error(e.into())
|
||||
}
|
||||
_ => warp_utils::reject::unhandled_error(
|
||||
BeaconChainError::from(e),
|
||||
),
|
||||
}
|
||||
})?;
|
||||
|
||||
@@ -1067,7 +1068,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
let validators = chain
|
||||
.validator_indices(sync_committee.pubkeys.iter())
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
let validator_aggregates = validators
|
||||
.chunks_exact(T::EthSpec::sync_subcommittee_size())
|
||||
@@ -1147,7 +1148,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let (cached_head, execution_status) = chain
|
||||
.canonical_head
|
||||
.head_and_execution_status()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
(
|
||||
cached_head.head_block_root(),
|
||||
cached_head.snapshot.beacon_block.clone_as_blinded(),
|
||||
@@ -1161,13 +1162,13 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
BlockId::from_root(parent_root).blinded_block(&chain)?;
|
||||
let (root, _slot) = chain
|
||||
.forwards_iter_block_roots(parent.slot())
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.map_err(warp_utils::reject::unhandled_error)?
|
||||
// Ignore any skip-slots immediately following the parent.
|
||||
.find(|res| {
|
||||
res.as_ref().map_or(false, |(root, _)| *root != parent_root)
|
||||
})
|
||||
.transpose()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.map_err(warp_utils::reject::unhandled_error)?
|
||||
.ok_or_else(|| {
|
||||
warp_utils::reject::custom_not_found(format!(
|
||||
"child of block with root {}",
|
||||
@@ -1248,7 +1249,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
let canonical = chain
|
||||
.block_root_at_slot(block.slot(), WhenSlotSkipped::None)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.map_err(warp_utils::reject::unhandled_error)?
|
||||
.map_or(false, |canonical| root == canonical);
|
||||
|
||||
let data = api_types::BlockHeaderData {
|
||||
@@ -2932,7 +2933,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let (head, head_execution_status) = chain
|
||||
.canonical_head
|
||||
.head_and_execution_status()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
let head_slot = head.head_slot();
|
||||
let current_slot =
|
||||
chain.slot_clock.now_or_genesis().ok_or_else(|| {
|
||||
@@ -2992,7 +2993,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.blocking_response_task(Priority::P0, move || {
|
||||
let is_optimistic = chain
|
||||
.is_optimistic_or_invalid_head()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
let is_syncing = !network_globals.sync_state.read().is_synced();
|
||||
|
||||
@@ -3300,9 +3301,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
task_spawner.blocking_json_task(Priority::P0, move || {
|
||||
not_synced_filter?;
|
||||
|
||||
let current_slot = chain
|
||||
.slot()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
let current_slot = chain.slot().map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
// allow a tolerance of one slot to account for clock skew
|
||||
if query.slot > current_slot + 1 {
|
||||
@@ -3316,7 +3315,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.produce_unaggregated_attestation(query.slot, query.committee_index)
|
||||
.map(|attestation| attestation.data().clone())
|
||||
.map(api_types::GenericResponse::from)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)
|
||||
.map_err(warp_utils::reject::unhandled_error)
|
||||
})
|
||||
},
|
||||
);
|
||||
@@ -3688,11 +3687,9 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.execution_layer
|
||||
.as_ref()
|
||||
.ok_or(BeaconChainError::ExecutionLayerMissing)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
let current_slot = chain
|
||||
.slot()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
let current_slot = chain.slot().map_err(warp_utils::reject::unhandled_error)?;
|
||||
let current_epoch = current_slot.epoch(T::EthSpec::slots_per_epoch());
|
||||
|
||||
debug!(
|
||||
@@ -3745,12 +3742,12 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.execution_layer
|
||||
.as_ref()
|
||||
.ok_or(BeaconChainError::ExecutionLayerMissing)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
let current_slot = chain
|
||||
.slot_clock
|
||||
.now_or_genesis()
|
||||
.ok_or(BeaconChainError::UnableToReadSlot)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
let current_epoch = current_slot.epoch(T::EthSpec::slots_per_epoch());
|
||||
|
||||
debug!(
|
||||
@@ -3846,12 +3843,12 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.execution_layer
|
||||
.as_ref()
|
||||
.ok_or(BeaconChainError::ExecutionLayerMissing)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.map_err(warp_utils::reject::unhandled_error)?
|
||||
.builder();
|
||||
let builder = arc_builder
|
||||
.as_ref()
|
||||
.ok_or(BeaconChainError::BuilderMissing)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
builder
|
||||
.post_builder_validators(&filtered_registration_data)
|
||||
.await
|
||||
@@ -3967,9 +3964,8 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.blocking_json_task(Priority::P0, move || {
|
||||
// Ensure the request is for either the current, previous or next epoch.
|
||||
let current_epoch = chain
|
||||
.epoch()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
let current_epoch =
|
||||
chain.epoch().map_err(warp_utils::reject::unhandled_error)?;
|
||||
let prev_epoch = current_epoch.saturating_sub(Epoch::new(1));
|
||||
let next_epoch = current_epoch.saturating_add(Epoch::new(1));
|
||||
|
||||
@@ -4008,9 +4004,8 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.blocking_json_task(Priority::P0, move || {
|
||||
// Ensure the request is for either the current, previous or next epoch.
|
||||
let current_epoch = chain
|
||||
.epoch()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
let current_epoch =
|
||||
chain.epoch().map_err(warp_utils::reject::unhandled_error)?;
|
||||
let prev_epoch = current_epoch.saturating_sub(Epoch::new(1));
|
||||
let next_epoch = current_epoch.saturating_add(Epoch::new(1));
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ pub async fn produce_blinded_block_v2<T: BeaconChainTypes>(
|
||||
BlockProductionVersion::BlindedV2,
|
||||
)
|
||||
.await
|
||||
.map_err(warp_utils::reject::block_production_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
build_response_v2(chain, block_response_type, endpoint_version, accept_header)
|
||||
}
|
||||
@@ -184,7 +184,7 @@ pub async fn produce_block_v2<T: BeaconChainTypes>(
|
||||
BlockProductionVersion::FullV2,
|
||||
)
|
||||
.await
|
||||
.map_err(warp_utils::reject::block_production_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
build_response_v2(chain, block_response_type, endpoint_version, accept_header)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ pub fn proposer_duties<T: BeaconChainTypes>(
|
||||
.now_or_genesis()
|
||||
.map(|slot| slot.epoch(T::EthSpec::slots_per_epoch()))
|
||||
.ok_or(BeaconChainError::UnableToReadSlot)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
// Determine what the current epoch would be if we fast-forward our system clock by
|
||||
// `MAXIMUM_GOSSIP_CLOCK_DISPARITY`.
|
||||
@@ -66,7 +66,7 @@ pub fn proposer_duties<T: BeaconChainTypes>(
|
||||
{
|
||||
let (proposers, dependent_root, execution_status, _fork) =
|
||||
compute_proposer_duties_from_head(request_epoch, chain)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
convert_to_api_response(
|
||||
chain,
|
||||
request_epoch,
|
||||
@@ -114,7 +114,7 @@ fn try_proposer_duties_from_cache<T: BeaconChainTypes>(
|
||||
.map_err(warp_utils::reject::beacon_state_error)?;
|
||||
let execution_optimistic = chain
|
||||
.is_optimistic_or_invalid_head_block(head_block)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
let dependent_root = match head_epoch.cmp(&request_epoch) {
|
||||
// head_epoch == request_epoch
|
||||
@@ -163,7 +163,7 @@ fn compute_and_cache_proposer_duties<T: BeaconChainTypes>(
|
||||
) -> Result<ApiDuties, warp::reject::Rejection> {
|
||||
let (indices, dependent_root, execution_status, fork) =
|
||||
compute_proposer_duties_from_head(current_epoch, chain)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
// Prime the proposer shuffling cache with the newly-learned value.
|
||||
chain
|
||||
@@ -171,7 +171,7 @@ fn compute_and_cache_proposer_duties<T: BeaconChainTypes>(
|
||||
.lock()
|
||||
.insert(current_epoch, dependent_root, indices.clone(), fork)
|
||||
.map_err(BeaconChainError::from)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
convert_to_api_response(
|
||||
chain,
|
||||
@@ -195,7 +195,7 @@ fn compute_historic_proposer_duties<T: BeaconChainTypes>(
|
||||
let (cached_head, execution_status) = chain
|
||||
.canonical_head
|
||||
.head_and_execution_status()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
let head = &cached_head.snapshot;
|
||||
|
||||
if head.beacon_state.current_epoch() <= epoch {
|
||||
@@ -214,7 +214,7 @@ fn compute_historic_proposer_duties<T: BeaconChainTypes>(
|
||||
// If we've loaded the head state it might be from a previous epoch, ensure it's in a
|
||||
// suitable epoch.
|
||||
ensure_state_is_in_epoch(&mut state, state_root, epoch, &chain.spec)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
(state, execution_optimistic)
|
||||
} else {
|
||||
let (state, execution_optimistic, _finalized) =
|
||||
@@ -234,14 +234,14 @@ fn compute_historic_proposer_duties<T: BeaconChainTypes>(
|
||||
let indices = state
|
||||
.get_beacon_proposer_indices(&chain.spec)
|
||||
.map_err(BeaconChainError::from)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
// We can supply the genesis block root as the block root since we know that the only block that
|
||||
// decides its own root is the genesis block.
|
||||
let dependent_root = state
|
||||
.proposer_shuffling_decision_root(chain.genesis_block_root)
|
||||
.map_err(BeaconChainError::from)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
convert_to_api_response(chain, epoch, dependent_root, execution_optimistic, indices)
|
||||
}
|
||||
@@ -257,7 +257,7 @@ fn convert_to_api_response<T: BeaconChainTypes>(
|
||||
) -> Result<ApiDuties, warp::reject::Rejection> {
|
||||
let index_to_pubkey_map = chain
|
||||
.validator_pubkey_bytes_many(&indices)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
// Map our internal data structure into the API structure.
|
||||
let proposer_data = indices
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::ExecutionOptimistic;
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
||||
use eth2::lighthouse::StandardBlockReward;
|
||||
use std::sync::Arc;
|
||||
use warp_utils::reject::beacon_chain_error;
|
||||
use warp_utils::reject::unhandled_error;
|
||||
/// The difference between block_rewards and beacon_block_rewards is the later returns block
|
||||
/// reward format that satisfies beacon-api specs
|
||||
pub fn compute_beacon_block_rewards<T: BeaconChainTypes>(
|
||||
@@ -19,7 +19,7 @@ pub fn compute_beacon_block_rewards<T: BeaconChainTypes>(
|
||||
|
||||
let rewards = chain
|
||||
.compute_beacon_block_reward(block_ref, &mut state)
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
|
||||
Ok((rewards, execution_optimistic, finalized))
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ impl StateId {
|
||||
let (cached_head, execution_status) = chain
|
||||
.canonical_head
|
||||
.head_and_execution_status()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
return Ok((
|
||||
cached_head.head_state_root(),
|
||||
execution_status.is_optimistic_or_invalid(),
|
||||
@@ -56,7 +56,7 @@ impl StateId {
|
||||
*slot,
|
||||
chain
|
||||
.is_optimistic_or_invalid_head()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?,
|
||||
.map_err(warp_utils::reject::unhandled_error)?,
|
||||
*slot
|
||||
<= chain
|
||||
.canonical_head
|
||||
@@ -70,11 +70,11 @@ impl StateId {
|
||||
.store
|
||||
.load_hot_state_summary(root)
|
||||
.map_err(BeaconChainError::DBError)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.map_err(warp_utils::reject::unhandled_error)?
|
||||
{
|
||||
let finalization_status = chain
|
||||
.state_finalization_and_canonicity(root, hot_summary.slot)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
let finalized = finalization_status.is_finalized();
|
||||
let fork_choice = chain.canonical_head.fork_choice_read_lock();
|
||||
let execution_optimistic = if finalization_status.slot_is_finalized
|
||||
@@ -94,14 +94,14 @@ impl StateId {
|
||||
fork_choice
|
||||
.is_optimistic_or_invalid_block(&hot_summary.latest_block_root)
|
||||
.map_err(BeaconChainError::ForkChoiceError)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.map_err(warp_utils::reject::unhandled_error)?
|
||||
};
|
||||
return Ok((*root, execution_optimistic, finalized));
|
||||
} else if let Some(_cold_state_slot) = chain
|
||||
.store
|
||||
.load_cold_state_slot(root)
|
||||
.map_err(BeaconChainError::DBError)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.map_err(warp_utils::reject::unhandled_error)?
|
||||
{
|
||||
let fork_choice = chain.canonical_head.fork_choice_read_lock();
|
||||
let finalized_root = fork_choice
|
||||
@@ -111,7 +111,7 @@ impl StateId {
|
||||
let execution_optimistic = fork_choice
|
||||
.is_optimistic_or_invalid_block_no_fallback(&finalized_root)
|
||||
.map_err(BeaconChainError::ForkChoiceError)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
return Ok((*root, execution_optimistic, true));
|
||||
} else {
|
||||
return Err(warp_utils::reject::custom_not_found(format!(
|
||||
@@ -124,7 +124,7 @@ impl StateId {
|
||||
|
||||
let root = chain
|
||||
.state_root_at_slot(slot)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.map_err(warp_utils::reject::unhandled_error)?
|
||||
.ok_or_else(|| {
|
||||
warp_utils::reject::custom_not_found(format!("beacon state at slot {}", slot))
|
||||
})?;
|
||||
@@ -178,7 +178,7 @@ impl StateId {
|
||||
let (cached_head, execution_status) = chain
|
||||
.canonical_head
|
||||
.head_and_execution_status()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
return Ok((
|
||||
cached_head.snapshot.beacon_state.clone(),
|
||||
execution_status.is_optimistic_or_invalid(),
|
||||
@@ -191,7 +191,7 @@ impl StateId {
|
||||
|
||||
let state = chain
|
||||
.get_state(&state_root, slot_opt)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)
|
||||
.map_err(warp_utils::reject::unhandled_error)
|
||||
.and_then(|opt| {
|
||||
opt.ok_or_else(|| {
|
||||
warp_utils::reject::custom_not_found(format!(
|
||||
@@ -224,7 +224,7 @@ impl StateId {
|
||||
let (head, execution_status) = chain
|
||||
.canonical_head
|
||||
.head_and_execution_status()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
return func(
|
||||
&head.snapshot.beacon_state,
|
||||
execution_status.is_optimistic_or_invalid(),
|
||||
@@ -273,7 +273,7 @@ pub fn checkpoint_slot_and_execution_optimistic<T: BeaconChainTypes>(
|
||||
let execution_optimistic = fork_choice
|
||||
.is_optimistic_or_invalid_block_no_fallback(root)
|
||||
.map_err(BeaconChainError::ForkChoiceError)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
Ok((slot, execution_optimistic))
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use slog::{debug, Logger};
|
||||
use state_processing::BlockReplayer;
|
||||
use std::sync::Arc;
|
||||
use types::{BeaconState, SignedBlindedBeaconBlock};
|
||||
use warp_utils::reject::{beacon_chain_error, custom_not_found};
|
||||
use warp_utils::reject::{custom_not_found, unhandled_error};
|
||||
|
||||
pub fn compute_sync_committee_rewards<T: BeaconChainTypes>(
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
@@ -20,7 +20,7 @@ pub fn compute_sync_committee_rewards<T: BeaconChainTypes>(
|
||||
|
||||
let reward_payload = chain
|
||||
.compute_sync_committee_rewards(block.message(), &mut state)
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
|
||||
let data = if reward_payload.is_empty() {
|
||||
debug!(log, "compute_sync_committee_rewards returned empty");
|
||||
@@ -71,7 +71,7 @@ pub fn get_state_before_applying_block<T: BeaconChainTypes>(
|
||||
.state_root_iter([Ok((parent_block.state_root(), parent_block.slot()))].into_iter())
|
||||
.minimal_block_root_verification()
|
||||
.apply_blocks(vec![], Some(block.slot()))
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error::<BeaconChainError>)?;
|
||||
|
||||
Ok(replayer.into_state())
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ pub fn sync_committee_duties<T: BeaconChainTypes>(
|
||||
// still dependent on the head. So using `is_optimistic_head` is fine for both cases.
|
||||
let execution_optimistic = chain
|
||||
.is_optimistic_or_invalid_head()
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
.map_err(warp_utils::reject::unhandled_error)?;
|
||||
|
||||
// Try using the head's sync committees to satisfy the request. This should be sufficient for
|
||||
// the vast majority of requests. Rather than checking if we think the request will succeed in a
|
||||
@@ -55,7 +55,7 @@ pub fn sync_committee_duties<T: BeaconChainTypes>(
|
||||
..
|
||||
}))
|
||||
| Err(BeaconChainError::SyncDutiesError(BeaconStateError::IncorrectStateVariant)) => (),
|
||||
Err(e) => return Err(warp_utils::reject::beacon_chain_error(e)),
|
||||
Err(e) => return Err(warp_utils::reject::unhandled_error(e)),
|
||||
}
|
||||
|
||||
let duties = duties_from_state_load(request_epoch, request_indices, altair_fork_epoch, chain)
|
||||
@@ -67,7 +67,7 @@ pub fn sync_committee_duties<T: BeaconChainTypes>(
|
||||
"invalid epoch: {}, current epoch: {}",
|
||||
request_epoch, current_epoch
|
||||
)),
|
||||
e => warp_utils::reject::beacon_chain_error(e),
|
||||
e => warp_utils::reject::unhandled_error(e),
|
||||
})?;
|
||||
Ok(convert_to_response(
|
||||
verify_unknown_validators(duties, request_epoch, chain)?,
|
||||
@@ -164,7 +164,7 @@ fn verify_unknown_validators<T: BeaconChainTypes>(
|
||||
BeaconChainError::SyncDutiesError(BeaconStateError::UnknownValidator(idx)) => {
|
||||
warp_utils::reject::custom_bad_request(format!("invalid validator index: {idx}"))
|
||||
}
|
||||
e => warp_utils::reject::beacon_chain_error(e),
|
||||
e => warp_utils::reject::unhandled_error(e),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use eth2::types::{Epoch, ValidatorStatus};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
use warp_utils::reject::beacon_chain_error;
|
||||
use warp_utils::reject::unhandled_error;
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ValidatorCountResponse {
|
||||
@@ -58,7 +58,7 @@ pub fn get_validator_count<T: BeaconChainTypes>(
|
||||
}
|
||||
Ok::<(), BeaconChainError>(())
|
||||
})
|
||||
.map_err(beacon_chain_error)?;
|
||||
.map_err(unhandled_error)?;
|
||||
|
||||
Ok(ValidatorCountResponse {
|
||||
active_ongoing,
|
||||
@@ -101,7 +101,7 @@ pub fn get_validator_info<T: BeaconChainTypes>(
|
||||
request_data: ValidatorInfoRequestData,
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
) -> Result<ValidatorInfoResponse, warp::Rejection> {
|
||||
let current_epoch = chain.epoch().map_err(beacon_chain_error)?;
|
||||
let current_epoch = chain.epoch().map_err(unhandled_error)?;
|
||||
|
||||
let epochs = current_epoch.saturating_sub(HISTORIC_EPOCHS).as_u64()..=current_epoch.as_u64();
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ edition = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
beacon_chain = { workspace = true }
|
||||
health_metrics = { workspace = true }
|
||||
lighthouse_network = { workspace = true }
|
||||
lighthouse_version = { workspace = true }
|
||||
malloc_utils = { workspace = true }
|
||||
|
||||
@@ -39,7 +39,7 @@ pub fn gather_prometheus_metrics<T: BeaconChainTypes>(
|
||||
|
||||
lighthouse_network::scrape_discovery_metrics();
|
||||
|
||||
warp_utils::metrics::scrape_health_metrics();
|
||||
health_metrics::metrics::scrape_health_metrics();
|
||||
|
||||
// It's important to ensure these metrics are explicitly enabled in the case that users aren't
|
||||
// using glibc and this function causes panics.
|
||||
|
||||
Reference in New Issue
Block a user