Skip to content

Commit b0e0829

Browse files
committed
Merge branch 'unstable' into prepare-proposer
2 parents d029c7b + 4186d11 commit b0e0829

22 files changed

Lines changed: 99 additions & 90 deletions

File tree

beacon_node/beacon_chain/src/attestation_verification.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,6 @@ impl<'a, T: BeaconChainTypes> VerifiedUnaggregatedAttestation<'a, T> {
961961
}
962962

963963
/// Returns `Ok(())` if the `attestation.data.beacon_block_root` is known to this chain.
964-
/// You can use this `shuffling_id` to read from the shuffling cache.
965964
///
966965
/// The block root may not be known for two reasons:
967966
///

beacon_node/beacon_chain/src/validator_pubkey_cache.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{BeaconChainTypes, BeaconStore};
33
use ssz::{Decode, DecodeError, Encode};
44
use std::collections::HashMap;
55
use std::convert::TryInto;
6-
use std::fs::{File, OpenOptions};
6+
use std::fs::File;
77
use std::io::{self, Read, Write};
88
use std::path::Path;
99
use store::{DBColumn, Error as StoreError, StoreItem};
@@ -255,7 +255,7 @@ impl From<Error> for BeaconChainError {
255255
impl ValidatorPubkeyCacheFile {
256256
/// Opens an existing file for reading and writing.
257257
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
258-
OpenOptions::new()
258+
File::options()
259259
.read(true)
260260
.write(true)
261261
.create(false)
@@ -453,7 +453,7 @@ mod test {
453453
let cache = ValidatorPubkeyCache::<T>::load_from_file(&path).expect("should open cache");
454454
drop(cache);
455455

456-
let mut file = OpenOptions::new()
456+
let mut file = File::options()
457457
.write(true)
458458
.append(true)
459459
.open(&path)

beacon_node/network/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ matches = "0.1.8"
1111
exit-future = "0.2.0"
1212
slog-term = "2.6.0"
1313
slog-async = "2.5.0"
14-
logging = { path = "../../common/logging" }
1514
environment = { path = "../../lighthouse/environment" }
1615

1716
[dependencies]
@@ -35,6 +34,7 @@ fnv = "1.0.7"
3534
rlp = "0.5.0"
3635
lazy_static = "1.4.0"
3736
lighthouse_metrics = { path = "../../common/lighthouse_metrics" }
37+
logging = { path = "../../common/logging" }
3838
task_executor = { path = "../../common/task_executor" }
3939
igd = "0.11.1"
4040
itertools = "0.10.0"

beacon_node/network/src/beacon_processor/mod.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ use lighthouse_network::{
4747
rpc::{BlocksByRangeRequest, BlocksByRootRequest, StatusMessage},
4848
Client, MessageId, NetworkGlobals, PeerId, PeerRequestId,
4949
};
50+
use logging::TimeLatch;
5051
use slog::{crit, debug, error, trace, warn, Logger};
5152
use std::collections::VecDeque;
5253
use std::fmt;
5354
use std::pin::Pin;
5455
use std::sync::{Arc, Weak};
5556
use std::task::Context;
56-
use std::time::{Duration, Instant};
57+
use std::time::Duration;
5758
use std::{cmp, collections::HashSet};
5859
use task_executor::TaskExecutor;
5960
use tokio::sync::{mpsc, oneshot};
@@ -159,9 +160,6 @@ const MANAGER_TASK_NAME: &str = "beacon_processor_manager";
159160
/// The name of the worker tokio tasks.
160161
const WORKER_TASK_NAME: &str = "beacon_processor_worker";
161162

162-
/// The minimum interval between log messages indicating that a queue is full.
163-
const LOG_DEBOUNCE_INTERVAL: Duration = Duration::from_secs(30);
164-
165163
/// The `MAX_..._BATCH_SIZE` variables define how many attestations can be included in a single
166164
/// batch.
167165
///
@@ -742,25 +740,6 @@ impl<T: BeaconChainTypes> Work<T> {
742740
}
743741
}
744742

745-
/// Provides de-bounce functionality for logging.
746-
#[derive(Default)]
747-
struct TimeLatch(Option<Instant>);
748-
749-
impl TimeLatch {
750-
/// Only returns true once every `LOG_DEBOUNCE_INTERVAL`.
751-
fn elapsed(&mut self) -> bool {
752-
let now = Instant::now();
753-
754-
let is_elapsed = self.0.map_or(false, |elapse_time| now > elapse_time);
755-
756-
if is_elapsed || self.0.is_none() {
757-
self.0 = Some(now + LOG_DEBOUNCE_INTERVAL);
758-
}
759-
760-
is_elapsed
761-
}
762-
}
763-
764743
/// Unifies all the messages processed by the `BeaconProcessor`.
765744
enum InboundEvent<T: BeaconChainTypes> {
766745
/// A worker has completed a task and is free.

beacon_node/network/src/beacon_processor/work_reprocessing_queue.rs

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use fnv::FnvHashMap;
1717
use futures::task::Poll;
1818
use futures::{Stream, StreamExt};
1919
use lighthouse_network::{MessageId, PeerId};
20+
use logging::TimeLatch;
2021
use slog::{crit, debug, error, warn, Logger};
2122
use slot_clock::SlotClock;
2223
use std::collections::{HashMap, HashSet};
@@ -133,6 +134,8 @@ struct ReprocessQueue<T: BeaconChainTypes> {
133134
/* Aux */
134135
/// Next attestation id, used for both aggregated and unaggregated attestations
135136
next_attestation: usize,
137+
early_block_debounce: TimeLatch,
138+
attestation_delay_debounce: TimeLatch,
136139
}
137140

138141
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -223,6 +226,8 @@ pub fn spawn_reprocess_scheduler<T: BeaconChainTypes>(
223226
queued_unaggregates: FnvHashMap::default(),
224227
awaiting_attestations_per_root: HashMap::new(),
225228
next_attestation: 0,
229+
early_block_debounce: TimeLatch::default(),
230+
attestation_delay_debounce: TimeLatch::default(),
226231
};
227232

228233
executor.spawn(
@@ -261,12 +266,14 @@ impl<T: BeaconChainTypes> ReprocessQueue<T> {
261266
if let Some(duration_till_slot) = slot_clock.duration_to_slot(block_slot) {
262267
// Check to ensure this won't over-fill the queue.
263268
if self.queued_block_roots.len() >= MAXIMUM_QUEUED_BLOCKS {
264-
warn!(
265-
log,
266-
"Early blocks queue is full";
267-
"queue_size" => MAXIMUM_QUEUED_BLOCKS,
268-
"msg" => "check system clock"
269-
);
269+
if self.early_block_debounce.elapsed() {
270+
warn!(
271+
log,
272+
"Early blocks queue is full";
273+
"queue_size" => MAXIMUM_QUEUED_BLOCKS,
274+
"msg" => "check system clock"
275+
);
276+
}
270277
// Drop the block.
271278
return;
272279
}
@@ -306,12 +313,14 @@ impl<T: BeaconChainTypes> ReprocessQueue<T> {
306313
}
307314
InboundEvent::Msg(UnknownBlockAggregate(queued_aggregate)) => {
308315
if self.attestations_delay_queue.len() >= MAXIMUM_QUEUED_ATTESTATIONS {
309-
error!(
310-
log,
311-
"Aggregate attestation delay queue is full";
312-
"queue_size" => MAXIMUM_QUEUED_ATTESTATIONS,
313-
"msg" => "check system clock"
314-
);
316+
if self.attestation_delay_debounce.elapsed() {
317+
error!(
318+
log,
319+
"Aggregate attestation delay queue is full";
320+
"queue_size" => MAXIMUM_QUEUED_ATTESTATIONS,
321+
"msg" => "check system clock"
322+
);
323+
}
315324
// Drop the attestation.
316325
return;
317326
}
@@ -337,12 +346,14 @@ impl<T: BeaconChainTypes> ReprocessQueue<T> {
337346
}
338347
InboundEvent::Msg(UnknownBlockUnaggregate(queued_unaggregate)) => {
339348
if self.attestations_delay_queue.len() >= MAXIMUM_QUEUED_ATTESTATIONS {
340-
error!(
341-
log,
342-
"Attestation delay queue is full";
343-
"queue_size" => MAXIMUM_QUEUED_ATTESTATIONS,
344-
"msg" => "check system clock"
345-
);
349+
if self.attestation_delay_debounce.elapsed() {
350+
error!(
351+
log,
352+
"Attestation delay queue is full";
353+
"queue_size" => MAXIMUM_QUEUED_ATTESTATIONS,
354+
"msg" => "check system clock"
355+
);
356+
}
346357
// Drop the attestation.
347358
return;
348359
}

beacon_node/network/src/beacon_processor/worker/gossip_methods.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ impl<T: BeaconChainTypes> Worker<T> {
15571557
/*
15581558
* The block indicated by the target root is not known to us.
15591559
*
1560-
* We should always get `AttnError::UnknwonHeadBlock` before we get this
1560+
* We should always get `AttnError::UnknownHeadBlock` before we get this
15611561
* error, so this means we can get this error if:
15621562
*
15631563
* 1. The target root does not represent a valid block.
@@ -1566,7 +1566,7 @@ impl<T: BeaconChainTypes> Worker<T> {
15661566
* For (2), we should only be processing attestations when we should have
15671567
* all the available information. Note: if we do a weak-subjectivity sync
15681568
* it's possible that this situation could occur, but I think it's
1569-
* unlikely. For now, we will declare this to be an invalid message>
1569+
* unlikely. For now, we will declare this to be an invalid message.
15701570
*
15711571
* The peer has published an invalid consensus message.
15721572
*/
@@ -1713,14 +1713,12 @@ impl<T: BeaconChainTypes> Worker<T> {
17131713
AttnError::HeadBlockFinalized { beacon_block_root } => {
17141714
debug!(
17151715
self.log,
1716-
"Rejected attestation to finalized block";
1716+
"Ignored attestation to finalized block";
17171717
"block_root" => ?beacon_block_root,
17181718
"attestation_slot" => failed_att.attestation().data.slot,
17191719
);
17201720

1721-
// We have to reject the message as it isn't a descendant of the finalized
1722-
// checkpoint.
1723-
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
1721+
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
17241722

17251723
// The peer that sent us this could be a lagger, or a spammer, or this failure could
17261724
// be due to us processing attestations extremely slowly. Don't be too harsh.

common/account_utils/src/validator_definitions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use regex::Regex;
1010
use serde_derive::{Deserialize, Serialize};
1111
use slog::{error, Logger};
1212
use std::collections::HashSet;
13-
use std::fs::{self, OpenOptions};
13+
use std::fs::{self, File};
1414
use std::io;
1515
use std::path::{Path, PathBuf};
1616
use types::{graffiti::GraffitiString, Address, PublicKey};
@@ -162,7 +162,7 @@ impl ValidatorDefinitions {
162162
/// Open an existing file, returning an error if the file does not exist.
163163
pub fn open<P: AsRef<Path>>(validators_dir: P) -> Result<Self, Error> {
164164
let config_path = validators_dir.as_ref().join(CONFIG_FILENAME);
165-
let file = OpenOptions::new()
165+
let file = File::options()
166166
.write(true)
167167
.read(true)
168168
.create_new(false)
@@ -219,7 +219,7 @@ impl ValidatorDefinitions {
219219
return None;
220220
}
221221

222-
let keystore_result = OpenOptions::new()
222+
let keystore_result = File::options()
223223
.read(true)
224224
.create(false)
225225
.open(&voting_keystore_path)

common/eth2_wallet_manager/src/filesystem.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use eth2_wallet::Error as WalletError;
44
use eth2_wallet::{Uuid, Wallet};
5-
use std::fs::{copy as copy_file, remove_file, OpenOptions};
5+
use std::fs::{copy as copy_file, remove_file, File};
66
use std::io;
77
use std::path::{Path, PathBuf};
88

@@ -27,7 +27,7 @@ pub fn read<P: AsRef<Path>>(wallet_dir: P, uuid: &Uuid) -> Result<Wallet, Error>
2727
if !json_path.exists() {
2828
Err(Error::WalletDoesNotExist(json_path))
2929
} else {
30-
OpenOptions::new()
30+
File::options()
3131
.read(true)
3232
.create(false)
3333
.open(json_path)
@@ -79,7 +79,7 @@ pub fn create<P: AsRef<Path>>(wallet_dir: P, wallet: &Wallet) -> Result<(), Erro
7979
if json_path.exists() {
8080
Err(Error::WalletAlreadyExists(json_path))
8181
} else {
82-
OpenOptions::new()
82+
File::options()
8383
.write(true)
8484
.create_new(true)
8585
.open(json_path)

common/eth2_wallet_manager/src/wallet_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use eth2_wallet::{bip39::Mnemonic, Error as WalletError, Uuid, Wallet, WalletBui
66
use lockfile::LockfileError;
77
use std::collections::HashMap;
88
use std::ffi::OsString;
9-
use std::fs::{create_dir_all, read_dir, OpenOptions};
9+
use std::fs::{create_dir_all, read_dir, File};
1010
use std::io;
1111
use std::path::{Path, PathBuf};
1212

@@ -172,7 +172,7 @@ impl WalletManager {
172172
// Ignore any paths that don't parse as a UUID.
173173
if let Ok(uuid) = Uuid::parse_str(&file_name) {
174174
let wallet_path = f.path().join(format!("{}", uuid));
175-
let wallet = OpenOptions::new()
175+
let wallet = File::options()
176176
.read(true)
177177
.create(false)
178178
.open(wallet_path)

common/lockfile/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use fs2::FileExt;
2-
use std::fs::{self, File, OpenOptions};
2+
use std::fs::{self, File};
33
use std::io::{self, ErrorKind};
44
use std::path::{Path, PathBuf};
55

@@ -30,7 +30,7 @@ impl Lockfile {
3030
let file = if file_existed {
3131
File::open(&path)
3232
} else {
33-
OpenOptions::new()
33+
File::options()
3434
.read(true)
3535
.write(true)
3636
.create_new(true)

0 commit comments

Comments
 (0)