Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Purge old validators #355

Merged
merged 5 commits into from
Jun 15, 2018
Merged

Conversation

aeyakovenko
Copy link
Member

@aeyakovenko aeyakovenko commented Jun 14, 2018

This needs an integration test still, and possibly a threshold to only purge when table is bigger than 2.

Fixes #344

@aeyakovenko aeyakovenko changed the title Purge old validators [wip] Purge old validators Jun 14, 2018
@codecov
Copy link

codecov bot commented Jun 14, 2018

Codecov Report

Merging #355 into master will increase coverage by 0.55%.
The diff coverage is 98.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #355      +/-   ##
==========================================
+ Coverage   90.58%   91.13%   +0.55%     
==========================================
  Files          36       36              
  Lines        3411     3465      +54     
==========================================
+ Hits         3090     3158      +68     
+ Misses        321      307      -14
Impacted Files Coverage Δ
src/crdt.rs 85.86% <98.3%> (+2.47%) ⬆️
src/tvu.rs 99.27% <0%> (+1.45%) ⬆️
src/timing.rs 100% <0%> (+40%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec713c1...6f6bc32. Read the comment docs.

src/crdt.rs Outdated
@@ -32,6 +32,9 @@ use std::sync::{Arc, RwLock};
use std::thread::{sleep, Builder, JoinHandle};
use std::time::Duration;
use streamer::{BlobReceiver, BlobSender, Window};
use timing::timestamp;

const GOSSIP_SLEEP_MILLIS: u64 = 100;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be a Duration and then name it something more intuitive like VALIDATOR_HEARTBEAT_DURATION or VALIDATOR_TIMEOUT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duration is a pia to do compute on or declare. id rather use millis

Copy link
Member Author

@aeyakovenko aeyakovenko Jun 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think gossip sleep is actually more descriptive, since its specific to membership in the gossip network, and not to what is using it, which can be leader, thin client, validator, replicator client...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -235,6 +240,37 @@ impl Crdt {
self.table[&v.id].version
);
}
//update the liveness table
let now = timestamp();
*self.alive.entry(v.id).or_insert(now) = now;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

src/crdt.rs Outdated
//wait for 4x as long as it would randomly take to reach our node
//assuming everyone is waiting the same amount of time as this node
let limit = self.table.len() as u64 * GOSSIP_SLEEP_MILLIS * 4;
let purge_set: Vec<PublicKey> = self.alive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about let dead_ids: Vec<_> =?

src/crdt.rs Outdated
.filter_map(|(k, v)| {
if *k != self.me && (now - v) > limit {
trace!("purging {:?} {}", &k[..4], v);
Some((*k).clone())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That clone() probably isn't needed

src/crdt.rs Outdated
let limit = self.table.len() as u64 * GOSSIP_SLEEP_MILLIS * 4;
let purge_set: Vec<PublicKey> = self.alive
.iter()
.filter_map(|(k, v)| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to try something like (ref k, ref v) or &(k, v) to get rid of all those dereferences below. Clippy would probably tell you which.

let len = crdt.table.len() as u64;
crdt.purge(now);
let rv = crdt.gossip_request().unwrap();
assert_eq!(rv.0, nxt.gossip_addr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlining rv on all 4 assertions would make this test easier to read

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes really long lines, harder to read for some

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@aeyakovenko aeyakovenko changed the title [wip] Purge old validators Purge old validators Jun 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants