mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-18 22:49:34 +00:00
Linting
This commit is contained in:
@@ -29,6 +29,8 @@ impl From<BeaconChainError> for GossipInclusionListError {
|
||||
}
|
||||
|
||||
pub struct GossipVerifiedInclusionList<T: BeaconChainTypes> {
|
||||
// TODO(focil) remove once this field is read
|
||||
#[allow(dead_code)]
|
||||
signed_il: SignedInclusionList<T::EthSpec>,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes};
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
||||
use eth2::types::{self as api_types};
|
||||
use slot_clock::SlotClock;
|
||||
use types::{Epoch, EthSpec, Hash256, InclusionListDuty};
|
||||
|
||||
@@ -2258,7 +2258,8 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
);
|
||||
|
||||
// POST beacon/pool/inclusion_lists
|
||||
let post_beacon_pool_inclusion_lists = beacon_pool_path
|
||||
// TODO(focil) unused endpoint and variables
|
||||
let _post_beacon_pool_inclusion_lists = beacon_pool_path
|
||||
.clone()
|
||||
.and(warp::path("inclusion_lists"))
|
||||
.and(warp::path::end())
|
||||
@@ -2267,12 +2268,12 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.and(log_filter.clone())
|
||||
.then(
|
||||
|task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
_chain: Arc<BeaconChain<T>>,
|
||||
inclusion_lists: Vec<SignedInclusionList<T::EthSpec>>,
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
_network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
log: Logger| {
|
||||
task_spawner.blocking_json_task(Priority::P0, move || {
|
||||
// TODO: actually gossip the inclusion lists
|
||||
// TODO(focil): actually gossip the inclusion lists
|
||||
info!(
|
||||
log,
|
||||
"Posting signed inclusion lists for gossip";
|
||||
@@ -3547,7 +3548,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// allow a tolerance of one slot to account for clock skew
|
||||
//
|
||||
// TODO: make sure tolerance is consistent with inner logic
|
||||
// TODO(focil) make sure tolerance is consistent with inner logic
|
||||
if query.slot > current_slot + 1 {
|
||||
return Err(warp_utils::reject::custom_bad_request(format!(
|
||||
"request slot {} is more than one slot past the current slot {}",
|
||||
@@ -3558,7 +3559,6 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let data = chain
|
||||
.produce_inclusion_list(query.slot)
|
||||
.await
|
||||
.map(|il| il.clone())
|
||||
.map(api_types::GenericResponse::from)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
Ok::<_, warp::reject::Rejection>(warp::reply::json(&data).into_response())
|
||||
|
||||
@@ -2165,15 +2165,16 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
};
|
||||
}
|
||||
|
||||
// TODO(focil) unused variables
|
||||
pub fn process_gossip_inclusion_list(
|
||||
self: &Arc<Self>,
|
||||
message_id: MessageId,
|
||||
peer_id: PeerId,
|
||||
_message_id: MessageId,
|
||||
_peer_id: PeerId,
|
||||
il: SignedInclusionList<T::EthSpec>,
|
||||
seen_timestamp: Duration,
|
||||
_seen_timestamp: Duration,
|
||||
) {
|
||||
match GossipVerifiedInclusionList::verify(&il, &self.chain) {
|
||||
Ok(gossip_verified_il) => {
|
||||
Ok(_gossip_verified_il) => {
|
||||
debug!(self.log, "Successfully verified gossip inclusion list");
|
||||
}
|
||||
Err(err) => match err {
|
||||
|
||||
@@ -541,8 +541,8 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
bls_to_execution_change,
|
||||
),
|
||||
),
|
||||
PubsubMessage::InclusionList(il) => {
|
||||
// TODO
|
||||
PubsubMessage::InclusionList(_il) => {
|
||||
// TODO(focil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
) -> Result<InclusionListCommittee<E>, Error> {
|
||||
let epoch = slot.epoch(E::slots_per_epoch());
|
||||
let current_epoch = self.current_epoch();
|
||||
let next_epoch = current_epoch + 1;
|
||||
let next_epoch = current_epoch.safe_add(1)?;
|
||||
if epoch != current_epoch || epoch != next_epoch {
|
||||
return Err(Error::SlotOutOfBounds);
|
||||
}
|
||||
@@ -828,9 +828,10 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
let seed = self.get_inclusion_list_seed(slot, spec)?;
|
||||
let indices = self.get_active_validator_indices(epoch, spec)?;
|
||||
|
||||
let start =
|
||||
(slot % E::slots_per_epoch()).as_usize() * E::InclusionListCommitteeSize::to_usize();
|
||||
let end = start + E::InclusionListCommitteeSize::to_usize();
|
||||
let start = (slot.safe_rem(E::slots_per_epoch())?)
|
||||
.as_usize()
|
||||
.safe_mul(E::InclusionListCommitteeSize::to_usize())?;
|
||||
let end = start.safe_add(E::InclusionListCommitteeSize::to_usize())?;
|
||||
|
||||
let mut i = start;
|
||||
let mut il_committee_indices =
|
||||
|
||||
@@ -6,7 +6,6 @@ use serde::{Deserialize, Serialize};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use ssz_types::VariableList;
|
||||
use test_random_derive::TestRandom;
|
||||
use tree_hash::TreeHash;
|
||||
use tree_hash_derive::TreeHash;
|
||||
|
||||
pub type InclusionListTransactions<E> = VariableList<
|
||||
|
||||
@@ -1441,7 +1441,8 @@ async fn poll_beacon_inclusion_list_duties_for_epoch<T: SlotClock + 'static, E:
|
||||
|
||||
// Update the duties service with the new `InclusionListDutyData` messages.
|
||||
let mut inclusion_list_duties = duties_service.inclusion_list_duties.write();
|
||||
let current_slot = duties_service
|
||||
// TODO(focil) this variable is unused at the moment
|
||||
let _current_slot = duties_service
|
||||
.slot_clock
|
||||
.now_or_genesis()
|
||||
.unwrap_or_default();
|
||||
@@ -1451,7 +1452,8 @@ async fn poll_beacon_inclusion_list_duties_for_epoch<T: SlotClock + 'static, E:
|
||||
match inclusion_list_duty_map.entry(epoch) {
|
||||
hash_map::Entry::Occupied(mut occupied) => {
|
||||
let mut_value = occupied.get_mut();
|
||||
let (prior_dependent_root, prior_duty) = &mut_value;
|
||||
// TODO(focil) unused variable
|
||||
let (prior_dependent_root, _prior_duty) = &mut_value;
|
||||
|
||||
// NOTE: We do not need to worry about an overwrite here, since there is no
|
||||
// information that we store aside from the duty itself. There is no selection proof
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
use crate::duties_service::{DutiesService, DutyAndProof};
|
||||
use crate::duties_service::DutiesService;
|
||||
use beacon_node_fallback::{ApiTopic, BeaconNodeFallback};
|
||||
use environment::RuntimeContext;
|
||||
use eth2::types::InclusionListDutyData;
|
||||
use futures::future::join_all;
|
||||
use slog::{crit, debug, error, info, trace, warn};
|
||||
use slog::{crit, error, info, trace, warn};
|
||||
use slot_clock::SlotClock;
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
use tokio::time::{sleep, sleep_until, Duration, Instant};
|
||||
use tree_hash::TreeHash;
|
||||
use types::{
|
||||
Attestation, AttestationData, ChainSpec, CommitteeIndex, EthSpec, InclusionList,
|
||||
SignedInclusionList, Slot,
|
||||
};
|
||||
use tokio::time::{sleep, Duration};
|
||||
use types::{ChainSpec, EthSpec, Slot};
|
||||
use validator_store::{Error as ValidatorStoreError, ValidatorStore};
|
||||
|
||||
/// Helper to minimise `Arc` usage.
|
||||
@@ -116,9 +111,13 @@ impl<T: SlotClock + 'static, E: EthSpec> InclusionListService<T, E> {
|
||||
}
|
||||
|
||||
/// Spawn a new task that downloads, signs and uploads the inclusion lists to the beacon node.
|
||||
fn spawn_inclusion_list_task(&self, slot_duration: Duration) -> Result<(), String> {
|
||||
// TODO(focil) I don't think we need `slot_duration` here, unless we need to make some calculation
|
||||
// related to the freeze deadline.
|
||||
fn spawn_inclusion_list_task(&self, _slot_duration: Duration) -> Result<(), String> {
|
||||
let slot = self.slot_clock.now().ok_or("Failed to read slot clock")?;
|
||||
let duration_to_next_slot = self
|
||||
|
||||
// TODO(focil) unused variable
|
||||
let _duration_to_next_slot = self
|
||||
.slot_clock
|
||||
.duration_to_next_slot()
|
||||
.ok_or("Unable to determine duration to next slot")?;
|
||||
@@ -160,7 +159,8 @@ impl<T: SlotClock + 'static, E: EthSpec> InclusionListService<T, E> {
|
||||
.now()
|
||||
.ok_or("Unable to determine current slot from clock")
|
||||
.map(|slot| slot.epoch(E::slots_per_epoch()));
|
||||
let current_epoch = current_epoch.map_err(|e| {
|
||||
// TODO(focil) unused variable
|
||||
let _current_epoch = current_epoch.map_err(|e| {
|
||||
crit!(
|
||||
log,
|
||||
"Error during inclusion list routine";
|
||||
@@ -172,12 +172,12 @@ impl<T: SlotClock + 'static, E: EthSpec> InclusionListService<T, E> {
|
||||
let inclusion_list = self
|
||||
.beacon_nodes
|
||||
.first_success(|beacon_node| async move {
|
||||
// TODO: add timer metric
|
||||
// TODO(focil) add timer metric
|
||||
beacon_node
|
||||
.get_validator_inclusion_list(slot)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to produce inclusion list: {:?}", e))
|
||||
.map(|result| result.ok_or(format!("Inclusion list unavailable")))?
|
||||
.map(|result| result.ok_or("Inclusion list unavailable".to_string()))?
|
||||
.map(|result| result.data)
|
||||
})
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user