Skip to content

Commit f14f060

Browse files
authored
Merge pull request #5191 from stacks-network/fix/5159
Fix: 5159, 5169, 5171, 5172, and others
2 parents 1a87f5b + 23482eb commit f14f060

File tree

24 files changed

+2095
-1375
lines changed

24 files changed

+2095
-1375
lines changed

.github/workflows/bitcoin-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ jobs:
105105
- tests::signer::v0::locally_rejected_blocks_overriden_by_global_acceptance
106106
- tests::signer::v0::reorg_locally_accepted_blocks_across_tenures_succeeds
107107
- tests::signer::v0::miner_recovers_when_broadcast_block_delay_across_tenures_occurs
108+
- tests::signer::v0::multiple_miners_with_nakamoto_blocks
109+
- tests::signer::v0::partial_tenure_fork
110+
- tests::signer::v0::mine_2_nakamoto_reward_cycles
111+
- tests::signer::v0::signer_set_rollover
108112
- tests::nakamoto_integrations::stack_stx_burn_op_integration_test
109113
- tests::nakamoto_integrations::check_block_heights
110114
- tests::nakamoto_integrations::clarity_burn_state
@@ -117,10 +121,6 @@ jobs:
117121
- tests::nakamoto_integrations::follower_bootup_across_multiple_cycles
118122
- tests::nakamoto_integrations::utxo_check_on_startup_panic
119123
- tests::nakamoto_integrations::utxo_check_on_startup_recover
120-
- tests::signer::v0::multiple_miners_with_nakamoto_blocks
121-
- tests::signer::v0::partial_tenure_fork
122-
- tests::signer::v0::mine_2_nakamoto_reward_cycles
123-
- tests::signer::v0::signer_set_rollover
124124
# Do not run this one until we figure out why it fails in CI
125125
# - tests::neon_integrations::bitcoin_reorg_flap
126126
# - tests::neon_integrations::bitcoin_reorg_flap_with_follower

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,29 @@ jobs:
186186
- check-release
187187
uses: ./.github/workflows/bitcoin-tests.yml
188188

