mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-17 18:58:23 +00:00
Fulu update to spec v1.6.0-alpha.4 (#7890)
Fulu update to spec [v1.6.0-alpha.4](https://github.com/ethereum/consensus-specs/releases/tag/v1.6.0-alpha.4). - Make `number_of_columns` a preset - Optimise `get_custody_groups` to avoid computing if cgc = 128 - Add support for additional typenum values in type_dispatch macro
This commit is contained in:
@@ -629,7 +629,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
self: &Arc<Self>,
|
||||
peer_id: PeerId,
|
||||
inbound_request_id: InboundRequestId,
|
||||
request: DataColumnsByRootRequest,
|
||||
request: DataColumnsByRootRequest<T::EthSpec>,
|
||||
) -> Result<(), Error<T::EthSpec>> {
|
||||
let processor = self.clone();
|
||||
let process_fn = move || {
|
||||
@@ -1008,7 +1008,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
|
||||
let blob_publication_batch_interval = chain.config.blob_publication_batch_interval;
|
||||
let blob_publication_batches = chain.config.blob_publication_batches;
|
||||
let number_of_columns = chain.spec.number_of_columns as usize;
|
||||
let number_of_columns = T::EthSpec::number_of_columns();
|
||||
let batch_size = number_of_columns / blob_publication_batches;
|
||||
let mut publish_count = 0usize;
|
||||
|
||||
|
||||
@@ -346,7 +346,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
self: Arc<Self>,
|
||||
peer_id: PeerId,
|
||||
inbound_request_id: InboundRequestId,
|
||||
request: DataColumnsByRootRequest,
|
||||
request: DataColumnsByRootRequest<T::EthSpec>,
|
||||
) {
|
||||
self.terminate_response_stream(
|
||||
peer_id,
|
||||
@@ -361,14 +361,14 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
&self,
|
||||
peer_id: PeerId,
|
||||
inbound_request_id: InboundRequestId,
|
||||
request: DataColumnsByRootRequest,
|
||||
request: DataColumnsByRootRequest<T::EthSpec>,
|
||||
) -> Result<(), (RpcErrorResponse, &'static str)> {
|
||||
let mut send_data_column_count = 0;
|
||||
|
||||
for data_column_ids_by_root in request.data_column_ids.as_slice() {
|
||||
match self.chain.get_data_columns_checking_all_caches(
|
||||
data_column_ids_by_root.block_root,
|
||||
data_column_ids_by_root.columns.as_slice(),
|
||||
data_column_ids_by_root.columns.iter().as_slice(),
|
||||
) {
|
||||
Ok(data_columns) => {
|
||||
send_data_column_count += data_columns.len();
|
||||
|
||||
@@ -186,11 +186,11 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
/* RPC - Related functionality */
|
||||
|
||||
/// A new RPC request has been received from the network.
|
||||
fn handle_rpc_request<E: EthSpec>(
|
||||
fn handle_rpc_request(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
inbound_request_id: InboundRequestId, // Use ResponseId here
|
||||
request_type: RequestType<E>,
|
||||
request_type: RequestType<T::EthSpec>,
|
||||
) {
|
||||
if !self.network_globals.peers.read().is_connected(&peer_id) {
|
||||
debug!(%peer_id, request = ?request_type, "Dropping request of disconnected peer");
|
||||
|
||||
@@ -243,7 +243,6 @@ impl<E: EthSpec> RangeBlockComponentsRequest<E> {
|
||||
column_to_peer_id,
|
||||
expected_custody_columns,
|
||||
*attempt,
|
||||
spec,
|
||||
);
|
||||
|
||||
if let Err(CouplingError::DataColumnPeerFailure {
|
||||
@@ -336,7 +335,6 @@ impl<E: EthSpec> RangeBlockComponentsRequest<E> {
|
||||
column_to_peer: HashMap<u64, PeerId>,
|
||||
expects_custody_columns: &[ColumnIndex],
|
||||
attempt: usize,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<Vec<RpcBlock<E>>, CouplingError> {
|
||||
// Group data columns by block_root and index
|
||||
let mut data_columns_by_block =
|
||||
@@ -415,7 +413,7 @@ impl<E: EthSpec> RangeBlockComponentsRequest<E> {
|
||||
);
|
||||
}
|
||||
|
||||
RpcBlock::new_with_custody_columns(Some(block_root), block, custody_columns, spec)
|
||||
RpcBlock::new_with_custody_columns(Some(block_root), block, custody_columns)
|
||||
.map_err(|e| CouplingError::InternalError(format!("{:?}", e)))?
|
||||
} else {
|
||||
// Block has no data, expects zero columns
|
||||
|
||||
@@ -948,9 +948,10 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
self.send_network_msg(NetworkMessage::SendRequest {
|
||||
peer_id,
|
||||
request: RequestType::DataColumnsByRoot(
|
||||
request
|
||||
.clone()
|
||||
.try_into_request(self.fork_context.current_fork_name(), &self.chain.spec)?,
|
||||
request.clone().try_into_request::<T::EthSpec>(
|
||||
self.fork_context.current_fork_name(),
|
||||
&self.chain.spec,
|
||||
)?,
|
||||
),
|
||||
app_request_id: AppRequestId::Sync(SyncRequestId::DataColumnsByRoot(id)),
|
||||
})?;
|
||||
|
||||
@@ -13,16 +13,14 @@ use std::collections::HashSet;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{collections::HashMap, marker::PhantomData, sync::Arc};
|
||||
use tracing::{debug, warn};
|
||||
use types::EthSpec;
|
||||
use types::{DataColumnSidecar, Hash256, data_column_sidecar::ColumnIndex};
|
||||
use types::{DataColumnSidecarList, EthSpec};
|
||||
|
||||
use super::{LookupRequestResult, PeerGroup, RpcResponseResult, SyncNetworkContext};
|
||||
|
||||
const FAILED_PEERS_CACHE_EXPIRY_SECONDS: u64 = 5;
|
||||
const MAX_STALE_NO_PEERS_DURATION: Duration = Duration::from_secs(30);
|
||||
|
||||
type DataColumnSidecarList<E> = Vec<Arc<DataColumnSidecar<E>>>;
|
||||
|
||||
pub struct ActiveCustodyRequest<T: BeaconChainTypes> {
|
||||
block_root: Hash256,
|
||||
custody_id: CustodyId,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use lighthouse_network::rpc::methods::DataColumnsByRootRequest;
|
||||
use ssz_types::VariableList;
|
||||
use std::sync::Arc;
|
||||
use types::{
|
||||
ChainSpec, DataColumnSidecar, DataColumnsByRootIdentifier, EthSpec, ForkName, Hash256,
|
||||
RuntimeVariableList,
|
||||
};
|
||||
|
||||
use super::{ActiveRequestItems, LookupVerifyError};
|
||||
@@ -14,13 +14,12 @@ pub struct DataColumnsByRootSingleBlockRequest {
|
||||
}
|
||||
|
||||
impl DataColumnsByRootSingleBlockRequest {
|
||||
pub fn try_into_request(
|
||||
pub fn try_into_request<E: EthSpec>(
|
||||
self,
|
||||
fork_name: ForkName,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<DataColumnsByRootRequest, &'static str> {
|
||||
let number_of_columns = spec.number_of_columns as usize;
|
||||
let columns = RuntimeVariableList::new(self.indices, number_of_columns)
|
||||
) -> Result<DataColumnsByRootRequest<E>, &'static str> {
|
||||
let columns = VariableList::new(self.indices)
|
||||
.map_err(|_| "Number of indices exceeds total number of columns")?;
|
||||
Ok(DataColumnsByRootRequest::new(
|
||||
vec![DataColumnsByRootIdentifier {
|
||||
|
||||
@@ -1922,7 +1922,7 @@ fn custody_lookup_happy_path() {
|
||||
let id = r.expect_block_lookup_request(block.canonical_root());
|
||||
r.complete_valid_block_request(id, block.into(), true);
|
||||
// for each slot we download `samples_per_slot` columns
|
||||
let sample_column_count = spec.samples_per_slot * spec.data_columns_per_group();
|
||||
let sample_column_count = spec.samples_per_slot * spec.data_columns_per_group::<E>();
|
||||
let custody_ids =
|
||||
r.expect_only_data_columns_by_root_requests(block_root, sample_column_count as usize);
|
||||
r.complete_valid_custody_request(custody_ids, data_columns, false);
|
||||
|
||||
@@ -427,7 +427,7 @@ impl TestRig {
|
||||
.chain
|
||||
.process_block(
|
||||
block_root,
|
||||
build_rpc_block(block.into(), &data_sidecars, &self.spec),
|
||||
build_rpc_block(block.into(), &data_sidecars),
|
||||
NotifyExecutionLayer::Yes,
|
||||
BlockImportSource::RangeSync,
|
||||
|| Ok(()),
|
||||
@@ -443,14 +443,13 @@ impl TestRig {
|
||||
fn build_rpc_block(
|
||||
block: Arc<SignedBeaconBlock<E>>,
|
||||
data_sidecars: &Option<DataSidecars<E>>,
|
||||
spec: &ChainSpec,
|
||||
) -> RpcBlock<E> {
|
||||
match data_sidecars {
|
||||
Some(DataSidecars::Blobs(blobs)) => {
|
||||
RpcBlock::new(None, block, Some(blobs.clone())).unwrap()
|
||||
}
|
||||
Some(DataSidecars::DataColumns(columns)) => {
|
||||
RpcBlock::new_with_custody_columns(None, block, columns.clone(), spec).unwrap()
|
||||
RpcBlock::new_with_custody_columns(None, block, columns.clone()).unwrap()
|
||||
}
|
||||
// Block has no data, expects zero columns
|
||||
None => RpcBlock::new_without_blobs(None, block),
|
||||
|
||||
Reference in New Issue
Block a user