diff --git a/beacon_node/beacon_chain/src/inclusion_list_verification.rs b/beacon_node/beacon_chain/src/inclusion_list_verification.rs index 092be0d185..dfa23ef709 100644 --- a/beacon_node/beacon_chain/src/inclusion_list_verification.rs +++ b/beacon_node/beacon_chain/src/inclusion_list_verification.rs @@ -29,6 +29,8 @@ impl From for GossipInclusionListError { } pub struct GossipVerifiedInclusionList { + // TODO(focil) remove once this field is read + #[allow(dead_code)] signed_il: SignedInclusionList, } diff --git a/beacon_node/http_api/src/inclusion_list_duties.rs b/beacon_node/http_api/src/inclusion_list_duties.rs index 01cb4f7309..745f6b78cc 100644 --- a/beacon_node/http_api/src/inclusion_list_duties.rs +++ b/beacon_node/http_api/src/inclusion_list_duties.rs @@ -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}; diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 91e5be15e8..1a024135aa 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -2258,7 +2258,8 @@ pub fn serve( ); // 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( .and(log_filter.clone()) .then( |task_spawner: TaskSpawner, - chain: Arc>, + _chain: Arc>, inclusion_lists: Vec>, - network_tx: UnboundedSender>, + _network_tx: UnboundedSender>, 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( // 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( 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()) diff --git a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs index b3fd6ee2af..73359248b0 100644 --- a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs @@ -2165,15 +2165,16 @@ impl NetworkBeaconProcessor { }; } + // TODO(focil) unused variables pub fn process_gossip_inclusion_list( self: &Arc, - message_id: MessageId, - peer_id: PeerId, + _message_id: MessageId, + _peer_id: PeerId, il: SignedInclusionList, - 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 { diff --git a/beacon_node/network/src/router.rs b/beacon_node/network/src/router.rs index cad1a19838..88dd33bd4d 100644 --- a/beacon_node/network/src/router.rs +++ b/beacon_node/network/src/router.rs @@ -541,8 +541,8 @@ impl Router { bls_to_execution_change, ), ), - PubsubMessage::InclusionList(il) => { - // TODO + PubsubMessage::InclusionList(_il) => { + // TODO(focil) } } } diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index d97e5333fa..c3e9a91066 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -820,7 +820,7 @@ impl BeaconState { ) -> Result, 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 BeaconState { 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 = diff --git a/consensus/types/src/inclusion_list.rs b/consensus/types/src/inclusion_list.rs index 9283bb5799..8ee55f0ee7 100644 --- a/consensus/types/src/inclusion_list.rs +++ b/consensus/types/src/inclusion_list.rs @@ -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 = VariableList< diff --git a/validator_client/validator_services/src/duties_service.rs b/validator_client/validator_services/src/duties_service.rs index cad23634f3..69b0c50242 100644 --- a/validator_client/validator_services/src/duties_service.rs +++ b/validator_client/validator_services/src/duties_service.rs @@ -1441,7 +1441,8 @@ async fn poll_beacon_inclusion_list_duties_for_epoch { 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 diff --git a/validator_client/validator_services/src/inclusion_list_service.rs b/validator_client/validator_services/src/inclusion_list_service.rs index f3abdb82b0..a2da25ef25 100644 --- a/validator_client/validator_services/src/inclusion_list_service.rs +++ b/validator_client/validator_services/src/inclusion_list_service.rs @@ -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 InclusionListService { } /// 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 InclusionListService { .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 InclusionListService { 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