mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 04:37:13 +00:00
Merge pull request #3845 from realbigsean/capella-cleanup
Capella cleanup
This commit is contained in:
@@ -6,7 +6,6 @@ use crate::attestation_verification::{
|
||||
use crate::attester_cache::{AttesterCache, AttesterCacheKey};
|
||||
use crate::beacon_proposer_cache::compute_proposer_duties_from_head;
|
||||
use crate::beacon_proposer_cache::BeaconProposerCache;
|
||||
use crate::blob_verification::{BlobError, VerifiedBlobsSidecar};
|
||||
use crate::block_times_cache::BlockTimesCache;
|
||||
use crate::block_verification::{
|
||||
check_block_is_finalized_descendant, check_block_relevancy, get_block_root,
|
||||
@@ -1818,23 +1817,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Accepts some `BlobsSidecar` received over from the network and attempts to verify it,
|
||||
/// returning `Ok(_)` if it is valid to be (re)broadcast on the gossip network.
|
||||
pub fn verify_blobs_sidecar_for_gossip<'a>(
|
||||
&self,
|
||||
blobs_sidecar: &'a BlobsSidecar<T::EthSpec>,
|
||||
) -> Result<VerifiedBlobsSidecar<'a, T>, BlobError> {
|
||||
metrics::inc_counter(&metrics::BLOBS_SIDECAR_PROCESSING_REQUESTS);
|
||||
let _timer = metrics::start_timer(&metrics::BLOBS_SIDECAR_GOSSIP_VERIFICATION_TIMES);
|
||||
VerifiedBlobsSidecar::verify(blobs_sidecar, self).map(|v| {
|
||||
if let Some(_event_handler) = self.event_handler.as_ref() {
|
||||
// TODO: Handle sse events
|
||||
}
|
||||
metrics::inc_counter(&metrics::BLOBS_SIDECAR_PROCESSING_SUCCESSES);
|
||||
v
|
||||
})
|
||||
}
|
||||
|
||||
/// Accepts some 'LightClientFinalityUpdate' from the network and attempts to verify it
|
||||
pub fn verify_finality_update_for_gossip(
|
||||
self: &Arc<Self>,
|
||||
@@ -4479,7 +4461,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
.try_into()
|
||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
||||
bls_to_execution_changes: bls_to_execution_changes.into(),
|
||||
//FIXME(sean) get blobs
|
||||
blob_kzg_commitments: VariableList::from(kzg_commitments),
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -460,7 +460,7 @@ where
|
||||
if is_terminal_block_hash_set && !is_activation_epoch_reached {
|
||||
// Use the "empty" payload if there's a terminal block hash, but we haven't reached the
|
||||
// terminal block epoch yet.
|
||||
return Ok(BlockProposalContents::default_at_fork(fork));
|
||||
return BlockProposalContents::default_at_fork(fork).map_err(Into::into);
|
||||
}
|
||||
|
||||
let terminal_pow_block_hash = execution_layer
|
||||
@@ -473,7 +473,7 @@ where
|
||||
} else {
|
||||
// If the merge transition hasn't occurred yet and the EL hasn't found the terminal
|
||||
// block, return an "empty" payload.
|
||||
return Ok(BlockProposalContents::default_at_fork(fork));
|
||||
return BlockProposalContents::default_at_fork(fork).map_err(Into::into);
|
||||
}
|
||||
} else {
|
||||
latest_execution_payload_header_block_hash
|
||||
|
||||
@@ -350,12 +350,14 @@ impl From<Withdrawal> for JsonWithdrawal {
|
||||
|
||||
impl From<JsonWithdrawal> for Withdrawal {
|
||||
fn from(jw: JsonWithdrawal) -> Self {
|
||||
// This comparison is done to avoid a scenario where the EE gives us too large a number and we
|
||||
// panic when attempting to cast to a `u64`.
|
||||
let amount = std::cmp::max(jw.amount / 1000000000, Uint256::from(u64::MAX));
|
||||
Self {
|
||||
index: jw.index,
|
||||
validator_index: jw.validator_index,
|
||||
address: jw.address,
|
||||
//FIXME(sean) if EE gives us too large a number this panics
|
||||
amount: (jw.amount / 1000000000).as_u64(),
|
||||
amount: amount.as_u64(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ use tokio::{
|
||||
time::sleep,
|
||||
};
|
||||
use tokio_stream::wrappers::WatchStream;
|
||||
use types::{AbstractExecPayload, Blob, ExecPayload, KzgCommitment};
|
||||
use types::{AbstractExecPayload, BeaconStateError, Blob, ExecPayload, KzgCommitment};
|
||||
use types::{
|
||||
BlindedPayload, BlockType, ChainSpec, Epoch, ExecutionBlockHash, ForkName,
|
||||
ProposerPreparationData, PublicKeyBytes, Signature, SignedBeaconBlock, Slot, Uint256,
|
||||
@@ -95,6 +95,13 @@ pub enum Error {
|
||||
FeeRecipientUnspecified,
|
||||
MissingLatestValidHash,
|
||||
InvalidJWTSecret(String),
|
||||
BeaconStateError(BeaconStateError),
|
||||
}
|
||||
|
||||
impl From<BeaconStateError> for Error {
|
||||
fn from(e: BeaconStateError) -> Self {
|
||||
Error::BeaconStateError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ApiError> for Error {
|
||||
@@ -153,17 +160,17 @@ impl<T: EthSpec, Payload: AbstractExecPayload<T>> BlockProposalContents<T, Paylo
|
||||
} => Some(blobs),
|
||||
}
|
||||
}
|
||||
pub fn default_at_fork(fork_name: ForkName) -> Self {
|
||||
match fork_name {
|
||||
pub fn default_at_fork(fork_name: ForkName) -> Result<Self, BeaconStateError> {
|
||||
Ok(match fork_name {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => {
|
||||
BlockProposalContents::Payload(Payload::default_at_fork(fork_name))
|
||||
BlockProposalContents::Payload(Payload::default_at_fork(fork_name)?)
|
||||
}
|
||||
ForkName::Eip4844 => BlockProposalContents::PayloadAndBlobs {
|
||||
payload: Payload::default_at_fork(fork_name),
|
||||
payload: Payload::default_at_fork(fork_name)?,
|
||||
blobs: vec![],
|
||||
kzg_commitments: vec![],
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -803,10 +810,6 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
spec,
|
||||
) {
|
||||
Ok(()) => Ok(ProvenancedPayload::Builder(
|
||||
//FIXME(sean) the builder API needs to be updated
|
||||
// NOTE the comment above was removed in the
|
||||
// rebase with unstable.. I think it goes
|
||||
// here now?
|
||||
BlockProposalContents::Payload(relay.data.message.header),
|
||||
)),
|
||||
Err(reason) if !reason.payload_invalid() => {
|
||||
@@ -858,19 +861,11 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
spec,
|
||||
) {
|
||||
Ok(()) => Ok(ProvenancedPayload::Builder(
|
||||
//FIXME(sean) the builder API needs to be updated
|
||||
// NOTE the comment above was removed in the
|
||||
// rebase with unstable.. I think it goes
|
||||
// here now?
|
||||
BlockProposalContents::Payload(relay.data.message.header),
|
||||
)),
|
||||
// If the payload is valid then use it. The local EE failed
|
||||
// to produce a payload so we have no alternative.
|
||||
Err(e) if !e.payload_invalid() => Ok(ProvenancedPayload::Builder(
|
||||
//FIXME(sean) the builder API needs to be updated
|
||||
// NOTE the comment above was removed in the
|
||||
// rebase with unstable.. I think it goes
|
||||
// here now?
|
||||
BlockProposalContents::Payload(relay.data.message.header),
|
||||
)),
|
||||
Err(reason) => {
|
||||
|
||||
@@ -189,6 +189,11 @@ async fn reconstruct_block<T: BeaconChainTypes>(
|
||||
.spec
|
||||
.fork_name_at_epoch(block.slot().epoch(T::EthSpec::slots_per_epoch())),
|
||||
)
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!(
|
||||
"Default payload construction error: {e:?}"
|
||||
))
|
||||
})?
|
||||
.into()
|
||||
// If we already have an execution payload with this transactions root cached, use it.
|
||||
} else if let Some(cached_payload) =
|
||||
|
||||
@@ -119,8 +119,8 @@ lazy_static! {
|
||||
pub(crate) const MAX_RPC_SIZE: usize = 1_048_576; // 1M
|
||||
/// The maximum bytes that can be sent across the RPC post-merge.
|
||||
pub(crate) const MAX_RPC_SIZE_POST_MERGE: usize = 10 * 1_048_576; // 10M
|
||||
//FIXME(sean) should these be the same?
|
||||
pub(crate) const MAX_RPC_SIZE_POST_CAPELLA: usize = 10 * 1_048_576; // 10M
|
||||
// FIXME(sean) should this be increased to account for blobs?
|
||||
pub(crate) const MAX_RPC_SIZE_POST_EIP4844: usize = 10 * 1_048_576; // 10M
|
||||
/// The protocol prefix the RPC protocol id.
|
||||
const PROTOCOL_PREFIX: &str = "/eth2/beacon_chain/req";
|
||||
|
||||
@@ -115,7 +115,8 @@ const MAX_AGGREGATED_ATTESTATION_REPROCESS_QUEUE_LEN: usize = 1_024;
|
||||
/// before we start dropping them.
|
||||
const MAX_GOSSIP_BLOCK_QUEUE_LEN: usize = 1_024;
|
||||
|
||||
//FIXME(sean) verify
|
||||
/// The maximum number of queued `SignedBeaconBlockAndBlobsSidecar` objects received on gossip that
|
||||
/// will be stored before we start dropping them.
|
||||
const MAX_GOSSIP_BLOCK_AND_BLOB_QUEUE_LEN: usize = 1_024;
|
||||
|
||||
/// The maximum number of queued `SignedBeaconBlock` objects received prior to their slot (but
|
||||
@@ -1186,7 +1187,6 @@ impl<T: BeaconChainTypes> BeaconProcessor<T> {
|
||||
// required to verify some attestations.
|
||||
} else if let Some(item) = gossip_block_queue.pop() {
|
||||
self.spawn_worker(item, toolbox);
|
||||
//FIXME(sean)
|
||||
} else if let Some(item) = gossip_block_and_blobs_sidecar_queue.pop() {
|
||||
self.spawn_worker(item, toolbox);
|
||||
// Check the aggregates, *then* the unaggregates since we assume that
|
||||
@@ -1675,23 +1675,9 @@ impl<T: BeaconChainTypes> BeaconProcessor<T> {
|
||||
/*
|
||||
* Verification for blobs sidecars received on gossip.
|
||||
*/
|
||||
Work::GossipBlockAndBlobsSidecar {
|
||||
message_id,
|
||||
peer_id,
|
||||
peer_client,
|
||||
block_and_blobs,
|
||||
seen_timestamp,
|
||||
} => task_spawner.spawn_async(async move {
|
||||
worker
|
||||
.process_gossip_block_and_blobs_sidecar(
|
||||
message_id,
|
||||
peer_id,
|
||||
peer_client,
|
||||
block_and_blobs,
|
||||
seen_timestamp,
|
||||
)
|
||||
.await
|
||||
}),
|
||||
Work::GossipBlockAndBlobsSidecar { .. } => {
|
||||
warn!(self.log, "Unexpected block and blobs on gossip")
|
||||
}
|
||||
/*
|
||||
* Import for blocks that we received earlier than their intended slot.
|
||||
*/
|
||||
@@ -1892,19 +1878,9 @@ impl<T: BeaconChainTypes> BeaconProcessor<T> {
|
||||
request,
|
||||
)
|
||||
}),
|
||||
Work::BlobsByRangeRequest {
|
||||
peer_id,
|
||||
request_id,
|
||||
request,
|
||||
} => task_spawner.spawn_blocking_with_manual_send_idle(move |send_idle_on_drop| {
|
||||
worker.handle_blobs_by_range_request(
|
||||
sub_executor,
|
||||
send_idle_on_drop,
|
||||
peer_id,
|
||||
request_id,
|
||||
request,
|
||||
)
|
||||
}),
|
||||
Work::BlobsByRangeRequest { .. } => {
|
||||
warn!(self.log.clone(), "Unexpected BlobsByRange Request")
|
||||
}
|
||||
/*
|
||||
* Processing of lightclient bootstrap requests from other peers.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,7 @@ use beacon_chain::{
|
||||
BeaconChainError, BeaconChainTypes, BlockError, CountUnrealized, ForkChoiceError,
|
||||
GossipVerifiedBlock, NotifyExecutionLayer,
|
||||
};
|
||||
use lighthouse_network::{
|
||||
Client, MessageAcceptance, MessageId, PeerAction, PeerId, ReportSource,
|
||||
SignedBeaconBlockAndBlobsSidecar,
|
||||
};
|
||||
use lighthouse_network::{Client, MessageAcceptance, MessageId, PeerAction, PeerId, ReportSource};
|
||||
use slog::{crit, debug, error, info, trace, warn};
|
||||
use slot_clock::SlotClock;
|
||||
use ssz::Encode;
|
||||
@@ -699,19 +696,6 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn process_gossip_block_and_blobs_sidecar(
|
||||
self,
|
||||
_message_id: MessageId,
|
||||
_peer_id: PeerId,
|
||||
_peer_client: Client,
|
||||
_block_and_blob: Arc<SignedBeaconBlockAndBlobsSidecar<T::EthSpec>>,
|
||||
_seen_timestamp: Duration,
|
||||
) {
|
||||
//FIXME
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
/// Process the beacon block received from the gossip network and
|
||||
/// if it passes gossip propagation criteria, tell the network thread to forward it.
|
||||
///
|
||||
|
||||
@@ -4,7 +4,6 @@ use crate::status::ToStatusMessage;
|
||||
use crate::sync::SyncMessage;
|
||||
use beacon_chain::{BeaconChainError, BeaconChainTypes, HistoricalBlockError, WhenSlotSkipped};
|
||||
use itertools::process_results;
|
||||
use lighthouse_network::rpc::methods::{BlobsByRangeRequest, MAX_REQUEST_BLOBS_SIDECARS};
|
||||
use lighthouse_network::rpc::StatusMessage;
|
||||
use lighthouse_network::rpc::*;
|
||||
use lighthouse_network::{PeerId, PeerRequestId, ReportSource, Response, SyncInfo};
|
||||
@@ -455,152 +454,4 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
"load_blocks_by_range_blocks",
|
||||
);
|
||||
}
|
||||
|
||||
/// Handle a `BlobsByRange` request from the peer.
|
||||
pub fn handle_blobs_by_range_request(
|
||||
self,
|
||||
_executor: TaskExecutor,
|
||||
_send_on_drop: SendOnDrop,
|
||||
peer_id: PeerId,
|
||||
_request_id: PeerRequestId,
|
||||
mut req: BlobsByRangeRequest,
|
||||
) {
|
||||
debug!(self.log, "Received BlobsByRange Request";
|
||||
"peer_id" => %peer_id,
|
||||
"count" => req.count,
|
||||
"start_slot" => req.start_slot,
|
||||
);
|
||||
|
||||
// Should not send more than max request blocks
|
||||
if req.count > MAX_REQUEST_BLOBS_SIDECARS {
|
||||
req.count = MAX_REQUEST_BLOBS_SIDECARS;
|
||||
}
|
||||
|
||||
//FIXME(sean) create the blobs iter
|
||||
|
||||
// let forwards_block_root_iter = match self
|
||||
// .chain
|
||||
// .forwards_iter_block_roots(Slot::from(req.start_slot))
|
||||
// {
|
||||
// Ok(iter) => iter,
|
||||
// Err(BeaconChainError::HistoricalBlockError(
|
||||
// HistoricalBlockError::BlockOutOfRange {
|
||||
// slot,
|
||||
// oldest_block_slot,
|
||||
// },
|
||||
// )) => {
|
||||
// debug!(self.log, "Range request failed during backfill"; "requested_slot" => slot, "oldest_known_slot" => oldest_block_slot);
|
||||
// return self.send_error_response(
|
||||
// peer_id,
|
||||
// RPCResponseErrorCode::ResourceUnavailable,
|
||||
// "Backfilling".into(),
|
||||
// request_id,
|
||||
// );
|
||||
// }
|
||||
// Err(e) => return error!(self.log, "Unable to obtain root iter"; "error" => ?e),
|
||||
// };
|
||||
//
|
||||
// // Pick out the required blocks, ignoring skip-slots.
|
||||
// let mut last_block_root = None;
|
||||
// let maybe_block_roots = process_results(forwards_block_root_iter, |iter| {
|
||||
// iter.take_while(|(_, slot)| slot.as_u64() < req.start_slot.saturating_add(req.count))
|
||||
// // map skip slots to None
|
||||
// .map(|(root, _)| {
|
||||
// let result = if Some(root) == last_block_root {
|
||||
// None
|
||||
// } else {
|
||||
// Some(root)
|
||||
// };
|
||||
// last_block_root = Some(root);
|
||||
// result
|
||||
// })
|
||||
// .collect::<Vec<Option<Hash256>>>()
|
||||
// });
|
||||
//
|
||||
// let block_roots = match maybe_block_roots {
|
||||
// Ok(block_roots) => block_roots,
|
||||
// Err(e) => return error!(self.log, "Error during iteration over blocks"; "error" => ?e),
|
||||
// };
|
||||
//
|
||||
// // remove all skip slots
|
||||
// let block_roots = block_roots.into_iter().flatten().collect::<Vec<_>>();
|
||||
//
|
||||
// // Fetching blocks is async because it may have to hit the execution layer for payloads.
|
||||
// executor.spawn(
|
||||
// async move {
|
||||
// let mut blocks_sent = 0;
|
||||
// let mut send_response = true;
|
||||
//
|
||||
// for root in block_roots {
|
||||
// match self.chain.store.get_blobs(&root) {
|
||||
// Ok(Some(blob)) => {
|
||||
// blocks_sent += 1;
|
||||
// self.send_network_message(NetworkMessage::SendResponse {
|
||||
// peer_id,
|
||||
// response: Response::BlobsByRange(Some(Arc::new(VariableList::new(vec![blob.message]).unwrap()))),
|
||||
// id: request_id,
|
||||
// });
|
||||
// }
|
||||
// Ok(None) => {
|
||||
// error!(
|
||||
// self.log,
|
||||
// "Blob in the chain is not in the store";
|
||||
// "request_root" => ?root
|
||||
// );
|
||||
// break;
|
||||
// }
|
||||
// Err(e) => {
|
||||
// error!(
|
||||
// self.log,
|
||||
// "Error fetching block for peer";
|
||||
// "block_root" => ?root,
|
||||
// "error" => ?e
|
||||
// );
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// let current_slot = self
|
||||
// .chain
|
||||
// .slot()
|
||||
// .unwrap_or_else(|_| self.chain.slot_clock.genesis_slot());
|
||||
//
|
||||
// if blocks_sent < (req.count as usize) {
|
||||
// debug!(
|
||||
// self.log,
|
||||
// "BlocksByRange Response processed";
|
||||
// "peer" => %peer_id,
|
||||
// "msg" => "Failed to return all requested blocks",
|
||||
// "start_slot" => req.start_slot,
|
||||
// "current_slot" => current_slot,
|
||||
// "requested" => req.count,
|
||||
// "returned" => blocks_sent
|
||||
// );
|
||||
// } else {
|
||||
// debug!(
|
||||
// self.log,
|
||||
// "BlocksByRange Response processed";
|
||||
// "peer" => %peer_id,
|
||||
// "start_slot" => req.start_slot,
|
||||
// "current_slot" => current_slot,
|
||||
// "requested" => req.count,
|
||||
// "returned" => blocks_sent
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// if send_response {
|
||||
// // send the stream terminator
|
||||
// self.send_network_message(NetworkMessage::SendResponse {
|
||||
// peer_id,
|
||||
// response: Response::BlobsByRange(None),
|
||||
// id: request_id,
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// drop(send_on_drop);
|
||||
// },
|
||||
// "load_blocks_by_range_blocks",
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ use lighthouse_network::rpc::methods::MAX_REQUEST_BLOCKS;
|
||||
use lighthouse_network::types::{NetworkGlobals, SyncState};
|
||||
use lighthouse_network::SyncInfo;
|
||||
use lighthouse_network::{PeerAction, PeerId};
|
||||
use slog::{crit, debug, error, info, trace, Logger};
|
||||
use slog::{crit, debug, error, info, trace, warn, Logger};
|
||||
use std::boxed::Box;
|
||||
use std::ops::Sub;
|
||||
use std::sync::Arc;
|
||||
@@ -592,8 +592,9 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
.block_lookups
|
||||
.parent_chain_processed(chain_hash, result, &mut self.network),
|
||||
},
|
||||
//FIXME(sean)
|
||||
SyncMessage::RpcBlob { .. } => todo!(),
|
||||
SyncMessage::RpcBlob { .. } => {
|
||||
warn!(self.log, "Unexpected blob message received");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user