mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-01 13:47:16 +00:00
resolve merge conflicts
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#![allow(clippy::result_large_err)]
|
||||
//! This crate contains a HTTP server which serves the endpoints listed here:
|
||||
//!
|
||||
//! https://github.com/ethereum/beacon-APIs
|
||||
@@ -6,12 +7,9 @@
|
||||
//! used for development.
|
||||
|
||||
mod aggregate_attestation;
|
||||
mod attestation_performance;
|
||||
mod attester_duties;
|
||||
mod beacon;
|
||||
mod block_id;
|
||||
mod block_packing_efficiency;
|
||||
mod block_rewards;
|
||||
mod build_block_contents;
|
||||
mod builder_states;
|
||||
mod custody;
|
||||
@@ -22,6 +20,7 @@ mod metrics;
|
||||
mod peer;
|
||||
mod produce_block;
|
||||
mod proposer_duties;
|
||||
mod ptc_duties;
|
||||
mod publish_attestations;
|
||||
mod publish_blocks;
|
||||
mod publish_inclusion_lists;
|
||||
@@ -38,6 +37,10 @@ mod validator_inclusion;
|
||||
mod validators;
|
||||
mod version;
|
||||
|
||||
use crate::beacon::execution_payload_envelope::{
|
||||
get_beacon_execution_payload_envelope, post_beacon_execution_payload_envelope,
|
||||
post_beacon_execution_payload_envelope_ssz,
|
||||
};
|
||||
use crate::beacon::pool::*;
|
||||
use crate::light_client::{get_light_client_bootstrap, get_light_client_updates};
|
||||
use crate::utils::{AnyVersionFilter, EthV1Filter};
|
||||
@@ -52,7 +55,6 @@ use builder_states::get_next_withdrawals;
|
||||
use bytes::Bytes;
|
||||
use context_deserialize::ContextDeserialize;
|
||||
use directory::DEFAULT_ROOT_DIR;
|
||||
use eth2::StatusCode;
|
||||
use eth2::lighthouse::sync_state::SyncState;
|
||||
use eth2::types::{
|
||||
self as api_types, BroadcastValidation, EndpointVersion, ForkChoice, ForkChoiceExtraData,
|
||||
@@ -71,6 +73,7 @@ use parking_lot::RwLock;
|
||||
pub use publish_blocks::{
|
||||
ProvenancedBlock, publish_blinded_block, publish_block, reconstruct_block,
|
||||
};
|
||||
use reqwest::StatusCode;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use slot_clock::SlotClock;
|
||||
use ssz::Encode;
|
||||
@@ -94,6 +97,7 @@ use types::{
|
||||
BeaconStateError, Checkpoint, ConfigAndPreset, Epoch, EthSpec, ForkName, Hash256,
|
||||
SignedBlindedBeaconBlock, SignedInclusionList, Slot,
|
||||
};
|
||||
use validator::execution_payload_envelope::get_validator_execution_payload_envelope;
|
||||
use version::{
|
||||
ResponseIncludesVersion, V1, V2, add_consensus_version_header, add_ssz_content_type_header,
|
||||
execution_optimistic_finalized_beacon_response, inconsistent_fork_rejection,
|
||||
@@ -262,6 +266,7 @@ pub fn prometheus_metrics() -> warp::filters::log::Log<impl Fn(warp::filters::lo
|
||||
.or_else(|| starts_with("v1/validator/contribution_and_proofs"))
|
||||
.or_else(|| starts_with("v1/validator/duties/attester"))
|
||||
.or_else(|| starts_with("v1/validator/duties/proposer"))
|
||||
.or_else(|| starts_with("v2/validator/duties/proposer"))
|
||||
.or_else(|| starts_with("v1/validator/duties/sync"))
|
||||
.or_else(|| starts_with("v1/validator/inclusion_list"))
|
||||
.or_else(|| starts_with("v1/validator/liveness"))
|
||||
@@ -649,6 +654,10 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let get_beacon_state_pending_consolidations =
|
||||
states::get_beacon_state_pending_consolidations(beacon_states_path.clone());
|
||||
|
||||
// GET beacon/states/{state_id}/proposer_lookahead
|
||||
let get_beacon_state_proposer_lookahead =
|
||||
states::get_beacon_state_proposer_lookahead(beacon_states_path.clone());
|
||||
|
||||
// GET beacon/headers
|
||||
//
|
||||
// Note: this endpoint only returns information about blocks in the canonical chain. Given that
|
||||
@@ -1194,7 +1203,28 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
Priority::P1
|
||||
};
|
||||
task_spawner.blocking_json_task(priority, move || {
|
||||
let (block_root, execution_optimistic, finalized) = block_id.root(&chain)?;
|
||||
// Fast-path for the head block root. We read from the early attester cache
|
||||
// so that we can produce sync committee messages for the new head prior
|
||||
// to it being fully imported (written to the DB/etc). We also check that the
|
||||
// cache is not stale or out of date by comparing against the cached head
|
||||
// prior to using it.
|
||||
//
|
||||
// See: https://github.com/sigp/lighthouse/issues/8667
|
||||
let (block_root, execution_optimistic, finalized) =
|
||||
if let BlockId(eth2::types::BlockId::Head) = block_id
|
||||
&& let Some((head_block_slot, head_block_root)) =
|
||||
chain.early_attester_cache.get_head_block_root()
|
||||
&& head_block_slot >= chain.canonical_head.cached_head().head_slot()
|
||||
{
|
||||
// We know execution is NOT optimistic if the block is from the early
|
||||
// attester cache because only properly validated blocks are added.
|
||||
// Similarly we know it is NOT finalized.
|
||||
let execution_optimistic = false;
|
||||
let finalized = false;
|
||||
(head_block_root, execution_optimistic, finalized)
|
||||
} else {
|
||||
block_id.root(&chain)?
|
||||
};
|
||||
Ok(
|
||||
api_types::GenericResponse::from(api_types::RootData::from(block_root))
|
||||
.add_execution_optimistic_finalized(execution_optimistic, finalized),
|
||||
@@ -1428,7 +1458,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
let post_beacon_pool_attestations_v2 = post_beacon_pool_attestations_v2(
|
||||
&network_tx_filter,
|
||||
optional_consensus_version_header_filter,
|
||||
optional_consensus_version_header_filter.clone(),
|
||||
&beacon_pool_path_v2,
|
||||
);
|
||||
|
||||
@@ -1461,6 +1491,21 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let post_beacon_pool_sync_committees =
|
||||
post_beacon_pool_sync_committees(&network_tx_filter, &beacon_pool_path);
|
||||
|
||||
// POST beacon/pool/payload_attestations
|
||||
let post_beacon_pool_payload_attestations = post_beacon_pool_payload_attestations(
|
||||
&network_tx_filter,
|
||||
optional_consensus_version_header_filter,
|
||||
&beacon_pool_path,
|
||||
);
|
||||
|
||||
// POST beacon/pool/payload_attestations (SSZ)
|
||||
let post_beacon_pool_payload_attestations_ssz = post_beacon_pool_payload_attestations_ssz(
|
||||
eth_v1.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
chain_filter.clone(),
|
||||
network_tx_filter.clone(),
|
||||
);
|
||||
|
||||
// GET beacon/pool/bls_to_execution_changes
|
||||
let get_beacon_pool_bls_to_execution_changes =
|
||||
get_beacon_pool_bls_to_execution_changes(&beacon_pool_path);
|
||||
@@ -1494,6 +1539,30 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
},
|
||||
);
|
||||
|
||||
// POST beacon/execution_payload_envelope
|
||||
let post_beacon_execution_payload_envelope = post_beacon_execution_payload_envelope(
|
||||
eth_v1.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
chain_filter.clone(),
|
||||
network_tx_filter.clone(),
|
||||
);
|
||||
|
||||
// POST beacon/execution_payload_envelope (SSZ)
|
||||
let post_beacon_execution_payload_envelope_ssz = post_beacon_execution_payload_envelope_ssz(
|
||||
eth_v1.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
chain_filter.clone(),
|
||||
network_tx_filter.clone(),
|
||||
);
|
||||
|
||||
// GET beacon/execution_payload_envelope/{block_id}
|
||||
let get_beacon_execution_payload_envelope = get_beacon_execution_payload_envelope(
|
||||
eth_v1.clone(),
|
||||
block_id_or_err,
|
||||
task_spawner_filter.clone(),
|
||||
chain_filter.clone(),
|
||||
);
|
||||
|
||||
let beacon_rewards_path = eth_v1
|
||||
.clone()
|
||||
.and(warp::path("beacon"))
|
||||
@@ -1784,8 +1853,16 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let execution_optimistic =
|
||||
chain.is_optimistic_or_invalid_head().unwrap_or_default();
|
||||
|
||||
Ok(api_types::GenericResponse::from(attestation_rewards))
|
||||
.map(|resp| resp.add_execution_optimistic(execution_optimistic))
|
||||
let finalized = epoch + 2
|
||||
<= chain
|
||||
.canonical_head
|
||||
.cached_head()
|
||||
.finalized_checkpoint()
|
||||
.epoch;
|
||||
|
||||
Ok(api_types::GenericResponse::from(attestation_rewards)).map(|resp| {
|
||||
resp.add_execution_optimistic_finalized(execution_optimistic, finalized)
|
||||
})
|
||||
})
|
||||
},
|
||||
);
|
||||
@@ -2066,52 +2143,66 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.nodes
|
||||
.iter()
|
||||
.map(|node| {
|
||||
let execution_status = if node.execution_status.is_execution_enabled() {
|
||||
Some(node.execution_status.to_string())
|
||||
let execution_status = if node
|
||||
.execution_status()
|
||||
.is_ok_and(|status| status.is_execution_enabled())
|
||||
{
|
||||
node.execution_status()
|
||||
.ok()
|
||||
.map(|status| status.to_string())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let execution_status_string = node
|
||||
.execution_status()
|
||||
.map_or_else(|_| "irrelevant".to_string(), |s| s.to_string());
|
||||
|
||||
ForkChoiceNode {
|
||||
slot: node.slot,
|
||||
block_root: node.root,
|
||||
slot: node.slot(),
|
||||
block_root: node.root(),
|
||||
parent_root: node
|
||||
.parent
|
||||
.parent()
|
||||
.and_then(|index| proto_array.nodes.get(index))
|
||||
.map(|parent| parent.root),
|
||||
justified_epoch: node.justified_checkpoint.epoch,
|
||||
finalized_epoch: node.finalized_checkpoint.epoch,
|
||||
weight: node.weight,
|
||||
.map(|parent| parent.root()),
|
||||
justified_epoch: node.justified_checkpoint().epoch,
|
||||
finalized_epoch: node.finalized_checkpoint().epoch,
|
||||
weight: node.weight(),
|
||||
validity: execution_status,
|
||||
execution_block_hash: node
|
||||
.execution_status
|
||||
.block_hash()
|
||||
.execution_status()
|
||||
.ok()
|
||||
.and_then(|status| status.block_hash())
|
||||
.map(|block_hash| block_hash.into_root()),
|
||||
extra_data: ForkChoiceExtraData {
|
||||
target_root: node.target_root,
|
||||
justified_root: node.justified_checkpoint.root,
|
||||
finalized_root: node.finalized_checkpoint.root,
|
||||
target_root: node.target_root(),
|
||||
justified_root: node.justified_checkpoint().root,
|
||||
finalized_root: node.finalized_checkpoint().root,
|
||||
unrealized_justified_root: node
|
||||
.unrealized_justified_checkpoint
|
||||
.unrealized_justified_checkpoint()
|
||||
.map(|checkpoint| checkpoint.root),
|
||||
unrealized_finalized_root: node
|
||||
.unrealized_finalized_checkpoint
|
||||
.unrealized_finalized_checkpoint()
|
||||
.map(|checkpoint| checkpoint.root),
|
||||
unrealized_justified_epoch: node
|
||||
.unrealized_justified_checkpoint
|
||||
.unrealized_justified_checkpoint()
|
||||
.map(|checkpoint| checkpoint.epoch),
|
||||
unrealized_finalized_epoch: node
|
||||
.unrealized_finalized_checkpoint
|
||||
.unrealized_finalized_checkpoint()
|
||||
.map(|checkpoint| checkpoint.epoch),
|
||||
execution_status: node.execution_status.to_string(),
|
||||
execution_status: execution_status_string,
|
||||
best_child: node
|
||||
.best_child
|
||||
.best_child()
|
||||
.ok()
|
||||
.flatten()
|
||||
.and_then(|index| proto_array.nodes.get(index))
|
||||
.map(|child| child.root),
|
||||
.map(|child| child.root()),
|
||||
best_descendant: node
|
||||
.best_descendant
|
||||
.best_descendant()
|
||||
.ok()
|
||||
.flatten()
|
||||
.and_then(|index| proto_array.nodes.get(index))
|
||||
.map(|descendant| descendant.root),
|
||||
.map(|descendant| descendant.root()),
|
||||
},
|
||||
}
|
||||
})
|
||||
@@ -2148,12 +2239,9 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let discovery_addresses = enr.multiaddr_p2p_udp();
|
||||
Ok(api_types::GenericResponse::from(api_types::IdentityData {
|
||||
peer_id: network_globals.local_peer_id().to_base58(),
|
||||
enr: enr.to_base64(),
|
||||
p2p_addresses: p2p_addresses.iter().map(|a| a.to_string()).collect(),
|
||||
discovery_addresses: discovery_addresses
|
||||
.iter()
|
||||
.map(|a| a.to_string())
|
||||
.collect(),
|
||||
enr,
|
||||
p2p_addresses,
|
||||
discovery_addresses,
|
||||
metadata: utils::from_meta_data::<T::EthSpec>(
|
||||
&network_globals.local_metadata,
|
||||
&chain.spec,
|
||||
@@ -2455,7 +2543,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// GET validator/duties/proposer/{epoch}
|
||||
let get_validator_duties_proposer = get_validator_duties_proposer(
|
||||
eth_v1.clone().clone(),
|
||||
any_version.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
@@ -2463,7 +2551,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// GET validator/blocks/{slot}
|
||||
let get_validator_blocks = get_validator_blocks(
|
||||
any_version.clone().clone(),
|
||||
any_version.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
@@ -2471,7 +2559,15 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// GET validator/blinded_blocks/{slot}
|
||||
let get_validator_blinded_blocks = get_validator_blinded_blocks(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
);
|
||||
|
||||
// GET validator/execution_payload_envelope/{slot}/{builder_index}
|
||||
let get_validator_execution_payload_envelope = get_validator_execution_payload_envelope(
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
@@ -2479,7 +2575,15 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// GET validator/attestation_data?slot,committee_index
|
||||
let get_validator_attestation_data = get_validator_attestation_data(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
);
|
||||
|
||||
// GET validator/payload_attestation_data/{slot}
|
||||
let get_validator_payload_attestation_data = get_validator_payload_attestation_data(
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
@@ -2487,7 +2591,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// GET validator/aggregate_attestation?attestation_data_root,slot
|
||||
let get_validator_aggregate_attestation = get_validator_aggregate_attestation(
|
||||
any_version.clone().clone(),
|
||||
any_version.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
@@ -2495,7 +2599,15 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// POST validator/duties/attester/{epoch}
|
||||
let post_validator_duties_attester = post_validator_duties_attester(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
);
|
||||
|
||||
// POST validator/duties/ptc/{epoch}
|
||||
let post_validator_duties_ptc = post_validator_duties_ptc(
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
@@ -2503,7 +2615,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// POST validator/duties/sync/{epoch}
|
||||
let post_validator_duties_sync = post_validator_duties_sync(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
@@ -2541,7 +2653,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// GET validator/sync_committee_contribution
|
||||
let get_validator_sync_committee_contribution = get_validator_sync_committee_contribution(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
@@ -2599,7 +2711,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
);
|
||||
// POST validator/aggregate_and_proofs
|
||||
let post_validator_aggregate_and_proofs = post_validator_aggregate_and_proofs(
|
||||
any_version.clone().clone(),
|
||||
any_version.clone(),
|
||||
chain_filter.clone(),
|
||||
network_tx_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
@@ -2607,7 +2719,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
);
|
||||
|
||||
let post_validator_contribution_and_proofs = post_validator_contribution_and_proofs(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
network_tx_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
@@ -2617,7 +2729,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
// POST validator/beacon_committee_subscriptions
|
||||
let post_validator_beacon_committee_subscriptions =
|
||||
post_validator_beacon_committee_subscriptions(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
validator_subscription_tx_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
@@ -2625,7 +2737,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// POST validator/prepare_beacon_proposer
|
||||
let post_validator_prepare_beacon_proposer = post_validator_prepare_beacon_proposer(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
network_tx_filter.clone(),
|
||||
not_while_syncing_filter.clone(),
|
||||
@@ -2634,13 +2746,13 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// POST validator/register_validator
|
||||
let post_validator_register_validator = post_validator_register_validator(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
);
|
||||
// POST validator/sync_committee_subscriptions
|
||||
let post_validator_sync_committee_subscriptions = post_validator_sync_committee_subscriptions(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
validator_subscription_tx_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
@@ -2648,7 +2760,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// POST validator/liveness/{epoch}
|
||||
let post_validator_liveness_epoch = post_validator_liveness_epoch(
|
||||
eth_v1.clone().clone(),
|
||||
eth_v1.clone(),
|
||||
chain_filter.clone(),
|
||||
task_spawner_filter.clone(),
|
||||
);
|
||||
@@ -3065,6 +3177,19 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
},
|
||||
);
|
||||
|
||||
// GET lighthouse/database/invariants
|
||||
let get_lighthouse_database_invariants = database_path
|
||||
.and(warp::path("invariants"))
|
||||
.and(warp::path::end())
|
||||
.and(task_spawner_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.then(
|
||||
|task_spawner: TaskSpawner<T::EthSpec>, chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner
|
||||
.blocking_json_task(Priority::P1, move || database::check_invariants(chain))
|
||||
},
|
||||
);
|
||||
|
||||
// POST lighthouse/database/reconstruct
|
||||
let post_lighthouse_database_reconstruct = database_path
|
||||
.and(warp::path("reconstruct"))
|
||||
@@ -3128,86 +3253,6 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
},
|
||||
);
|
||||
|
||||
// GET lighthouse/analysis/block_rewards
|
||||
let get_lighthouse_block_rewards = warp::path("lighthouse")
|
||||
.and(warp::path("analysis"))
|
||||
.and(warp::path("block_rewards"))
|
||||
.and(warp::query::<eth2::lighthouse::BlockRewardsQuery>())
|
||||
.and(warp::path::end())
|
||||
.and(task_spawner_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.then(|query, task_spawner: TaskSpawner<T::EthSpec>, chain| {
|
||||
task_spawner.blocking_json_task(Priority::P1, move || {
|
||||
block_rewards::get_block_rewards(query, chain)
|
||||
})
|
||||
});
|
||||
|
||||
// POST lighthouse/analysis/block_rewards
|
||||
let post_lighthouse_block_rewards = warp::path("lighthouse")
|
||||
.and(warp::path("analysis"))
|
||||
.and(warp::path("block_rewards"))
|
||||
.and(warp_utils::json::json())
|
||||
.and(warp::path::end())
|
||||
.and(task_spawner_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.then(|blocks, task_spawner: TaskSpawner<T::EthSpec>, chain| {
|
||||
task_spawner.blocking_json_task(Priority::P1, move || {
|
||||
block_rewards::compute_block_rewards(blocks, chain)
|
||||
})
|
||||
});
|
||||
|
||||
// GET lighthouse/analysis/attestation_performance/{index}
|
||||
let get_lighthouse_attestation_performance = warp::path("lighthouse")
|
||||
.and(warp::path("analysis"))
|
||||
.and(warp::path("attestation_performance"))
|
||||
.and(warp::path::param::<String>())
|
||||
.and(warp::query::<eth2::lighthouse::AttestationPerformanceQuery>())
|
||||
.and(warp::path::end())
|
||||
.and(task_spawner_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.then(
|
||||
|target, query, task_spawner: TaskSpawner<T::EthSpec>, chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.blocking_json_task(Priority::P1, move || {
|
||||
attestation_performance::get_attestation_performance(target, query, chain)
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
// GET lighthouse/analysis/block_packing_efficiency
|
||||
let get_lighthouse_block_packing_efficiency = warp::path("lighthouse")
|
||||
.and(warp::path("analysis"))
|
||||
.and(warp::path("block_packing_efficiency"))
|
||||
.and(warp::query::<eth2::lighthouse::BlockPackingEfficiencyQuery>())
|
||||
.and(warp::path::end())
|
||||
.and(task_spawner_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.then(
|
||||
|query, task_spawner: TaskSpawner<T::EthSpec>, chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.blocking_json_task(Priority::P1, move || {
|
||||
block_packing_efficiency::get_block_packing_efficiency(query, chain)
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
// GET lighthouse/merge_readiness
|
||||
let get_lighthouse_merge_readiness = warp::path("lighthouse")
|
||||
.and(warp::path("merge_readiness"))
|
||||
.and(warp::path::end())
|
||||
.and(task_spawner_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.then(
|
||||
|task_spawner: TaskSpawner<T::EthSpec>, chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.spawn_async_with_rejection(Priority::P1, async move {
|
||||
let current_slot = chain.slot_clock.now_or_genesis().unwrap_or(Slot::new(0));
|
||||
let merge_readiness = chain.check_bellatrix_readiness(current_slot).await;
|
||||
Ok::<_, warp::reject::Rejection>(
|
||||
warp::reply::json(&api_types::GenericResponse::from(merge_readiness))
|
||||
.into_response(),
|
||||
)
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
let get_events = eth_v1
|
||||
.clone()
|
||||
.and(warp::path("events"))
|
||||
@@ -3265,9 +3310,6 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
api_types::EventTopic::LightClientOptimisticUpdate => {
|
||||
event_handler.subscribe_light_client_optimistic_update()
|
||||
}
|
||||
api_types::EventTopic::BlockReward => {
|
||||
event_handler.subscribe_block_reward()
|
||||
}
|
||||
api_types::EventTopic::AttesterSlashing => {
|
||||
event_handler.subscribe_attester_slashing()
|
||||
}
|
||||
@@ -3283,6 +3325,21 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
api_types::EventTopic::InclusionList => {
|
||||
event_handler.subscribe_inclusion_list()
|
||||
}
|
||||
api_types::EventTopic::ExecutionPayload => {
|
||||
event_handler.subscribe_execution_payload()
|
||||
}
|
||||
api_types::EventTopic::ExecutionPayloadGossip => {
|
||||
event_handler.subscribe_execution_payload_gossip()
|
||||
}
|
||||
api_types::EventTopic::ExecutionPayloadAvailable => {
|
||||
event_handler.subscribe_execution_payload_available()
|
||||
}
|
||||
api_types::EventTopic::ExecutionPayloadBid => {
|
||||
event_handler.subscribe_execution_payload_bid()
|
||||
}
|
||||
api_types::EventTopic::PayloadAttestationMessage => {
|
||||
event_handler.subscribe_payload_attestation_message()
|
||||
}
|
||||
};
|
||||
|
||||
receivers.push(
|
||||
@@ -3317,7 +3374,19 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
let s = futures::stream::select_all(receivers);
|
||||
|
||||
Ok(warp::sse::reply(warp::sse::keep_alive().stream(s)))
|
||||
let response = warp::sse::reply(warp::sse::keep_alive().stream(s));
|
||||
|
||||
// Set headers to bypass nginx caching and buffering, which breaks realtime
|
||||
// delivery.
|
||||
let response = warp::reply::with_header(response, "X-Accel-Buffering", "no");
|
||||
let response = warp::reply::with_header(response, "X-Accel-Expires", "0");
|
||||
let response = warp::reply::with_header(
|
||||
response,
|
||||
"Cache-Control",
|
||||
"no-cache, no-store, must-revalidate",
|
||||
);
|
||||
|
||||
Ok(response)
|
||||
})
|
||||
},
|
||||
);
|
||||
@@ -3387,6 +3456,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.uor(get_beacon_state_pending_deposits)
|
||||
.uor(get_beacon_state_pending_partial_withdrawals)
|
||||
.uor(get_beacon_state_pending_consolidations)
|
||||
.uor(get_beacon_state_proposer_lookahead)
|
||||
.uor(get_beacon_headers)
|
||||
.uor(get_beacon_headers_block_id)
|
||||
.uor(get_beacon_block)
|
||||
@@ -3395,6 +3465,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.uor(get_beacon_block_root)
|
||||
.uor(get_blob_sidecars)
|
||||
.uor(get_blobs)
|
||||
.uor(get_beacon_execution_payload_envelope)
|
||||
.uor(get_beacon_pool_attestations)
|
||||
.uor(get_beacon_pool_attester_slashings)
|
||||
.uor(get_beacon_pool_proposer_slashings)
|
||||
@@ -3418,7 +3489,9 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.uor(get_validator_duties_proposer)
|
||||
.uor(get_validator_blocks)
|
||||
.uor(get_validator_blinded_blocks)
|
||||
.uor(get_validator_execution_payload_envelope)
|
||||
.uor(get_validator_attestation_data)
|
||||
.uor(get_validator_payload_attestation_data)
|
||||
.uor(get_validator_aggregate_attestation)
|
||||
.uor(get_validator_sync_committee_contribution)
|
||||
.uor(get_validator_inclusion_list)
|
||||
@@ -3434,15 +3507,12 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.uor(get_lighthouse_validator_inclusion)
|
||||
.uor(get_lighthouse_staking)
|
||||
.uor(get_lighthouse_database_info)
|
||||
.uor(get_lighthouse_database_invariants)
|
||||
.uor(get_lighthouse_custody_info)
|
||||
.uor(get_lighthouse_block_rewards)
|
||||
.uor(get_lighthouse_attestation_performance)
|
||||
.uor(get_beacon_light_client_optimistic_update)
|
||||
.uor(get_beacon_light_client_finality_update)
|
||||
.uor(get_beacon_light_client_bootstrap)
|
||||
.uor(get_beacon_light_client_updates)
|
||||
.uor(get_lighthouse_block_packing_efficiency)
|
||||
.uor(get_lighthouse_merge_readiness)
|
||||
.uor(get_events)
|
||||
.uor(get_expected_withdrawals)
|
||||
.uor(lighthouse_log_events.boxed())
|
||||
@@ -3457,7 +3527,9 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
post_beacon_blocks_ssz
|
||||
.uor(post_beacon_blocks_v2_ssz)
|
||||
.uor(post_beacon_blinded_blocks_ssz)
|
||||
.uor(post_beacon_blinded_blocks_v2_ssz),
|
||||
.uor(post_beacon_blinded_blocks_v2_ssz)
|
||||
.uor(post_beacon_execution_payload_envelope_ssz)
|
||||
.uor(post_beacon_pool_payload_attestations_ssz),
|
||||
)
|
||||
.uor(post_beacon_blocks)
|
||||
.uor(post_beacon_blinded_blocks)
|
||||
@@ -3468,13 +3540,16 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.uor(post_beacon_pool_proposer_slashings)
|
||||
.uor(post_beacon_pool_voluntary_exits)
|
||||
.uor(post_beacon_pool_sync_committees)
|
||||
.uor(post_beacon_pool_payload_attestations)
|
||||
.uor(post_beacon_pool_bls_to_execution_changes)
|
||||
.uor(post_beacon_execution_payload_envelope)
|
||||
.uor(post_beacon_state_validators)
|
||||
.uor(post_beacon_state_validator_balances)
|
||||
.uor(post_beacon_state_validator_identities)
|
||||
.uor(post_beacon_rewards_attestations)
|
||||
.uor(post_beacon_rewards_sync_committee)
|
||||
.uor(post_validator_duties_attester)
|
||||
.uor(post_validator_duties_ptc)
|
||||
.uor(post_validator_duties_sync)
|
||||
.uor(post_validator_duties_inclusion_list)
|
||||
.uor(post_validator_aggregate_and_proofs)
|
||||
@@ -3486,7 +3561,6 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.uor(post_validator_liveness_epoch)
|
||||
.uor(post_lighthouse_liveness)
|
||||
.uor(post_lighthouse_database_reconstruct)
|
||||
.uor(post_lighthouse_block_rewards)
|
||||
.uor(post_lighthouse_ui_validator_metrics)
|
||||
.uor(post_lighthouse_ui_validator_info)
|
||||
.uor(post_beacon_pool_inclusion_lists)
|
||||
|
||||
Reference in New Issue
Block a user