mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-15 09:48:20 +00:00
resolve merge conlfict
This commit is contained in:
@@ -95,7 +95,7 @@ pub async fn publish_execution_payload_envelope<T: BeaconChainTypes>(
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
network_tx: &UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
) -> Result<Response<Body>, Rejection> {
|
||||
let slot = envelope.message.slot;
|
||||
let slot = envelope.slot();
|
||||
let beacon_block_root = envelope.message.beacon_block_root;
|
||||
let builder_index = envelope.message.builder_index;
|
||||
|
||||
@@ -198,9 +198,7 @@ pub(crate) fn get_beacon_execution_payload_envelope<T: BeaconChainTypes>(
|
||||
))
|
||||
})?;
|
||||
|
||||
let fork_name = chain
|
||||
.spec
|
||||
.fork_name_at_slot::<T::EthSpec>(envelope.message.slot);
|
||||
let fork_name = chain.spec.fork_name_at_slot::<T::EthSpec>(envelope.slot());
|
||||
|
||||
match accept_header {
|
||||
Some(api_types::Accept::Ssz) => Response::builder()
|
||||
|
||||
@@ -2536,6 +2536,14 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
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(),
|
||||
);
|
||||
|
||||
// GET validator/aggregate_attestation?attestation_data_root,slot
|
||||
let get_validator_aggregate_attestation = get_validator_aggregate_attestation(
|
||||
any_version.clone(),
|
||||
@@ -3347,6 +3355,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.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_lighthouse_health)
|
||||
|
||||
@@ -70,7 +70,7 @@ pub async fn produce_block_v4<T: BeaconChainTypes>(
|
||||
|
||||
let graffiti_settings = GraffitiSettings::new(query.graffiti, query.graffiti_policy);
|
||||
|
||||
let (block, _pending_state, consensus_block_value) = chain
|
||||
let (block, _block_state, consensus_block_value) = chain
|
||||
.produce_block_with_verification_gloas(
|
||||
randao_reveal,
|
||||
slot,
|
||||
|
||||
@@ -35,15 +35,13 @@
|
||||
//! appears that this validator is capable of producing valid
|
||||
//! attestations and there's no immediate cause for concern.
|
||||
use crate::task_spawner::{Priority, TaskSpawner};
|
||||
use beacon_chain::{
|
||||
AttestationError, BeaconChain, BeaconChainError, BeaconChainTypes,
|
||||
validator_monitor::timestamp_now,
|
||||
};
|
||||
use beacon_chain::{AttestationError, BeaconChain, BeaconChainError, BeaconChainTypes};
|
||||
use beacon_processor::work_reprocessing_queue::{QueuedUnaggregate, ReprocessQueueMessage};
|
||||
use beacon_processor::{Work, WorkEvent};
|
||||
use eth2::types::Failure;
|
||||
use lighthouse_network::PubsubMessage;
|
||||
use network::NetworkMessage;
|
||||
use slot_clock::SlotClock;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tokio::sync::{mpsc::UnboundedSender, oneshot};
|
||||
@@ -138,7 +136,7 @@ pub async fn publish_attestations<T: BeaconChainTypes>(
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Gossip validate and publish attestations that can be immediately processed.
|
||||
let seen_timestamp = timestamp_now();
|
||||
let seen_timestamp = chain.slot_clock.now_duration().unwrap_or_default();
|
||||
let mut prelim_results = task_spawner
|
||||
.clone()
|
||||
.blocking_task(Priority::P0, move || {
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::future::Future;
|
||||
use beacon_chain::blob_verification::{GossipBlobError, GossipVerifiedBlob};
|
||||
use beacon_chain::block_verification_types::{AsBlock, LookupBlock};
|
||||
use beacon_chain::data_column_verification::GossipVerifiedDataColumn;
|
||||
use beacon_chain::validator_monitor::{get_block_delay_ms, timestamp_now};
|
||||
use beacon_chain::validator_monitor::get_block_delay_ms;
|
||||
use beacon_chain::{
|
||||
AvailabilityProcessingStatus, BeaconChain, BeaconChainError, BeaconChainTypes, BlockError,
|
||||
IntoGossipVerifiedBlock, NotifyExecutionLayer, build_blob_data_column_sidecars,
|
||||
@@ -19,6 +19,7 @@ use lighthouse_network::PubsubMessage;
|
||||
use network::NetworkMessage;
|
||||
use rand::prelude::SliceRandom;
|
||||
use reqwest::StatusCode;
|
||||
use slot_clock::SlotClock;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
@@ -88,7 +89,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
|
||||
validation_level: BroadcastValidation,
|
||||
duplicate_status_code: StatusCode,
|
||||
) -> Result<Response, Rejection> {
|
||||
let seen_timestamp = timestamp_now();
|
||||
let seen_timestamp = chain.slot_clock.now_duration().unwrap_or_default();
|
||||
let block_publishing_delay_for_testing = chain.config.block_publishing_delay;
|
||||
let data_column_publishing_delay_for_testing = chain.config.data_column_publishing_delay;
|
||||
|
||||
@@ -113,11 +114,12 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
|
||||
debug!("Signed block received in HTTP API");
|
||||
|
||||
/* actually publish a block */
|
||||
let publish_chain = chain.clone();
|
||||
let publish_block_p2p = move |block: Arc<SignedBeaconBlock<T::EthSpec>>,
|
||||
sender,
|
||||
seen_timestamp|
|
||||
-> Result<(), BlockError> {
|
||||
let publish_timestamp = timestamp_now();
|
||||
let publish_timestamp = publish_chain.slot_clock.now_duration().unwrap_or_default();
|
||||
let publish_delay = publish_timestamp
|
||||
.checked_sub(seen_timestamp)
|
||||
.unwrap_or_else(|| Duration::from_secs(0));
|
||||
@@ -676,7 +678,7 @@ pub async fn reconstruct_block<T: BeaconChainTypes>(
|
||||
// us.
|
||||
late_block_logging(
|
||||
&chain,
|
||||
timestamp_now(),
|
||||
chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
block.message(),
|
||||
block_root,
|
||||
"builder",
|
||||
|
||||
@@ -66,12 +66,11 @@ pub fn get_state_before_applying_block<T: BeaconChainTypes>(
|
||||
})
|
||||
.map_err(|e| custom_not_found(format!("Parent state is not available! {:?}", e)))?;
|
||||
|
||||
// TODO(gloas): handle payloads?
|
||||
let replayer = BlockReplayer::new(parent_state, &chain.spec)
|
||||
.no_signature_verification()
|
||||
.state_root_iter([Ok((parent_block.state_root(), parent_block.slot()))].into_iter())
|
||||
.minimal_block_root_verification()
|
||||
.apply_blocks(vec![], vec![], Some(block.slot()))
|
||||
.apply_blocks(vec![], Some(block.slot()))
|
||||
.map_err(unhandled_error::<BeaconChainError>)?;
|
||||
|
||||
Ok(replayer.into_state())
|
||||
|
||||
@@ -4,10 +4,7 @@ use crate::utils::publish_pubsub_message;
|
||||
use beacon_chain::sync_committee_verification::{
|
||||
Error as SyncVerificationError, VerifiedSyncCommitteeMessage,
|
||||
};
|
||||
use beacon_chain::{
|
||||
BeaconChain, BeaconChainError, BeaconChainTypes, StateSkipConfig,
|
||||
validator_monitor::timestamp_now,
|
||||
};
|
||||
use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes, StateSkipConfig};
|
||||
use eth2::types::{self as api_types};
|
||||
use lighthouse_network::PubsubMessage;
|
||||
use network::NetworkMessage;
|
||||
@@ -188,7 +185,7 @@ pub fn process_sync_committee_signatures<T: BeaconChainTypes>(
|
||||
) -> Result<(), warp::reject::Rejection> {
|
||||
let mut failures = vec![];
|
||||
|
||||
let seen_timestamp = timestamp_now();
|
||||
let seen_timestamp = chain.slot_clock.now_duration().unwrap_or_default();
|
||||
|
||||
for (i, sync_committee_signature) in sync_committee_signatures.iter().enumerate() {
|
||||
let subnet_positions = match get_subnet_positions_for_sync_committee_message(
|
||||
@@ -319,7 +316,7 @@ pub fn process_signed_contribution_and_proofs<T: BeaconChainTypes>(
|
||||
let mut verified_contributions = Vec::with_capacity(signed_contribution_and_proofs.len());
|
||||
let mut failures = vec![];
|
||||
|
||||
let seen_timestamp = timestamp_now();
|
||||
let seen_timestamp = chain.slot_clock.now_duration().unwrap_or_default();
|
||||
|
||||
if let Some(latest_optimistic_update) = chain
|
||||
.light_client_server_cache
|
||||
|
||||
@@ -215,24 +215,22 @@ pub fn post_validator_monitor_metrics<T: BeaconChainTypes>(
|
||||
drop(val_metrics);
|
||||
|
||||
let attestations = attestation_hits + attestation_misses;
|
||||
let attestation_hit_percentage: f64 = if attestations == 0 {
|
||||
0.0
|
||||
} else {
|
||||
(100 * attestation_hits / attestations) as f64
|
||||
};
|
||||
let attestation_hit_percentage: f64 = (100 * attestation_hits)
|
||||
.checked_div(attestations)
|
||||
.map(|f| f as f64)
|
||||
.unwrap_or(0.0);
|
||||
|
||||
let head_attestations = attestation_head_hits + attestation_head_misses;
|
||||
let attestation_head_hit_percentage: f64 = if head_attestations == 0 {
|
||||
0.0
|
||||
} else {
|
||||
(100 * attestation_head_hits / head_attestations) as f64
|
||||
};
|
||||
let attestation_head_hit_percentage: f64 = (100 * attestation_head_hits)
|
||||
.checked_div(head_attestations)
|
||||
.map(|f| f as f64)
|
||||
.unwrap_or(0.0);
|
||||
|
||||
let target_attestations = attestation_target_hits + attestation_target_misses;
|
||||
let attestation_target_hit_percentage: f64 = if target_attestations == 0 {
|
||||
0.0
|
||||
} else {
|
||||
(100 * attestation_target_hits / target_attestations) as f64
|
||||
};
|
||||
let attestation_target_hit_percentage: f64 = (100 * attestation_target_hits)
|
||||
.checked_div(target_attestations)
|
||||
.map(|f| f as f64)
|
||||
.unwrap_or(0.0);
|
||||
|
||||
let metrics = ValidatorMetrics {
|
||||
attestation_hits,
|
||||
|
||||
@@ -9,7 +9,6 @@ use crate::utils::{
|
||||
use crate::version::{V1, V2, V3, unsupported_version_rejection};
|
||||
use crate::{StateId, attester_duties, proposer_duties, sync_committees};
|
||||
use beacon_chain::attestation_verification::VerifiedAttestation;
|
||||
use beacon_chain::validator_monitor::timestamp_now;
|
||||
use beacon_chain::{AttestationError, BeaconChain, BeaconChainError, BeaconChainTypes};
|
||||
use bls::PublicKeyBytes;
|
||||
use eth2::types::{
|
||||
@@ -249,6 +248,106 @@ pub fn get_validator_attestation_data<T: BeaconChainTypes>(
|
||||
.boxed()
|
||||
}
|
||||
|
||||
// GET validator/payload_attestation_data/{slot}
|
||||
pub fn get_validator_payload_attestation_data<T: BeaconChainTypes>(
|
||||
eth_v1: EthV1Filter,
|
||||
chain_filter: ChainFilter<T>,
|
||||
not_while_syncing_filter: NotWhileSyncingFilter,
|
||||
task_spawner_filter: TaskSpawnerFilter<T>,
|
||||
) -> ResponseFilter {
|
||||
use eth2::beacon_response::{EmptyMetadata, ForkVersionedResponse};
|
||||
use ssz::Encode;
|
||||
use warp::http::Response;
|
||||
|
||||
eth_v1
|
||||
.and(warp::path("validator"))
|
||||
.and(warp::path("payload_attestation_data"))
|
||||
.and(warp::path::param::<Slot>().or_else(|_| async {
|
||||
Err(warp_utils::reject::custom_bad_request(
|
||||
"Invalid slot".to_string(),
|
||||
))
|
||||
}))
|
||||
.and(warp::path::end())
|
||||
.and(warp::header::optional::<Accept>("accept"))
|
||||
.and(not_while_syncing_filter)
|
||||
.and(task_spawner_filter)
|
||||
.and(chain_filter)
|
||||
.then(
|
||||
|slot: Slot,
|
||||
accept_header: Option<Accept>,
|
||||
not_synced_filter: Result<(), Rejection>,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.blocking_response_task(Priority::P0, move || {
|
||||
not_synced_filter?;
|
||||
|
||||
let fork_name = chain.spec.fork_name_at_slot::<T::EthSpec>(slot);
|
||||
|
||||
// Payload attestations are only valid for Gloas and later forks
|
||||
if !fork_name.gloas_enabled() {
|
||||
return Err(warp_utils::reject::custom_bad_request(format!(
|
||||
"Payload attestations are not supported for fork: {fork_name}"
|
||||
)));
|
||||
}
|
||||
|
||||
let payload_attestation_data = chain
|
||||
.produce_payload_attestation_data(slot)
|
||||
.map_err(|e| match e {
|
||||
BeaconChainError::InvalidSlot(_)
|
||||
| BeaconChainError::NoBlockForSlot(_) => {
|
||||
warp_utils::reject::custom_bad_request(format!(
|
||||
"Unable to produce payload attestation data: {e:?}"
|
||||
))
|
||||
}
|
||||
_ => warp_utils::reject::custom_server_error(format!(
|
||||
"Unable to produce payload attestation data: {e:?}"
|
||||
)),
|
||||
})?;
|
||||
|
||||
match accept_header {
|
||||
Some(Accept::Ssz) => Response::builder()
|
||||
.status(200)
|
||||
.header("Content-Type", "application/octet-stream")
|
||||
.header("Eth-Consensus-Version", fork_name.to_string())
|
||||
.body(payload_attestation_data.as_ssz_bytes().into())
|
||||
.map(|res: Response<warp::hyper::Body>| res)
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!(
|
||||
"Failed to build SSZ response: {e}"
|
||||
))
|
||||
}),
|
||||
_ => {
|
||||
let json_response = ForkVersionedResponse {
|
||||
version: fork_name,
|
||||
metadata: EmptyMetadata {},
|
||||
data: payload_attestation_data,
|
||||
};
|
||||
Response::builder()
|
||||
.status(200)
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Eth-Consensus-Version", fork_name.to_string())
|
||||
.body(
|
||||
serde_json::to_string(&json_response)
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!(
|
||||
"Failed to serialize response: {e}"
|
||||
))
|
||||
})?
|
||||
.into(),
|
||||
)
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!(
|
||||
"Failed to build JSON response: {e}"
|
||||
))
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
.boxed()
|
||||
}
|
||||
|
||||
// GET validator/blinded_blocks/{slot}
|
||||
pub fn get_validator_blinded_blocks<T: BeaconChainTypes>(
|
||||
eth_v1: EthV1Filter,
|
||||
@@ -871,7 +970,7 @@ pub fn post_validator_aggregate_and_proofs<T: BeaconChainTypes>(
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>| {
|
||||
task_spawner.blocking_json_task(Priority::P0, move || {
|
||||
not_synced_filter?;
|
||||
let seen_timestamp = timestamp_now();
|
||||
let seen_timestamp = chain.slot_clock.now_duration().unwrap_or_default();
|
||||
let mut verified_aggregates = Vec::with_capacity(aggregates.len());
|
||||
let mut messages = Vec::with_capacity(aggregates.len());
|
||||
let mut failures = Vec::new();
|
||||
|
||||
Reference in New Issue
Block a user