Skip to content

Commit

Permalink
lints
Browse files Browse the repository at this point in the history
  • Loading branch information
realbigsean committed Mar 31, 2022
1 parent 0b22312 commit 312d250
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 40 deletions.
6 changes: 3 additions & 3 deletions beacon_node/execution_layer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use lru::LruCache;
use payload_status::process_multiple_payload_statuses;
use sensitive_url::SensitiveUrl;
use serde::{Deserialize, Serialize};
use slog::{crit, debug, error, info, trace, Logger, warn};
use slog::{crit, debug, error, info, trace, warn, Logger};
use slot_clock::SlotClock;
use std::collections::HashMap;
use std::convert::TryInto;
Expand All @@ -26,7 +26,7 @@ use tokio::{
time::{sleep, sleep_until, Instant},
};
use types::{
BlindedPayload, BlockType, ChainSpec, Epoch, ExecPayload, ExecutionBlockHash, FullPayload,
BlindedPayload, BlockType, ChainSpec, Epoch, ExecPayload, ExecutionBlockHash,
ProposerPreparationData, SignedBeaconBlock, Slot,
};

Expand Down Expand Up @@ -806,7 +806,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
.get_payload_v1::<T>(payload_id)
.await
.map(|full_payload| {
if let Some(evicted_payload) = f(self, &full_payload) {
if let Some(_evicted_payload) = f(self, &full_payload) {
warn!(self.log(), "Evicted a payload from the cache, this might indicate redundant proposal attempts.");
}
full_payload.into()
Expand Down
5 changes: 1 addition & 4 deletions beacon_node/execution_layer/src/payload_cache.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use lru::LruCache;
use parking_lot::Mutex;
use std::sync::Arc;
use tree_hash::TreeHash;
use types::{
BeaconBlock, BlindedPayload, EthSpec, ExecutionPayload, FullPayload, Hash256, SignedBeaconBlock,
};
use types::{EthSpec, ExecutionPayload, Hash256};

pub const DEFAULT_PAYLOAD_CACHE_SIZE: usize = 10;

Expand Down
21 changes: 8 additions & 13 deletions beacon_node/http_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,15 @@ mod validator_inclusion;
mod version;

use beacon_chain::{
attestation_verification::VerifiedAttestation,
observed_operations::ObservationOutcome,
validator_monitor::{get_block_delay_ms, timestamp_now},
AttestationError as AttnError, BeaconChain, BeaconChainError, BeaconChainTypes,
HeadSafetyStatus, ProduceBlockVerification, WhenSlotSkipped,
attestation_verification::VerifiedAttestation, observed_operations::ObservationOutcome,
validator_monitor::timestamp_now, AttestationError as AttnError, BeaconChain, BeaconChainError,
BeaconChainTypes, HeadSafetyStatus, ProduceBlockVerification, WhenSlotSkipped,
};
use block_id::BlockId;
use eth2::types::{self as api_types, EndpointVersion, ValidatorId};
use lighthouse_network::{types::SyncState, EnrExt, NetworkGlobals, PeerId, PubsubMessage};
use lighthouse_version::version_with_platform;
use network::NetworkMessage;
use parking_lot::lock_api::RwLock;
use parking_lot::Mutex;
use serde::{Deserialize, Serialize};
use slog::{crit, debug, error, info, warn, Logger};
use slot_clock::SlotClock;
Expand All @@ -41,19 +37,18 @@ use state_id::StateId;
use std::borrow::Cow;
use std::convert::TryInto;
use std::future::Future;
use std::hash::Hash;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::path::PathBuf;
use std::pin::Pin;
use std::sync::Arc;
use tokio::sync::mpsc::UnboundedSender;
use tokio_stream::{wrappers::BroadcastStream, StreamExt};
use types::{
Attestation, AttesterSlashing, BeaconBlockBodyMerge, BeaconBlockMerge, BeaconStateError,
BlindedPayload, CommitteeCache, ConfigAndPreset, Epoch, EthSpec, ExecutionPayload, ForkName,
FullPayload, Hash256, ProposerPreparationData, ProposerSlashing, RelativeEpoch, Signature,
SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockMerge, SignedContributionAndProof,
SignedVoluntaryExit, Slot, SyncCommitteeMessage, SyncContributionData,
Attestation, AttesterSlashing, BeaconStateError, BlindedPayload, CommitteeCache,
ConfigAndPreset, Epoch, EthSpec, ForkName, FullPayload, ProposerPreparationData,
ProposerSlashing, RelativeEpoch, Signature, SignedAggregateAndProof, SignedBeaconBlock,
SignedContributionAndProof, SignedVoluntaryExit, Slot, SyncCommitteeMessage,
SyncContributionData,
};
use version::{
add_consensus_version_header, fork_versioned_response, inconsistent_fork_rejection,
Expand Down
34 changes: 14 additions & 20 deletions beacon_node/http_api/src/publish_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ use slot_clock::SlotClock;
use std::marker::PhantomData;
use std::sync::Arc;
use tokio::sync::mpsc::UnboundedSender;
use types::BlockType::Full;
use types::{
map_fork_name, BeaconBlockAltair, BeaconBlockBase, BeaconBlockBodyAltair, BeaconBlockBodyBase,
BeaconBlockBodyMerge, BeaconBlockMerge, BlindedPayload, EthSpec, ExecPayload, ExecutionPayload,
ExecutionPayloadHeader, ForkName, FullPayload, SignedBeaconBlock, SignedBeaconBlockAltair,
SignedBeaconBlockBase, SignedBeaconBlockMerge,
BeaconBlockAltair, BeaconBlockBase, BeaconBlockBodyAltair, BeaconBlockBodyBase,
BeaconBlockBodyMerge, BeaconBlockMerge, BlindedPayload, FullPayload, SignedBeaconBlock,
SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockMerge,
};
use warp::path::full;
use warp::Rejection;

pub fn publish_block<T: BeaconChainTypes>(
Expand All @@ -29,7 +26,7 @@ pub fn publish_block<T: BeaconChainTypes>(
// Send the block, regardless of whether or not it is valid. The API
// specification is very clear that this is the desired behaviour.
crate::publish_pubsub_message(
&network_tx,
network_tx,
PubsubMessage::BeaconBlock(Box::new(block.clone())),
)?;

Expand Down Expand Up @@ -235,22 +232,19 @@ fn reconstruct_block<T: BeaconChainTypes>(
execution_payload,
} = body;

let el = chain
.execution_layer
.as_ref().ok_or(warp_utils::reject::custom_server_error("Missing execution layer".to_string()))?;
let el = chain.execution_layer.as_ref().ok_or_else(|| {
warp_utils::reject::custom_server_error("Missing execution layer".to_string())
})?;

let full_payload = if let Some(cached_payload) = el.get_payload_by_tx_root(
&execution_payload
.execution_payload_header
.transactions_root){
&execution_payload.execution_payload_header.transactions_root,
) {
cached_payload
}else {
el.block_on(|el| el.propose_blinded_beacon_block(&block_clone)).map_err(|e| {
warp_utils::reject::custom_server_error(format!(
"proposal failed: {:?}",
e
))
})?
} else {
el.block_on(|el| el.propose_blinded_beacon_block(&block_clone))
.map_err(|e| {
warp_utils::reject::custom_server_error(format!("proposal failed: {:?}", e))
})?
};

SignedBeaconBlock::Merge(SignedBeaconBlockMerge {
Expand Down

0 comments on commit 312d250

Please sign in to comment.