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: 5159, 5169, 5171, 5172, and others #5191

Merged
merged 29 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
572fb81
chore: stdext and rlimit dev-dependencies
jcnelson Sep 16, 2024
95b72cd
bugfix: always save new neighbor data when we get it
jcnelson Sep 16, 2024
69ecf2e
chore: reduce some debug noise, and log connection name for bandwidth…
jcnelson Sep 16, 2024
62bdacd
chore: document neighbor walk connection opts, and add `log_neighbors…
jcnelson Sep 16, 2024
71bdd84
fix: if we're not in IBD and we dno't have a seed node connection (wh…
jcnelson Sep 16, 2024
6c56f71
fix: collate peers by public key and only report the one with the lat…
jcnelson Sep 16, 2024
43d1ba9
feat: log all p2p conversations every `log_neighbor_freq` milliseconds
jcnelson Sep 16, 2024
32b5726
fix: when discovering a new neighbor, don't replace its inbound peer …
jcnelson Sep 16, 2024
88c9a50
fix: don't forward stackerdb chunks that are known to be locally stale
jcnelson Sep 16, 2024
f9b94dc
chore: log the neighbor address which sent the chunk
jcnelson Sep 16, 2024
39265dd
fix: check local rc_consensus_hash against rc_consensus_hash of a sch…
jcnelson Sep 16, 2024
b389d5e
fix/refactor: make it so the small-scale neighbor tests will bind to …
jcnelson Sep 16, 2024
6f37fa6
fix: sort_unstable_by() for sorting peers by health, since our compar…
jcnelson Sep 16, 2024
50a967b
chore: add pathological reward cycles to downloader tests where the o…
jcnelson Sep 16, 2024
d442f2c
build: build tests with `feature = "testing"`, and disable unused war…
jcnelson Sep 16, 2024
f20061f
chore: add dev-dependencies that will allow test modules to compile f…
jcnelson Sep 16, 2024
2ee25e4
build: use `feature = "testing"` to build stackslib test code, and su…
jcnelson Sep 16, 2024
6ed83d0
build: plumb through features
jcnelson Sep 16, 2024
b721cf6
build: buidl stackslib and deps with "testing" feature so we can use …
jcnelson Sep 16, 2024
6324422
chore: expose walk_seed_probability and log_neighbors_freq connection…
jcnelson Sep 16, 2024
f7c2c2a
chore: move topology neighbor convergence tests to integration test CI
jcnelson Sep 16, 2024
ca9c516
chore: activate p2p convergence tests
jcnelson Sep 16, 2024
9ad8852
Merge branch 'develop' into fix/5159
jcnelson Sep 16, 2024
629d032
Merge branch 'develop' into fix/5159
jcnelson Sep 16, 2024
6edfac8
Merge branch 'develop' into fix/5159
jcnelson Sep 16, 2024
50b0ea3
Merge branch 'develop' into fix/5159
jcnelson Sep 16, 2024
8ad5e95
chore: move p2p::conv tests back to stackslib
kantai Sep 16, 2024
e5b9a73
chore: last cleanup from p2p::conv test movement
kantai Sep 16, 2024
23482eb
Add new workflow for p2p convergence tests
wileyj Sep 16, 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
21 changes: 17 additions & 4 deletions .github/workflows/bitcoin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ jobs:
- tests::signer::v0::locally_rejected_blocks_overriden_by_global_acceptance
- tests::signer::v0::reorg_locally_accepted_blocks_across_tenures_succeeds
- tests::signer::v0::miner_recovers_when_broadcast_block_delay_across_tenures_occurs
- tests::signer::v0::multiple_miners_with_nakamoto_blocks
- tests::signer::v0::partial_tenure_fork
- tests::signer::v0::mine_2_nakamoto_reward_cycles
- tests::signer::v0::signer_set_rollover
- tests::nakamoto_integrations::stack_stx_burn_op_integration_test
- tests::nakamoto_integrations::check_block_heights
- tests::nakamoto_integrations::clarity_burn_state
Expand All @@ -117,10 +121,19 @@ jobs:
- tests::nakamoto_integrations::follower_bootup_across_multiple_cycles
- tests::nakamoto_integrations::utxo_check_on_startup_panic
- tests::nakamoto_integrations::utxo_check_on_startup_recover
- tests::signer::v0::multiple_miners_with_nakamoto_blocks
- tests::signer::v0::partial_tenure_fork
- tests::signer::v0::mine_2_nakamoto_reward_cycles
- tests::signer::v0::signer_set_rollover
- tests::p2p::convergence::test_walk_ring_allow_15
- tests::p2p::convergence::test_walk_ring_15_plain
- tests::p2p::convergence::test_walk_ring_15_pingback
- tests::p2p::convergence::test_walk_ring_15_org_biased
- tests::p2p::convergence::test_walk_line_allowed_15
- tests::p2p::convergence::test_walk_line_15_plain
- tests::p2p::convergence::test_walk_line_15_org_biased
- tests::p2p::convergence::test_walk_line_15_pingback
- tests::p2p::convergence::test_walk_star_allowed_15
- tests::p2p::convergence::test_walk_star_15_plain
- tests::p2p::convergence::test_walk_star_15_pingback
- tests::p2p::convergence::test_walk_star_15_org_biased
- tests::p2p::convergence::test_walk_inbound_line_15
# Do not run this one until we figure out why it fails in CI
# - tests::neon_integrations::bitcoin_reorg_flap
# - tests::neon_integrations::bitcoin_reorg_flap_with_follower
Expand Down
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions stackslib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ siphasher = "0.3.7"
wsts = { workspace = true }
hashbrown = { workspace = true }
rusqlite = { workspace = true }
rstest = { version = "0.17.0", optional = true }
rstest_reuse = { version = "0.5.0", optional = true }
stdext = { version = "0.3.1", optional = true }
stx-genesis = { path = "../stx-genesis", optional = true }
kantai marked this conversation as resolved.
Show resolved Hide resolved

[target.'cfg(not(any(target_os = "macos",target_os="windows", target_arch = "arm" )))'.dependencies]
tikv-jemallocator = {workspace = true}
Expand Down Expand Up @@ -95,7 +99,7 @@ features = ["std"]
assert-json-diff = "1.0.0"
criterion = "0.3.5"
stdext = "0.3.1"
stx-genesis = { path = "../stx-genesis"}
stx-genesis = { path = "../stx-genesis" }
clarity = { features = ["default", "testing"], path = "../clarity" }
stacks-common = { features = ["default", "testing"], path = "../stacks-common" }
rstest = "0.17.0"
Expand All @@ -109,7 +113,7 @@ disable-costs = []
developer-mode = ["clarity/developer-mode"]
monitoring_prom = ["prometheus"]
slog_json = ["slog-json", "stacks-common/slog_json", "clarity/slog_json", "pox-locking/slog_json"]
testing = []
testing = ["stdext", "rstest", "rstest_reuse", "stx-genesis"]

[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(any(target_os="windows"))))'.dependencies]
sha2 = { version = "0.10", features = ["asm"] }
Expand Down
10 changes: 5 additions & 5 deletions stackslib/src/burnchains/bitcoin/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl BitcoinIndexerConfig {
}
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn test_default(spv_headers_path: String) -> BitcoinIndexerConfig {
BitcoinIndexerConfig {
peer_host: "127.0.0.1".to_string(),
Expand Down Expand Up @@ -203,7 +203,7 @@ impl BitcoinIndexerRuntime {
}

impl BitcoinIndexer {
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn new(
config: BitcoinIndexerConfig,
runtime: BitcoinIndexerRuntime,
Expand All @@ -216,7 +216,7 @@ impl BitcoinIndexer {
}
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn new_unit_test(working_dir: &str) -> BitcoinIndexer {
let mut working_dir_path = PathBuf::from(working_dir);
if fs::metadata(&working_dir_path).is_err() {
Expand Down Expand Up @@ -861,7 +861,7 @@ impl BitcoinIndexer {
Ok(new_tip)
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn raw_store_header(&mut self, header: BurnchainBlockHeader) -> Result<(), btc_error> {
let mut spv_client = SpvClient::new(
&self.config.spv_headers_path,
Expand All @@ -887,7 +887,7 @@ impl BitcoinIndexer {
Ok(())
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn mock_bitcoin_header(
parent_block_hash: &BurnchainHeaderHash,
timestamp: u32,
Expand Down
10 changes: 5 additions & 5 deletions stackslib/src/burnchains/bitcoin/spv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl SpvClient {
Ok(client)
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn new_without_migration(
headers_path: &str,
start_block: u64,
Expand Down Expand Up @@ -211,7 +211,7 @@ impl SpvClient {
Ok(client)
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn disable_check_txcount(&mut self) {
self.check_txcount = false;
}
Expand All @@ -220,7 +220,7 @@ impl SpvClient {
&self.headers_db
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn conn_mut(&mut self) -> &mut DBConn {
&mut self.headers_db
}
Expand Down Expand Up @@ -277,7 +277,7 @@ impl SpvClient {
.and_then(|_| Ok(()))
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn test_db_migrate(conn: &mut DBConn) -> Result<(), btc_error> {
SpvClient::db_migrate(conn)
}
Expand Down Expand Up @@ -925,7 +925,7 @@ impl SpvClient {
Ok(())
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn test_write_block_headers(
&mut self,
height: u64,
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/burnchains/burnchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ impl Burnchain {
ret
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn default_unittest(
first_block_height: u64,
first_block_hash: &BurnchainHeaderHash,
Expand Down
8 changes: 4 additions & 4 deletions stackslib/src/burnchains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub mod burnchain;
pub mod db;
pub mod indexer;

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub mod tests;

pub struct Txid(pub [u8; 32]);
Expand Down Expand Up @@ -351,7 +351,7 @@ impl PoxConstants {
_shadow: PhantomData,
}
}
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn test_default() -> PoxConstants {
// 20 reward slots; 10 prepare-phase slots
PoxConstants::new(
Expand All @@ -369,7 +369,7 @@ impl PoxConstants {
)
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
/// Create a PoX constants used in tests with 5-block cycles,
/// 3-block prepare phases, a threshold of 3, rejection fraction of 25%,
/// a participation threshold of 5% and no sunset or transition to pox-2 or beyond.
Expand Down Expand Up @@ -821,7 +821,7 @@ impl From<btc_error> for Error {
}

impl BurnchainView {
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn make_test_data(&mut self) {
let oldest_height = if self.burn_stable_block_height < MAX_NEIGHBOR_BLOCK_DELAY {
0
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/burnchains/tests/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl BurnchainDB {

/// Get back all of the parsed burnchain operations for a given block.
/// Used in testing to replay burnchain data.
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn get_burnchain_block_ops(
&self,
block_hash: &BurnchainHeaderHash,
Expand Down
1 change: 1 addition & 0 deletions stackslib/src/burnchains/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#![allow(unused)]
kantai marked this conversation as resolved.
Show resolved Hide resolved

pub mod affirmation;
pub mod burnchain;
Expand Down
4 changes: 2 additions & 2 deletions stackslib/src/chainstate/burn/db/sortdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5482,7 +5482,7 @@ impl<'a> SortitionHandleTx<'a> {
sn.canonical_stacks_tip_height,
)?;

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
{
let (block_consensus_hash, block_bhh) =
SortitionDB::get_canonical_stacks_chain_tip_hash(self).unwrap();
Expand Down Expand Up @@ -6566,7 +6566,7 @@ impl ChainstateDB for SortitionDB {
}
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub mod tests {
use std::sync::mpsc::sync_channel;
use std::thread;
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/burn/distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl BurnSamplePoint {
}
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
mod tests {
use std::marker::PhantomData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub static OUTPUTS_PER_COMMIT: usize = 2;
pub static BURN_BLOCK_MINED_AT_MODULUS: u64 = 5;

impl LeaderBlockCommitOp {
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn initial(
block_header_hash: &BlockHeaderHash,
block_height: u64,
Expand Down Expand Up @@ -131,10 +131,10 @@ impl LeaderBlockCommitOp {
}
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn new(
block_header_hash: &BlockHeaderHash,
block_height: u64,
_block_height: u64,
new_seed: &VRFSeed,
parent: &LeaderBlockCommitOp,
key_block_ptr: u32,
Expand Down Expand Up @@ -170,7 +170,7 @@ impl LeaderBlockCommitOp {
}
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn set_burn_height(&mut self, height: u64) {
self.block_height = height;
let new_burn_parent_modulus = if height > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct ParsedData {
}

impl LeaderKeyRegisterOp {
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn new(public_key: &VRFPublicKey) -> LeaderKeyRegisterOp {
LeaderKeyRegisterOp {
public_key: public_key.clone(),
Expand All @@ -59,10 +59,10 @@ impl LeaderKeyRegisterOp {
}
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn new_from_secrets(
num_sigs: u16,
hash_mode: &AddressHashMode,
_num_sigs: u16,
_hash_mode: &AddressHashMode,
prover_key: &VRFPrivateKey,
) -> Option<LeaderKeyRegisterOp> {
let prover_pubk = VRFPublicKey::from_private(prover_key);
Expand Down
6 changes: 3 additions & 3 deletions stackslib/src/chainstate/burn/operations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub mod stack_stx;
pub mod transfer_stx;
pub mod vote_for_aggregate_key;

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
mod test;

/// This module contains all burn-chain operations
Expand Down Expand Up @@ -439,7 +439,7 @@ impl BlockstackOperationType {
}
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn set_block_height(&mut self, height: u64) {
match self {
BlockstackOperationType::LeaderKeyRegister(ref mut data) => data.block_height = height,
Expand All @@ -456,7 +456,7 @@ impl BlockstackOperationType {
};
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn set_burn_header_hash(&mut self, hash: BurnchainHeaderHash) {
match self {
BlockstackOperationType::LeaderKeyRegister(ref mut data) => {
Expand Down
4 changes: 2 additions & 2 deletions stackslib/src/chainstate/burn/operations/stack_stx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct ParsedData {
pub static OUTPUTS_PER_COMMIT: usize = 2;

impl PreStxOp {
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn new(sender: &StacksAddress) -> PreStxOp {
PreStxOp {
output: sender.clone(),
Expand Down Expand Up @@ -155,7 +155,7 @@ impl PreStxOp {
}

impl StackStxOp {
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn new(
sender: &StacksAddress,
reward_addr: &PoxAddress,
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/burn/operations/transfer_stx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct ParsedData {
}

impl TransferStxOp {
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn new(
sender: &StacksAddress,
recipient: &StacksAddress,
Expand Down
Loading