Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: snappy downloader #5393

Merged
merged 42 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
28fb59b
fix: drain the relayer channel to alleviate block download pressure
jcnelson Oct 28, 2024
61d701b
chore: only consider block-bearing network results if in ibd mode or …
jcnelson Oct 28, 2024
e8cb18f
chore: shed network results when in ibd or with download backpressure…
jcnelson Oct 28, 2024
be96888
chore: fix compile issues
jcnelson Oct 28, 2024
c5ec5b3
fix: drive main loop wakeups when we're backlogged
jcnelson Oct 28, 2024
0d26d50
Merge branch 'develop' into fix/relayer-drain-channel
jcnelson Oct 29, 2024
0685670
chore: option to disable block pushes
jcnelson Oct 30, 2024
9bc3125
Merge branch 'fix/relayer-drain-channel' of https://github.com/stacks…
jcnelson Oct 30, 2024
babd3d9
feat: make NetworkResults mergeable
jcnelson Oct 31, 2024
596d41d
chore: make StackerDBSyncResult Debug and PartialEq
jcnelson Oct 31, 2024
1fc9d72
chore: test NetworkResult::update()
jcnelson Oct 31, 2024
225ada1
chore: remove logic to drain the network result channel (it's not nee…
jcnelson Oct 31, 2024
07b65cb
chore: remove dead code
jcnelson Oct 31, 2024
27e7301
chore: count download attempts, and don't download processed tenures,…
jcnelson Oct 31, 2024
d1bf24f
chore: p2p --> relayer channel only needs one slot
jcnelson Oct 31, 2024
72c9f54
chore: pub(crate) visibility to avoid private leakage
jcnelson Oct 31, 2024
9361bea
chore: log attempt failures, and only start as many downloaders as given
jcnelson Oct 31, 2024
c88d0e6
chore: log more downloader diagnostics
jcnelson Oct 31, 2024
fa493d5
chore: deprioritize unreliable peers
jcnelson Oct 31, 2024
71eccc9
Merge branch 'develop' into fix/relayer-drain-channel
jcnelson Nov 1, 2024
26d8a4d
Merge branch 'develop' into fix/relayer-drain-channel
jcnelson Nov 1, 2024
1074fe0
fix: off-by-one error in reward set caching logic in p2p stack
jcnelson Nov 1, 2024
e4e9b18
Merge branch 'fix/relayer-drain-channel' of https://github.com/stacks…
jcnelson Nov 1, 2024
e3b41fa
Merge branch 'develop' into fix/relayer-drain-channel
jcnelson Nov 1, 2024
ca3b2ae
chore: API sync
jcnelson Nov 4, 2024
06108f2
fix: use burnchain tip reward cycle to infer whether or not to sync t…
jcnelson Nov 4, 2024
3369de5
chore: API sync
jcnelson Nov 4, 2024
0e1058e
chore: store burnchain DB handle in p2p network and load burnchain he…
jcnelson Nov 4, 2024
ad4faaf
chore: API sync, and test fixes
jcnelson Nov 4, 2024
4365ebf
chore: API sync
jcnelson Nov 4, 2024
19b7c94
Merge branch 'fix/relayer-drain-channel' of https://github.com/stacks…
jcnelson Nov 4, 2024
30292cb
Merge branch 'develop' into fix/relayer-drain-channel
jcnelson Nov 4, 2024
18be1fe
chore: address PR feedback
jcnelson Nov 4, 2024
bce9839
fix: disconnect from neighbors serving unconfirmed tenures that are s…
jcnelson Nov 5, 2024
5ed737a
Merge branch 'develop' into fix/relayer-drain-channel
jcnelson Nov 5, 2024
ead50a8
fix: fix unit tests that broke due to PeerNetwork needing an existing…
jcnelson Nov 5, 2024
9731059
Merge branch 'develop' into fix/relayer-drain-channel
jcnelson Nov 5, 2024
45adc33
chore: address remaining PR feedback and get tests to pass
jcnelson Nov 5, 2024
3fb6d6f
chore: fix p2p handling of unsolicited nakamoto blocks by loading the…
jcnelson Nov 7, 2024
5fdaaf0
fix: we now report the actual block height
jcnelson Nov 7, 2024
5f7590b
Merge branch 'develop' into fix/relayer-drain-channel
jcnelson Nov 7, 2024
4c59af8
chore: address PR feedback
jcnelson Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testnet/stacks-node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1956,7 +1956,7 @@ impl Default for NodeConfig {
max_microblocks: u16::MAX as u64,
wait_time_for_microblocks: 30_000,
wait_time_for_blocks: 30_000,
next_initiative_delay: 10_000,
next_initiative_delay: 1_000,
jcnelson marked this conversation as resolved.
Show resolved Hide resolved
prometheus_bind: None,
marf_cache_strategy: None,
marf_defer_hashing: true,
Expand Down
83 changes: 63 additions & 20 deletions testnet/stacks-node/src/nakamoto_node/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use core::fmt;
use std::collections::HashSet;
use std::fs;
use std::io::Read;
use std::sync::mpsc::{Receiver, RecvTimeoutError};
use std::sync::mpsc::{Receiver, RecvTimeoutError, TryRecvError};
use std::thread::JoinHandle;
use std::time::{Duration, Instant};

Expand Down Expand Up @@ -1198,36 +1198,79 @@ impl RelayerThread {
while self.globals.keep_running() {
let raised_initiative = self.globals.take_initiative();
let timed_out = Instant::now() >= self.next_initiative;
let directive = if raised_initiative.is_some() || timed_out {
let mut initiative_directive = if raised_initiative.is_some() || timed_out {
self.next_initiative =
Instant::now() + Duration::from_millis(self.config.node.next_initiative_delay);
self.initiative()
} else {
None
};

let directive = if let Some(directive) = directive {
directive
} else {
match relay_rcv.recv_timeout(Duration::from_millis(
self.config.node.next_initiative_delay,
)) {
Ok(directive) => directive,
Err(RecvTimeoutError::Timeout) => {
continue;
jcnelson marked this conversation as resolved.
Show resolved Hide resolved
let mut handled = true;
let mut disconnect = false;
let mut try_recv = true;
let mut drained = false;
let raised_initiative_fmt =
format!("{}", raised_initiative.unwrap_or("relay_rcv".to_string()));

debug!("Relayer: drain channel");
// drain the channel
while !disconnect && handled && !drained {
let directive = if let Some(directive) = initiative_directive.take() {
debug!("Relayer: initiative from directive");
directive
} else if try_recv {
// drain the channel
match relay_rcv.try_recv() {
Ok(directive) => {
debug!("Relayer: initiative from try_recv");
directive
}
Err(TryRecvError::Empty) => {
try_recv = false;
continue;
}
Err(TryRecvError::Disconnected) => {
disconnect = true;
break;
}
}
Err(RecvTimeoutError::Disconnected) => {
break;
} else {
// channel was drained, so do a time-bound recv
match relay_rcv.recv_timeout(Duration::from_millis(
self.config.node.next_initiative_delay,
)) {
Ok(directive) => {
// only do this once, so we can call .initiative() again
debug!("Relayer: initiative from recv_timeout");
drained = true;
directive
}
Err(RecvTimeoutError::Timeout) => {
break;
}
Err(RecvTimeoutError::Disconnected) => {
disconnect = true;
break;
}
}
}
};
};

debug!("Relayer: main loop directive";
"directive" => %directive,
"raised_initiative" => %raised_initiative.unwrap_or("relay_rcv".to_string()),
"timed_out" => %timed_out);
debug!("Relayer: main loop directive";
"try_recv" => %try_recv,
"drained" => %drained,
"directive" => %directive,
"raised_initiative" => %raised_initiative_fmt,
"timed_out" => %timed_out);

if !self.handle_directive(directive) {
if !self.handle_directive(directive) {
handled = false;
break;
}
}
debug!("Relayer: drained channel");
if disconnect || !handled {
info!("Exiting relayer main loop");
break;
}
}
Expand Down