189+
190+
p2p-tests:
191+
if: |
192+
needs.check-release.outputs.is_release == 'true' || (
193+
github.event_name == 'workflow_dispatch' ||
194+
github.event_name == 'pull_request' ||
195+
github.event_name == 'merge_group' ||
196+
(
197+
contains('
198+
refs/heads/master
199+
refs/heads/develop
200+
refs/heads/next
201+
', github.event.pull_request.head.ref) &&
202+
github.event_name == 'push'
203+
)
204+
)
205+
name: P2P Tests
206+
needs:
207+
- rustfmt
208+
- create-cache
209+
- check-release
210+
uses: ./.github/workflows/p2p-tests.yml
211+
189212
## Test to run on a tagged release
190213
##
191214
## Runs when:

.github/workflows/p2p-tests.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
## Github workflow to run p2p tests
2+
3+
name: Tests::P2P
4+
5+
on:
6+
workflow_call:
7+
8+
## env vars are transferred to composite action steps
9+
env:
10+
BITCOIND_TEST: 0
11+
RUST_BACKTRACE: full
12+
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 15
13+
TEST_TIMEOUT: 30
14+
15+
concurrency:
16+
group: stackslib-tests-${{ github.head_ref || github.ref || github.run_id}}
17+
## Only cancel in progress if this is for a PR
18+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
19+
20+
jobs:
21+
# p2p integration tests with code coverage
22+
integration-tests:
23+
name: Integration Tests
24+
runs-on: ubuntu-latest
25+
strategy:
26+
## Continue with the test matrix even if we've had a failure
27+
fail-fast: false
28+
## Run a maximum of 32 concurrent tests from the test matrix
29+
max-parallel: 32
30+
matrix:
31+
test-name:
32+
- net::tests::convergence::test_walk_ring_allow_15
33+
- net::tests::convergence::test_walk_ring_15_plain
34+
- net::tests::convergence::test_walk_ring_15_pingback
35+
- net::tests::convergence::test_walk_ring_15_org_biased
36+
- net::tests::convergence::test_walk_line_allowed_15
37+
- net::tests::convergence::test_walk_line_15_plain
38+
- net::tests::convergence::test_walk_line_15_org_biased
39+
- net::tests::convergence::test_walk_line_15_pingback
40+
- net::tests::convergence::test_walk_star_allowed_15
41+
- net::tests::convergence::test_walk_star_15_plain
42+
- net::tests::convergence::test_walk_star_15_pingback
43+
- net::tests::convergence::test_walk_star_15_org_biased
44+
- net::tests::convergence::test_walk_inbound_line_15
45+
steps:
46+
## Setup test environment
47+
- name: Setup Test Environment
48+
id: setup_tests
49+
uses: stacks-network/actions/stacks-core/testenv@main
50+
with:
51+
btc-version: "25.0"
52+
53+
## Increase open file descriptors limit
54+
- name: Increase Open File Descriptors
55+
run: |
56+
sudo prlimit --nofile=4096:4096
57+
58+
## Run test matrix using restored cache of archive file
59+
## - Test will timeout after env.TEST_TIMEOUT minutes
60+
- name: Run Tests
61+
id: run_tests
62+
timeout-minutes: ${{ fromJSON(env.TEST_TIMEOUT) }}
63+
uses: stacks-network/actions/stacks-core/run-tests@main
64+
with:
65+
test-name: ${{ matrix.test-name }}
66+
threads: 1
67+
68+
## Create and upload code coverage file
69+
- name: Code Coverage
70+
id: codecov
71+
uses: stacks-network/actions/codecov@main
72+
with:
73+
test-name: ${{ matrix.test-name }}
74+
75+
check-tests:
76+
name: Check Tests
77+
runs-on: ubuntu-latest
78+
if: always()
79+
needs:
80+
- integration-tests
81+
steps:
82+
- name: Check Tests Status
83+
id: check_tests_status
84+
uses: stacks-network/actions/check-jobs-status@main
85+
with:
86+
jobs: ${{ toJson(needs) }}
87+
summary_print: "true"

.github/workflows/standalone-tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ on:
2121
- Atlas Tests
2222
- Bitcoin Tests
2323
- Epoch Tests
24+
- P2P Tests
2425
- Slow Tests
2526
- Stacks-Core Tests
2627
- SBTC Tests
@@ -69,6 +70,23 @@ jobs:
6970
- create-cache
7071
uses: ./.github/workflows/bitcoin-tests.yml
7172

73+
## Runs when:
74+
## either or of the following:
75+
## - workflow is 'Release Tests'
76+
## - workflow is 'CI Tests'
77+
## - workflow is 'P2P Tests'
78+
p2p-tests:
79+
if: |
80+
(
81+
inputs.workflow == 'Release Tests' ||
82+
inputs.workflow == 'CI Tests' ||
83+
inputs.workflow == 'P2P Tests'
84+
)
85+
name: P2P Tests
86+
needs:
87+
- create-cache
88+
uses: ./.github/workflows/p2p-tests.yml
89+
7290
#####################################################
7391
## Runs when:
7492
## either or of the following:

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stackslib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ stacks-common = { features = ["default", "testing"], path = "../stacks-common" }
101101
rstest = "0.17.0"
102102
rstest_reuse = "0.5.0"
103103
mutants = "0.0.3"
104+
rlimit = "0.10.2"
104105

105106
[features]
106107
default = []

stackslib/src/chainstate/nakamoto/coordinator/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ pub fn load_nakamoto_reward_set<U: RewardSetProvider>(
506506
Err(e) => return Some(Err(e)),
507507
Ok(None) => {
508508
// no header for this snapshot (possibly invalid)
509-
info!("Failed to find block by consensus hash"; "consensus_hash" => %sn.consensus_hash);
509+
debug!("Failed to find Stacks block by consensus hash"; "consensus_hash" => %sn.consensus_hash);
510510
return None
511511
}
512512
}

stackslib/src/net/api/getneighbors.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::io::{Read, Write};
1919
use clarity::vm::types::QualifiedContractIdentifier;
2020
use regex::{Captures, Regex};
2121
use stacks_common::types::net::{PeerAddress, PeerHost};
22+
use stacks_common::util::get_epoch_time_secs;
2223
use stacks_common::util::hash::Hash160;
2324

2425
use crate::net::db::PeerDB;
@@ -145,10 +146,11 @@ impl RPCNeighborsInfo {
145146
peerdb_conn,
146147
network_id,
147148
network_epoch,
148-
max_neighbor_age,
149+
get_epoch_time_secs().saturating_sub(max_neighbor_age),
149150
MAX_NEIGHBORS_DATA_LEN,
150151
burnchain_view.burn_block_height,
151152
false,
153+
true,
152154
)
153155
.map_err(NetError::DBError)?;
154156

stackslib/src/net/chat.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,8 @@ impl ConversationP2P {
14331433

14341434
// get neighbors at random as long as they're fresh, and as long as they're compatible with
14351435
// the current system epoch.
1436+
// Alternate at random between serving public-only and public/private-mixed IPs, since for
1437+
// the time being, the remote peer has no way of asking for a particular subset.
14361438
let mut neighbors = PeerDB::get_fresh_random_neighbors(
14371439
peer_dbconn,
14381440
self.network_id,
@@ -1441,6 +1443,7 @@ impl ConversationP2P {
14411443
MAX_NEIGHBORS_DATA_LEN,
14421444
chain_view.burn_block_height,
14431445
false,
1446+
thread_rng().gen(),
14441447
)
14451448
.map_err(net_error::DBError)?;
14461449

@@ -1917,10 +1920,12 @@ impl ConversationP2P {
19171920
/// Generates a Nack if we don't have this DB, or if the request's consensus hash is invalid.
19181921
fn make_stacker_db_getchunkinv_response(
19191922
network: &PeerNetwork,
1923+
naddr: NeighborAddress,
19201924
chainstate: &mut StacksChainState,
19211925
getchunkinv: &StackerDBGetChunkInvData,
19221926
) -> Result<StacksMessageType, net_error> {
19231927
Ok(network.make_StackerDBChunksInv_or_Nack(
1928+
naddr,
19241929
chainstate,
19251930
&getchunkinv.contract_id,
19261931
&getchunkinv.rc_consensus_hash,
@@ -1938,6 +1943,7 @@ impl ConversationP2P {
19381943
) -> Result<ReplyHandleP2P, net_error> {
19391944
let response = ConversationP2P::make_stacker_db_getchunkinv_response(
19401945
network,
1946+
self.to_neighbor_address(),
19411947
chainstate,
19421948
getchunkinv,
19431949
)?;
@@ -2120,7 +2126,8 @@ impl ConversationP2P {
21202126
> (self.connection.options.max_block_push_bandwidth as f64)
21212127
{
21222128
debug!(
2123-
"Neighbor {:?} exceeded max block-push bandwidth of {} bytes/sec (currently at {})",
2129+
"{:?}: Neighbor {:?} exceeded max block-push bandwidth of {} bytes/sec (currently at {})",
2130+
&self,
21242131
&self.to_neighbor_key(),
21252132
self.connection.options.max_block_push_bandwidth,
21262133
self.stats.get_block_push_bandwidth()
@@ -2162,7 +2169,7 @@ impl ConversationP2P {
21622169
&& self.stats.get_microblocks_push_bandwidth()
21632170
> (self.connection.options.max_microblocks_push_bandwidth as f64)
21642171
{
2165-
debug!("Neighbor {:?} exceeded max microblocks-push bandwidth of {} bytes/sec (currently at {})", &self.to_neighbor_key(), self.connection.options.max_microblocks_push_bandwidth, self.stats.get_microblocks_push_bandwidth());
2172+
debug!("{:?}: Neighbor {:?} exceeded max microblocks-push bandwidth of {} bytes/sec (currently at {})", self, &self.to_neighbor_key(), self.connection.options.max_microblocks_push_bandwidth, self.stats.get_microblocks_push_bandwidth());
21662173
return self
21672174
.reply_nack(local_peer, chain_view, preamble, NackErrorCodes::Throttled)
21682175
.and_then(|handle| Ok(Some(handle)));
@@ -2199,7 +2206,7 @@ impl ConversationP2P {
21992206
&& self.stats.get_transaction_push_bandwidth()
22002207
> (self.connection.options.max_transaction_push_bandwidth as f64)
22012208
{
2202-
debug!("Neighbor {:?} exceeded max transaction-push bandwidth of {} bytes/sec (currently at {})", &self.to_neighbor_key(), self.connection.options.max_transaction_push_bandwidth, self.stats.get_transaction_push_bandwidth());
2209+
debug!("{:?}: Neighbor {:?} exceeded max transaction-push bandwidth of {} bytes/sec (currently at {})", self, &self.to_neighbor_key(), self.connection.options.max_transaction_push_bandwidth, self.stats.get_transaction_push_bandwidth());
22032210
return self
22042211
.reply_nack(local_peer, chain_view, preamble, NackErrorCodes::Throttled)
22052212
.and_then(|handle| Ok(Some(handle)));
@@ -2237,7 +2244,7 @@ impl ConversationP2P {
22372244
&& self.stats.get_stackerdb_push_bandwidth()
22382245
> (self.connection.options.max_stackerdb_push_bandwidth as f64)
22392246
{
2240-
debug!("Neighbor {:?} exceeded max stackerdb-push bandwidth of {} bytes/sec (currently at {})", &self.to_neighbor_key(), self.connection.options.max_stackerdb_push_bandwidth, self.stats.get_stackerdb_push_bandwidth());
2247+
debug!("{:?}: Neighbor {:?} exceeded max stackerdb-push bandwidth of {} bytes/sec (currently at {})", self, &self.to_neighbor_key(), self.connection.options.max_stackerdb_push_bandwidth, self.stats.get_stackerdb_push_bandwidth());
22412248
return self
22422249
.reply_nack(local_peer, chain_view, preamble, NackErrorCodes::Throttled)
22432250
.and_then(|handle| Ok(Some(handle)));
@@ -2276,7 +2283,7 @@ impl ConversationP2P {
22762283
&& self.stats.get_nakamoto_block_push_bandwidth()
22772284
> (self.connection.options.max_nakamoto_block_push_bandwidth as f64)
22782285
{
2279-
debug!("Neighbor {:?} exceeded max Nakamoto block push bandwidth of {} bytes/sec (currently at {})", &self.to_neighbor_key(), self.connection.options.max_nakamoto_block_push_bandwidth, self.stats.get_nakamoto_block_push_bandwidth());
2286+
debug!("{:?}: Neighbor {:?} exceeded max Nakamoto block push bandwidth of {} bytes/sec (currently at {})", self, &self.to_neighbor_key(), self.connection.options.max_nakamoto_block_push_bandwidth, self.stats.get_nakamoto_block_push_bandwidth());
22802287
return self
22812288
.reply_nack(local_peer, chain_view, preamble, NackErrorCodes::Throttled)
22822289
.and_then(|handle| Ok(Some(handle)));
@@ -2415,11 +2422,11 @@ impl ConversationP2P {
24152422
Ok(num_recved) => {
24162423
total_recved += num_recved;
24172424
if num_recved > 0 {
2418-
debug!("{:?}: received {} bytes", self, num_recved);
2425+
test_debug!("{:?}: received {} bytes", self, num_recved);
24192426
self.stats.last_recv_time = get_epoch_time_secs();
24202427
self.stats.bytes_rx += num_recved as u64;
24212428
} else {
2422-
debug!("{:?}: received {} bytes, stopping", self, num_recved);
2429+
test_debug!("{:?}: received {} bytes, stopping", self, num_recved);
24232430
break;
24242431
}
24252432
}
@@ -2436,7 +2443,7 @@ impl ConversationP2P {
24362443
}
24372444
}
24382445
}
2439-
debug!("{:?}: received {} bytes", self, total_recved);
2446+
test_debug!("{:?}: received {} bytes", self, total_recved);
24402447
Ok(total_recved)
24412448
}
24422449

@@ -2464,7 +2471,7 @@ impl ConversationP2P {
24642471
}
24652472
}
24662473
}
2467-
debug!("{:?}: sent {} bytes", self, total_sent);
2474+
test_debug!("{:?}: sent {} bytes", self, total_sent);
24682475
Ok(total_sent)
24692476
}
24702477

0 commit comments

Comments
 (0)