Skip to content

Commit

Permalink
make low performing node
Browse files Browse the repository at this point in the history
  • Loading branch information
lanvidr committed Mar 20, 2023
1 parent e563c4f commit 11ea10a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion narwhal/node/src/primary_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl PrimaryNodeInner {
/// The window where the schedule change takes place in consensus. It represents number
/// of committed sub dags.
/// TODO: move this to node properties
const CONSENSUS_SCHEDULE_CHANGE_SUB_DAGS: u64 = 10_000;
const CONSENSUS_SCHEDULE_CHANGE_SUB_DAGS: u64 = 300;

// Starts the primary node with the provided info. If the node is already running then this
// method will return an error instead.
Expand Down
52 changes: 32 additions & 20 deletions narwhal/primary/src/proposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,15 @@ impl Proposer {
debug!("Dag starting at round {}", self.round);
let mut advance = true;

let position = self
.committee
.authorities()
.position(|(name, _a)| name.clone() == self.name)
.unwrap();
if position == 0 {
debug!("I have been selected as a low performing authority");
}

let timer_start = Instant::now();
let max_delay_timer = sleep_until(timer_start + self.max_header_delay);
let min_delay_timer = sleep_until(timer_start + self.min_header_delay);
Expand Down Expand Up @@ -462,26 +471,29 @@ impl Proposer {
debug!("Dag moved to round {}", self.round);

// Make a new header.
match self.make_header().await {
Err(e @ DagError::ShuttingDown) => debug!("{e}"),
Err(e) => panic!("Unexpected error: {e}"),
Ok((header, digests)) => {
let reason = if max_delay_timed_out {
"max_timeout"
} else if enough_digests {
"threshold_size_reached"
} else {
"min_timeout"
};

// Save the header
opt_latest_header = Some(header);
header_repeat_timer = Box::pin(sleep(header_resend_timeout));

self.metrics
.num_of_batch_digests_in_header
.with_label_values(&[reason])
.observe(digests as f64);
let make = rand::random::<usize>() % 100;
if position > 0 || make < 25 {
match self.make_header().await {
Err(e @ DagError::ShuttingDown) => debug!("{e}"),
Err(e) => panic!("Unexpected error: {e}"),
Ok((header, digests)) => {
let reason = if max_delay_timed_out {
"max_timeout"
} else if enough_digests {
"threshold_size_reached"
} else {
"min_timeout"
};

// Save the header
opt_latest_header = Some(header);
header_repeat_timer = Box::pin(sleep(header_resend_timeout));

self.metrics
.num_of_batch_digests_in_header
.with_label_values(&[reason])
.observe(digests as f64);
}
}
}

Expand Down

0 comments on commit 11ea10a

Please sign in to comment.