Skip to content

Commit 790c1e1

Browse files
committed
merged with develop, reintroduces old logic for condition variables, improved rejections comparison
1 parent 33642c3 commit 790c1e1

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

testnet/stacks-node/src/nakamoto_node/signer_coordinator.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ use stacks::util_lib::boot::boot_code_id;
4040
use super::stackerdb_listener::StackerDBListenerComms;
4141
use super::Error as NakamotoNodeError;
4242
use crate::event_dispatcher::StackerDBChannel;
43-
use crate::nakamoto_node::stackerdb_listener::{
44-
BlockStatus, StackerDBListener, EVENT_RECEIVER_POLL,
45-
};
43+
use crate::nakamoto_node::stackerdb_listener::{StackerDBListener, EVENT_RECEIVER_POLL};
4644
use crate::neon::Counters;
4745
use crate::Config;
4846

@@ -320,8 +318,6 @@ impl SignerCoordinator {
320318
"Invalid rejection timeout step function definition".into(),
321319
)
322320
})?;
323-
// this is used for comparing block_status to identify if it has been changed from the previous event
324-
let mut block_status_tracker = BlockStatus::default();
325321

326322
// this is used to track the start of the waiting cycle
327323
let rejections_timer = Instant::now();
@@ -333,20 +329,19 @@ impl SignerCoordinator {
333329
block_signer_sighash,
334330
EVENT_RECEIVER_POLL,
335331
|status| {
332+
// rejections-based timeout expired?
336333
if rejections_timer.elapsed() > *rejections_timeout {
337334
return false;
338335
}
339-
if *status != block_status_tracker {
336+
// number or rejections changed?
337+
if status.total_reject_weight as u64 != rejections {
340338
return false;
341339
}
342-
return true;
340+
// enough signatures?
341+
return status.total_weight_signed < self.weight_threshold;
343342
},
344343
)? {
345-
Some(status) => {
346-
// keep track of the last status
347-
block_status_tracker = status.clone();
348-
status
349-
}
344+
Some(status) => status,
350345
None => {
351346
// If we just received a timeout, we should check if the burnchain
352347
// tip has changed or if we received this signed block already in

testnet/stacks-node/src/nakamoto_node/stackerdb_listener.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,10 @@ impl StackerDBListener {
337337
block.gathered_signatures.insert(slot_id, signature);
338338
block.responded_signers.insert(signer_pubkey);
339339

340-
// Signal to anyone waiting on this block that we have a new status
341-
cvar.notify_all();
340+
if block.total_weight_signed >= self.weight_threshold {
341+
// Signal to anyone waiting on this block that we have enough signatures
342+
cvar.notify_all();
343+
}
342344

343345
// Update the idle timestamp for this signer
344346
self.update_idle_timestamp(
@@ -394,8 +396,14 @@ impl StackerDBListener {
394396
"server_version" => rejected_data.metadata.server_version,
395397
);
396398

397-
// Signal to anyone waiting on this block that we have a new status
398-
cvar.notify_all();
399+
if block
400+
.total_reject_weight
401+
.saturating_add(self.weight_threshold)
402+
> self.total_weight
403+
{
404+
// Signal to anyone waiting on this block that we have enough rejections
405+
cvar.notify_all();
406+
}
399407

400408
// Update the idle timestamp for this signer
401409
self.update_idle_timestamp(

testnet/stacks-node/src/tests/signer/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ pub struct RunningNodes {
8686
pub counters: Counters,
8787
pub coord_channel: Arc<Mutex<CoordinatorChannels>>,
8888
pub conf: NeonConfig,
89-
pub counters: Counters,
9089
}
9190

9291
/// A test harness for running a v0 or v1 signer integration test
@@ -939,8 +938,6 @@ fn setup_stx_btc_node<G: FnMut(&mut NeonConfig)>(
939938

940939
let coord_channel = run_loop.coordinator_channels();
941940

942-
let run_loop_counters = run_loop.counters();
943-
944941
let run_loop_thread = thread::spawn(move || run_loop.start(None, 0));
945942

946943
// Give the run loop some time to start up!
@@ -978,6 +975,5 @@ fn setup_stx_btc_node<G: FnMut(&mut NeonConfig)>(
978975
coord_channel,
979976
counters,
980977
conf: naka_conf,
981-
counters: run_loop_counters,
982978
}
983979
}

0 commit comments

Comments
 (0)