From 46634a04e46d69a4e58b3ba8c93f1e6ee5238ff4 Mon Sep 17 00:00:00 2001 From: "rearden-grok[bot]" <317016512+rearden-grok[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:06:06 -0700 Subject: [PATCH 01/10] fix: release profile compiles again; qc checks it #1097 mapped cfg(test) onto cfg(debug_assertions). Two of those gates landed on items production code also uses, so `cargo check --release` failed in rbitcoin-store (lib) and, once that was patched, rbitcoin-query: - scripthash_head.rs gated `use crate::open_address::{self, MAX_LOAD_DEN, MAX_LOAD_NUM}` while `hash_slot` and the bulk-fill load cap use it. - confirm_run/mod.rs re-exported `expected_bits_extending` and `ensure_spend_abs_layouts`, both debug-only, from ungated `pub use`. No PR job compiles the release profile; release.yml and nix do. `qc` now runs `cargo check --release --workspace --exclude rbitcoin-bench` after clippy, and coverage.test.sh pins that step the way it pins the test job's commands. --- .github/workflows/ci.yml | 4 ++++ crates/rbitcoin-query/src/confirm_run/mod.rs | 10 ++++++++-- crates/rbitcoin-store/src/scripthash_head.rs | 1 - scripts/coverage.test.sh | 4 ++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4cf41015e..9311f14ac9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,6 +109,10 @@ jobs: workspaces: ". -> target/dev" - name: cargo clippy run: cargo clippy --workspace --all-targets -- -D warnings + # Suites link cfg(debug_assertions) hooks and cannot run in release, so + # this is the only PR check that compiles what release.yml and nix ship. + - name: cargo check --release + run: cargo check --release --workspace --exclude rbitcoin-bench - uses: cachix/install-nix-action@448cde739abec1eaf0646249e3d25bb8d9bc7702 # v31.11.2 with: github_access_token: ${{ github.token }} diff --git a/crates/rbitcoin-query/src/confirm_run/mod.rs b/crates/rbitcoin-query/src/confirm_run/mod.rs index 956f5315fc..9be8267313 100644 --- a/crates/rbitcoin-query/src/confirm_run/mod.rs +++ b/crates/rbitcoin-query/src/confirm_run/mod.rs @@ -70,11 +70,17 @@ pub use lookup::{ confirm_wire_load_from_plan, confirm_wire_lookup_stamp, parent_missing_from_chain, ParentPinStamp, PlanStampOutcome, WireBlockIn, }; +#[cfg(debug_assertions)] +#[doc(hidden)] +pub use phases::expected_bits_extending; +#[doc(hidden)] +pub use phases::post_commit; use phases::{assemble_run, Assembled}; +#[cfg(debug_assertions)] #[doc(hidden)] -pub use phases::{expected_bits_extending, post_commit}; +pub use pin::ensure_spend_abs_layouts; #[doc(hidden)] -pub use pin::{collect_spend_abs_after_fill, ensure_spend_abs_layouts, pin_for_wire_batch}; +pub use pin::{collect_spend_abs_after_fill, pin_for_wire_batch}; pub use scripts::{confirm_scripts_phase, drive_script_waves_with}; pub use write::finish_post_commit; pub use write::{ diff --git a/crates/rbitcoin-store/src/scripthash_head.rs b/crates/rbitcoin-store/src/scripthash_head.rs index d0d5dec474..b29a6cb645 100644 --- a/crates/rbitcoin-store/src/scripthash_head.rs +++ b/crates/rbitcoin-store/src/scripthash_head.rs @@ -13,7 +13,6 @@ use crate::error::StoreError; use crate::file::{TableFile, FILE_HEADER_LEN}; -#[cfg(debug_assertions)] use crate::open_address::{self, MAX_LOAD_DEN, MAX_LOAD_NUM}; use crate::scripthash_layout::{ head_key_from_full, pack8_bytes, unpack8_bytes, ShHeadKey, ShHeadValue, SH_HEAD_KEY_LEN, diff --git a/scripts/coverage.test.sh b/scripts/coverage.test.sh index 5264b8fbb3..4036cef60e 100755 --- a/scripts/coverage.test.sh +++ b/scripts/coverage.test.sh @@ -77,6 +77,10 @@ assert_ok "required test job excludes rbitcoin-bench" \ grep -q 'cargo test --workspace --exclude rbitcoin-bench' "$ROOT/.github/workflows/ci.yml" assert_ok "required test job still pins the bench scripthash" \ grep -q 'cargo test -p rbitcoin-bench --lib hot_corpus_includes_p2a' "$ROOT/.github/workflows/ci.yml" +# Suites link cfg(debug_assertions) hooks, so release is check-only. Without +# this step a debug-only import on a production path ships uncompiled. +assert_ok "qc checks the release profile compiles" \ + grep -q 'cargo check --release --workspace --exclude rbitcoin-bench' "$ROOT/.github/workflows/ci.yml" assert_ok "gitignore ignores apilog jsonl" \ bash -c 'grep -q "apilog\\*\\.jsonl" "$1/.gitignore" && git -C "$1" check-ignore -q -- apilog.jsonl && git -C "$1" check-ignore -q -- apilog-old.jsonl' _ "$ROOT" From 14afcd3300f5e90923e95bad988c5d1acf86a7ed Mon Sep 17 00:00:00 2001 From: "rearden-grok[bot]" <317016512+rearden-grok[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:06:07 -0700 Subject: [PATCH 02/10] fix: spindle trace records only after a test arms it `spindle_mark` pushed onto a thread-local Vec on every confirm batch. Under cfg(test) that never ran in a node. Under cfg(debug_assertions) every debug node (core-functional nightly, warnet, `cargo run`) grew the write thread's trace for the life of the process; only the one schedule test ever cleared it. The trace is now opt-in like the other debug hooks: `spindle_trace_arm` clears and starts recording on this thread, `spindle_trace_clear` stops and drops it, and an un-armed `spindle_mark` is a no-op. Co-authored-by: Cursor --- .../rbitcoin-query/src/confirm_run/write.rs | 16 +++++++++- .../confirm_run/write_idempotent_tests.rs | 30 +++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/crates/rbitcoin-query/src/confirm_run/write.rs b/crates/rbitcoin-query/src/confirm_run/write.rs index a8db29b85b..0e550872d8 100644 --- a/crates/rbitcoin-query/src/confirm_run/write.rs +++ b/crates/rbitcoin-query/src/confirm_run/write.rs @@ -9,19 +9,33 @@ thread_local! { RefCell::new(super::phases::StructuralReuse::default()); } +// Opt-in: a debug node runs `spindle_mark` on every batch and nothing +// reads the trace, so it records only after `spindle_trace_arm`. #[cfg(debug_assertions)] thread_local! { + static SPINDLE_TRACE_ON: std::cell::Cell = const { std::cell::Cell::new(false) }; static SPINDLE_TRACE: RefCell> = const { RefCell::new(Vec::new()) }; } #[doc(hidden)] pub fn spindle_mark(_ev: &'static str) { #[cfg(debug_assertions)] - SPINDLE_TRACE.with(|trace| trace.borrow_mut().push(_ev)); + if SPINDLE_TRACE_ON.with(|on| on.get()) { + SPINDLE_TRACE.with(|trace| trace.borrow_mut().push(_ev)); + } +} + +/// Start recording on this thread, from an empty trace. +#[cfg(debug_assertions)] +pub fn spindle_trace_arm() { + SPINDLE_TRACE.with(|trace| trace.borrow_mut().clear()); + SPINDLE_TRACE_ON.with(|on| on.set(true)); } +/// Stop recording on this thread and drop what was recorded. #[cfg(debug_assertions)] pub fn spindle_trace_clear() { + SPINDLE_TRACE_ON.with(|on| on.set(false)); SPINDLE_TRACE.with(|trace| trace.borrow_mut().clear()); } diff --git a/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs b/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs index ce94659067..b8a2146b83 100644 --- a/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs +++ b/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs @@ -3491,13 +3491,36 @@ fn assert_spindle_schedule(trace: &[&str], hdd: bool, expect_class_a: bool) { } } +/// A debug node runs `spindle_mark` on every confirm batch. The trace must +/// stay empty until a test arms it, or the write thread grows a Vec forever. +#[test] +fn spindle_mark_records_only_while_armed() { + use rbitcoin_query::confirm_run::write::{ + spindle_mark, spindle_trace_arm, spindle_trace_clear, spindle_trace_snapshot, + }; + + spindle_trace_clear(); + spindle_mark("unarmed"); + assert!(spindle_trace_snapshot().is_empty()); + + spindle_trace_arm(); + spindle_mark("armed"); + assert_eq!(spindle_trace_snapshot(), vec!["armed"]); + + spindle_trace_clear(); + spindle_mark("after-clear"); + assert!(spindle_trace_snapshot().is_empty()); +} + #[test] fn datadir_hdd_submits_head_after_annotate() { use bitcoin::hashes::Hash; use rbitcoin_consensus::mine_empty_regtest; use rbitcoin_primitives::{Fk, Height}; use rbitcoin_query::accept_and_connect_block; - use rbitcoin_query::confirm_run::write::{spindle_trace_clear, spindle_trace_snapshot}; + use rbitcoin_query::confirm_run::write::{ + spindle_trace_arm, spindle_trace_clear, spindle_trace_snapshot, + }; use rbitcoin_query::confirm_run::{ confirm_scripts_phase, confirm_wire_load_from_plan, confirm_wire_lookup_stamp, confirm_write_phase, finish_post_commit_hashes, ScriptPreverified, @@ -3524,15 +3547,16 @@ fn datadir_hdd_submits_head_after_annotate() { ) .expect("load"); let ok = confirm_scripts_phase(mat.batch).expect("scripts"); - spindle_trace_clear(); + spindle_trace_arm(); confirm_write_phase(&q, ¶ms, Milestone::NONE, ok.batch).expect("write"); assert_spindle_schedule(&spindle_trace_snapshot(), hdd, true); let txid = b1.txdata[0].compute_txid().to_byte_array(); q.store().txs.head_note_pending(&[(txid, Fk(2))]); - spindle_trace_clear(); + spindle_trace_arm(); finish_post_commit_hashes(&q, &[(1, b1.block_hash().to_byte_array())]).expect("finish"); assert_spindle_schedule(&spindle_trace_snapshot(), hdd, false); + spindle_trace_clear(); let _ = std::fs::remove_dir_all(&path); } } From da99c9584ea54e269caba57ce4db61a4efaaeaf1 Mon Sep 17 00:00:00 2001 From: "rearden-grok[bot]" <317016512+rearden-grok[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:06:09 -0700 Subject: [PATCH 03/10] layout: suite roots drop the blanket allow Every tests/suite.rs opened with `#![allow(unused_imports, dead_code, unused_variables)]`, which switched the compiler's warnings off for all test code. With the allow gone the workspace reported ~2000 unused imports (all from the src/ -> tests/ move; `cargo fix` removed them), ~20 unused trait imports (by hand), and one dead helper: the `RBITCOIN_BLOCK_QUEUE_*` env lock in ibd/assign.rs, which #1097 replaced with a config field. No unused variables. Imports used only inside a Windows or Darwin cfg block were checked by hand; none were removed. Co-authored-by: Cursor --- crates/rbitcoin-cli/tests/root.rs | 6 +- crates/rbitcoin-cli/tests/suite.rs | 1 - .../tests/block/bip34_tests.rs | 28 ------- .../tests/block/block_866342.rs | 22 +----- .../tests/block/fact_reject_tests.rs | 27 ------- .../tests/block/finality_tests.rs | 28 +------ crates/rbitcoin-consensus/tests/block/mod.rs | 28 ------- .../tests/block/sigop_cost_tests.rs | 26 +------ crates/rbitcoin-consensus/tests/clock.rs | 3 - crates/rbitcoin-consensus/tests/error.rs | 2 - .../tests/header/median_time_past_tests.rs | 3 +- crates/rbitcoin-consensus/tests/header/mod.rs | 7 -- crates/rbitcoin-consensus/tests/id_map.rs | 3 +- crates/rbitcoin-consensus/tests/params.rs | 5 -- .../rbitcoin-consensus/tests/regtest_pad.rs | 13 +--- .../tests/script/classify.rs | 1 - .../tests/script/core_bip341.rs | 4 - .../tests/script/core_data.rs | 6 -- .../tests/script/core_fixture.rs | 6 -- .../tests/script/core_sighash.rs | 5 -- .../tests/script/core_tx_vectors.rs | 3 - .../tests/script/core_vectors.rs | 3 - .../tests/script/der_tests.rs | 7 -- .../script/interpreter/minimal_data_tests.rs | 9 +-- .../tests/script/interpreter/mod.rs | 9 --- .../interpreter/p2sh_redeem_parse_tests.rs | 9 +-- .../interpreter/success_and_disabled_tests.rs | 8 +- .../interpreter/untaken_consensus_arms.rs | 8 +- crates/rbitcoin-consensus/tests/script/mod.rs | 6 -- .../rbitcoin-consensus/tests/script/nested.rs | 5 +- .../rbitcoin-consensus/tests/script/p2pkh.rs | 5 +- .../tests/script/p2tr/bip341_tests.rs | 8 +- .../tests/script/p2tr/mod.rs | 11 --- .../rbitcoin-consensus/tests/script/p2wpkh.rs | 4 - .../rbitcoin-consensus/tests/script/p2wsh.rs | 4 - .../tests/script/tests_flag_parity.rs | 3 - .../tests/script/tests_verify.rs | 3 - .../tests/script/verify_routing_tests.rs | 2 - .../tests/script_edge_fixtures.rs | 41 ---------- .../rbitcoin-consensus/tests/script_pool.rs | 6 +- crates/rbitcoin-consensus/tests/signet.rs | 4 +- .../tests/silent_payments.rs | 8 +- crates/rbitcoin-consensus/tests/suite.rs | 1 - .../rbitcoin-consensus/tests/tx_precompute.rs | 9 +-- crates/rbitcoin-electrum/tests/server/mod.rs | 17 ++-- .../tests/server/surface_tests.rs | 19 +---- crates/rbitcoin-electrum/tests/silent_scan.rs | 7 +- crates/rbitcoin-electrum/tests/suite.rs | 1 - crates/rbitcoin-electrum/tests/tweaks.rs | 5 -- crates/rbitcoin-esplora/tests/handlers/mod.rs | 30 -------- .../tests/handlers/pure_helper_tests.rs | 33 +------- crates/rbitcoin-esplora/tests/internal.rs | 17 +--- crates/rbitcoin-esplora/tests/server.rs | 25 ++---- crates/rbitcoin-esplora/tests/suite.rs | 1 - crates/rbitcoin-esplora/tests/tx_json.rs | 11 +-- .../ibd/archive/class_a_rehydrate_tests.rs | 3 - crates/rbitcoin-ibd/tests/ibd/archive/mod.rs | 6 -- .../tests/ibd/archive_sat_tests.rs | 56 -------------- crates/rbitcoin-ibd/tests/ibd/assign.rs | 46 +---------- crates/rbitcoin-ibd/tests/ibd/body.rs | 4 +- crates/rbitcoin-ibd/tests/ibd/confirm.rs | 9 --- crates/rbitcoin-ibd/tests/ibd/dial.rs | 9 +-- .../tests/ibd/events/addr_bucket_tests.rs | 28 ------- .../tests/ibd/events/confirm_reject_tests.rs | 27 ------- .../ibd/events/decode_header_prefix_tests.rs | 30 -------- .../tests/ibd/events/header_batch_tests.rs | 27 ------- .../tests/ibd/events/ibd_memory_tests.rs | 28 +------ .../ibd/events/misbehavior_dead_tests.rs | 28 ------- crates/rbitcoin-ibd/tests/ibd/events/mod.rs | 30 -------- .../tests/ibd/events/parent_height_tests.rs | 27 ------- crates/rbitcoin-ibd/tests/ibd/header_walk.rs | 3 +- crates/rbitcoin-ibd/tests/ibd/mod.rs | 57 -------------- crates/rbitcoin-ibd/tests/ibd/path.rs | 4 - .../tests/ibd/peer_book_and_config_tests.rs | 55 ------------- crates/rbitcoin-ibd/tests/ibd/peer_io.rs | 15 +--- crates/rbitcoin-ibd/tests/ibd/perf_log.rs | 1 - crates/rbitcoin-ibd/tests/ibd/progress.rs | 5 -- crates/rbitcoin-ibd/tests/ibd/reorg.rs | 5 +- crates/rbitcoin-ibd/tests/ibd/state.rs | 7 -- crates/rbitcoin-ibd/tests/ibd/status.rs | 4 +- crates/rbitcoin-ibd/tests/ibd_smoke.rs | 56 +------------- crates/rbitcoin-ibd/tests/suite.rs | 2 - crates/rbitcoin-log/tests/api_log.rs | 5 -- crates/rbitcoin-log/tests/progress.rs | 4 +- crates/rbitcoin-log/tests/root.rs | 6 +- crates/rbitcoin-log/tests/suite.rs | 1 - crates/rbitcoin-mempool/tests/accept.rs | 14 +--- crates/rbitcoin-mempool/tests/error.rs | 2 - crates/rbitcoin-mempool/tests/fee_flow.rs | 2 +- crates/rbitcoin-mempool/tests/graph.rs | 5 +- crates/rbitcoin-mempool/tests/orphanage.rs | 4 +- crates/rbitcoin-mempool/tests/packed.rs | 5 +- crates/rbitcoin-mempool/tests/store_tests.rs | 30 ++------ crates/rbitcoin-mempool/tests/suite.rs | 1 - crates/rbitcoin-net/tests/asmap.rs | 1 - crates/rbitcoin-net/tests/cache.rs | 5 -- crates/rbitcoin-net/tests/chain.rs | 22 +----- crates/rbitcoin-net/tests/codec.rs | 3 +- crates/rbitcoin-net/tests/compact.rs | 8 +- crates/rbitcoin-net/tests/ephemeral.rs | 5 +- crates/rbitcoin-net/tests/error.rs | 1 - crates/rbitcoin-net/tests/fee_history.rs | 4 +- crates/rbitcoin-net/tests/fee_history_file.rs | 5 +- crates/rbitcoin-net/tests/i2p_sam.rs | 4 - crates/rbitcoin-net/tests/msg_decode.rs | 5 +- crates/rbitcoin-net/tests/net_permissions.rs | 2 +- crates/rbitcoin-net/tests/netaddr.rs | 4 - crates/rbitcoin-net/tests/netgroup.rs | 1 - crates/rbitcoin-net/tests/parent_req.rs | 3 +- .../rbitcoin-net/tests/peer/log_text_tests.rs | 35 --------- crates/rbitcoin-net/tests/peer/mod.rs | 26 ++----- crates/rbitcoin-net/tests/peer_dos.rs | 2 - crates/rbitcoin-net/tests/peers.rs | 11 +-- crates/rbitcoin-net/tests/perf_meter.rs | 1 - crates/rbitcoin-net/tests/root.rs | 54 ------------- crates/rbitcoin-net/tests/seeds.rs | 13 +--- crates/rbitcoin-net/tests/service.rs | 20 +---- crates/rbitcoin-net/tests/socks.rs | 2 - crates/rbitcoin-net/tests/suite.rs | 1 - crates/rbitcoin-net/tests/tip_accept.rs | 8 +- crates/rbitcoin-net/tests/tx_relay.rs | 25 ++---- crates/rbitcoin-net/tests/v2.rs | 19 +---- crates/rbitcoin-net/tests/versionbits_warn.rs | 1 - crates/rbitcoin-node/tests/cli.rs | 8 +- crates/rbitcoin-node/tests/config.rs | 11 +-- crates/rbitcoin-node/tests/error.rs | 1 - crates/rbitcoin-node/tests/health/metrics.rs | 4 - crates/rbitcoin-node/tests/health/mod.rs | 15 +--- crates/rbitcoin-node/tests/inhibit.rs | 2 - crates/rbitcoin-node/tests/lock.rs | 3 - crates/rbitcoin-node/tests/regtest_rpc.rs | 1 - crates/rbitcoin-node/tests/run.rs | 31 ++------ crates/rbitcoin-node/tests/suite.rs | 1 - crates/rbitcoin-primitives/tests/compact.rs | 1 - crates/rbitcoin-primitives/tests/hex.rs | 3 +- crates/rbitcoin-primitives/tests/merkle.rs | 1 - crates/rbitcoin-primitives/tests/root.rs | 19 ----- crates/rbitcoin-primitives/tests/scriptnum.rs | 1 - crates/rbitcoin-primitives/tests/suite.rs | 1 - crates/rbitcoin-query/tests/archive.rs | 5 -- crates/rbitcoin-query/tests/batch_parents.rs | 10 +-- .../rbitcoin-query/tests/bip68_store_tests.rs | 74 +----------------- crates/rbitcoin-query/tests/block_filter.rs | 9 --- .../tests/block_pipeline/mod.rs | 13 ---- .../block_pipeline/overlay_meta_skip_tests.rs | 14 +--- .../block_pipeline/run_create_height_tests.rs | 13 ---- crates/rbitcoin-query/tests/bq_lock_pin.rs | 76 +----------------- crates/rbitcoin-query/tests/catchup.rs | 2 - crates/rbitcoin-query/tests/combined_stage.rs | 5 +- crates/rbitcoin-query/tests/confirm_error.rs | 2 - .../tests/confirm_parent_cache.rs | 3 - .../tests/confirm_run/bq_resolve.rs | 9 +-- .../rbitcoin-query/tests/confirm_run/index.rs | 11 +-- .../tests/confirm_run/lookup.rs | 1 - .../rbitcoin-query/tests/confirm_run/mod.rs | 30 -------- .../tests/confirm_run/phases.rs | 2 - .../tests/confirm_run/spend_durable_tests.rs | 25 ------ .../confirm_run/write_idempotent_tests.rs | 31 +------- crates/rbitcoin-query/tests/confirm_stats.rs | 2 - .../tests/connect_facade/coverage_tests.rs | 22 +----- .../tests/connect_facade/mod.rs | 22 ------ crates/rbitcoin-query/tests/convert.rs | 2 - .../tests/header_store_tests.rs | 70 +---------------- crates/rbitcoin-query/tests/in_flight.rs | 5 -- .../rbitcoin-query/tests/index_writebehind.rs | 9 +-- .../rbitcoin-query/tests/overlay_csv_tests.rs | 73 +----------------- .../tests/reconstruct/encode_witness_tests.rs | 3 - .../rbitcoin-query/tests/reconstruct/mod.rs | 3 - crates/rbitcoin-query/tests/resolved_wire.rs | 1 - crates/rbitcoin-query/tests/root.rs | 77 ++----------------- .../rbitcoin-query/tests/run_builder_core.rs | 2 - .../tests/scripthash/history_filter_tests.rs | 3 - crates/rbitcoin-query/tests/scripthash/mod.rs | 3 - crates/rbitcoin-query/tests/sh_builder.rs | 10 +-- .../tests/sp_read/classifier_record_tests.rs | 10 +-- crates/rbitcoin-query/tests/sp_read/mod.rs | 8 -- crates/rbitcoin-query/tests/sp_store_tests.rs | 75 +----------------- crates/rbitcoin-query/tests/sp_tweaks.rs | 1 - crates/rbitcoin-query/tests/spend_sync.rs | 6 +- crates/rbitcoin-query/tests/stamp.rs | 8 +- .../tests/structure_rule_tests.rs | 69 +---------------- crates/rbitcoin-query/tests/suite.rs | 1 - .../rbitcoin-query/tests/wire_agree_tests.rs | 73 +----------------- .../rbitcoin-query/tests/write_create_loc.rs | 3 - crates/rbitcoin-rpc/tests/auth.rs | 1 - crates/rbitcoin-rpc/tests/blockstats/mod.rs | 10 --- .../tests/blockstats/unit_tests.rs | 11 +-- .../tests/methods/chain/core_double_tests.rs | 8 -- .../rbitcoin-rpc/tests/methods/chain/mod.rs | 8 -- .../tests/methods/chain/wait_tests.rs | 8 +- .../tests/methods/mempool/fee_look_tests.rs | 7 -- .../rbitcoin-rpc/tests/methods/mempool/mod.rs | 7 -- .../tests/methods/mempool/smart_fee_tests.rs | 7 -- crates/rbitcoin-rpc/tests/methods/mod.rs | 15 +--- crates/rbitcoin-rpc/tests/root.rs | 10 --- crates/rbitcoin-rpc/tests/server.rs | 26 ++----- crates/rbitcoin-rpc/tests/suite.rs | 1 - crates/rbitcoin-store/tests/address_head.rs | 8 +- crates/rbitcoin-store/tests/array_table.rs | 4 +- crates/rbitcoin-store/tests/bdz.rs | 6 -- crates/rbitcoin-store/tests/binary_fuse8.rs | 1 - crates/rbitcoin-store/tests/block_filter.rs | 8 +- crates/rbitcoin-store/tests/block_queue.rs | 3 - crates/rbitcoin-store/tests/block_wire.rs | 1 - crates/rbitcoin-store/tests/bulk_io.rs | 1 - .../tests/chain/chain_table_tests.rs | 4 +- crates/rbitcoin-store/tests/chain/mod.rs | 4 - .../tests/chain/strong_tests.rs | 4 +- crates/rbitcoin-store/tests/compact.rs | 2 - crates/rbitcoin-store/tests/create_loc.rs | 13 +--- crates/rbitcoin-store/tests/delta_loc.rs | 9 +-- crates/rbitcoin-store/tests/error.rs | 1 - .../rbitcoin-store/tests/file/advise_tests.rs | 9 +-- crates/rbitcoin-store/tests/file/mod.rs | 8 -- crates/rbitcoin-store/tests/fuse8_filter.rs | 4 - crates/rbitcoin-store/tests/hashhead.rs | 7 +- .../tests/head_resolve_denserels.rs | 5 -- .../rbitcoin-store/tests/head_resolve_pick.rs | 2 +- .../tests/head_resolve_stats.rs | 1 - crates/rbitcoin-store/tests/header_table.rs | 3 - crates/rbitcoin-store/tests/height_fence.rs | 5 +- .../rbitcoin-store/tests/idx_body_pipeline.rs | 4 - .../rbitcoin-store/tests/index_build_uring.rs | 13 +--- crates/rbitcoin-store/tests/input.rs | 7 +- crates/rbitcoin-store/tests/int_map.rs | 3 +- crates/rbitcoin-store/tests/integrity.rs | 8 +- crates/rbitcoin-store/tests/io_backend.rs | 2 - .../rbitcoin-store/tests/io_session_iocp.rs | 3 - crates/rbitcoin-store/tests/public_surface.rs | 35 ++------- crates/rbitcoin-store/tests/readonly_map.rs | 3 - crates/rbitcoin-store/tests/scripthash.rs | 33 +++----- .../rbitcoin-store/tests/scripthash_head.rs | 12 +-- .../tests/scripthash_materialize.rs | 25 ++---- .../rbitcoin-store/tests/scripthash_mphf.rs | 7 +- .../rbitcoin-store/tests/scripthash_pages.rs | 5 +- .../rbitcoin-store/tests/scripthash_slabs.rs | 4 +- .../tests/scripthash_sorted_head.rs | 13 +--- crates/rbitcoin-store/tests/segmented_head.rs | 14 ++-- crates/rbitcoin-store/tests/sp_tweaks.rs | 8 +- .../rbitcoin-store/tests/sp_tweaks_uring.rs | 10 +-- .../tests/spend_annotate_uring.rs | 5 +- crates/rbitcoin-store/tests/spend_durable.rs | 4 - crates/rbitcoin-store/tests/spender_table.rs | 7 +- .../tests/store/legacy_rename_tests.rs | 12 --- crates/rbitcoin-store/tests/store/mod.rs | 18 ++--- crates/rbitcoin-store/tests/store_secret.rs | 4 - crates/rbitcoin-store/tests/suite.rs | 1 - crates/rbitcoin-store/tests/testutil.rs | 4 - crates/rbitcoin-store/tests/tx_head_mphf.rs | 3 +- crates/rbitcoin-store/tests/tx_table/mod.rs | 9 +-- .../packed/borrowed_input_encode_tests.rs | 2 - .../tests/tx_table/packed/mod.rs | 2 - .../tests/tx_table/packed/scan_p2tr_tests.rs | 1 - crates/rbitcoin-store/tests/txid_body.rs | 5 +- crates/rbitcoin-store/tests/txstat.rs | 5 +- crates/rbitcoin-store/tests/uring_session.rs | 6 +- crates/rbitcoin-store/tests/var_table.rs | 6 +- crates/rbitcoin-sv2/tests/listener_tests.rs | 8 +- crates/rbitcoin-sv2/tests/session.rs | 32 -------- crates/rbitcoin-sv2/tests/suite.rs | 1 - crates/rbitcoin-sv2/tests/template_tests.rs | 11 +-- crates/rbitcoin-sv2/tests/test_chain.rs | 12 +-- crates/rbitcoin-test/tests/suite.rs | 2 - 263 files changed, 276 insertions(+), 2832 deletions(-) diff --git a/crates/rbitcoin-cli/tests/root.rs b/crates/rbitcoin-cli/tests/root.rs index c1dfb31fad..7fa433a003 100644 --- a/crates/rbitcoin-cli/tests/root.rs +++ b/crates/rbitcoin-cli/tests/root.rs @@ -1,12 +1,8 @@ use rbitcoin_cli::*; use rbitcoin_primitives::Network; -use serde_json::Value; -use std::ffi::OsString; use std::io::{Read, Write}; -use std::net::TcpStream; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::process::ExitCode; -use std::time::Duration; use std::net::TcpListener; diff --git a/crates/rbitcoin-cli/tests/suite.rs b/crates/rbitcoin-cli/tests/suite.rs index 585b4356ac..6ee09e6a42 100644 --- a/crates/rbitcoin-cli/tests/suite.rs +++ b/crates/rbitcoin-cli/tests/suite.rs @@ -1,2 +1 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod root; diff --git a/crates/rbitcoin-consensus/tests/block/bip34_tests.rs b/crates/rbitcoin-consensus/tests/block/bip34_tests.rs index a22d9800ba..1efffd506f 100644 --- a/crates/rbitcoin-consensus/tests/block/bip34_tests.rs +++ b/crates/rbitcoin-consensus/tests/block/bip34_tests.rs @@ -1,32 +1,4 @@ //! bip34_tests (peeled from block.rs). -use bitcoin::block::Block; -use bitcoin::hashes::{sha256d, Hash}; -use bitcoin::script::{Script, ScriptBuf}; -use bitcoin::{Amount, Transaction, TxOut, Witness}; -use rbitcoin_consensus::block::facts::{ - add_fee, add_sigops, add_value_in, fee_from_values, fee_sat, header_gap_on_chain, - median_or_bad_header, reject_assemble_block_shape, reject_batch_starts_at, reject_bits, - reject_carried_header_hash, reject_confirm_batch, reject_csv_create_height, - reject_duplicate_input, reject_empty_confirm_batch, reject_genesis_coinbase_spend, - reject_non_final, reject_prev_link, reject_prevout_spent, reject_same_block_create, - reject_sequence_locks, reject_spend_cursor, reject_tx_without_inputs, - reject_tx_without_outputs, reject_txid_count, reject_unresolved_spend, - reject_unspendable_prevout, reject_vout_past_n_out, reject_witness_before_segwit, - require_linked_parent, require_next_work, require_retarget_first, require_same_block_output, - unresolved_parent_create, -}; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::milestone::Milestone; -use rbitcoin_consensus::params::ChainParams; -use rbitcoin_consensus::TxPrecompute; -use rbitcoin_consensus::TxidHasher; -use rbitcoin_primitives::script_sigop_count; -use rbitcoin_primitives::Height; -use std::borrow::Borrow; -use std::hash::BuildHasherDefault; -use std::ops::{Deref, DerefMut}; -use std::sync::Arc; -use std::time::Instant; use rbitcoin_consensus::block::bip34_height_script; diff --git a/crates/rbitcoin-consensus/tests/block/block_866342.rs b/crates/rbitcoin-consensus/tests/block/block_866342.rs index 66711303a2..eb41ae8ba9 100644 --- a/crates/rbitcoin-consensus/tests/block/block_866342.rs +++ b/crates/rbitcoin-consensus/tests/block/block_866342.rs @@ -4,31 +4,13 @@ //! Floresta's MIT/Apache `spent_utxos.zst` (ordered non-coinbase inputs). #![cfg(test)] use bitcoin::block::Block; -use bitcoin::hashes::{sha256d, Hash}; -use bitcoin::script::{Script, ScriptBuf}; +use bitcoin::hashes::Hash; +use bitcoin::script::ScriptBuf; use bitcoin::{Amount, Transaction, TxOut, Witness}; -use rbitcoin_consensus::block::facts::{ - add_fee, add_sigops, add_value_in, fee_from_values, fee_sat, header_gap_on_chain, - median_or_bad_header, reject_assemble_block_shape, reject_batch_starts_at, reject_bits, - reject_carried_header_hash, reject_confirm_batch, reject_csv_create_height, - reject_duplicate_input, reject_empty_confirm_batch, reject_genesis_coinbase_spend, - reject_non_final, reject_prev_link, reject_prevout_spent, reject_same_block_create, - reject_sequence_locks, reject_spend_cursor, reject_tx_without_inputs, - reject_tx_without_outputs, reject_txid_count, reject_unresolved_spend, - reject_unspendable_prevout, reject_vout_past_n_out, reject_witness_before_segwit, - require_linked_parent, require_next_work, require_retarget_first, require_same_block_output, - unresolved_parent_create, -}; use rbitcoin_consensus::error::ConsensusError; use rbitcoin_consensus::milestone::Milestone; use rbitcoin_consensus::params::ChainParams; -use rbitcoin_consensus::TxPrecompute; -use rbitcoin_consensus::TxidHasher; -use rbitcoin_primitives::script_sigop_count; use rbitcoin_primitives::Height; -use std::borrow::Borrow; -use std::hash::BuildHasherDefault; -use std::ops::{Deref, DerefMut}; use std::sync::Arc; use std::time::Instant; diff --git a/crates/rbitcoin-consensus/tests/block/fact_reject_tests.rs b/crates/rbitcoin-consensus/tests/block/fact_reject_tests.rs index 6d7874caf0..68e126a302 100644 --- a/crates/rbitcoin-consensus/tests/block/fact_reject_tests.rs +++ b/crates/rbitcoin-consensus/tests/block/fact_reject_tests.rs @@ -1,32 +1,5 @@ -use bitcoin::block::Block; -use bitcoin::hashes::{sha256d, Hash}; -use bitcoin::script::{Script, ScriptBuf}; -use bitcoin::{Amount, Transaction, TxOut, Witness}; -use rbitcoin_consensus::block::facts::{ - add_fee, add_sigops, add_value_in, fee_from_values, fee_sat, header_gap_on_chain, - median_or_bad_header, reject_assemble_block_shape, reject_batch_starts_at, reject_bits, - reject_carried_header_hash, reject_confirm_batch, reject_csv_create_height, - reject_duplicate_input, reject_empty_confirm_batch, reject_genesis_coinbase_spend, - reject_non_final, reject_prev_link, reject_prevout_spent, reject_same_block_create, - reject_sequence_locks, reject_spend_cursor, reject_tx_without_inputs, - reject_tx_without_outputs, reject_txid_count, reject_unresolved_spend, - reject_unspendable_prevout, reject_vout_past_n_out, reject_witness_before_segwit, - require_linked_parent, require_next_work, require_retarget_first, require_same_block_output, - unresolved_parent_create, -}; use rbitcoin_consensus::block::{reject_bip30_unspent_prior, reject_one_create}; use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::milestone::Milestone; -use rbitcoin_consensus::params::ChainParams; -use rbitcoin_consensus::TxPrecompute; -use rbitcoin_consensus::TxidHasher; -use rbitcoin_primitives::script_sigop_count; -use rbitcoin_primitives::Height; -use std::borrow::Borrow; -use std::hash::BuildHasherDefault; -use std::ops::{Deref, DerefMut}; -use std::sync::Arc; -use std::time::Instant; #[test] fn bip30_and_immature_coinbase_reject_from_facts() { diff --git a/crates/rbitcoin-consensus/tests/block/finality_tests.rs b/crates/rbitcoin-consensus/tests/block/finality_tests.rs index b14eca5df6..d0705cc4b2 100644 --- a/crates/rbitcoin-consensus/tests/block/finality_tests.rs +++ b/crates/rbitcoin-consensus/tests/block/finality_tests.rs @@ -1,32 +1,6 @@ //! finality_tests (peeled from block.rs). -use bitcoin::block::Block; -use bitcoin::hashes::{sha256d, Hash}; -use bitcoin::script::{Script, ScriptBuf}; +use bitcoin::script::ScriptBuf; use bitcoin::{Amount, Transaction, TxOut, Witness}; -use rbitcoin_consensus::block::facts::{ - add_fee, add_sigops, add_value_in, fee_from_values, fee_sat, header_gap_on_chain, - median_or_bad_header, reject_assemble_block_shape, reject_batch_starts_at, reject_bits, - reject_carried_header_hash, reject_confirm_batch, reject_csv_create_height, - reject_duplicate_input, reject_empty_confirm_batch, reject_genesis_coinbase_spend, - reject_non_final, reject_prev_link, reject_prevout_spent, reject_same_block_create, - reject_sequence_locks, reject_spend_cursor, reject_tx_without_inputs, - reject_tx_without_outputs, reject_txid_count, reject_unresolved_spend, - reject_unspendable_prevout, reject_vout_past_n_out, reject_witness_before_segwit, - require_linked_parent, require_next_work, require_retarget_first, require_same_block_output, - unresolved_parent_create, -}; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::milestone::Milestone; -use rbitcoin_consensus::params::ChainParams; -use rbitcoin_consensus::TxPrecompute; -use rbitcoin_consensus::TxidHasher; -use rbitcoin_primitives::script_sigop_count; -use rbitcoin_primitives::Height; -use std::borrow::Borrow; -use std::hash::BuildHasherDefault; -use std::ops::{Deref, DerefMut}; -use std::sync::Arc; -use std::time::Instant; use bitcoin::absolute::LockTime; use rbitcoin_consensus::block::{ diff --git a/crates/rbitcoin-consensus/tests/block/mod.rs b/crates/rbitcoin-consensus/tests/block/mod.rs index b453131696..c847f421cc 100644 --- a/crates/rbitcoin-consensus/tests/block/mod.rs +++ b/crates/rbitcoin-consensus/tests/block/mod.rs @@ -1,31 +1,3 @@ -use bitcoin::block::Block; -use bitcoin::hashes::{sha256d, Hash}; -use bitcoin::script::{Script, ScriptBuf}; -use bitcoin::{Amount, Transaction, TxOut, Witness}; -use rbitcoin_consensus::block::facts::{ - add_fee, add_sigops, add_value_in, fee_from_values, fee_sat, header_gap_on_chain, - median_or_bad_header, reject_assemble_block_shape, reject_batch_starts_at, reject_bits, - reject_carried_header_hash, reject_confirm_batch, reject_csv_create_height, - reject_duplicate_input, reject_empty_confirm_batch, reject_genesis_coinbase_spend, - reject_non_final, reject_prev_link, reject_prevout_spent, reject_same_block_create, - reject_sequence_locks, reject_spend_cursor, reject_tx_without_inputs, - reject_tx_without_outputs, reject_txid_count, reject_unresolved_spend, - reject_unspendable_prevout, reject_vout_past_n_out, reject_witness_before_segwit, - require_linked_parent, require_next_work, require_retarget_first, require_same_block_output, - unresolved_parent_create, -}; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::milestone::Milestone; -use rbitcoin_consensus::params::ChainParams; -use rbitcoin_consensus::TxPrecompute; -use rbitcoin_consensus::TxidHasher; -use rbitcoin_primitives::script_sigop_count; -use rbitcoin_primitives::Height; -use std::borrow::Borrow; -use std::hash::BuildHasherDefault; -use std::ops::{Deref, DerefMut}; -use std::sync::Arc; -use std::time::Instant; mod bip34_tests; mod block_866342; mod fact_reject_tests; diff --git a/crates/rbitcoin-consensus/tests/block/sigop_cost_tests.rs b/crates/rbitcoin-consensus/tests/block/sigop_cost_tests.rs index 70099aaa01..26791cf214 100644 --- a/crates/rbitcoin-consensus/tests/block/sigop_cost_tests.rs +++ b/crates/rbitcoin-consensus/tests/block/sigop_cost_tests.rs @@ -1,32 +1,8 @@ //! sigop_cost_tests (peeled from block.rs). -use bitcoin::block::Block; -use bitcoin::hashes::{sha256d, Hash}; +use bitcoin::hashes::Hash; use bitcoin::script::{Script, ScriptBuf}; use bitcoin::{Amount, Transaction, TxOut, Witness}; -use rbitcoin_consensus::block::facts::{ - add_fee, add_sigops, add_value_in, fee_from_values, fee_sat, header_gap_on_chain, - median_or_bad_header, reject_assemble_block_shape, reject_batch_starts_at, reject_bits, - reject_carried_header_hash, reject_confirm_batch, reject_csv_create_height, - reject_duplicate_input, reject_empty_confirm_batch, reject_genesis_coinbase_spend, - reject_non_final, reject_prev_link, reject_prevout_spent, reject_same_block_create, - reject_sequence_locks, reject_spend_cursor, reject_tx_without_inputs, - reject_tx_without_outputs, reject_txid_count, reject_unresolved_spend, - reject_unspendable_prevout, reject_vout_past_n_out, reject_witness_before_segwit, - require_linked_parent, require_next_work, require_retarget_first, require_same_block_output, - unresolved_parent_create, -}; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::milestone::Milestone; -use rbitcoin_consensus::params::ChainParams; -use rbitcoin_consensus::TxPrecompute; -use rbitcoin_consensus::TxidHasher; use rbitcoin_primitives::script_sigop_count; -use rbitcoin_primitives::Height; -use std::borrow::Borrow; -use std::hash::BuildHasherDefault; -use std::ops::{Deref, DerefMut}; -use std::sync::Arc; -use std::time::Instant; use bitcoin::absolute::LockTime; use rbitcoin_consensus::block::{ diff --git a/crates/rbitcoin-consensus/tests/clock.rs b/crates/rbitcoin-consensus/tests/clock.rs index 9a00db801d..4898c99333 100644 --- a/crates/rbitcoin-consensus/tests/clock.rs +++ b/crates/rbitcoin-consensus/tests/clock.rs @@ -1,7 +1,4 @@ use rbitcoin_consensus::clock::*; -use std::sync::atomic::{AtomicI64, AtomicU64, Ordering}; -use std::sync::Arc; -use std::time::{SystemTime, UNIX_EPOCH}; #[test] fn mock_then_wall() { diff --git a/crates/rbitcoin-consensus/tests/error.rs b/crates/rbitcoin-consensus/tests/error.rs index 8c2381609f..e3d124ef47 100644 --- a/crates/rbitcoin-consensus/tests/error.rs +++ b/crates/rbitcoin-consensus/tests/error.rs @@ -1,6 +1,4 @@ use rbitcoin_consensus::error::*; -use rbitcoin_primitives::ScriptNumError; -use std::fmt; #[test] fn block_reject_reason_bip113_and_bip112_needles() { diff --git a/crates/rbitcoin-consensus/tests/header/median_time_past_tests.rs b/crates/rbitcoin-consensus/tests/header/median_time_past_tests.rs index b4bf7bea2e..9f7db66b93 100644 --- a/crates/rbitcoin-consensus/tests/header/median_time_past_tests.rs +++ b/crates/rbitcoin-consensus/tests/header/median_time_past_tests.rs @@ -1,10 +1,9 @@ -use bitcoin::block::Header; use bitcoin::block::Version; use bitcoin::hashes::Hash; use bitcoin::{CompactTarget, Target}; use rbitcoin_consensus::error::ConsensusError; use rbitcoin_consensus::header::*; -use rbitcoin_consensus::params::{check_genesis_hash, ChainParams}; +use rbitcoin_consensus::params::ChainParams; use rbitcoin_primitives::median_time_past_times; use rbitcoin_primitives::Height; diff --git a/crates/rbitcoin-consensus/tests/header/mod.rs b/crates/rbitcoin-consensus/tests/header/mod.rs index 30423933b3..9d27fdfaf4 100644 --- a/crates/rbitcoin-consensus/tests/header/mod.rs +++ b/crates/rbitcoin-consensus/tests/header/mod.rs @@ -1,8 +1 @@ -use bitcoin::block::Header; -use bitcoin::hashes::Hash; -use bitcoin::{CompactTarget, Target}; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::params::{check_genesis_hash, ChainParams}; -use rbitcoin_primitives::median_time_past_times; -use rbitcoin_primitives::Height; mod median_time_past_tests; diff --git a/crates/rbitcoin-consensus/tests/id_map.rs b/crates/rbitcoin-consensus/tests/id_map.rs index 96c8b7e4f4..8be4173215 100644 --- a/crates/rbitcoin-consensus/tests/id_map.rs +++ b/crates/rbitcoin-consensus/tests/id_map.rs @@ -1,7 +1,6 @@ use rbitcoin_consensus::id_map::*; use rbitcoin_primitives::Fk; -use std::collections::HashMap; -use std::hash::{BuildHasherDefault, Hasher}; +use std::hash::Hasher; #[test] fn txid_hasher_uses_first_8_bytes() { diff --git a/crates/rbitcoin-consensus/tests/params.rs b/crates/rbitcoin-consensus/tests/params.rs index 4ca030c347..a67234dd94 100644 --- a/crates/rbitcoin-consensus/tests/params.rs +++ b/crates/rbitcoin-consensus/tests/params.rs @@ -1,10 +1,5 @@ -use bitcoin::blockdata::constants; -use bitcoin::consensus::Params as BtcParams; -use bitcoin::hashes::Hash; use bitcoin::script::ScriptBuf; -use bitcoin::{BlockHash, Network, Target}; use rbitcoin_consensus::params::*; -use std::str::FromStr; /// Core `SigNetParams` / Inquisition signet: soft forks at height 1 (not 0). #[test] diff --git a/crates/rbitcoin-consensus/tests/regtest_pad.rs b/crates/rbitcoin-consensus/tests/regtest_pad.rs index 41fc5af571..767d84d602 100644 --- a/crates/rbitcoin-consensus/tests/regtest_pad.rs +++ b/crates/rbitcoin-consensus/tests/regtest_pad.rs @@ -1,14 +1,7 @@ -use bitcoin::absolute::LockTime; -use bitcoin::block::{Header, Version}; -use bitcoin::hashes::Hash; -use bitcoin::transaction::Version as TxVersion; -use bitcoin::{ - Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Sequence, Target, Transaction, - TxIn, TxMerkleNode, TxOut, Witness, -}; -use rbitcoin_consensus::block::apply_witness_commitment; +use bitcoin::block::Version; +use bitcoin::{Amount, Block, CompactTarget, ScriptBuf, Target}; use rbitcoin_consensus::regtest_pad::*; -use rbitcoin_consensus::{bip34_height_script, block_has_witness, block_subsidy, ChainParams}; +use rbitcoin_consensus::ChainParams; #[test] fn mine_regtest_paying_sets_coinbase_script() { diff --git a/crates/rbitcoin-consensus/tests/script/classify.rs b/crates/rbitcoin-consensus/tests/script/classify.rs index ae2dc189b7..30c4f352b2 100644 --- a/crates/rbitcoin-consensus/tests/script/classify.rs +++ b/crates/rbitcoin-consensus/tests/script/classify.rs @@ -1,4 +1,3 @@ -use bitcoin::script::Script; use bitcoin::script::ScriptBuf; use rbitcoin_consensus::script::classify::*; diff --git a/crates/rbitcoin-consensus/tests/script/core_bip341.rs b/crates/rbitcoin-consensus/tests/script/core_bip341.rs index 4af286b12c..acfb0ceed4 100644 --- a/crates/rbitcoin-consensus/tests/script/core_bip341.rs +++ b/crates/rbitcoin-consensus/tests/script/core_bip341.rs @@ -5,12 +5,8 @@ //! rows (non-`0xc0`) go through the same job: BIP341 commitment must hold and //! the leaf is not executed. This Core file has no marked-invalid spends. #![cfg(test)] -use bitcoin::hashes::Hash; use bitcoin::Transaction; use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; use bitcoin::absolute::LockTime; use bitcoin::consensus::deserialize; diff --git a/crates/rbitcoin-consensus/tests/script/core_data.rs b/crates/rbitcoin-consensus/tests/script/core_data.rs index 4c73bfd295..82afd05ff8 100644 --- a/crates/rbitcoin-consensus/tests/script/core_data.rs +++ b/crates/rbitcoin-consensus/tests/script/core_data.rs @@ -4,12 +4,6 @@ //! run hard-links (or copies) the pin into `$CARGO_TARGET_DIR/core-data/`. //! If the submodule is missing (typical CI checkout), this runs //! `scripts/core-functional/init-submodule.sh`. -use bitcoin::hashes::Hash; -use bitcoin::Transaction; -use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; use std::fs; use std::path::{Path, PathBuf}; diff --git a/crates/rbitcoin-consensus/tests/script/core_fixture.rs b/crates/rbitcoin-consensus/tests/script/core_fixture.rs index 8b6bca6578..43bc67a28e 100644 --- a/crates/rbitcoin-consensus/tests/script/core_fixture.rs +++ b/crates/rbitcoin-consensus/tests/script/core_fixture.rs @@ -1,9 +1,3 @@ -use bitcoin::hashes::Hash; -use bitcoin::Transaction; -use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; use std::fs; use std::path::PathBuf; diff --git a/crates/rbitcoin-consensus/tests/script/core_sighash.rs b/crates/rbitcoin-consensus/tests/script/core_sighash.rs index 0522f1f6ab..59ce285052 100644 --- a/crates/rbitcoin-consensus/tests/script/core_sighash.rs +++ b/crates/rbitcoin-consensus/tests/script/core_sighash.rs @@ -4,12 +4,7 @@ //! Digests come from [`bitcoin::sighash::SighashCache::legacy_signature_hash`] //! with the **raw** hashType byte (same as P2PKH / interpreter CHECKSIG). #![cfg(test)] -use bitcoin::hashes::Hash; use bitcoin::Transaction; -use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; use super::core_script::decode_hex; use bitcoin::consensus::deserialize; diff --git a/crates/rbitcoin-consensus/tests/script/core_tx_vectors.rs b/crates/rbitcoin-consensus/tests/script/core_tx_vectors.rs index a447b3ca69..26ddb4935b 100644 --- a/crates/rbitcoin-consensus/tests/script/core_tx_vectors.rs +++ b/crates/rbitcoin-consensus/tests/script/core_tx_vectors.rs @@ -8,9 +8,6 @@ use bitcoin::hashes::Hash; use bitcoin::Transaction; use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; use super::core_script::{assemble_script, decode_hex}; use bitcoin::consensus::deserialize; diff --git a/crates/rbitcoin-consensus/tests/script/core_vectors.rs b/crates/rbitcoin-consensus/tests/script/core_vectors.rs index 5a76253d10..434bbfb754 100644 --- a/crates/rbitcoin-consensus/tests/script/core_vectors.rs +++ b/crates/rbitcoin-consensus/tests/script/core_vectors.rs @@ -8,9 +8,6 @@ use bitcoin::hashes::Hash; use bitcoin::Transaction; use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; use super::core_script::{assemble_script as assemble, credit_and_spend, SpendShape}; use rbitcoin_consensus::block::JobTx; diff --git a/crates/rbitcoin-consensus/tests/script/der_tests.rs b/crates/rbitcoin-consensus/tests/script/der_tests.rs index 6d2277ad48..51757aa7e7 100644 --- a/crates/rbitcoin-consensus/tests/script/der_tests.rs +++ b/crates/rbitcoin-consensus/tests/script/der_tests.rs @@ -1,14 +1,7 @@ -use bitcoin::hashes::Hash; -use bitcoin::Transaction; -use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; use rbitcoin_consensus::script::crypto::{ is_compressed_or_uncompressed_pubkey, is_compressed_pubkey, is_defined_hashtype, is_valid_signature_encoding, parse_der_sig, TapSpentHashes, }; -use rbitcoin_consensus::script::*; fn valid_der_sig() -> Vec { // Minimal valid-shaped DER + SIGHASH_ALL diff --git a/crates/rbitcoin-consensus/tests/script/interpreter/minimal_data_tests.rs b/crates/rbitcoin-consensus/tests/script/interpreter/minimal_data_tests.rs index 958fa8aef0..39ad50e2d8 100644 --- a/crates/rbitcoin-consensus/tests/script/interpreter/minimal_data_tests.rs +++ b/crates/rbitcoin-consensus/tests/script/interpreter/minimal_data_tests.rs @@ -1,16 +1,9 @@ use bitcoin::absolute::LockTime; -use bitcoin::hashes::Hash; +use bitcoin::script::Script; use bitcoin::script::ScriptBuf; -use bitcoin::script::{Instruction, Script}; -use bitcoin::sighash::SighashCache; use bitcoin::{Amount, Sequence, Transaction}; use bitcoin::{OutPoint, TxIn, TxOut, Witness}; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::crypto; use rbitcoin_consensus::script::interpreter::*; -use rbitcoin_primitives::{scriptnum_decode_width, scriptnum_encode}; -use std::borrow::Cow; -use std::cell::{Cell, RefCell}; fn eval_md(script_bytes: &[u8], md: bool) -> Result<(), String> { let tx = Transaction { diff --git a/crates/rbitcoin-consensus/tests/script/interpreter/mod.rs b/crates/rbitcoin-consensus/tests/script/interpreter/mod.rs index 9d087f65e9..d9ca1197f3 100644 --- a/crates/rbitcoin-consensus/tests/script/interpreter/mod.rs +++ b/crates/rbitcoin-consensus/tests/script/interpreter/mod.rs @@ -1,12 +1,3 @@ -use bitcoin::hashes::Hash; -use bitcoin::script::{Instruction, Script}; -use bitcoin::sighash::SighashCache; -use bitcoin::{Amount, Sequence, Transaction}; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::crypto; -use rbitcoin_primitives::{scriptnum_decode_width, scriptnum_encode}; -use std::borrow::Cow; -use std::cell::{Cell, RefCell}; mod minimal_data_tests; mod p2sh_redeem_parse_tests; mod success_and_disabled_tests; diff --git a/crates/rbitcoin-consensus/tests/script/interpreter/p2sh_redeem_parse_tests.rs b/crates/rbitcoin-consensus/tests/script/interpreter/p2sh_redeem_parse_tests.rs index be568807dd..a00ff78813 100644 --- a/crates/rbitcoin-consensus/tests/script/interpreter/p2sh_redeem_parse_tests.rs +++ b/crates/rbitcoin-consensus/tests/script/interpreter/p2sh_redeem_parse_tests.rs @@ -1,16 +1,9 @@ use bitcoin::absolute::LockTime; -use bitcoin::hashes::Hash; +use bitcoin::script::Script; use bitcoin::script::ScriptBuf; -use bitcoin::script::{Instruction, Script}; -use bitcoin::sighash::SighashCache; use bitcoin::{Amount, Sequence, Transaction}; use bitcoin::{OutPoint, TxIn, TxOut, Witness}; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::crypto; use rbitcoin_consensus::script::interpreter::*; -use rbitcoin_primitives::{scriptnum_decode_width, scriptnum_encode}; -use std::borrow::Cow; -use std::cell::{Cell, RefCell}; #[test] fn eval_sig_then_p2sh_style() { diff --git a/crates/rbitcoin-consensus/tests/script/interpreter/success_and_disabled_tests.rs b/crates/rbitcoin-consensus/tests/script/interpreter/success_and_disabled_tests.rs index 6773665cbc..2b2cdcb842 100644 --- a/crates/rbitcoin-consensus/tests/script/interpreter/success_and_disabled_tests.rs +++ b/crates/rbitcoin-consensus/tests/script/interpreter/success_and_disabled_tests.rs @@ -1,16 +1,10 @@ use bitcoin::absolute::LockTime; -use bitcoin::hashes::Hash; +use bitcoin::script::Script; use bitcoin::script::ScriptBuf; -use bitcoin::script::{Instruction, Script}; -use bitcoin::sighash::SighashCache; use bitcoin::{Amount, Sequence, Transaction}; use bitcoin::{OutPoint, TxIn, TxOut, Witness}; use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::crypto; use rbitcoin_consensus::script::interpreter::*; -use rbitcoin_primitives::{scriptnum_decode_width, scriptnum_encode}; -use std::borrow::Cow; -use std::cell::{Cell, RefCell}; fn eval(script_bytes: &[u8], sig_version: SigVersion) -> Result { eval_with_null_dummy(script_bytes, sig_version, false) diff --git a/crates/rbitcoin-consensus/tests/script/interpreter/untaken_consensus_arms.rs b/crates/rbitcoin-consensus/tests/script/interpreter/untaken_consensus_arms.rs index 897c81161f..d83834ab20 100644 --- a/crates/rbitcoin-consensus/tests/script/interpreter/untaken_consensus_arms.rs +++ b/crates/rbitcoin-consensus/tests/script/interpreter/untaken_consensus_arms.rs @@ -1,12 +1,6 @@ -use bitcoin::hashes::Hash; -use bitcoin::script::{Instruction, Script}; -use bitcoin::sighash::SighashCache; +use bitcoin::script::Script; use bitcoin::{Amount, Sequence, Transaction}; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::crypto; -use rbitcoin_primitives::{scriptnum_decode_width, scriptnum_encode}; use std::borrow::Cow; -use std::cell::{Cell, RefCell}; use bitcoin::absolute::LockTime; use bitcoin::script::ScriptBuf; diff --git a/crates/rbitcoin-consensus/tests/script/mod.rs b/crates/rbitcoin-consensus/tests/script/mod.rs index d60ece32d4..a3d4cf1894 100644 --- a/crates/rbitcoin-consensus/tests/script/mod.rs +++ b/crates/rbitcoin-consensus/tests/script/mod.rs @@ -1,9 +1,3 @@ -use bitcoin::hashes::Hash; -use bitcoin::Transaction; -use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; mod classify; mod core_bip341; mod core_data; diff --git a/crates/rbitcoin-consensus/tests/script/nested.rs b/crates/rbitcoin-consensus/tests/script/nested.rs index 9265b6537e..79f6fd9543 100644 --- a/crates/rbitcoin-consensus/tests/script/nested.rs +++ b/crates/rbitcoin-consensus/tests/script/nested.rs @@ -3,12 +3,9 @@ use bitcoin::sighash::SighashCache; use bitcoin::Transaction; use rbitcoin_consensus::block::ScriptCheckJob; use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify; use rbitcoin_consensus::script::crypto; -use rbitcoin_consensus::script::interpreter::{self, EvalContext, SigVersion}; +use rbitcoin_consensus::script::interpreter::{self}; use rbitcoin_consensus::script::nested::*; -use rbitcoin_consensus::script::p2wpkh; -use rbitcoin_consensus::script::p2wsh; use bitcoin::absolute::LockTime; use bitcoin::hashes::Hash; diff --git a/crates/rbitcoin-consensus/tests/script/p2pkh.rs b/crates/rbitcoin-consensus/tests/script/p2pkh.rs index 9faf444699..44c34c14c3 100644 --- a/crates/rbitcoin-consensus/tests/script/p2pkh.rs +++ b/crates/rbitcoin-consensus/tests/script/p2pkh.rs @@ -1,11 +1,8 @@ -use bitcoin::hashes::Hash; -use bitcoin::script::{Instruction, Script}; +use bitcoin::script::Script; use bitcoin::sighash::SighashCache; use bitcoin::Transaction; use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; use rbitcoin_consensus::script::p2pkh::*; -use rbitcoin_consensus::script::{crypto, interpreter}; use bitcoin::absolute::LockTime; use bitcoin::script::ScriptBuf; diff --git a/crates/rbitcoin-consensus/tests/script/p2tr/bip341_tests.rs b/crates/rbitcoin-consensus/tests/script/p2tr/bip341_tests.rs index fa548dc12e..657e25a0cb 100644 --- a/crates/rbitcoin-consensus/tests/script/p2tr/bip341_tests.rs +++ b/crates/rbitcoin-consensus/tests/script/p2tr/bip341_tests.rs @@ -1,22 +1,18 @@ use bitcoin::absolute::LockTime; -use bitcoin::consensus::Encodable; use bitcoin::hashes::Hash; use bitcoin::key::XOnlyPublicKey; use bitcoin::key::{TapTweak, TweakedKeypair}; -use bitcoin::script::Script; +use bitcoin::secp256k1::Message; use bitcoin::secp256k1::{Keypair, Secp256k1, SecretKey}; -use bitcoin::secp256k1::{Message, Parity}; use bitcoin::sighash::TapSighashType; use bitcoin::sighash::{Prevouts, SighashCache}; use bitcoin::taproot::{ControlBlock, LeafVersion, TaprootBuilder}; -use bitcoin::taproot::{TapLeafHash, TapNodeHash, TapTweakHash}; +use bitcoin::taproot::{TapLeafHash, TapNodeHash}; use bitcoin::{Amount, OutPoint, ScriptBuf, Sequence, TxIn, TxOut}; use bitcoin::{Transaction, Witness}; use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; use rbitcoin_consensus::script; use rbitcoin_consensus::script::crypto; -use rbitcoin_consensus::script::interpreter::{self, EvalContext, SigVersion}; use rbitcoin_consensus::script::p2tr::*; fn owned_prevout_mut(job: &mut ScriptCheckJob) -> &mut TxOut { diff --git a/crates/rbitcoin-consensus/tests/script/p2tr/mod.rs b/crates/rbitcoin-consensus/tests/script/p2tr/mod.rs index 5927592889..884ab04d09 100644 --- a/crates/rbitcoin-consensus/tests/script/p2tr/mod.rs +++ b/crates/rbitcoin-consensus/tests/script/p2tr/mod.rs @@ -1,13 +1,2 @@ -use bitcoin::consensus::Encodable; -use bitcoin::hashes::Hash; -use bitcoin::key::XOnlyPublicKey; -use bitcoin::script::Script; -use bitcoin::secp256k1::{Message, Parity}; -use bitcoin::sighash::TapSighashType; -use bitcoin::taproot::{TapLeafHash, TapNodeHash, TapTweakHash}; -use bitcoin::{Transaction, Witness}; -use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; use rbitcoin_consensus::script::crypto; -use rbitcoin_consensus::script::interpreter::{self, EvalContext, SigVersion}; mod bip341_tests; diff --git a/crates/rbitcoin-consensus/tests/script/p2wpkh.rs b/crates/rbitcoin-consensus/tests/script/p2wpkh.rs index 376500991e..4662b3808e 100644 --- a/crates/rbitcoin-consensus/tests/script/p2wpkh.rs +++ b/crates/rbitcoin-consensus/tests/script/p2wpkh.rs @@ -1,10 +1,6 @@ -use bitcoin::script::Script; use bitcoin::Transaction; use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; use rbitcoin_consensus::script::p2wpkh::*; -use rbitcoin_consensus::script::{crypto, interpreter, p2wsh}; -use rbitcoin_consensus::TxPrecompute; use bitcoin::absolute::LockTime; use bitcoin::script::ScriptBuf; diff --git a/crates/rbitcoin-consensus/tests/script/p2wsh.rs b/crates/rbitcoin-consensus/tests/script/p2wsh.rs index 01d746f423..a9d7779c05 100644 --- a/crates/rbitcoin-consensus/tests/script/p2wsh.rs +++ b/crates/rbitcoin-consensus/tests/script/p2wsh.rs @@ -1,9 +1,5 @@ -use bitcoin::script::Script; use bitcoin::Transaction; use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::crypto; -use rbitcoin_consensus::script::interpreter::{self, EvalContext, SigVersion}; use rbitcoin_consensus::script::p2wsh::*; use bitcoin::absolute::LockTime; diff --git a/crates/rbitcoin-consensus/tests/script/tests_flag_parity.rs b/crates/rbitcoin-consensus/tests/script/tests_flag_parity.rs index 5f619367cb..ea5cdf3d54 100644 --- a/crates/rbitcoin-consensus/tests/script/tests_flag_parity.rs +++ b/crates/rbitcoin-consensus/tests/script/tests_flag_parity.rs @@ -3,9 +3,6 @@ use bitcoin::hashes::Hash; use bitcoin::Transaction; use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; use bitcoin::absolute::LockTime; diff --git a/crates/rbitcoin-consensus/tests/script/tests_verify.rs b/crates/rbitcoin-consensus/tests/script/tests_verify.rs index df56471944..4f0b597841 100644 --- a/crates/rbitcoin-consensus/tests/script/tests_verify.rs +++ b/crates/rbitcoin-consensus/tests/script/tests_verify.rs @@ -2,9 +2,6 @@ use bitcoin::hashes::Hash; use bitcoin::Transaction; use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; use bitcoin::absolute::LockTime; use bitcoin::hashes::hash160; diff --git a/crates/rbitcoin-consensus/tests/script/verify_routing_tests.rs b/crates/rbitcoin-consensus/tests/script/verify_routing_tests.rs index 0101432e9b..e0f1551263 100644 --- a/crates/rbitcoin-consensus/tests/script/verify_routing_tests.rs +++ b/crates/rbitcoin-consensus/tests/script/verify_routing_tests.rs @@ -2,8 +2,6 @@ use bitcoin::hashes::Hash; use bitcoin::Transaction; use rbitcoin_consensus::block::ScriptCheckJob; use rbitcoin_consensus::error::ConsensusError; -use rbitcoin_consensus::script::classify::is_anyone_can_spend; -use rbitcoin_consensus::script::classify::ScriptKind; use rbitcoin_consensus::script::*; use bitcoin::absolute::LockTime; diff --git a/crates/rbitcoin-consensus/tests/script_edge_fixtures.rs b/crates/rbitcoin-consensus/tests/script_edge_fixtures.rs index b612d4fe46..e102ca056c 100644 --- a/crates/rbitcoin-consensus/tests/script_edge_fixtures.rs +++ b/crates/rbitcoin-consensus/tests/script_edge_fixtures.rs @@ -2,47 +2,6 @@ //! //! Captured blocks are not Core JSON rows. One table pins hash / opcode //! presence; detached verify stays for the two script-engine edges. -use rbitcoin_consensus::block::validate_block_structure_hashed; -use rbitcoin_consensus::block::ScriptCheckJob; -use rbitcoin_consensus::block::{ - bip34_height_script, bip68_active_for_tx, block_has_witness, block_mutated_without_coinbase, - block_subsidy, check_block_wire, is_final_tx, sequence_locks_satisfied, tx_sigop_cost, - validate_block_structure, witness_commitment_script, witness_commitment_vout_index, - ScriptVerifyFlags, ValidationContext, BIP16_EXCEPTION_MAINNET, MAX_BLOCK_TX_COUNT, - MAX_BLOCK_WEIGHT, MIN_TX_WEIGHT, TAPROOT_EXCEPTION_MAINNET, -}; -use rbitcoin_consensus::clock::{with_now, NodeClock}; -use rbitcoin_consensus::error::{ - block_reject_log_line, block_reject_reason, script_flag_paren, ConsensusError, -}; -use rbitcoin_consensus::header::{ - check_header, next_work_bits, validate_header_on_parent, ParentHeader, -}; -use rbitcoin_consensus::id_map::{ - IdMap, OutPointHasher, OutPointSet, TxidHasher, TxidMap, TxidSet, -}; -use rbitcoin_consensus::milestone::{Milestone, MilestoneAnchor}; -use rbitcoin_consensus::params::{ - default_milestone_anchor, default_milestone_height, default_min_chain_work_be, genesis_block, - ChainParams, MAINNET_MILESTONE_HASH, TESTNET_MILESTONE_HASH, -}; -use rbitcoin_consensus::policy::PolicyResult; -use rbitcoin_consensus::regtest_pad::{ - grind_regtest_pow, mine_empty_regtest, mine_op_true_signet_paying, mine_regtest_paying, - prepare_regtest_candidate, regtest_coinbase, REGTEST_BLOCK_SPACING, REGTEST_POW_BITS, -}; -use rbitcoin_consensus::script::core_script; -use rbitcoin_consensus::script_pool::unpark_script_publisher; -use rbitcoin_consensus::signet::{ - default_signet_challenge, signet_challenge_transactions, signet_magic, - validate_signet_block_solution, -}; -use rbitcoin_consensus::silent_payments::{ - taproot_matches_scan, tweak_from_tx, TaprootOut, TxTweak, -}; -use rbitcoin_consensus::tx_precompute::{ - block_wire_len_from_pres, decode_block_precomputes, pres_for_tip, TxPrecompute, -}; use bitcoin::consensus::deserialize; use bitcoin::script::ScriptBuf; diff --git a/crates/rbitcoin-consensus/tests/script_pool.rs b/crates/rbitcoin-consensus/tests/script_pool.rs index 3ca9efc381..abf0c713bf 100644 --- a/crates/rbitcoin-consensus/tests/script_pool.rs +++ b/crates/rbitcoin-consensus/tests/script_pool.rs @@ -1,12 +1,8 @@ -use arc_swap::ArcSwap; use rbitcoin_consensus::error::ConsensusError; use rbitcoin_consensus::script_pool::*; -use std::cell::Cell; -use std::collections::VecDeque; -use std::ops::Range; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::mpsc; -use std::sync::{Arc, Condvar, Mutex, OnceLock}; +use std::sync::{Arc, Condvar, Mutex}; use std::thread; use std::sync::MutexGuard; diff --git a/crates/rbitcoin-consensus/tests/signet.rs b/crates/rbitcoin-consensus/tests/signet.rs index 2ffcd16089..dd9397008c 100644 --- a/crates/rbitcoin-consensus/tests/signet.rs +++ b/crates/rbitcoin-consensus/tests/signet.rs @@ -1,10 +1,8 @@ use bitcoin::absolute::LockTime; use bitcoin::consensus::encode::deserialize; -use bitcoin::consensus::{serialize, Encodable}; -use bitcoin::hashes::{sha256d, Hash}; +use bitcoin::hashes::Hash; use bitcoin::script::{Script, ScriptBuf}; use bitcoin::{Amount, Block, OutPoint, Sequence, Transaction, TxIn, TxOut, Witness}; -use rbitcoin_consensus::block::ScriptCheckJob; use rbitcoin_consensus::error::ConsensusError; use rbitcoin_consensus::signet::*; diff --git a/crates/rbitcoin-consensus/tests/silent_payments.rs b/crates/rbitcoin-consensus/tests/silent_payments.rs index a5893e444f..757ebb82d8 100644 --- a/crates/rbitcoin-consensus/tests/silent_payments.rs +++ b/crates/rbitcoin-consensus/tests/silent_payments.rs @@ -1,12 +1,10 @@ use bitcoin::absolute::LockTime; use bitcoin::consensus::encode::deserialize; -use bitcoin::hashes::{hash160, sha256, Hash, HashEngine}; -use bitcoin::key::{Parity, XOnlyPublicKey}; -use bitcoin::script::{Instruction, Script}; -use bitcoin::secp256k1::{All, PublicKey, Scalar, Secp256k1, SecretKey}; +use bitcoin::hashes::Hash; +use bitcoin::script::Script; +use bitcoin::secp256k1::{PublicKey, SecretKey}; use bitcoin::{OutPoint, Transaction, TxOut, Witness}; use rbitcoin_consensus::silent_payments::*; -use std::sync::OnceLock; use bitcoin::script::ScriptBuf; diff --git a/crates/rbitcoin-consensus/tests/suite.rs b/crates/rbitcoin-consensus/tests/suite.rs index ee7eb994cd..e2c44c4903 100644 --- a/crates/rbitcoin-consensus/tests/suite.rs +++ b/crates/rbitcoin-consensus/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod block; mod clock; mod error; diff --git a/crates/rbitcoin-consensus/tests/tx_precompute.rs b/crates/rbitcoin-consensus/tests/tx_precompute.rs index d3def3b6f7..8bc1001c27 100644 --- a/crates/rbitcoin-consensus/tests/tx_precompute.rs +++ b/crates/rbitcoin-consensus/tests/tx_precompute.rs @@ -1,12 +1,9 @@ use bitcoin::absolute::LockTime; -use bitcoin::consensus::encode::{Encodable, VarInt}; -use bitcoin::hashes::{sha256, sha256d, Hash, HashEngine}; -use bitcoin::{Script, Transaction, TxOut}; +use bitcoin::consensus::encode::Encodable; +use bitcoin::hashes::{sha256, sha256d, Hash}; +use bitcoin::{Transaction, TxOut}; use rbitcoin_consensus::tx_precompute::*; use rbitcoin_primitives::script_sigop_count; -use std::collections::HashSet; -use std::sync::Arc; -use std::sync::OnceLock; use bitcoin::script::ScriptBuf; use bitcoin::transaction::Version; diff --git a/crates/rbitcoin-electrum/tests/server/mod.rs b/crates/rbitcoin-electrum/tests/server/mod.rs index 7d5e6749e1..1a7dd22b5c 100644 --- a/crates/rbitcoin-electrum/tests/server/mod.rs +++ b/crates/rbitcoin-electrum/tests/server/mod.rs @@ -1,22 +1,15 @@ -use bitcoin::consensus::Encodable; -use bitcoin::hashes::Hash; use rbitcoin_consensus::ChainParams; use rbitcoin_electrum::server::*; -use rbitcoin_net::RequestMeter; -use rbitcoin_net::{BlockingRegion, MempoolHub}; +use rbitcoin_net::MempoolHub; use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::{ChainView, ChainViewKind, HistoryFilter, Query, ShJoinSlot}; -use rbitcoin_store::{script_hash, StoreError}; +use rbitcoin_query::Query; use serde_json::{json, Value}; use std::collections::{HashMap, HashSet}; -use std::net::SocketAddr; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Mutex, OnceLock}; +use std::sync::Arc; use std::time::{Duration, Instant}; -use tokio::io::{AsyncBufRead, AsyncBufReadExt, AsyncRead, AsyncWrite, AsyncWriteExt, BufReader}; -use tokio::net::TcpListener; -use tokio::sync::{broadcast, Notify, Semaphore}; -use tokio::task::JoinHandle; +use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; +use tokio::sync::broadcast; use rbitcoin_query::testutil::FixtureChain; diff --git a/crates/rbitcoin-electrum/tests/server/surface_tests.rs b/crates/rbitcoin-electrum/tests/server/surface_tests.rs index b64f54e6b6..8f856793b0 100644 --- a/crates/rbitcoin-electrum/tests/server/surface_tests.rs +++ b/crates/rbitcoin-electrum/tests/server/surface_tests.rs @@ -1,22 +1,5 @@ -use bitcoin::consensus::Encodable; -use bitcoin::hashes::Hash; -use rbitcoin_consensus::ChainParams; use rbitcoin_electrum::server::*; -use rbitcoin_net::RequestMeter; -use rbitcoin_net::{BlockingRegion, MempoolHub}; -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::{ChainView, ChainViewKind, HistoryFilter, Query, ShJoinSlot}; -use rbitcoin_store::{script_hash, StoreError}; -use serde_json::{json, Value}; -use std::collections::{HashMap, HashSet}; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Mutex, OnceLock}; -use std::time::{Duration, Instant}; -use tokio::io::{AsyncBufRead, AsyncBufReadExt, AsyncRead, AsyncWrite, AsyncWriteExt, BufReader}; -use tokio::net::TcpListener; -use tokio::sync::{broadcast, Notify, Semaphore}; -use tokio::task::JoinHandle; +use serde_json::json; #[test] fn silent_payment_log_drops_the_scan_secret() { diff --git a/crates/rbitcoin-electrum/tests/silent_scan.rs b/crates/rbitcoin-electrum/tests/silent_scan.rs index 30dce7ff8a..b21a67c1e6 100644 --- a/crates/rbitcoin-electrum/tests/silent_scan.rs +++ b/crates/rbitcoin-electrum/tests/silent_scan.rs @@ -1,12 +1,7 @@ use bitcoin::secp256k1::Secp256k1; -use bitcoin::secp256k1::{PublicKey, SecretKey}; use bitcoin::Network; -use rbitcoin_consensus::{taproot_matches_scan, ChainParams}; use rbitcoin_electrum::silent_scan::*; -use rbitcoin_primitives::Height; -use rbitcoin_query::tweaks_for_height; -use rbitcoin_query::Query; -use serde_json::{json, Value}; +use serde_json::json; #[test] fn parse_sub_indexes_a_non_string_param() { diff --git a/crates/rbitcoin-electrum/tests/suite.rs b/crates/rbitcoin-electrum/tests/suite.rs index 22518eb189..65f77c1507 100644 --- a/crates/rbitcoin-electrum/tests/suite.rs +++ b/crates/rbitcoin-electrum/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod electrum_sh_journey; mod server; mod silent_scan; diff --git a/crates/rbitcoin-electrum/tests/tweaks.rs b/crates/rbitcoin-electrum/tests/tweaks.rs index 947ca6c8ef..cf67fed6e4 100644 --- a/crates/rbitcoin-electrum/tests/tweaks.rs +++ b/crates/rbitcoin-electrum/tests/tweaks.rs @@ -1,12 +1,7 @@ use rbitcoin_consensus::{ChainParams, TxTweak}; use rbitcoin_electrum::tweaks::*; -use rbitcoin_primitives::Height; -use rbitcoin_query::tweaks_for_height; use rbitcoin_query::{Query, ThinTweakRangeLimits, ThinTweakRow}; -use serde_json::Map; use serde_json::{json, Value}; -use std::collections::BTreeMap; -use std::time::{Duration, Instant}; use rbitcoin_query::testutil::FixtureChain; diff --git a/crates/rbitcoin-esplora/tests/handlers/mod.rs b/crates/rbitcoin-esplora/tests/handlers/mod.rs index 8d647a36f7..a2c3a5e8b5 100644 --- a/crates/rbitcoin-esplora/tests/handlers/mod.rs +++ b/crates/rbitcoin-esplora/tests/handlers/mod.rs @@ -1,31 +1 @@ -use axum::body::Bytes; -use axum::extract::{Path, Query as AxumQuery, State}; -use axum::http::{header, StatusCode}; -use axum::response::{IntoResponse, Response}; -use axum::Json; -use bitcoin::address::Address; -use bitcoin::consensus::{deserialize, encode::serialize, Encodable}; -use bitcoin::hashes::Hash; -use bitcoin::pow::{CompactTarget, Target}; -use bitcoin::{MerkleBlock, Network, OutPoint, Txid}; -use rbitcoin_esplora::server::{ - block_hash_hex, maybe_attach_view, mempool_wire, not_found, parse_hash32, pin_or_reject, - plain_ok, store_err, AppState, AsOf, GbtCache, JoinClient, -}; -use rbitcoin_esplora::tx_json::{ - build_tx_json, build_tx_json_from_tx, history_items_to_tx_json, tx_status_json_in, - utxo_list_json, -}; -use rbitcoin_net::MempoolHub; -use rbitcoin_primitives::{median_time_past_times, Height}; -use rbitcoin_query::{ - ChainViewKind, HistoryFilter, Query, ScriptHashChainStats, ScriptHashTxSummary, ShJoinSlot, -}; -use rbitcoin_store::{script_hash, StoreError}; -use serde::Deserialize; -use serde_json::{json, Value}; -use std::collections::{HashMap, HashSet}; -use std::str::FromStr; -use std::sync::Arc; -use std::time::{Duration, Instant}; mod pure_helper_tests; diff --git a/crates/rbitcoin-esplora/tests/handlers/pure_helper_tests.rs b/crates/rbitcoin-esplora/tests/handlers/pure_helper_tests.rs index 4746bbe37c..25ec53778d 100644 --- a/crates/rbitcoin-esplora/tests/handlers/pure_helper_tests.rs +++ b/crates/rbitcoin-esplora/tests/handlers/pure_helper_tests.rs @@ -1,38 +1,11 @@ -use axum::body::Bytes; -use axum::extract::{Path, Query as AxumQuery, State}; -use axum::http::{header, StatusCode}; -use axum::response::{IntoResponse, Response}; -use axum::Json; -use bitcoin::address::Address; -use bitcoin::consensus::{deserialize, encode::serialize, Encodable}; -use bitcoin::hashes::Hash; -use bitcoin::pow::{CompactTarget, Target}; -use bitcoin::{MerkleBlock, Network, OutPoint, Txid}; use rbitcoin_esplora::handlers::{block_summary_json, fee_estimates_from, outspend_json}; -use rbitcoin_esplora::server::{ - block_hash_hex, maybe_attach_view, mempool_wire, not_found, parse_hash32, pin_or_reject, - plain_ok, store_err, AppState, AsOf, GbtCache, JoinClient, -}; -use rbitcoin_esplora::tx_json::{ - build_tx_json, build_tx_json_from_tx, history_items_to_tx_json, tx_status_json_in, - utxo_list_json, -}; -use rbitcoin_net::MempoolHub; use rbitcoin_primitives::Fk; -use rbitcoin_primitives::{median_time_past_times, Height}; +use rbitcoin_primitives::Height; use rbitcoin_query::testutil::FixtureChain; +use rbitcoin_query::Query; use rbitcoin_query::TxApply; -use rbitcoin_query::{ - ChainViewKind, HistoryFilter, Query, ScriptHashChainStats, ScriptHashTxSummary, ShJoinSlot, -}; -use rbitcoin_store::{script_hash, StoreError}; use rbitcoin_store::{HeaderRecord, InputRecord, OutputRecord, TxRecord}; -use serde::Deserialize; -use serde_json::{json, Value}; -use std::collections::{HashMap, HashSet}; -use std::str::FromStr; -use std::sync::Arc; -use std::time::{Duration, Instant}; +use serde_json::json; fn temp_query() -> (rbitcoin_query::testutil::TempDir, Query) { rbitcoin_query::testutil::tiny_query_labeled("esplora-pure") diff --git a/crates/rbitcoin-esplora/tests/internal.rs b/crates/rbitcoin-esplora/tests/internal.rs index 2d471dcc8e..262cc3871e 100644 --- a/crates/rbitcoin-esplora/tests/internal.rs +++ b/crates/rbitcoin-esplora/tests/internal.rs @@ -1,25 +1,10 @@ -use axum::body::Bytes; -use axum::extract::{Path, Query as AxumQuery, State}; -use axum::http::StatusCode; -use axum::response::{IntoResponse, Response}; -use axum::Json; use bitcoin::absolute::LockTime; -use bitcoin::hashes::Hash; use bitcoin::Txid; use bitcoin::{Amount, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Witness}; use rbitcoin_consensus::{ChainParams, Milestone}; -use rbitcoin_esplora::handlers::{outspend_json, spawn_join}; use rbitcoin_esplora::internal::*; -use rbitcoin_esplora::server::not_found; -use rbitcoin_esplora::server::{block_hash_hex, parse_hash32, pin_or_reject, store_err, AppState}; use rbitcoin_esplora::server::{run_esplora, EsploraConfig, EsploraListen}; -use rbitcoin_esplora::tx_json::{ - build_tx_json, build_tx_json_from_tx, build_tx_json_from_tx_with_status, tx_status_json, -}; -use rbitcoin_net::{MempoolHub, MempoolTxSnapEntry}; -use rbitcoin_query::ChainViewKind; -use rbitcoin_store::StoreError; -use serde::Deserialize; +use rbitcoin_net::MempoolHub; use serde_json::{json, Value}; use rbitcoin_primitives::Height; diff --git a/crates/rbitcoin-esplora/tests/server.rs b/crates/rbitcoin-esplora/tests/server.rs index 7e3acd458c..055146632d 100644 --- a/crates/rbitcoin-esplora/tests/server.rs +++ b/crates/rbitcoin-esplora/tests/server.rs @@ -1,44 +1,29 @@ use axum::extract::ConnectInfo; -use axum::extract::{FromRequestParts, Path, Query as AxumQuery, Request, State}; -use axum::http::request::Parts; -use axum::http::{header, HeaderValue, StatusCode}; -use axum::middleware::{self, Next}; -use axum::response::{IntoResponse, Response}; +use axum::extract::State; +use axum::middleware::{self}; use axum::routing::{get, post}; -use axum::Json; use axum::Router; -use bitcoin::consensus::Encodable; use bitcoin::Network; use rbitcoin_electrum::ServeLimits; use rbitcoin_esplora::handlers; use rbitcoin_esplora::server::*; use rbitcoin_esplora::tx_json::tx_status_json; -use rbitcoin_esplora::tx_json::{build_tx_json, build_tx_json_from_tx, tx_status_json_in}; -use rbitcoin_net::MempoolHub; -use rbitcoin_net::RequestMeter; use rbitcoin_primitives::Fk; use rbitcoin_primitives::Height; +use rbitcoin_query::Query; use rbitcoin_query::TxApply; -use rbitcoin_query::{ChainView, ChainViewKind, Query, ShJoinSlot}; use rbitcoin_store::script_hash; -use rbitcoin_store::StoreError; use rbitcoin_store::{HeaderRecord, InputRecord, OutputRecord, TxRecord}; -use serde::Deserialize; use serde_json::{json, Value}; use std::collections::HashMap; use std::net::SocketAddr; -use std::path::PathBuf; use std::sync::atomic::AtomicU64; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Mutex, OnceLock}; +use std::sync::atomic::Ordering; +use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::TcpListener; use tokio::net::TcpStream; -use tokio::task::JoinHandle; -use tower::limit::ConcurrencyLimitLayer; -use tower_http::limit::RequestBodyLimitLayer; -use tower_http::timeout::TimeoutLayer; use rbitcoin_query::testutil::FixtureChain; fn temp_query(label: &str) -> (rbitcoin_query::testutil::TempDir, Query) { diff --git a/crates/rbitcoin-esplora/tests/suite.rs b/crates/rbitcoin-esplora/tests/suite.rs index 1d17309f94..3b4ce626b9 100644 --- a/crates/rbitcoin-esplora/tests/suite.rs +++ b/crates/rbitcoin-esplora/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod handlers; mod internal; mod server; diff --git a/crates/rbitcoin-esplora/tests/tx_json.rs b/crates/rbitcoin-esplora/tests/tx_json.rs index 6f2c260c40..e9e4068c99 100644 --- a/crates/rbitcoin-esplora/tests/tx_json.rs +++ b/crates/rbitcoin-esplora/tests/tx_json.rs @@ -1,14 +1,7 @@ -use bitcoin::hashes::Hash; -use bitcoin::{Network, Transaction}; -use rbitcoin_esplora::script_fields::esplora_script_fields; +use bitcoin::Network; use rbitcoin_esplora::tx_json::*; -use rbitcoin_net::MempoolHub; use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::{Query, QueryError, ScriptHashHistoryItem, ScriptHashUtxo}; -use rbitcoin_store::InputRecord; -use serde::Serialize; -use serde_json::{json, Value}; -use std::collections::HashMap; +use rbitcoin_query::Query; use rbitcoin_query::testutil::FixtureChain; #[test] diff --git a/crates/rbitcoin-ibd/tests/ibd/archive/class_a_rehydrate_tests.rs b/crates/rbitcoin-ibd/tests/ibd/archive/class_a_rehydrate_tests.rs index ef61db048a..7c420a44e5 100644 --- a/crates/rbitcoin-ibd/tests/ibd/archive/class_a_rehydrate_tests.rs +++ b/crates/rbitcoin-ibd/tests/ibd/archive/class_a_rehydrate_tests.rs @@ -1,6 +1,5 @@ use bitcoin::absolute::LockTime; use bitcoin::block::{Header, Version}; -use bitcoin::consensus::Encodable; use bitcoin::hashes::Hash; use bitcoin::BlockHash; use rbitcoin_ibd::ibd::archive::{ @@ -9,9 +8,7 @@ use rbitcoin_ibd::ibd::archive::{ use rbitcoin_ibd::ibd::confirm::ConfirmFeed; use rbitcoin_ibd::ibd::progress::claim_ready; use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_net::chain::ChainHub; use rbitcoin_primitives::Fk; -use std::time::Instant; use bitcoin::script::ScriptBuf; use bitcoin::transaction::Version as TxVersion; diff --git a/crates/rbitcoin-ibd/tests/ibd/archive/mod.rs b/crates/rbitcoin-ibd/tests/ibd/archive/mod.rs index 0ec0f54527..e65d26a6e1 100644 --- a/crates/rbitcoin-ibd/tests/ibd/archive/mod.rs +++ b/crates/rbitcoin-ibd/tests/ibd/archive/mod.rs @@ -1,7 +1 @@ -use bitcoin::consensus::Encodable; -use bitcoin::hashes::Hash; -use bitcoin::BlockHash; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_primitives::Fk; -use std::time::Instant; mod class_a_rehydrate_tests; diff --git a/crates/rbitcoin-ibd/tests/ibd/archive_sat_tests.rs b/crates/rbitcoin-ibd/tests/ibd/archive_sat_tests.rs index d16c82b4fa..0187a0ec3e 100644 --- a/crates/rbitcoin-ibd/tests/ibd/archive_sat_tests.rs +++ b/crates/rbitcoin-ibd/tests/ibd/archive_sat_tests.rs @@ -1,60 +1,4 @@ -use bitcoin::p2p::Magic; -use rbitcoin_ibd::ibd::archive::{ - rehydrate_block_queue_into_confirm, rehydrate_class_a_into_body_queue, -}; use rbitcoin_ibd::ibd::assign::bq_pipeline_saturated; -use rbitcoin_ibd::ibd::assign::{assign_work_ordered, AssignDepth}; -use rbitcoin_ibd::ibd::assign_plan::need_ready_headroom; -use rbitcoin_ibd::ibd::assign_plan::want_headers_beyond_soft_cap; -use rbitcoin_ibd::ibd::cadence::IbdLoopCadence; -use rbitcoin_ibd::ibd::confirm::{ - offer_confirm_ready, spawn_confirm_engine, ConfirmEvent, ConfirmFeed, -}; -use rbitcoin_ibd::ibd::confirm::{ConfirmRejectClass, RejectParent}; -use rbitcoin_ibd::ibd::dial::{ - admit_cooldown_fallback, alive_dial_addrs, apply_dial_result, dial_batch, dial_blocked_addrs, - disconnect_relative_slow_block_peers, disconnect_stalled_block_peers, expire_addr_cooldown, - redial_want, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::events::drain_ready_peer_and_body_events; -use rbitcoin_ibd::ibd::events::{ - apply_confirm_events, apply_peer_event, disconnect_all_peers, update_confirm_lag, -}; -use rbitcoin_ibd::ibd::events::{apply_confirm_reject, apply_headers_event}; -use rbitcoin_ibd::ibd::exit::{ - all_peers_dead_action, best_chain_remainder, dark_empty_after, empty_path_header_fan, - header_lag_behind_peers, ibd_caught_up, may_spawn_redial, path_drained, - should_unlatch_headers_done, AllPeersDead, -}; -use rbitcoin_ibd::ibd::header_walk::{ - candidate_tip, candidate_work, forget_walk_peer, header_poll, header_status_view, - install_origin, load_origin, note_block_inv, note_reservation, origin_input, send_getheaders, - settle_walk_peer, take_header_ask, HeaderPoll, HeaderPollIn, -}; -use rbitcoin_ibd::ibd::peer_io::{empty_header_fk_bus, PeerCmd, PeerEvent}; -use rbitcoin_ibd::ibd::peer_io::{sample_peer_rates, PeerEventSinks}; -use rbitcoin_ibd::ibd::peer_io::{solicit_track, GetdataWire, PeerSlot}; -use rbitcoin_ibd::ibd::perf_log::{read_platform_rss, tip_perf_json, ProcessRss, TipPerfLog}; -use rbitcoin_ibd::ibd::progress::{log_progress_tick, StatusClock}; -use rbitcoin_ibd::ibd::progress::{read_progress_published, StatusSnap}; -use rbitcoin_ibd::ibd::progress::{ - spawn_status_thread, work_chain_progress_at, StatusBoard, TipRateTracker, -}; -use rbitcoin_ibd::ibd::published::spawn_header_thread; -use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::state::{enqueue_header_cmd, HeaderCmd}; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_log::{info, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; -use std::collections::{HashMap, HashSet}; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::sync::Arc; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; -use tokio::task::JoinHandle; #[test] fn bq_pipeline_saturated_gates_full_assign() { diff --git a/crates/rbitcoin-ibd/tests/ibd/assign.rs b/crates/rbitcoin-ibd/tests/ibd/assign.rs index a7f2229eec..9fb8a8d79e 100644 --- a/crates/rbitcoin-ibd/tests/ibd/assign.rs +++ b/crates/rbitcoin-ibd/tests/ibd/assign.rs @@ -1,19 +1,12 @@ use bitcoin::hashes::Hash; use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::assign_plan::densify_slots_for_peer; -use rbitcoin_ibd::ibd::dial::{ - median_u64, relative_slow_pick, RelativeSlowSample, RELATIVE_SLOW_CLUSTER_SPREAD, -}; use rbitcoin_ibd::ibd::peer_io::solicit_track; -use rbitcoin_ibd::ibd::peer_io::{ibd_mono_ms, PeerCmd, PeerSlot}; +use rbitcoin_ibd::ibd::peer_io::{PeerCmd, PeerSlot}; use rbitcoin_ibd::ibd::state::{self, IbdWorkState}; use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_ibd::ibd::{ - IbdConfig, CONTIG_DENSIFY_AHEAD, FAR_SCAN_BUDGET, PENDING_STALE, PRE_HOLE_MAX_PEERS, - TIP_HOLE_MAX, TIP_HOLE_MAX_PEERS, -}; +use rbitcoin_ibd::ibd::{IbdConfig, PRE_HOLE_MAX_PEERS, TIP_HOLE_MAX, TIP_HOLE_MAX_PEERS}; use rbitcoin_net::chain::ChainHub; -use std::collections::{HashMap, HashSet, VecDeque}; +use std::collections::{HashSet, VecDeque}; use std::sync::atomic::Ordering; use std::time::{Duration, Instant}; @@ -1090,39 +1083,6 @@ fn ibd_cover_tip_holes() { let _ = std::fs::remove_dir_all(dir); } -/// Serialize env mutators — parallel suite races `bq_assign_stop_bytes`. -static BQ_ASSIGN_STOP_ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); - -pub(crate) struct AssignStopEnvRestore(Option, Option); -impl Drop for AssignStopEnvRestore { - fn drop(&mut self) { - match self.0.take() { - Some(v) => std::env::set_var("RBITCOIN_BLOCK_QUEUE_BYTES", v), - None => std::env::remove_var("RBITCOIN_BLOCK_QUEUE_BYTES"), - } - match self.1.take() { - Some(v) => std::env::set_var("RBITCOIN_BLOCK_QUEUE_GB", v), - None => std::env::remove_var("RBITCOIN_BLOCK_QUEUE_GB"), - } - } -} - -/// Tuple fields drop in order: the env is restored before the lock is -/// released, so the next holder's own setting survives. -pub(crate) fn lock_default_assign_stop( -) -> (AssignStopEnvRestore, std::sync::MutexGuard<'static, ()>) { - let g = BQ_ASSIGN_STOP_ENV_LOCK - .lock() - .unwrap_or_else(|e| e.into_inner()); - let restore = AssignStopEnvRestore( - std::env::var_os("RBITCOIN_BLOCK_QUEUE_BYTES"), - std::env::var_os("RBITCOIN_BLOCK_QUEUE_GB"), - ); - std::env::remove_var("RBITCOIN_BLOCK_QUEUE_BYTES"); - std::env::remove_var("RBITCOIN_BLOCK_QUEUE_GB"); - (restore, g) -} - /// Densify on one hub at genesis across IBD restarts: assign depth, the /// tip batch, band limits from the body queue, per-peer caps, hung /// owners, and reorg need. diff --git a/crates/rbitcoin-ibd/tests/ibd/body.rs b/crates/rbitcoin-ibd/tests/ibd/body.rs index 957d48cf29..b91ee5c6b6 100644 --- a/crates/rbitcoin-ibd/tests/ibd/body.rs +++ b/crates/rbitcoin-ibd/tests/ibd/body.rs @@ -1,9 +1,7 @@ use bitcoin::hashes::Hash; use bitcoin::BlockHash; use rbitcoin_ibd::ibd::body::BodyPresence; -use rbitcoin_net::chain::ChainHub; -use std::collections::{HashMap, HashSet}; -use std::time::{Duration, Instant}; +use std::time::Duration; fn h(n: u8) -> BlockHash { let mut b = [0u8; 32]; diff --git a/crates/rbitcoin-ibd/tests/ibd/confirm.rs b/crates/rbitcoin-ibd/tests/ibd/confirm.rs index 60dd5330a5..2dd5dc2637 100644 --- a/crates/rbitcoin-ibd/tests/ibd/confirm.rs +++ b/crates/rbitcoin-ibd/tests/ibd/confirm.rs @@ -1,16 +1,7 @@ //! tests (peeled from ibd/confirm.rs). use bitcoin::hashes::Hash; use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::body::BodyPresence; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_log::{debug, info, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_query::WireLoadPipeline; -use std::cell::Cell; -use std::collections::HashMap; -use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering}; use std::sync::Arc; -use std::time::{Duration, Instant}; use rbitcoin_ibd::ibd::confirm::{ format_conf_q, format_queue_depth, format_stamp_reject_missing_prevout, inflight_prune_height, diff --git a/crates/rbitcoin-ibd/tests/ibd/dial.rs b/crates/rbitcoin-ibd/tests/ibd/dial.rs index b0b0298d1b..1d4ae0e6af 100644 --- a/crates/rbitcoin-ibd/tests/ibd/dial.rs +++ b/crates/rbitcoin-ibd/tests/ibd/dial.rs @@ -3,16 +3,13 @@ use bitcoin::p2p::Magic; use bitcoin::BlockHash; use rbitcoin_ibd::ibd::dial::*; use rbitcoin_ibd::ibd::peer_io::solicit_track; -use rbitcoin_ibd::ibd::peer_io::{ibd_mono_ms, spawn_peer, PeerCmd, PeerEventSinks, PeerSlot}; -use rbitcoin_ibd::ibd::rate::{PROGRESS_STEP, RELSLOW_ACTIVE_MS}; -use rbitcoin_log::{debug, error, warn}; -use rbitcoin_net::chain::ChainHub; +use rbitcoin_ibd::ibd::peer_io::{ibd_mono_ms, PeerEventSinks, PeerSlot}; +use rbitcoin_ibd::ibd::rate::RELSLOW_ACTIVE_MS; use rbitcoin_net::error::NetError; -use rbitcoin_net::peers::{trying_connection_log, PeerConnType}; use rbitcoin_net::seeds::AddrMan; use std::collections::{HashMap, HashSet}; use std::net::SocketAddr; -use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::atomic::Ordering; use std::sync::Arc; use std::time::{Duration, Instant}; diff --git a/crates/rbitcoin-ibd/tests/ibd/events/addr_bucket_tests.rs b/crates/rbitcoin-ibd/tests/ibd/events/addr_bucket_tests.rs index a7208558bf..bdce977e1e 100644 --- a/crates/rbitcoin-ibd/tests/ibd/events/addr_bucket_tests.rs +++ b/crates/rbitcoin-ibd/tests/ibd/events/addr_bucket_tests.rs @@ -1,35 +1,7 @@ use super::super::assign::dummy_slot; -use bitcoin::hashes::Hash; -use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::assign::clear_hash_inflight; -use rbitcoin_ibd::ibd::assign_plan::{ - remove_from_ordered, should_enqueue_header, want_headers_beyond_soft_cap, -}; -use rbitcoin_ibd::ibd::dial::{ - disconnect_peer, note_dead_without_block_bytes, note_misbehavior_dead, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::exit::{ - header_lag_behind_peers, should_advance_locator_after_known_batch, - should_log_empty_headers_lag, should_rerequest_headers_on_empty_lag, - should_reseed_work_path_on_empty_lag, -}; use rbitcoin_ibd::ibd::peer_io::ibd_mono_ms; -use rbitcoin_ibd::ibd::peer_io::{note_block_progress, note_block_rx, PeerCmd, PeerEvent}; use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_ibd::ibd::{ - CONTIG_DENSIFY_AHEAD, MAX_ORDERED_HEADERS, MAX_PEER_POOL, ORDERED_HEADERS_SOFT_CAP, -}; -use rbitcoin_log::{info, trace, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; use rbitcoin_net::seeds::AddrMan; -use std::collections::HashMap; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; use rbitcoin_ibd::ibd::events::{apply_peer_dead, take_addr_tokens}; diff --git a/crates/rbitcoin-ibd/tests/ibd/events/confirm_reject_tests.rs b/crates/rbitcoin-ibd/tests/ibd/events/confirm_reject_tests.rs index ecc4f883d8..37cebed6fa 100644 --- a/crates/rbitcoin-ibd/tests/ibd/events/confirm_reject_tests.rs +++ b/crates/rbitcoin-ibd/tests/ibd/events/confirm_reject_tests.rs @@ -1,34 +1,7 @@ //! Tests for rbitcoin_ibd::ibd::events:: events helpers (peeled from events.rs). use bitcoin::hashes::Hash; use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::assign::clear_hash_inflight; -use rbitcoin_ibd::ibd::assign_plan::{ - remove_from_ordered, should_enqueue_header, want_headers_beyond_soft_cap, -}; -use rbitcoin_ibd::ibd::dial::{ - disconnect_peer, note_dead_without_block_bytes, note_misbehavior_dead, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::exit::{ - header_lag_behind_peers, should_advance_locator_after_known_batch, - should_log_empty_headers_lag, should_rerequest_headers_on_empty_lag, - should_reseed_work_path_on_empty_lag, -}; -use rbitcoin_ibd::ibd::peer_io::{note_block_progress, note_block_rx, PeerCmd, PeerEvent}; use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_ibd::ibd::{ - CONTIG_DENSIFY_AHEAD, MAX_ORDERED_HEADERS, MAX_PEER_POOL, ORDERED_HEADERS_SOFT_CAP, -}; -use rbitcoin_log::{info, trace, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; -use rbitcoin_net::seeds::AddrMan; -use std::collections::HashMap; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; use rbitcoin_ibd::ibd::confirm::{ConfirmRejectClass, RejectParent}; diff --git a/crates/rbitcoin-ibd/tests/ibd/events/decode_header_prefix_tests.rs b/crates/rbitcoin-ibd/tests/ibd/events/decode_header_prefix_tests.rs index 70a6c809f8..f2ad30dbbb 100644 --- a/crates/rbitcoin-ibd/tests/ibd/events/decode_header_prefix_tests.rs +++ b/crates/rbitcoin-ibd/tests/ibd/events/decode_header_prefix_tests.rs @@ -1,34 +1,4 @@ //! Tests for rbitcoin_ibd::ibd::events:: events helpers (peeled from events.rs). -use bitcoin::hashes::Hash; -use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::assign::clear_hash_inflight; -use rbitcoin_ibd::ibd::assign_plan::{ - remove_from_ordered, should_enqueue_header, want_headers_beyond_soft_cap, -}; -use rbitcoin_ibd::ibd::dial::{ - disconnect_peer, note_dead_without_block_bytes, note_misbehavior_dead, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::exit::{ - header_lag_behind_peers, should_advance_locator_after_known_batch, - should_log_empty_headers_lag, should_rerequest_headers_on_empty_lag, - should_reseed_work_path_on_empty_lag, -}; -use rbitcoin_ibd::ibd::peer_io::{note_block_progress, note_block_rx, PeerCmd, PeerEvent}; -use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_ibd::ibd::{ - CONTIG_DENSIFY_AHEAD, MAX_ORDERED_HEADERS, MAX_PEER_POOL, ORDERED_HEADERS_SOFT_CAP, -}; -use rbitcoin_log::{info, trace, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; -use rbitcoin_net::seeds::AddrMan; -use std::collections::HashMap; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; use bitcoin::consensus::Encodable; use rbitcoin_consensus::{genesis_block, ChainParams}; diff --git a/crates/rbitcoin-ibd/tests/ibd/events/header_batch_tests.rs b/crates/rbitcoin-ibd/tests/ibd/events/header_batch_tests.rs index 53c5e30829..4c343cbd68 100644 --- a/crates/rbitcoin-ibd/tests/ibd/events/header_batch_tests.rs +++ b/crates/rbitcoin-ibd/tests/ibd/events/header_batch_tests.rs @@ -1,34 +1,7 @@ use bitcoin::hashes::Hash; use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::assign::clear_hash_inflight; -use rbitcoin_ibd::ibd::assign_plan::{ - remove_from_ordered, should_enqueue_header, want_headers_beyond_soft_cap, -}; -use rbitcoin_ibd::ibd::dial::{ - disconnect_peer, note_dead_without_block_bytes, note_misbehavior_dead, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::exit::{ - header_lag_behind_peers, should_advance_locator_after_known_batch, - should_log_empty_headers_lag, should_rerequest_headers_on_empty_lag, - should_reseed_work_path_on_empty_lag, -}; use rbitcoin_ibd::ibd::peer_io::empty_header_fk_bus; -use rbitcoin_ibd::ibd::peer_io::{note_block_progress, note_block_rx, PeerCmd, PeerEvent}; use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_ibd::ibd::{ - CONTIG_DENSIFY_AHEAD, MAX_ORDERED_HEADERS, MAX_PEER_POOL, ORDERED_HEADERS_SOFT_CAP, -}; -use rbitcoin_log::{info, trace, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; -use rbitcoin_net::seeds::AddrMan; -use std::collections::HashMap; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; use rbitcoin_ibd::ibd::events::run_header_batch; diff --git a/crates/rbitcoin-ibd/tests/ibd/events/ibd_memory_tests.rs b/crates/rbitcoin-ibd/tests/ibd/events/ibd_memory_tests.rs index 40b58baf63..40528b2b5a 100644 --- a/crates/rbitcoin-ibd/tests/ibd/events/ibd_memory_tests.rs +++ b/crates/rbitcoin-ibd/tests/ibd/events/ibd_memory_tests.rs @@ -1,34 +1,8 @@ //! Header-path and body-intake bounds (findings C03, C05). use bitcoin::hashes::Hash; use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::assign::clear_hash_inflight; -use rbitcoin_ibd::ibd::assign_plan::{ - remove_from_ordered, should_enqueue_header, want_headers_beyond_soft_cap, -}; -use rbitcoin_ibd::ibd::dial::{ - disconnect_peer, note_dead_without_block_bytes, note_misbehavior_dead, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::exit::{ - header_lag_behind_peers, should_advance_locator_after_known_batch, - should_log_empty_headers_lag, should_rerequest_headers_on_empty_lag, - should_reseed_work_path_on_empty_lag, -}; -use rbitcoin_ibd::ibd::peer_io::{note_block_progress, note_block_rx, PeerCmd, PeerEvent}; use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_ibd::ibd::{ - CONTIG_DENSIFY_AHEAD, MAX_ORDERED_HEADERS, MAX_PEER_POOL, ORDERED_HEADERS_SOFT_CAP, -}; -use rbitcoin_log::{info, trace, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; -use rbitcoin_net::seeds::AddrMan; -use std::collections::HashMap; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; +use std::sync::atomic::AtomicU32; use bitcoin::consensus::encode::serialize; use rbitcoin_ibd::ibd::events::{ diff --git a/crates/rbitcoin-ibd/tests/ibd/events/misbehavior_dead_tests.rs b/crates/rbitcoin-ibd/tests/ibd/events/misbehavior_dead_tests.rs index 74629bc7d8..748397454d 100644 --- a/crates/rbitcoin-ibd/tests/ibd/events/misbehavior_dead_tests.rs +++ b/crates/rbitcoin-ibd/tests/ibd/events/misbehavior_dead_tests.rs @@ -1,34 +1,6 @@ use super::super::assign::dummy_slot; -use bitcoin::hashes::Hash; -use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::assign::clear_hash_inflight; -use rbitcoin_ibd::ibd::assign_plan::{ - remove_from_ordered, should_enqueue_header, want_headers_beyond_soft_cap, -}; -use rbitcoin_ibd::ibd::dial::{ - disconnect_peer, note_dead_without_block_bytes, note_misbehavior_dead, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::exit::{ - header_lag_behind_peers, should_advance_locator_after_known_batch, - should_log_empty_headers_lag, should_rerequest_headers_on_empty_lag, - should_reseed_work_path_on_empty_lag, -}; -use rbitcoin_ibd::ibd::peer_io::{note_block_progress, note_block_rx, PeerCmd, PeerEvent}; use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_ibd::ibd::{ - CONTIG_DENSIFY_AHEAD, MAX_ORDERED_HEADERS, MAX_PEER_POOL, ORDERED_HEADERS_SOFT_CAP, -}; -use rbitcoin_log::{info, trace, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; use rbitcoin_net::seeds::AddrMan; -use std::collections::HashMap; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; use rbitcoin_ibd::ibd::events::apply_peer_dead; diff --git a/crates/rbitcoin-ibd/tests/ibd/events/mod.rs b/crates/rbitcoin-ibd/tests/ibd/events/mod.rs index 26c884ac47..f79e41cb74 100644 --- a/crates/rbitcoin-ibd/tests/ibd/events/mod.rs +++ b/crates/rbitcoin-ibd/tests/ibd/events/mod.rs @@ -1,33 +1,3 @@ -use bitcoin::hashes::Hash; -use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::assign::clear_hash_inflight; -use rbitcoin_ibd::ibd::assign_plan::{ - remove_from_ordered, should_enqueue_header, want_headers_beyond_soft_cap, -}; -use rbitcoin_ibd::ibd::dial::{ - disconnect_peer, note_dead_without_block_bytes, note_misbehavior_dead, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::exit::{ - header_lag_behind_peers, should_advance_locator_after_known_batch, - should_log_empty_headers_lag, should_rerequest_headers_on_empty_lag, - should_reseed_work_path_on_empty_lag, -}; -use rbitcoin_ibd::ibd::peer_io::{note_block_progress, note_block_rx, PeerCmd, PeerEvent}; -use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_ibd::ibd::{ - CONTIG_DENSIFY_AHEAD, MAX_ORDERED_HEADERS, MAX_PEER_POOL, ORDERED_HEADERS_SOFT_CAP, -}; -use rbitcoin_log::{info, trace, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; -use rbitcoin_net::seeds::AddrMan; -use std::collections::HashMap; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; mod addr_bucket_tests; mod confirm_reject_tests; mod decode_header_prefix_tests; diff --git a/crates/rbitcoin-ibd/tests/ibd/events/parent_height_tests.rs b/crates/rbitcoin-ibd/tests/ibd/events/parent_height_tests.rs index 9189a1c306..0bc9d25731 100644 --- a/crates/rbitcoin-ibd/tests/ibd/events/parent_height_tests.rs +++ b/crates/rbitcoin-ibd/tests/ibd/events/parent_height_tests.rs @@ -1,34 +1,7 @@ //! Tests for rbitcoin_ibd::ibd::events:: events helpers (peeled from events.rs). use bitcoin::hashes::Hash; use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::assign::clear_hash_inflight; -use rbitcoin_ibd::ibd::assign_plan::{ - remove_from_ordered, should_enqueue_header, want_headers_beyond_soft_cap, -}; -use rbitcoin_ibd::ibd::dial::{ - disconnect_peer, note_dead_without_block_bytes, note_misbehavior_dead, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::exit::{ - header_lag_behind_peers, should_advance_locator_after_known_batch, - should_log_empty_headers_lag, should_rerequest_headers_on_empty_lag, - should_reseed_work_path_on_empty_lag, -}; -use rbitcoin_ibd::ibd::peer_io::{note_block_progress, note_block_rx, PeerCmd, PeerEvent}; -use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_ibd::ibd::{ - CONTIG_DENSIFY_AHEAD, MAX_ORDERED_HEADERS, MAX_PEER_POOL, ORDERED_HEADERS_SOFT_CAP, -}; -use rbitcoin_log::{info, trace, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; -use rbitcoin_net::seeds::AddrMan; use std::collections::HashMap; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; use bitcoin::absolute::LockTime; use bitcoin::block::{Header, Version}; diff --git a/crates/rbitcoin-ibd/tests/ibd/header_walk.rs b/crates/rbitcoin-ibd/tests/ibd/header_walk.rs index 8f9d6a4a72..4227e3aa8a 100644 --- a/crates/rbitcoin-ibd/tests/ibd/header_walk.rs +++ b/crates/rbitcoin-ibd/tests/ibd/header_walk.rs @@ -6,10 +6,9 @@ use bitcoin::Work; use rbitcoin_ibd::ibd::events::apply_peer_event; use rbitcoin_ibd::ibd::header_walk::*; use rbitcoin_ibd::ibd::peer_io::{solicit_track, PeerCmd, PeerEvent, PeerSlot}; -use rbitcoin_ibd::ibd::state::{ConfirmedLocatorTail, IbdWorkState}; +use rbitcoin_ibd::ibd::state::IbdWorkState; use rbitcoin_ibd::ibd::ORDERED_HEADERS_SOFT_CAP; use rbitcoin_net::chain::ChainHub; -use std::collections::{HashMap, HashSet}; use std::time::{Duration, Instant}; use rbitcoin_net::seeds::AddrMan; diff --git a/crates/rbitcoin-ibd/tests/ibd/mod.rs b/crates/rbitcoin-ibd/tests/ibd/mod.rs index 423a1600b0..8dfd330230 100644 --- a/crates/rbitcoin-ibd/tests/ibd/mod.rs +++ b/crates/rbitcoin-ibd/tests/ibd/mod.rs @@ -1,60 +1,3 @@ -use bitcoin::p2p::Magic; -use rbitcoin_ibd::ibd::archive::{ - rehydrate_block_queue_into_confirm, rehydrate_class_a_into_body_queue, -}; -use rbitcoin_ibd::ibd::assign::bq_pipeline_saturated; -use rbitcoin_ibd::ibd::assign::{assign_work_ordered, AssignDepth}; -use rbitcoin_ibd::ibd::assign_plan::need_ready_headroom; -use rbitcoin_ibd::ibd::assign_plan::want_headers_beyond_soft_cap; -use rbitcoin_ibd::ibd::cadence::IbdLoopCadence; -use rbitcoin_ibd::ibd::confirm::{ - offer_confirm_ready, spawn_confirm_engine, ConfirmEvent, ConfirmFeed, -}; -use rbitcoin_ibd::ibd::confirm::{ConfirmRejectClass, RejectParent}; -use rbitcoin_ibd::ibd::dial::{ - admit_cooldown_fallback, alive_dial_addrs, apply_dial_result, dial_batch, dial_blocked_addrs, - disconnect_relative_slow_block_peers, disconnect_stalled_block_peers, expire_addr_cooldown, - redial_want, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::events::drain_ready_peer_and_body_events; -use rbitcoin_ibd::ibd::events::{ - apply_confirm_events, apply_peer_event, disconnect_all_peers, update_confirm_lag, -}; -use rbitcoin_ibd::ibd::events::{apply_confirm_reject, apply_headers_event}; -use rbitcoin_ibd::ibd::exit::{ - all_peers_dead_action, best_chain_remainder, dark_empty_after, empty_path_header_fan, - header_lag_behind_peers, ibd_caught_up, may_spawn_redial, path_drained, - should_unlatch_headers_done, AllPeersDead, -}; -use rbitcoin_ibd::ibd::header_walk::{ - candidate_tip, candidate_work, forget_walk_peer, header_poll, header_status_view, - install_origin, load_origin, note_block_inv, note_reservation, origin_input, send_getheaders, - settle_walk_peer, take_header_ask, HeaderPoll, HeaderPollIn, -}; -use rbitcoin_ibd::ibd::peer_io::{empty_header_fk_bus, PeerCmd, PeerEvent}; -use rbitcoin_ibd::ibd::peer_io::{sample_peer_rates, PeerEventSinks}; -use rbitcoin_ibd::ibd::peer_io::{solicit_track, GetdataWire, PeerSlot}; -use rbitcoin_ibd::ibd::perf_log::{read_platform_rss, tip_perf_json, ProcessRss, TipPerfLog}; -use rbitcoin_ibd::ibd::progress::{log_progress_tick, StatusClock}; -use rbitcoin_ibd::ibd::progress::{read_progress_published, StatusSnap}; -use rbitcoin_ibd::ibd::progress::{ - spawn_status_thread, work_chain_progress_at, StatusBoard, TipRateTracker, -}; -use rbitcoin_ibd::ibd::published::spawn_header_thread; -use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::state::{enqueue_header_cmd, HeaderCmd}; -use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_log::{info, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; -use std::collections::{HashMap, HashSet}; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::sync::Arc; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; -use tokio::task::JoinHandle; mod archive; mod archive_sat_tests; mod assign; diff --git a/crates/rbitcoin-ibd/tests/ibd/path.rs b/crates/rbitcoin-ibd/tests/ibd/path.rs index 719cb8d468..835553eb69 100644 --- a/crates/rbitcoin-ibd/tests/ibd/path.rs +++ b/crates/rbitcoin-ibd/tests/ibd/path.rs @@ -1,10 +1,6 @@ use bitcoin::hashes::Hash; use bitcoin::BlockHash; use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::MAX_ORDERED_HEADERS; -use rbitcoin_log::{info, warn}; -use rbitcoin_net::chain::ChainHub; -use std::time::Instant; use rbitcoin_ibd::ibd::path::work_path_tips; diff --git a/crates/rbitcoin-ibd/tests/ibd/peer_book_and_config_tests.rs b/crates/rbitcoin-ibd/tests/ibd/peer_book_and_config_tests.rs index 841a74a16d..b0bd63432d 100644 --- a/crates/rbitcoin-ibd/tests/ibd/peer_book_and_config_tests.rs +++ b/crates/rbitcoin-ibd/tests/ibd/peer_book_and_config_tests.rs @@ -1,64 +1,9 @@ -use bitcoin::p2p::Magic; -use rbitcoin_ibd::ibd::archive::{ - rehydrate_block_queue_into_confirm, rehydrate_class_a_into_body_queue, -}; -use rbitcoin_ibd::ibd::assign::bq_pipeline_saturated; -use rbitcoin_ibd::ibd::assign::{assign_work_ordered, AssignDepth}; -use rbitcoin_ibd::ibd::assign_plan::need_ready_headroom; -use rbitcoin_ibd::ibd::assign_plan::want_headers_beyond_soft_cap; -use rbitcoin_ibd::ibd::cadence::IbdLoopCadence; -use rbitcoin_ibd::ibd::confirm::{ - offer_confirm_ready, spawn_confirm_engine, ConfirmEvent, ConfirmFeed, -}; -use rbitcoin_ibd::ibd::confirm::{ConfirmRejectClass, RejectParent}; -use rbitcoin_ibd::ibd::dial::{ - admit_cooldown_fallback, alive_dial_addrs, apply_dial_result, dial_batch, dial_blocked_addrs, - disconnect_relative_slow_block_peers, disconnect_stalled_block_peers, expire_addr_cooldown, - redial_want, release_peer_block_work, -}; -use rbitcoin_ibd::ibd::events::drain_ready_peer_and_body_events; -use rbitcoin_ibd::ibd::events::{ - apply_confirm_events, apply_peer_event, disconnect_all_peers, update_confirm_lag, -}; -use rbitcoin_ibd::ibd::events::{apply_confirm_reject, apply_headers_event}; -use rbitcoin_ibd::ibd::exit::{ - all_peers_dead_action, best_chain_remainder, dark_empty_after, empty_path_header_fan, - header_lag_behind_peers, ibd_caught_up, may_spawn_redial, path_drained, - should_unlatch_headers_done, AllPeersDead, -}; -use rbitcoin_ibd::ibd::header_walk::{ - candidate_tip, candidate_work, forget_walk_peer, header_poll, header_status_view, - install_origin, load_origin, note_block_inv, note_reservation, origin_input, send_getheaders, - settle_walk_peer, take_header_ask, HeaderPoll, HeaderPollIn, -}; -use rbitcoin_ibd::ibd::peer_io::{empty_header_fk_bus, PeerCmd, PeerEvent}; -use rbitcoin_ibd::ibd::peer_io::{sample_peer_rates, PeerEventSinks}; -use rbitcoin_ibd::ibd::peer_io::{solicit_track, GetdataWire, PeerSlot}; -use rbitcoin_ibd::ibd::perf_log::{read_platform_rss, tip_perf_json, ProcessRss, TipPerfLog}; -use rbitcoin_ibd::ibd::progress::{log_progress_tick, StatusClock}; -use rbitcoin_ibd::ibd::progress::{read_progress_published, StatusSnap}; -use rbitcoin_ibd::ibd::progress::{ - spawn_status_thread, work_chain_progress_at, StatusBoard, TipRateTracker, -}; -use rbitcoin_ibd::ibd::published::spawn_header_thread; -use rbitcoin_ibd::ibd::state::IbdWorkState; -use rbitcoin_ibd::ibd::state::{enqueue_header_cmd, HeaderCmd}; -use rbitcoin_ibd::ibd::status::LoopStats; use rbitcoin_ibd::ibd::PeerBookSession; -use rbitcoin_log::{info, warn}; -use rbitcoin_net::chain::ChainHub; -use rbitcoin_net::codec::MAX_HEADERS_RESULTS; -use rbitcoin_net::error::NetError; use rbitcoin_net::seeds::AddrMan; -use std::collections::{HashMap, HashSet}; use std::net::SocketAddr; use std::net::{IpAddr, Ipv4Addr}; -use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::Arc; use std::sync::Mutex; -use std::time::{Duration, Instant}; -use tokio::sync::mpsc; -use tokio::task::JoinHandle; fn sa(o: u8) -> SocketAddr { SocketAddr::new(IpAddr::V4(Ipv4Addr::new(10, 0, 0, o)), 18444) diff --git a/crates/rbitcoin-ibd/tests/ibd/peer_io.rs b/crates/rbitcoin-ibd/tests/ibd/peer_io.rs index b5ce7a6f81..e6c4c38cfa 100644 --- a/crates/rbitcoin-ibd/tests/ibd/peer_io.rs +++ b/crates/rbitcoin-ibd/tests/ibd/peer_io.rs @@ -1,27 +1,20 @@ use bitcoin::block::Header; use bitcoin::hashes::Hash; use bitcoin::p2p::message::NetworkMessage; -use bitcoin::p2p::message_blockdata::{GetHeadersMessage, Inventory}; +use bitcoin::p2p::message_blockdata::Inventory; use bitcoin::p2p::{Magic, ServiceFlags}; use bitcoin::BlockHash; use rbitcoin_ibd::ibd::peer_io::*; use rbitcoin_ibd::ibd::rate::PeerRate; -use rbitcoin_net::codec::{FramedMessage, MAX_INV_SIZE}; +use rbitcoin_net::codec::FramedMessage; use rbitcoin_net::error::NetError; -use rbitcoin_net::msg_decode::spawn_decode_then_with_err; -use rbitcoin_net::peer::{ - connect_and_handshake_timed, HandshakePolicy, BAN_SCORE_THRESHOLD, HANDSHAKE_TIMEOUT, -}; use rbitcoin_net::peer_dos::{PeerRateLimiter, RATE_LIMIT_BAN_SCORE}; -use rbitcoin_net::v2::{read_v2_frame_with_progress, write_v2_msg_offload, V2Reader, V2Writer}; use std::collections::HashSet; use std::net::SocketAddr; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; -use std::sync::atomic::{AtomicI64, AtomicU64, AtomicUsize, Ordering}; +use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::{Arc, Mutex}; -use std::time::Instant; -use tokio::sync::{mpsc, OwnedSemaphorePermit, Semaphore}; -use tokio::task::JoinHandle; +use tokio::sync::{mpsc, Semaphore}; fn dummy_slot(id: usize) -> PeerSlot { let (cmd_tx, _rx) = mpsc::unbounded_channel(); diff --git a/crates/rbitcoin-ibd/tests/ibd/perf_log.rs b/crates/rbitcoin-ibd/tests/ibd/perf_log.rs index 9ac8d87ad4..1adeab54c4 100644 --- a/crates/rbitcoin-ibd/tests/ibd/perf_log.rs +++ b/crates/rbitcoin-ibd/tests/ibd/perf_log.rs @@ -2,7 +2,6 @@ use rbitcoin_ibd::ibd::confirm::ConfirmPipelineSizes; use rbitcoin_ibd::ibd::perf_log::*; use rbitcoin_ibd::ibd::state::WorkStructureSizes; use rbitcoin_ibd::ibd::status::LoopStats; -use rbitcoin_log::debug; use rbitcoin_log::Level; use rbitcoin_query::ProcessOwnedSizes; use std::sync::atomic::Ordering; diff --git a/crates/rbitcoin-ibd/tests/ibd/progress.rs b/crates/rbitcoin-ibd/tests/ibd/progress.rs index e976dab899..45b70e37b3 100644 --- a/crates/rbitcoin-ibd/tests/ibd/progress.rs +++ b/crates/rbitcoin-ibd/tests/ibd/progress.rs @@ -1,15 +1,10 @@ -use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::body::BodyPresence; use rbitcoin_ibd::ibd::progress::{ format_duration_short, format_progress_line, format_rate, ibd_pct, tip_hole_from_claim_ready, ProgressLineInput, TipRateTracker, }; -use rbitcoin_net::chain::ChainHub; use rbitcoin_query::{ soft_assign_restricted, soft_confirm_window_n, soft_densify_band_hi, BQ_SOFT_FREE_BYTES, }; -use std::collections::HashMap; -use std::sync::Arc; use std::time::{Duration, Instant}; /// Shipped progress line: tip + in-RAM bq soft depth; forbid retired tokens. diff --git a/crates/rbitcoin-ibd/tests/ibd/reorg.rs b/crates/rbitcoin-ibd/tests/ibd/reorg.rs index a6f6599405..33262d0695 100644 --- a/crates/rbitcoin-ibd/tests/ibd/reorg.rs +++ b/crates/rbitcoin-ibd/tests/ibd/reorg.rs @@ -1,12 +1,9 @@ use bitcoin::hashes::Hash; use bitcoin::{Block, BlockHash, CompactTarget, Target}; use rbitcoin_ibd::ibd::reorg::*; -use rbitcoin_log::{info, warn}; use rbitcoin_net::chain::ChainHub; use rbitcoin_net::error::NetError; -use rbitcoin_net::most_work::{sum_work, work_better, InvalidHashSet}; -use rbitcoin_primitives::{Fk, Height}; -use std::collections::{HashMap, HashSet}; +use rbitcoin_primitives::Height; fn tmp_hub() -> (rbitcoin_query::testutil::TempDir, ChainHub) { rbitcoin_net::chain::tiny_regtest_hub_labeled("ibd-reorg") diff --git a/crates/rbitcoin-ibd/tests/ibd/state.rs b/crates/rbitcoin-ibd/tests/ibd/state.rs index 5f33f2a0e3..99881f5338 100644 --- a/crates/rbitcoin-ibd/tests/ibd/state.rs +++ b/crates/rbitcoin-ibd/tests/ibd/state.rs @@ -1,14 +1,7 @@ use bitcoin::hashes::Hash; use bitcoin::BlockHash; -use rbitcoin_ibd::ibd::assign_plan::compact_ordered; -use rbitcoin_ibd::ibd::body::{BodyPresence, BodyPresenceSizes}; -use rbitcoin_ibd::ibd::peer_io::PeerSlot; -use rbitcoin_ibd::ibd::reorg::IbdReorgState; use rbitcoin_ibd::ibd::state::*; use rbitcoin_primitives::Fk; -use std::collections::{HashMap, HashSet, VecDeque}; -use std::net::SocketAddr; -use std::time::Instant; fn h(n: u8) -> BlockHash { let mut b = [0u8; 32]; diff --git a/crates/rbitcoin-ibd/tests/ibd/status.rs b/crates/rbitcoin-ibd/tests/ibd/status.rs index 9ba586527e..8bec278a90 100644 --- a/crates/rbitcoin-ibd/tests/ibd/status.rs +++ b/crates/rbitcoin-ibd/tests/ibd/status.rs @@ -1,7 +1,5 @@ use rbitcoin_ibd::ibd::status::*; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::Mutex; -use std::time::Instant; +use std::sync::atomic::Ordering; use std::time::Duration; diff --git a/crates/rbitcoin-ibd/tests/ibd_smoke.rs b/crates/rbitcoin-ibd/tests/ibd_smoke.rs index 65b738454e..9dff50e31f 100644 --- a/crates/rbitcoin-ibd/tests/ibd_smoke.rs +++ b/crates/rbitcoin-ibd/tests/ibd_smoke.rs @@ -1,62 +1,8 @@ //! Short regtest IBD smoke: seed node with a few blocks, peer catch-up via //! [`P2PNode::sync`]. Hits the main IBD loop, archive pipeline, confirm engine, //! peer_io, and dial/events paths without live datadirs. -use rbitcoin_ibd::ibd::{ - read_platform_rss, rehydrate_block_queue_residue, tip_perf_json, IbdConfig, ProcessRss, - TipPerfLog, DEFAULT_BLOCKS_IN_TRANSIT_PER_PEER, DEFAULT_IBD_WINDOW, -}; -use rbitcoin_net::asmap::{ - AsMap, ASMAP_EIGHT_TRAILING_ZEROS, ASMAP_JUMP_OFF_END, ASMAP_JUMP_PAST_FILE, - ASMAP_JUMP_SHORT_TAIL, ASMAP_MATCH_PAST_END, ASMAP_SECOND_DEFAULT, ASMAP_TRAILING_ONE, - ASMAP_TWO_SHORT_MATCHES, LONE_RETURN_ASMAP, LOOPBACK_ASMAP, TWO_PREFIX_ASMAP, -}; -use rbitcoin_net::cache::BlockCache; -use rbitcoin_net::chain::{ - check_block_proposal_with, AcceptOutcome, ChainHub, ChainTipInfo, TipEvent, -}; -use rbitcoin_net::compact::{ - classify_v2_cmpct_peer, prefilled_indexes_ok, shortid_map_from_txs, try_reconstruct, - v2_header_hashes, CmpctPeerFrame, -}; -use rbitcoin_net::ephemeral::spawn_isolated_broadcast_loop; -use rbitcoin_net::error::NetError; -use rbitcoin_net::eviction::{select_inbound_eviction, InboundEvictCandidate}; -use rbitcoin_net::i2p_sam::{i2p_addr_from_sam_b64, I2pSam}; -use rbitcoin_net::most_work::{sum_work, WorkOverflow}; -use rbitcoin_net::net_permissions::{ - apply_implicit, parse_whitebind, parse_whitelist, NetPermTable, NetPermissionFlags, - WhitebindGrant, WhitelistGrant, DEFAULT_WHITELISTFORCERELAY, DEFAULT_WHITELISTRELAY, -}; -use rbitcoin_net::netaddr::{is_cjdns_ip, NetAddr, OnlyNet}; -use rbitcoin_net::netgroup::netgroup; -use rbitcoin_net::peer::{ - drain_pending_now, flush_tx_invs, force_announce_txid, local_service_flags, run_feeler_timed, - PendingBlocks, V2PlainSession, MAX_SERVE_BLOCKS, -}; -use rbitcoin_net::peer_dos::DEFAULT_MAX_INBOUND; -use rbitcoin_net::peers::{ - connection_counts, outbound_time_offset, parse_peer_addr, parse_peer_addr_with_port, - parse_peer_net, pick_stale_follow_evict, DialRequest, DialTarget, LivePeer, PeerConnType, - PeerHub, PeerInfo, PeerOut, PingAction, -}; -use rbitcoin_net::perf_meter::RequestMeter; -use rbitcoin_net::reactor::BlockingRegion; -use rbitcoin_net::seeds::{ - default_port, default_rpc_port, dns_seeds, fixed_seed_hosts, resolve_all_seeds, - resolve_dns_seeds, resolve_fixed_seeds, socks_dns_seed_dests, AddrMan, PeerEntry, PeerFlags, - MAX_ADDR_MAN, -}; -use rbitcoin_net::serve_perf::{ - format_serve_perf, sample_reset_serve_perf, serve_perf_totals, ServePerfSample, -}; +use rbitcoin_ibd::ibd::IbdConfig; use rbitcoin_net::service::P2PNode; -use rbitcoin_net::socks::{install_i2p_dialer, Dialer}; -use rbitcoin_net::tx_relay::{ - ElectrumMempoolItem, FeeHistoryBackfillStats, MempoolAnnounce, MempoolHub, MempoolPerfSample, - MempoolTxSnapEntry, MempoolTxSnapshot, -}; -use rbitcoin_net::v2::{encode_v2_contents, parse_v2_regtest, parse_v2_regtest_named, WireBytes}; -use rbitcoin_net::versionbits_warn::warning_strings; use bitcoin::hashes::Hash; use bitcoin::{Block, BlockHash}; diff --git a/crates/rbitcoin-ibd/tests/suite.rs b/crates/rbitcoin-ibd/tests/suite.rs index eafdf8abf1..f34c4ba583 100644 --- a/crates/rbitcoin-ibd/tests/suite.rs +++ b/crates/rbitcoin-ibd/tests/suite.rs @@ -1,4 +1,2 @@ -#![allow(unused_imports, dead_code, unused_variables)] - mod ibd; mod ibd_smoke; diff --git a/crates/rbitcoin-log/tests/api_log.rs b/crates/rbitcoin-log/tests/api_log.rs index f88797b9d9..f90f6f96af 100644 --- a/crates/rbitcoin-log/tests/api_log.rs +++ b/crates/rbitcoin-log/tests/api_log.rs @@ -1,11 +1,6 @@ use rbitcoin_log::PARAMS_MAX; use rbitcoin_log::*; -use rbitcoin_log::{format_timestamp, trace}; -use std::fs::{File, OpenOptions}; -use std::io::Write; -use std::path::Path; use std::sync::Mutex; -use std::time::SystemTime; static TEST_LOCK: Mutex<()> = Mutex::new(()); diff --git a/crates/rbitcoin-log/tests/progress.rs b/crates/rbitcoin-log/tests/progress.rs index 9b65d9626a..a811e21936 100644 --- a/crates/rbitcoin-log/tests/progress.rs +++ b/crates/rbitcoin-log/tests/progress.rs @@ -1,6 +1,4 @@ -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{Arc, Mutex, MutexGuard}; -use std::time::{Duration, Instant, SystemTime}; +use std::time::{Duration, SystemTime}; use rbitcoin_log::progress::*; diff --git a/crates/rbitcoin-log/tests/root.rs b/crates/rbitcoin-log/tests/root.rs index 77733161c4..7dc9ee8639 100644 --- a/crates/rbitcoin-log/tests/root.rs +++ b/crates/rbitcoin-log/tests/root.rs @@ -1,10 +1,6 @@ -use rbitcoin_log::api_log::PARAMS_MAX; -use rbitcoin_log::api_log::{api_call, close_api_log, init_api_log}; use rbitcoin_log::*; -use std::fmt; use std::io::{self, Write}; -use std::sync::atomic::{AtomicU8, Ordering}; -use std::time::{SystemTime, UNIX_EPOCH}; +use std::time::UNIX_EPOCH; use std::sync::{Mutex, OnceLock}; diff --git a/crates/rbitcoin-log/tests/suite.rs b/crates/rbitcoin-log/tests/suite.rs index 5af44b1d7c..be2cb09506 100644 --- a/crates/rbitcoin-log/tests/suite.rs +++ b/crates/rbitcoin-log/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod api_log; mod progress; mod root; diff --git a/crates/rbitcoin-mempool/tests/accept.rs b/crates/rbitcoin-mempool/tests/accept.rs index 87e2778fc3..5cbad333d8 100644 --- a/crates/rbitcoin-mempool/tests/accept.rs +++ b/crates/rbitcoin-mempool/tests/accept.rs @@ -2,23 +2,15 @@ use bitcoin::absolute::LockTime; use bitcoin::hashes::Hash; use bitcoin::transaction::Version; use bitcoin::{Amount, ScriptBuf, Sequence, TxIn, Witness}; -use bitcoin::{OutPoint, Transaction, TxOut, Txid, Wtxid}; -use rbitcoin_consensus::policy::{self, PolicyResult}; +use bitcoin::{OutPoint, Transaction, TxOut, Txid}; +use rbitcoin_consensus::policy::{self}; use rbitcoin_mempool::accept::*; use rbitcoin_mempool::error::MempoolError; -use rbitcoin_mempool::graph::{ - sigops_adjusted_weight, SelectBudget, Selected, TxEntry, TxGraph, MAX_BLOCK_SIGOPS_COST, -}; use rbitcoin_mempool::graph::{MAX_CLUSTER_COUNT, MAX_CLUSTER_VSIZE, MAX_CLUSTER_WEIGHT}; -use rbitcoin_mempool::orphanage::Orphanage; -use rbitcoin_mempool::packed::VinAux; -use rbitcoin_mempool::store::Mempool; -use rbitcoin_primitives::Fk; +use std::collections::BTreeSet; use std::collections::HashMap; -use std::collections::{BTreeMap, BTreeSet, HashSet, VecDeque}; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Arc; -use std::time::Instant; fn tmp_dir() -> rbitcoin_store::testutil::TempDir { rbitcoin_store::testutil::TempDir::labeled("mempool-accept").unwrap() diff --git a/crates/rbitcoin-mempool/tests/error.rs b/crates/rbitcoin-mempool/tests/error.rs index e638eba089..4b22f6a9b4 100644 --- a/crates/rbitcoin-mempool/tests/error.rs +++ b/crates/rbitcoin-mempool/tests/error.rs @@ -1,9 +1,7 @@ use rbitcoin_mempool::error::*; use rbitcoin_primitives::PackError; use std::error::Error; -use std::fmt; use std::io; -use std::path::PathBuf; #[test] fn display_and_source_all_variants() { diff --git a/crates/rbitcoin-mempool/tests/fee_flow.rs b/crates/rbitcoin-mempool/tests/fee_flow.rs index 60e0874bd9..28355f6bdf 100644 --- a/crates/rbitcoin-mempool/tests/fee_flow.rs +++ b/crates/rbitcoin-mempool/tests/fee_flow.rs @@ -1,4 +1,4 @@ -use rbitcoin_mempool::fee_est::{bucket_count, bucket_index, BLOCK_WEIGHT_WU, SECONDS_PER_BLOCK}; +use rbitcoin_mempool::fee_est::{bucket_index, BLOCK_WEIGHT_WU, SECONDS_PER_BLOCK}; use rbitcoin_mempool::fee_flow::*; use std::time::Instant; diff --git a/crates/rbitcoin-mempool/tests/graph.rs b/crates/rbitcoin-mempool/tests/graph.rs index 72a05899da..e46d55e0b5 100644 --- a/crates/rbitcoin-mempool/tests/graph.rs +++ b/crates/rbitcoin-mempool/tests/graph.rs @@ -2,10 +2,9 @@ use bitcoin::absolute::LockTime; use bitcoin::hashes::Hash; use bitcoin::transaction::Version; use bitcoin::{Amount, ScriptBuf, Sequence, TxIn, TxOut, Witness}; -use bitcoin::{OutPoint, Transaction, Txid, Wtxid}; +use bitcoin::{OutPoint, Transaction, Txid}; use rbitcoin_mempool::graph::*; -use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque}; -use std::sync::Mutex; +use std::collections::BTreeSet; fn txid_n(n: u8) -> Txid { Txid::from_byte_array([n; 32]) diff --git a/crates/rbitcoin-mempool/tests/orphanage.rs b/crates/rbitcoin-mempool/tests/orphanage.rs index cd6766b6f0..c2a4e53074 100644 --- a/crates/rbitcoin-mempool/tests/orphanage.rs +++ b/crates/rbitcoin-mempool/tests/orphanage.rs @@ -2,9 +2,9 @@ use bitcoin::absolute::LockTime; use bitcoin::hashes::Hash; use bitcoin::transaction::Version; use bitcoin::{Amount, OutPoint, ScriptBuf, Sequence, TxIn, TxOut, Witness}; -use bitcoin::{Transaction, Txid, Wtxid}; +use bitcoin::{Transaction, Txid}; use rbitcoin_mempool::orphanage::*; -use std::collections::{BTreeSet, HashMap, HashSet, VecDeque}; +use std::collections::BTreeSet; fn txid_n(n: u8) -> Txid { Txid::from_byte_array([n; 32]) diff --git a/crates/rbitcoin-mempool/tests/packed.rs b/crates/rbitcoin-mempool/tests/packed.rs index ce74d84081..fc18a92dc7 100644 --- a/crates/rbitcoin-mempool/tests/packed.rs +++ b/crates/rbitcoin-mempool/tests/packed.rs @@ -2,11 +2,10 @@ use bitcoin::absolute::LockTime; use bitcoin::consensus::encode::serialize; use bitcoin::hashes::Hash; use bitcoin::transaction::Version; -use bitcoin::{Amount, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Txid, Witness, Wtxid}; +use bitcoin::{Amount, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Txid, Witness}; use rbitcoin_mempool::error::MempoolError; use rbitcoin_mempool::packed::*; -use rbitcoin_primitives::{read_compact_size, write_compact_size, Fk}; -use rbitcoin_store::OutputRecord; +use rbitcoin_primitives::{write_compact_size, Fk}; /// First vin's flag byte: the fixed prefix (ids, version and locktime, /// 104 B) plus the one-byte input and output counts. diff --git a/crates/rbitcoin-mempool/tests/store_tests.rs b/crates/rbitcoin-mempool/tests/store_tests.rs index 186b3b854e..7e5d60fce6 100644 --- a/crates/rbitcoin-mempool/tests/store_tests.rs +++ b/crates/rbitcoin-mempool/tests/store_tests.rs @@ -1,32 +1,12 @@ -use bitcoin::consensus::encode::deserialize; use bitcoin::hashes::Hash; -use bitcoin::{Transaction, Txid, Wtxid}; -use rbitcoin_mempool::accept::{ - check_mempool_structural, AcceptError, AcceptFailureRecord, AcceptResult, AcceptStageUs, - ActiveMempool, ChainPrevout, ChainTipCtx, Coin, LiftedOrphan, PreparedAdmit, UtxoProvider, - DEFAULT_MAX_MEMPOOL_WEIGHT, MAX_PACKAGE_COUNT, MAX_PACKAGE_WEIGHT, -}; +use bitcoin::Txid; use rbitcoin_mempool::error::MempoolError; -use rbitcoin_mempool::fee_analog::{AnalogHistory, HISTORICAL_CONFIDENCE_FAR}; -use rbitcoin_mempool::fee_est::{ - block_individual_p10_sat_kvb, default_candidate_rates, depth_rate_sat_kvb, - enforce_monotone_desc, fee_at_target_sat_kvb, fine_candidate_rates, flow_for_depth, - hold_defined_then_monotone, min_rate_for_capacity, percentile_sat, published_depth_rate, - warmup_blend, BLOCK_WEIGHT_WU, CONFIDENCE_FAR, CONFIDENCE_NEAR, -}; -use rbitcoin_mempool::fee_flow::FeeFlowMeter; -use rbitcoin_mempool::graph::{ - frontier_feerate_from_chunks, weight_above_from_chunks, Chunk, Cluster, MempoolGraphStats, - SelectBudget, Selected, StockAbove, TxEntry, TxGraph, MAX_CLUSTER_COUNT, MAX_CLUSTER_VSIZE, -}; -use rbitcoin_mempool::orphanage::{OrphanSnapshot, Orphanage}; use rbitcoin_mempool::packed::{VinAux, SIGOP_COST_OFF}; +use rbitcoin_mempool::store::Mempool; use rbitcoin_mempool::store::*; -use rbitcoin_mempool::store::{Mempool, MempoolMeta}; -use std::fs::{self, File, OpenOptions}; -use std::io::{Read, Seek, SeekFrom, Write}; -use std::path::{Path, PathBuf}; -use std::time::Instant; +use std::fs::{self, OpenOptions}; +use std::io::{Seek, SeekFrom, Write}; +use std::path::Path; /// Rewrite a closed current pool under `dir` as schema 2 (drop each /// record's sigops and accept time, stamp headers 2) — pre-upgrade fixture. diff --git a/crates/rbitcoin-mempool/tests/suite.rs b/crates/rbitcoin-mempool/tests/suite.rs index aa527e9eac..ef10b9ba19 100644 --- a/crates/rbitcoin-mempool/tests/suite.rs +++ b/crates/rbitcoin-mempool/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod accept; mod error; mod fee_analog; diff --git a/crates/rbitcoin-net/tests/asmap.rs b/crates/rbitcoin-net/tests/asmap.rs index 08003a2b14..6ab7503e82 100644 --- a/crates/rbitcoin-net/tests/asmap.rs +++ b/crates/rbitcoin-net/tests/asmap.rs @@ -1,7 +1,6 @@ use rbitcoin_net::asmap::*; use std::net::IpAddr; use std::net::Ipv4Addr; -use std::path::Path; #[test] fn asmap_rejected_bytecodes_fail_sanity() { diff --git a/crates/rbitcoin-net/tests/cache.rs b/crates/rbitcoin-net/tests/cache.rs index 979027115e..14f44a94c8 100644 --- a/crates/rbitcoin-net/tests/cache.rs +++ b/crates/rbitcoin-net/tests/cache.rs @@ -1,9 +1,4 @@ -use bitcoin::block::{Block, Header}; -use bitcoin::hashes::Hash; -use bitcoin::BlockHash; use rbitcoin_net::cache::*; -use std::collections::HashMap; -use std::sync::RwLock; #[test] fn default_body_depth_is_compact_serve_window() { diff --git a/crates/rbitcoin-net/tests/chain.rs b/crates/rbitcoin-net/tests/chain.rs index d940d09c89..a124437ccf 100644 --- a/crates/rbitcoin-net/tests/chain.rs +++ b/crates/rbitcoin-net/tests/chain.rs @@ -1,30 +1,16 @@ use bitcoin::block::Header; use bitcoin::hashes::Hash; use bitcoin::{ - Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Target, Transaction, TxOut, Txid, - Work, + Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Target, Transaction, TxOut, Work, }; -use rbitcoin_consensus::{ - genesis_block, mine_op_true_signet_paying, mine_regtest_paying, validate_header_on_parent, - ChainParams, Milestone, -}; -use rbitcoin_log::{debug, info, warn}; -use rbitcoin_net::cache::BlockCache; +use rbitcoin_consensus::{genesis_block, mine_regtest_paying, ChainParams, Milestone}; use rbitcoin_net::chain::*; use rbitcoin_net::error::NetError; use rbitcoin_net::most_work::work_better; use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::Query; -use rbitcoin_query::{ - accept_and_connect_block_preverified, confirm_wire_load_from_plan as consensus_load_from_plan, - confirm_wire_load_phase_pipelined, confirm_write_phase, header_to_record, validate_header, - PlanStampOutcome, ScriptOkBatch, ScriptPreverified, WireLoadPipeline, -}; -use std::collections::{HashMap, HashSet, VecDeque}; -use std::sync::atomic::{AtomicBool, AtomicI32, AtomicU32, AtomicU64, Ordering}; +use std::collections::HashMap; +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use std::sync::RwLock; -use tokio::sync::{broadcast, Notify}; #[test] fn fork_tips_drop_the_oldest_at_the_cap() { diff --git a/crates/rbitcoin-net/tests/codec.rs b/crates/rbitcoin-net/tests/codec.rs index 11341079a8..e72a91451a 100644 --- a/crates/rbitcoin-net/tests/codec.rs +++ b/crates/rbitcoin-net/tests/codec.rs @@ -1,7 +1,6 @@ use bitcoin::blockdata::constants::genesis_block; -use bitcoin::consensus::encode::Decodable; use bitcoin::consensus::serialize; -use bitcoin::p2p::message::{CommandString, NetworkMessage, RawNetworkMessage}; +use bitcoin::p2p::message::NetworkMessage; use bitcoin::p2p::Magic; use bitcoin::Network; use rbitcoin_net::codec::*; diff --git a/crates/rbitcoin-net/tests/compact.rs b/crates/rbitcoin-net/tests/compact.rs index 05305be161..70c8b3abbd 100644 --- a/crates/rbitcoin-net/tests/compact.rs +++ b/crates/rbitcoin-net/tests/compact.rs @@ -1,15 +1,13 @@ use bitcoin::absolute::LockTime; -use bitcoin::bip152::{BlockTransactions, BlockTransactionsRequest, HeaderAndShortIds, ShortId}; +use bitcoin::bip152::{BlockTransactions, HeaderAndShortIds, ShortId}; use bitcoin::block::Header; use bitcoin::block::Version; use bitcoin::hashes::Hash; use bitcoin::p2p::message::NetworkMessage; -use bitcoin::p2p::Magic; -use bitcoin::{Block, BlockHash, Transaction, Wtxid}; +use bitcoin::{Block, BlockHash, Transaction}; use rbitcoin_net::compact::*; use std::borrow::Borrow; -use std::collections::{HashMap, HashSet}; -use std::fmt; +use std::collections::HashMap; use bitcoin::script::ScriptBuf; use bitcoin::{Amount, CompactTarget, OutPoint, Sequence, TxIn, TxMerkleNode, TxOut, Witness}; diff --git a/crates/rbitcoin-net/tests/ephemeral.rs b/crates/rbitcoin-net/tests/ephemeral.rs index f53b1b42d1..fec7a1f343 100644 --- a/crates/rbitcoin-net/tests/ephemeral.rs +++ b/crates/rbitcoin-net/tests/ephemeral.rs @@ -2,18 +2,15 @@ use bitcoin::p2p::message::NetworkMessage; use bitcoin::p2p::Magic; use bitcoin::Transaction; use rbitcoin_net::ephemeral::*; -use rbitcoin_net::error::NetError; use rbitcoin_net::msg_decode::decode_framed_offload; -use rbitcoin_net::peer::{connect_and_handshake_timed, HandshakePolicy, HANDSHAKE_TIMEOUT}; +use rbitcoin_net::peer::{connect_and_handshake_timed, HandshakePolicy}; use rbitcoin_net::seeds::AddrMan; use rbitcoin_net::socks::Dialer; use rbitcoin_net::tx_relay::MempoolHub; -use rbitcoin_net::v2::write_v2_msg; use rbitcoin_net::NetAddr; use std::net::SocketAddr; use std::sync::{Arc, Mutex}; use std::time::Duration; -use tokio::task::JoinHandle; use bitcoin::absolute::LockTime; use rbitcoin_net::v2::read_v2_frame; diff --git a/crates/rbitcoin-net/tests/error.rs b/crates/rbitcoin-net/tests/error.rs index e057261db5..99ef52e67f 100644 --- a/crates/rbitcoin-net/tests/error.rs +++ b/crates/rbitcoin-net/tests/error.rs @@ -1,6 +1,5 @@ use rbitcoin_net::error::*; use std::error::Error; -use std::fmt; use std::io; #[test] diff --git a/crates/rbitcoin-net/tests/fee_history.rs b/crates/rbitcoin-net/tests/fee_history.rs index 17e56a9942..855f61050c 100644 --- a/crates/rbitcoin-net/tests/fee_history.rs +++ b/crates/rbitcoin-net/tests/fee_history.rs @@ -1,8 +1,6 @@ use rbitcoin_mempool::CONFIDENCE_FAR; -use rbitcoin_mempool::{AnalogHistory, CONFIDENCE_NEAR, HISTORICAL_CONFIDENCE_FAR}; +use rbitcoin_mempool::{AnalogHistory, CONFIDENCE_NEAR}; use rbitcoin_net::fee_history::*; -use std::cmp::Ordering; -use std::collections::{BTreeMap, HashMap}; fn block(rate: Option, bytes: u64) -> HistoricalFeeBlock { HistoricalFeeBlock { diff --git a/crates/rbitcoin-net/tests/fee_history_file.rs b/crates/rbitcoin-net/tests/fee_history_file.rs index 9dbbc29d63..3f17ef65f5 100644 --- a/crates/rbitcoin-net/tests/fee_history_file.rs +++ b/crates/rbitcoin-net/tests/fee_history_file.rs @@ -1,9 +1,6 @@ -use bitcoin::hashes::{sha256d, Hash}; use rbitcoin_net::fee_history::HistoricalFeeBlock; use rbitcoin_net::fee_history_file::*; -use std::fs::{File, OpenOptions}; -use std::io::{self, Write}; -use std::path::Path; +use std::io::Write; fn dir() -> std::path::PathBuf { static N: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); diff --git a/crates/rbitcoin-net/tests/i2p_sam.rs b/crates/rbitcoin-net/tests/i2p_sam.rs index 348e0aba46..542ada4255 100644 --- a/crates/rbitcoin-net/tests/i2p_sam.rs +++ b/crates/rbitcoin-net/tests/i2p_sam.rs @@ -1,11 +1,7 @@ -use bitcoin::hashes::{sha256, Hash}; use rbitcoin_net::error::NetError; use rbitcoin_net::i2p_sam::*; -use std::io::Write; use std::net::SocketAddr; -use std::path::Path; use std::sync::Mutex; -use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::TcpStream; #[tokio::test(flavor = "current_thread")] diff --git a/crates/rbitcoin-net/tests/msg_decode.rs b/crates/rbitcoin-net/tests/msg_decode.rs index 13cb690b9b..dfe6355aab 100644 --- a/crates/rbitcoin-net/tests/msg_decode.rs +++ b/crates/rbitcoin-net/tests/msg_decode.rs @@ -1,13 +1,10 @@ use bitcoin::p2p::message::NetworkMessage; -use bitcoin::p2p::message::RawNetworkMessage; use bitcoin::p2p::Magic; use bitcoin::Network; use rbitcoin_net::codec::FramedMessage; -use rbitcoin_net::error::NetError; use rbitcoin_net::msg_decode::*; +use std::sync::Arc; use std::sync::Mutex; -use std::sync::{Arc, OnceLock}; -use tokio::sync::{OwnedSemaphorePermit, Semaphore}; fn verack_frame() -> FramedMessage { FramedMessage { diff --git a/crates/rbitcoin-net/tests/net_permissions.rs b/crates/rbitcoin-net/tests/net_permissions.rs index 75514f6305..8b51685068 100644 --- a/crates/rbitcoin-net/tests/net_permissions.rs +++ b/crates/rbitcoin-net/tests/net_permissions.rs @@ -1,6 +1,6 @@ use rbitcoin_net::net_permissions::*; use std::net::SocketAddrV4; -use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; +use std::net::{IpAddr, Ipv4Addr, SocketAddr}; fn ip() -> IpAddr { IpAddr::V4(Ipv4Addr::LOCALHOST) diff --git a/crates/rbitcoin-net/tests/netaddr.rs b/crates/rbitcoin-net/tests/netaddr.rs index 1d0eba02ef..9fca0cfae8 100644 --- a/crates/rbitcoin-net/tests/netaddr.rs +++ b/crates/rbitcoin-net/tests/netaddr.rs @@ -1,10 +1,6 @@ use bitcoin::p2p::address::{AddrV2, AddrV2Message}; -use rbitcoin_net::error::NetError; use rbitcoin_net::netaddr::*; -use sha3::{Digest, Sha3_256}; -use std::fmt; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; -use std::str::FromStr; #[test] fn netaddr_onion_parse_roundtrip() { diff --git a/crates/rbitcoin-net/tests/netgroup.rs b/crates/rbitcoin-net/tests/netgroup.rs index 40b0e68f18..f56284c6f9 100644 --- a/crates/rbitcoin-net/tests/netgroup.rs +++ b/crates/rbitcoin-net/tests/netgroup.rs @@ -1,7 +1,6 @@ use rbitcoin_net::asmap::two_prefix_asmap_bytes; use rbitcoin_net::asmap::AsMap; use rbitcoin_net::netgroup::*; -use std::collections::HashSet; use std::net::{IpAddr, SocketAddr}; use std::net::{Ipv4Addr, Ipv6Addr}; diff --git a/crates/rbitcoin-net/tests/parent_req.rs b/crates/rbitcoin-net/tests/parent_req.rs index ab9bb78a45..dd3bdf1115 100644 --- a/crates/rbitcoin-net/tests/parent_req.rs +++ b/crates/rbitcoin-net/tests/parent_req.rs @@ -1,6 +1,5 @@ use rbitcoin_net::tx_relay::parent_req::*; -use rbitcoin_net::tx_relay::{GETDATA_TX_INTERVAL_SECS, MAX_PARENTS_PER_PARK}; -use std::collections::{BTreeMap, HashMap, HashSet}; +use rbitcoin_net::tx_relay::GETDATA_TX_INTERVAL_SECS; #[test] fn txid_parent_already_have_does_not_follow_another_peers_wtxid() { diff --git a/crates/rbitcoin-net/tests/peer/log_text_tests.rs b/crates/rbitcoin-net/tests/peer/log_text_tests.rs index 1d64a8dfc5..8f7f3ece69 100644 --- a/crates/rbitcoin-net/tests/peer/log_text_tests.rs +++ b/crates/rbitcoin-net/tests/peer/log_text_tests.rs @@ -1,40 +1,5 @@ use super::non_version_before_handshake_log; use super::unsupported_before_verack_log; -use bitcoin::bip152::{BlockTransactions, BlockTransactionsRequest, HeaderAndShortIds}; -use bitcoin::hashes::Hash; -use bitcoin::p2p::address::{AddrV2Message, Address}; -use bitcoin::p2p::message::{NetworkMessage, RawNetworkMessage}; -use bitcoin::p2p::message_blockdata::{GetBlocksMessage, GetHeadersMessage, Inventory}; -use bitcoin::p2p::message_compact_blocks::{BlockTxn, CmpctBlock, GetBlockTxn, SendCmpct}; -use bitcoin::p2p::message_network::VersionMessage; -use bitcoin::p2p::{Magic, ServiceFlags, PROTOCOL_VERSION}; -use bitcoin::{Block, BlockHash, Transaction}; -use rbitcoin_net::cache::BlockCache; -use rbitcoin_net::chain::{ - accept_block_header_nodos_log, accept_prev_not_found_log, ignoring_low_work_chain_log, - received_getdata_wtx_log, received_tx_log, synchronizing_blockheaders_log, AcceptOutcome, - ChainHub, -}; -use rbitcoin_net::codec::{ - FramedMessage, MAX_HEADERS_RESULTS, MAX_INV_SIZE, MAX_LOCATOR_SZ, TX_INV_BATCH, -}; -use rbitcoin_net::error::NetError; -use rbitcoin_net::msg_decode::decode_framed_offload; -use rbitcoin_net::peer_dos::{PeerRateLimiter, OVERSIZE_BAN_SCORE, RATE_LIMIT_BAN_SCORE}; -use rbitcoin_net::peers::{CappedSet, PeerOut, PingAction}; -use rbitcoin_net::v2::{ - open_v2, open_v2_with_wire, read_v2_contents, read_v2_frame, read_v2_frame_with_progress, - write_v2_contents, write_v2_msg, write_v2_msg_offload, V2Reader, V2Writer, -}; -use rbitcoin_primitives::Height; -use rbitcoin_query::Query; -use std::collections::{BTreeSet, HashMap, HashSet, VecDeque}; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}; -use std::sync::Arc; -use std::time::{Duration, SystemTime, UNIX_EPOCH}; -use tokio::net::TcpStream; -use tokio::sync::{broadcast, mpsc}; #[test] fn peer_command_logs_have_no_raw_newline() { diff --git a/crates/rbitcoin-net/tests/peer/mod.rs b/crates/rbitcoin-net/tests/peer/mod.rs index e8cb02b011..714235861a 100644 --- a/crates/rbitcoin-net/tests/peer/mod.rs +++ b/crates/rbitcoin-net/tests/peer/mod.rs @@ -6,34 +6,22 @@ use bitcoin::p2p::message::{NetworkMessage, RawNetworkMessage}; use bitcoin::p2p::message_blockdata::{GetBlocksMessage, GetHeadersMessage, Inventory}; use bitcoin::p2p::message_compact_blocks::{BlockTxn, CmpctBlock, GetBlockTxn, SendCmpct}; use bitcoin::p2p::message_network::VersionMessage; -use bitcoin::p2p::{Magic, ServiceFlags, PROTOCOL_VERSION}; +use bitcoin::p2p::{Magic, ServiceFlags}; use bitcoin::script::ScriptBuf; +use bitcoin::BlockHash; use bitcoin::Network; -use bitcoin::{Block, BlockHash, Transaction}; use rbitcoin_net::cache::BlockCache; -use rbitcoin_net::chain::{ - accept_block_header_nodos_log, accept_prev_not_found_log, ignoring_low_work_chain_log, - received_getdata_wtx_log, received_tx_log, synchronizing_blockheaders_log, AcceptOutcome, - ChainHub, -}; -use rbitcoin_net::codec::{ - FramedMessage, MAX_HEADERS_RESULTS, MAX_INV_SIZE, MAX_LOCATOR_SZ, TX_INV_BATCH, -}; +use rbitcoin_net::chain::ChainHub; +use rbitcoin_net::codec::{FramedMessage, MAX_HEADERS_RESULTS, MAX_INV_SIZE, MAX_LOCATOR_SZ}; use rbitcoin_net::error::NetError; -use rbitcoin_net::msg_decode::decode_framed_offload; use rbitcoin_net::peer::*; -use rbitcoin_net::peer_dos::{PeerRateLimiter, OVERSIZE_BAN_SCORE, RATE_LIMIT_BAN_SCORE}; -use rbitcoin_net::peers::{CappedSet, PeerOut, PingAction}; +use rbitcoin_net::peers::{CappedSet, PeerOut}; use rbitcoin_net::seeds::AddrMan; -use rbitcoin_net::v2::{ - open_v2, open_v2_with_wire, read_v2_contents, read_v2_frame, read_v2_frame_with_progress, - write_v2_contents, write_v2_msg, write_v2_msg_offload, V2Reader, V2Writer, -}; use rbitcoin_primitives::Height; use rbitcoin_query::Query; -use std::collections::{BTreeSet, HashMap, HashSet, VecDeque}; +use std::collections::{HashMap, HashSet, VecDeque}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; -use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}; +use std::sync::atomic::{AtomicU32, AtomicUsize, Ordering}; use std::sync::Arc; use std::time::{Duration, SystemTime, UNIX_EPOCH}; use tokio::net::TcpStream; diff --git a/crates/rbitcoin-net/tests/peer_dos.rs b/crates/rbitcoin-net/tests/peer_dos.rs index ac9573bb97..0993cb41a6 100644 --- a/crates/rbitcoin-net/tests/peer_dos.rs +++ b/crates/rbitcoin-net/tests/peer_dos.rs @@ -1,7 +1,5 @@ use rbitcoin_net::peer_dos::*; -use std::sync::Arc; use std::time::{Duration, Instant}; -use tokio::sync::Semaphore; #[test] fn rate_limiter_allows_under_budget() { diff --git a/crates/rbitcoin-net/tests/peers.rs b/crates/rbitcoin-net/tests/peers.rs index 2ffb0c1864..21620bdf9e 100644 --- a/crates/rbitcoin-net/tests/peers.rs +++ b/crates/rbitcoin-net/tests/peers.rs @@ -4,14 +4,11 @@ use bitcoin::p2p::message::NetworkMessage; use bitcoin::p2p::message_network::VersionMessage; use bitcoin::p2p::ServiceFlags; use bitcoin::{BlockHash, Wtxid}; -use rbitcoin_net::error::NetError; pub use rbitcoin_net::peers::*; -use std::collections::{HashMap, HashSet, VecDeque}; -use std::net::{IpAddr, SocketAddr, ToSocketAddrs}; -use std::sync::atomic::{ - AtomicBool, AtomicI64, AtomicU16, AtomicU32, AtomicU64, AtomicUsize, Ordering, -}; -use std::sync::{Arc, Mutex, RwLock, Weak}; +use std::collections::HashSet; +use std::net::{IpAddr, SocketAddr}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex}; use tokio::sync::mpsc; use std::net::Ipv4Addr; diff --git a/crates/rbitcoin-net/tests/perf_meter.rs b/crates/rbitcoin-net/tests/perf_meter.rs index f1f7a779f6..4c44da8789 100644 --- a/crates/rbitcoin-net/tests/perf_meter.rs +++ b/crates/rbitcoin-net/tests/perf_meter.rs @@ -1,5 +1,4 @@ use rbitcoin_net::perf_meter::*; -use std::sync::atomic::{AtomicU64, Ordering}; #[test] fn a_window_sample_leaves_the_running_total() { diff --git a/crates/rbitcoin-net/tests/root.rs b/crates/rbitcoin-net/tests/root.rs index 70e70cfdd3..a01418965a 100644 --- a/crates/rbitcoin-net/tests/root.rs +++ b/crates/rbitcoin-net/tests/root.rs @@ -1,57 +1,3 @@ -use rbitcoin_mempool::MempoolGraphStats; -use rbitcoin_mempool::{AcceptError, SelectBudget, Selected}; -use rbitcoin_net::asmap::{ - AsMap, ASMAP_EIGHT_TRAILING_ZEROS, ASMAP_JUMP_OFF_END, ASMAP_JUMP_PAST_FILE, - ASMAP_JUMP_SHORT_TAIL, ASMAP_MATCH_PAST_END, ASMAP_SECOND_DEFAULT, ASMAP_TRAILING_ONE, - ASMAP_TWO_SHORT_MATCHES, LONE_RETURN_ASMAP, LOOPBACK_ASMAP, TWO_PREFIX_ASMAP, -}; -use rbitcoin_net::cache::BlockCache; -use rbitcoin_net::chain::{ - check_block_proposal_with, AcceptOutcome, ChainHub, ChainTipInfo, TipEvent, -}; -use rbitcoin_net::compact::{ - classify_v2_cmpct_peer, prefilled_indexes_ok, shortid_map_from_txs, try_reconstruct, - v2_header_hashes, CmpctPeerFrame, -}; -use rbitcoin_net::ephemeral::spawn_isolated_broadcast_loop; -use rbitcoin_net::error::NetError; -use rbitcoin_net::eviction::{select_inbound_eviction, InboundEvictCandidate}; -use rbitcoin_net::i2p_sam::{i2p_addr_from_sam_b64, I2pSam}; -use rbitcoin_net::most_work::{sum_work, WorkOverflow}; -use rbitcoin_net::net_permissions::{ - apply_implicit, parse_whitebind, parse_whitelist, NetPermTable, NetPermissionFlags, - WhitebindGrant, WhitelistGrant, DEFAULT_WHITELISTFORCERELAY, DEFAULT_WHITELISTRELAY, -}; -use rbitcoin_net::netaddr::{is_cjdns_ip, NetAddr, OnlyNet}; -use rbitcoin_net::netgroup::netgroup; -use rbitcoin_net::peer::{ - drain_pending_now, flush_tx_invs, force_announce_txid, local_service_flags, run_feeler_timed, - PendingBlocks, V2PlainSession, MAX_SERVE_BLOCKS, -}; -use rbitcoin_net::peer_dos::DEFAULT_MAX_INBOUND; -use rbitcoin_net::peers::{ - connection_counts, outbound_time_offset, parse_peer_addr, parse_peer_addr_with_port, - parse_peer_net, pick_stale_follow_evict, DialRequest, DialTarget, LivePeer, PeerConnType, - PeerHub, PeerInfo, PeerOut, PingAction, -}; -use rbitcoin_net::perf_meter::RequestMeter; -use rbitcoin_net::reactor::BlockingRegion; -use rbitcoin_net::seeds::{ - default_port, default_rpc_port, dns_seeds, fixed_seed_hosts, resolve_all_seeds, - resolve_dns_seeds, resolve_fixed_seeds, socks_dns_seed_dests, AddrMan, PeerEntry, PeerFlags, - MAX_ADDR_MAN, -}; -use rbitcoin_net::serve_perf::{ - format_serve_perf, sample_reset_serve_perf, serve_perf_totals, ServePerfSample, -}; -use rbitcoin_net::service::P2PNode; -use rbitcoin_net::socks::{install_i2p_dialer, Dialer}; -use rbitcoin_net::tx_relay::{ - ElectrumMempoolItem, FeeHistoryBackfillStats, MempoolAnnounce, MempoolHub, MempoolPerfSample, - MempoolTxSnapEntry, MempoolTxSnapshot, -}; -use rbitcoin_net::v2::{encode_v2_contents, parse_v2_regtest, parse_v2_regtest_named, WireBytes}; -use rbitcoin_net::versionbits_warn::warning_strings; use rbitcoin_net::*; #[test] diff --git a/crates/rbitcoin-net/tests/seeds.rs b/crates/rbitcoin-net/tests/seeds.rs index df57716547..f7f27a454e 100644 --- a/crates/rbitcoin-net/tests/seeds.rs +++ b/crates/rbitcoin-net/tests/seeds.rs @@ -1,15 +1,10 @@ -use bitcoin::p2p::ServiceFlags; -use rbitcoin_net::asmap::AsMap; -use rbitcoin_net::netaddr::{addr_allowed, NetAddr, OnlyNet}; -use rbitcoin_net::netgroup::{netgroup, select_diverse}; +use rbitcoin_net::netaddr::{NetAddr, OnlyNet}; +use rbitcoin_net::netgroup::netgroup; use rbitcoin_net::seeds::*; use rbitcoin_primitives::Network; -use std::collections::{HashMap, HashSet}; -use std::io::{BufRead, BufReader, Write}; +use std::collections::HashSet; +use std::net::SocketAddr; use std::net::{IpAddr, Ipv4Addr}; -use std::net::{SocketAddr, ToSocketAddrs}; -use std::path::Path; -use std::sync::Arc; use std::time::{Duration, Instant}; fn addr(o: u8) -> SocketAddr { diff --git a/crates/rbitcoin-net/tests/service.rs b/crates/rbitcoin-net/tests/service.rs index e9acb0d1f5..3d1809b144 100644 --- a/crates/rbitcoin-net/tests/service.rs +++ b/crates/rbitcoin-net/tests/service.rs @@ -1,25 +1,13 @@ use bitcoin::p2p::Magic; -use bitcoin::Block; -use bitcoin::BlockHash; -use rbitcoin_consensus::{signet_magic, ChainParams, Milestone}; -use rbitcoin_net::cache::BlockCache; -use rbitcoin_net::chain::{AcceptOutcome, ChainHub}; +use rbitcoin_consensus::{ChainParams, Milestone}; use rbitcoin_net::error::NetError; -use rbitcoin_net::peer::{ - connect_and_handshake_timed, inbound_connect_and_handshake, peer_session_with, - FollowSessionMeta, HandshakePolicy, HANDSHAKE_TIMEOUT, -}; -use rbitcoin_net::peer_dos::{inbound_semaphore, DEFAULT_MAX_INBOUND}; -use rbitcoin_net::peers::{DialRequest, DialTarget, LivePeer, PeerConnType, PeerHub}; +use rbitcoin_net::peers::PeerConnType; use rbitcoin_net::service::*; -use rbitcoin_net::v2::{V2Reader, V2Writer}; use rbitcoin_query::Query; -use std::net::SocketAddr; -use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; -use std::sync::{Arc, Mutex}; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::Arc; use std::time::Duration; use tokio::net::TcpListener; -use tokio::task::JoinHandle; #[test] fn magic_for_all_networks() { diff --git a/crates/rbitcoin-net/tests/socks.rs b/crates/rbitcoin-net/tests/socks.rs index 229a22da42..e926004f10 100644 --- a/crates/rbitcoin-net/tests/socks.rs +++ b/crates/rbitcoin-net/tests/socks.rs @@ -1,10 +1,8 @@ -use rbitcoin_net::error::NetError; use rbitcoin_net::socks::{ dial_isolated, socks5_connect, socks5_connect_domain, Dialer, ProxyCreds, }; use std::net::Ipv4Addr; use std::net::SocketAddr; -use std::sync::Arc; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::TcpStream; diff --git a/crates/rbitcoin-net/tests/suite.rs b/crates/rbitcoin-net/tests/suite.rs index 7f8bfa89ab..c49a62cae9 100644 --- a/crates/rbitcoin-net/tests/suite.rs +++ b/crates/rbitcoin-net/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod asmap; mod cache; mod chain; diff --git a/crates/rbitcoin-net/tests/tip_accept.rs b/crates/rbitcoin-net/tests/tip_accept.rs index ccfadbd719..c904d36a69 100644 --- a/crates/rbitcoin-net/tests/tip_accept.rs +++ b/crates/rbitcoin-net/tests/tip_accept.rs @@ -1,11 +1,5 @@ use rbitcoin_net::tip_accept::*; -use std::future::Future; -use std::panic::{self, AssertUnwindSafe}; -use std::pin::Pin; -use std::sync::atomic::{AtomicU32, AtomicU64, Ordering}; -use std::sync::mpsc::{SyncSender, TrySendError}; -use std::sync::{Arc, Condvar, Mutex, OnceLock}; -use std::task::{Context, Poll, Waker}; +use std::sync::Arc; use std::thread; #[test] diff --git a/crates/rbitcoin-net/tests/tx_relay.rs b/crates/rbitcoin-net/tests/tx_relay.rs index b6c333bdab..e8b1e3785b 100644 --- a/crates/rbitcoin-net/tests/tx_relay.rs +++ b/crates/rbitcoin-net/tests/tx_relay.rs @@ -1,28 +1,17 @@ -use arc_swap::ArcSwap; use bitcoin::absolute::LockTime; use bitcoin::hashes::Hash; use bitcoin::{Amount, OutPoint, ScriptBuf, Transaction, TxOut, Txid, Wtxid}; -use rbitcoin_mempool::{ - fee_at_target_sat_kvb, fine_candidate_rates, flow_for_depth, frontier_feerate_from_chunks, - hold_defined_then_monotone, min_rate_for_capacity, percentile_sat, published_depth_rate, - weight_above_from_chunks, AcceptError, AcceptResult, ActiveMempool, ChainPrevout, ChainTipCtx, - Chunk, Coin, FeeFlowMeter, SelectBudget, Selected, StockAbove, UtxoProvider, BLOCK_WEIGHT_WU, - MAX_PACKAGE_COUNT, -}; -use rbitcoin_net::fee_history::{FeeHistory, HistoricalFeeBlock}; +use rbitcoin_mempool::{fee_at_target_sat_kvb, AcceptError, Coin, UtxoProvider}; +use rbitcoin_net::fee_history::HistoricalFeeBlock; use rbitcoin_net::fee_history_file; -use rbitcoin_net::perf_meter::{PerfCounter, PerfMax}; -use rbitcoin_net::tx_relay::parent_req::{DueParent, ParentNote}; +use rbitcoin_net::tx_relay::parent_req::ParentNote; use rbitcoin_net::tx_relay::*; -use rbitcoin_primitives::{Fk, Height}; +use rbitcoin_primitives::Height; use rbitcoin_query::Query; -use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque}; -use std::ops::Bound; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering}; -use std::sync::{Arc, Mutex, RwLock}; +use std::collections::{BTreeSet, HashMap}; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; -use tokio::sync::broadcast; use bitcoin::transaction::Version; use bitcoin::{Sequence, TxIn, Witness}; diff --git a/crates/rbitcoin-net/tests/v2.rs b/crates/rbitcoin-net/tests/v2.rs index cb46ea928c..afc51bd6b9 100644 --- a/crates/rbitcoin-net/tests/v2.rs +++ b/crates/rbitcoin-net/tests/v2.rs @@ -1,25 +1,14 @@ -use bip324::futures::{Protocol, ProtocolReader, ProtocolSessionReader, ProtocolWriter}; -use bip324::io::{Payload, ProtocolError, ProtocolFailureSuggestion}; -use bip324::{Error as Bip324Error, InboundCipher, PacketType, Role}; -use bitcoin::consensus::serialize; +use bip324::futures::Protocol; +use bip324::io::Payload; +use bip324::{PacketType, Role}; use bitcoin::p2p::message::NetworkMessage; use bitcoin::p2p::Magic; use bitcoin::Network; -use rbitcoin_net::codec::{ - command_bytes_ok, encode_is_cpu_heavy, FramedMessage, MAX_HEADERS_RESULTS, MAX_INV_SIZE, - MAX_LOCATOR_SZ, MAX_PROTOCOL_MESSAGE_LENGTH, -}; use rbitcoin_net::error::NetError; use rbitcoin_net::v2::*; -use std::pin::Pin; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::Arc; -use std::task::{Context, Poll}; use tokio::io::duplex; use tokio::io::AsyncWriteExt; -use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, BufReader, ReadBuf}; -use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf}; -use tokio::net::TcpStream; +use tokio::io::{AsyncReadExt, BufReader}; fn signet_magic() -> Magic { Magic::from(Network::Signet) diff --git a/crates/rbitcoin-net/tests/versionbits_warn.rs b/crates/rbitcoin-net/tests/versionbits_warn.rs index 6ca02f9d70..e89ca31d41 100644 --- a/crates/rbitcoin-net/tests/versionbits_warn.rs +++ b/crates/rbitcoin-net/tests/versionbits_warn.rs @@ -1,7 +1,6 @@ use rbitcoin_net::versionbits_warn::*; use rbitcoin_primitives::{Height, Network}; use rbitcoin_query::Query; -use std::sync::Mutex; /// Core `WarningBitsConditionChecker`: mainnet keeps 1815 of 2016 (BIP /// 341's 90%), test chains take 75% of the difficulty interval, and each diff --git a/crates/rbitcoin-node/tests/cli.rs b/crates/rbitcoin-node/tests/cli.rs index 3c049621fc..000b36b09e 100644 --- a/crates/rbitcoin-node/tests/cli.rs +++ b/crates/rbitcoin-node/tests/cli.rs @@ -1,12 +1,8 @@ -use rbitcoin_consensus::{default_milestone_height, default_min_chain_work_be}; -use rbitcoin_log::{self, error, info, warn, Level}; +use rbitcoin_consensus::default_milestone_height; use rbitcoin_node::cli::*; +use rbitcoin_node::config::NodeConfig; use rbitcoin_node::config::OPERATOR_ENV_TEST_LOCK; -use rbitcoin_node::config::{ConfApply, NodeConfig}; -use rbitcoin_node::inhibit::SuspendInhibit; -use rbitcoin_node::run::{run_node, run_p2p}; use rbitcoin_primitives::Network; -use rbitcoin_store::HeadScale; use std::ffi::OsString; use std::path::PathBuf; use std::process::ExitCode; diff --git a/crates/rbitcoin-node/tests/config.rs b/crates/rbitcoin-node/tests/config.rs index 8159433be1..42321885b2 100644 --- a/crates/rbitcoin-node/tests/config.rs +++ b/crates/rbitcoin-node/tests/config.rs @@ -1,14 +1,7 @@ -use bitcoin::hex::FromHex; -use bitcoin::ScriptBuf; -use rbitcoin_consensus::{default_milestone_anchor, ChainParams, Milestone}; -use rbitcoin_esplora::EsploraListen; +use rbitcoin_consensus::Milestone; use rbitcoin_node::config::*; -use rbitcoin_node::error::NodeError; -use rbitcoin_primitives::{ - Network, DEFAULT_ELECTRUM_PORT, DEFAULT_ESPLORA_PORT, DEFAULT_HEALTH_PORT, -}; +use rbitcoin_primitives::Network; use rbitcoin_store::HeadScale; -use std::net::SocketAddr; use std::path::{Path, PathBuf}; use std::time::{Duration, SystemTime, UNIX_EPOCH}; diff --git a/crates/rbitcoin-node/tests/error.rs b/crates/rbitcoin-node/tests/error.rs index d6b4035dc2..98bc8e82fa 100644 --- a/crates/rbitcoin-node/tests/error.rs +++ b/crates/rbitcoin-node/tests/error.rs @@ -1,7 +1,6 @@ use rbitcoin_node::error::*; use rbitcoin_primitives::ParseNetworkError; use rbitcoin_store::StoreError; -use std::fmt; use std::path::PathBuf; use std::error::Error; diff --git a/crates/rbitcoin-node/tests/health/metrics.rs b/crates/rbitcoin-node/tests/health/metrics.rs index 8e895604f5..d742444730 100644 --- a/crates/rbitcoin-node/tests/health/metrics.rs +++ b/crates/rbitcoin-node/tests/health/metrics.rs @@ -1,9 +1,5 @@ use rbitcoin_log::progress::Snapshot; -use rbitcoin_net::ChainHub; use rbitcoin_node::health::metrics::*; -use rbitcoin_node::health::{readiness, NodeStatus, Phase}; -use std::fmt::{Display, Write}; -use std::time::UNIX_EPOCH; use std::time::{Duration, SystemTime}; fn stage(stage: &'static str, done: u64) -> Snapshot { diff --git a/crates/rbitcoin-node/tests/health/mod.rs b/crates/rbitcoin-node/tests/health/mod.rs index 8551ce5fa9..f011822774 100644 --- a/crates/rbitcoin-node/tests/health/mod.rs +++ b/crates/rbitcoin-node/tests/health/mod.rs @@ -1,20 +1,11 @@ -use axum::extract::State; -use axum::http::{header, StatusCode}; -use axum::response::{IntoResponse, Response}; use axum::Router; -use rbitcoin_log::{info, progress, warn}; -use rbitcoin_net::{BlockingRegion, ChainHub, MempoolHub, PeerHub}; +use rbitcoin_log::progress; use rbitcoin_node::health::*; use rbitcoin_primitives::Network; use std::net::SocketAddr; -use std::sync::atomic::{AtomicU8, Ordering}; -use std::sync::{Arc, OnceLock}; -use std::time::{Duration, SystemTime}; +use std::sync::Arc; +use std::time::Duration; use tokio::net::TcpListener; -use tokio::sync::Semaphore; -use tokio::task::{JoinError, JoinHandle}; -use tower_http::limit::RequestBodyLimitLayer; -use tower_http::timeout::TimeoutLayer; fn following() -> ReadySnapshot { ReadySnapshot { diff --git a/crates/rbitcoin-node/tests/inhibit.rs b/crates/rbitcoin-node/tests/inhibit.rs index 6e2b13ec24..aca435e8f5 100644 --- a/crates/rbitcoin-node/tests/inhibit.rs +++ b/crates/rbitcoin-node/tests/inhibit.rs @@ -1,6 +1,4 @@ -use rbitcoin_log::{info, warn}; use rbitcoin_node::inhibit::*; -use std::process::{Child, Command, Stdio}; #[test] fn try_start_and_drop_is_safe() { diff --git a/crates/rbitcoin-node/tests/lock.rs b/crates/rbitcoin-node/tests/lock.rs index 3aea6a2c29..d59afbde3d 100644 --- a/crates/rbitcoin-node/tests/lock.rs +++ b/crates/rbitcoin-node/tests/lock.rs @@ -1,9 +1,6 @@ use rbitcoin_node::config::NodeConfig; use rbitcoin_node::error::NodeError; use rbitcoin_node::lock::*; -use std::fs::{File, OpenOptions}; -use std::io; -use std::path::Path; use std::path::PathBuf; use std::time::{SystemTime, UNIX_EPOCH}; diff --git a/crates/rbitcoin-node/tests/regtest_rpc.rs b/crates/rbitcoin-node/tests/regtest_rpc.rs index da44bd4702..d97242c18c 100644 --- a/crates/rbitcoin-node/tests/regtest_rpc.rs +++ b/crates/rbitcoin-node/tests/regtest_rpc.rs @@ -1,7 +1,6 @@ use bitcoin::ScriptBuf; use rbitcoin_consensus::{ChainParams, Milestone}; use rbitcoin_net::ChainHub; -use rbitcoin_node::regtest_rpc::*; use rbitcoin_query::Query; use rbitcoin_rpc::HubRegtest; use rbitcoin_rpc::RpcRegtest; diff --git a/crates/rbitcoin-node/tests/run.rs b/crates/rbitcoin-node/tests/run.rs index d1ad7eeebe..a4b0d3e6c3 100644 --- a/crates/rbitcoin-node/tests/run.rs +++ b/crates/rbitcoin-node/tests/run.rs @@ -1,31 +1,14 @@ -use bitcoin::consensus::Encodable; -use rbitcoin_electrum::{run_electrum, ElectrumConfig, ElectrumHandle, TipNotify}; -use rbitcoin_esplora::{run_esplora, BlockTemplateFn, EsploraConfig, EsploraHandle, EsploraListen}; -use rbitcoin_ibd::{read_platform_rss, tip_perf_json, IbdConfig, TipPerfLog}; -use rbitcoin_log::{debug, enabled, info, warn, Level}; -use rbitcoin_net::{ - default_port, netgroup, sample_reset_serve_perf, socks_dns_seed_dests, AddrMan, AsMap, - BlockingRegion, ChainHub, Dialer, MempoolHub, P2PNode, PeerConnType, TipEvent, -}; -use rbitcoin_node::config::{parse_btc_to_sat, ListenOpts, NodeConfig}; -use rbitcoin_node::error::NodeError; -use rbitcoin_node::health::{run_health, NodeStatus, Phase}; -use rbitcoin_node::regtest_rpc::HubRegtest; +use rbitcoin_ibd::IbdConfig; +use rbitcoin_net::{AddrMan, Dialer, PeerConnType, TipEvent}; +use rbitcoin_node::config::{parse_btc_to_sat, NodeConfig}; use rbitcoin_node::run::*; -use rbitcoin_primitives::Network; -use rbitcoin_query::{spawn_sh_writebehind, Query, SpendSync}; -use rbitcoin_rpc::{ - gbt_template, run_rpc, RpcActive, RpcConfig, RpcContext, RpcHandle, RpcRegtest, -}; -use rbitcoin_store::StoreError; -use rbitcoin_sv2::{run_sv2_tp, Sv2TpConfig, Sv2TpHandle}; +use rbitcoin_query::Query; use std::net::SocketAddr; -use std::path::Path; -use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; -use std::sync::{Arc, OnceLock}; +use std::sync::atomic::AtomicBool; +use std::sync::Arc; use std::time::{Duration, Instant}; use std::time::{SystemTime, UNIX_EPOCH}; -use tokio::sync::{broadcast, Notify}; +use tokio::sync::broadcast; fn tiny_regtest(dir: impl AsRef) -> NodeConfig { NodeConfig::default() .with_datadir(dir.as_ref()) diff --git a/crates/rbitcoin-node/tests/suite.rs b/crates/rbitcoin-node/tests/suite.rs index d6a6e4c5c2..05aab94c46 100644 --- a/crates/rbitcoin-node/tests/suite.rs +++ b/crates/rbitcoin-node/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod cli; mod config; mod error; diff --git a/crates/rbitcoin-primitives/tests/compact.rs b/crates/rbitcoin-primitives/tests/compact.rs index 79a94790cd..5ccd30d2c4 100644 --- a/crates/rbitcoin-primitives/tests/compact.rs +++ b/crates/rbitcoin-primitives/tests/compact.rs @@ -1,5 +1,4 @@ use rbitcoin_primitives::compact::*; -use std::fmt; #[test] fn compact_size_roundtrip() { diff --git a/crates/rbitcoin-primitives/tests/hex.rs b/crates/rbitcoin-primitives/tests/hex.rs index 1c91ff8225..1020845e98 100644 --- a/crates/rbitcoin-primitives/tests/hex.rs +++ b/crates/rbitcoin-primitives/tests/hex.rs @@ -1,6 +1,5 @@ use bitcoin_hashes::{sha256, Hash}; -use hex_conservative::{DisplayHex, FromHex}; -use hex_conservative::{HexToArrayError, HexToBytesError}; +use hex_conservative::FromHex; use rbitcoin_primitives::hex::*; diff --git a/crates/rbitcoin-primitives/tests/merkle.rs b/crates/rbitcoin-primitives/tests/merkle.rs index 7652551bd8..ba784b7c12 100644 --- a/crates/rbitcoin-primitives/tests/merkle.rs +++ b/crates/rbitcoin-primitives/tests/merkle.rs @@ -1,4 +1,3 @@ -use bitcoin_hashes::{sha256, Hash, HashEngine}; use rbitcoin_primitives::merkle::*; #[test] diff --git a/crates/rbitcoin-primitives/tests/root.rs b/crates/rbitcoin-primitives/tests/root.rs index fe3fc637d5..9768030930 100644 --- a/crates/rbitcoin-primitives/tests/root.rs +++ b/crates/rbitcoin-primitives/tests/root.rs @@ -1,23 +1,4 @@ -use hex::{ - decode as hex_decode, display_hash_hex, encode as hex_encode, parse_display_hash32, - HexToArrayError, HexToBytesError, -}; -use rbitcoin_primitives::compact::{ - compact_size_len, read_compact_size, read_compact_size_from, read_uleb128, uleb128_len, - write_compact_size, write_uleb128, write_uleb128_into, PackError, -}; -use rbitcoin_primitives::loc_simd::{deinterleave_pairs_u8x8, inclusive_u8x8_times_8}; -use rbitcoin_primitives::median_time::median_time_past_times; -use rbitcoin_primitives::merkle::{ - merkle_branch, merkle_root_from_branch, merkle_root_from_txids, merkle_root_mutated, -}; -use rbitcoin_primitives::script_sigops::script_sigop_count; -use rbitcoin_primitives::scriptnum::{ - scriptnum_decode, scriptnum_decode_width, scriptnum_encode, scriptnum_is_minimal, - ScriptNumError, -}; use rbitcoin_primitives::*; -use std::fmt; #[test] fn fk_display_and_get() { diff --git a/crates/rbitcoin-primitives/tests/scriptnum.rs b/crates/rbitcoin-primitives/tests/scriptnum.rs index 1543bf709e..93e2719612 100644 --- a/crates/rbitcoin-primitives/tests/scriptnum.rs +++ b/crates/rbitcoin-primitives/tests/scriptnum.rs @@ -1,5 +1,4 @@ use rbitcoin_primitives::scriptnum::*; -use std::fmt; #[test] fn scriptnum_minimal_encoding() { diff --git a/crates/rbitcoin-primitives/tests/suite.rs b/crates/rbitcoin-primitives/tests/suite.rs index 15c55f15f9..fa31620b5c 100644 --- a/crates/rbitcoin-primitives/tests/suite.rs +++ b/crates/rbitcoin-primitives/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod compact; mod hex; mod loc_simd; diff --git a/crates/rbitcoin-query/tests/archive.rs b/crates/rbitcoin-query/tests/archive.rs index 747568c3bb..31ebfa73c7 100644 --- a/crates/rbitcoin-query/tests/archive.rs +++ b/crates/rbitcoin-query/tests/archive.rs @@ -1,11 +1,6 @@ use rbitcoin_primitives::Fk; use rbitcoin_query::testutil::FixtureChain; -use rbitcoin_query::*; use rbitcoin_query::{Query, TxApply, WirePlanNeed}; -use rbitcoin_store::{ - encode_seqsigwit_with_secret, encode_txout_meta_and_outs, encode_unspent_output_into_secret, - encode_wire_seqsigwit_input, seqsigwit_input_len_upper, InputEdge, PackedCreate, -}; use rbitcoin_store::{InputRecord, OutputRecord, TxRecord}; use std::sync::Arc; diff --git a/crates/rbitcoin-query/tests/batch_parents.rs b/crates/rbitcoin-query/tests/batch_parents.rs index 4e96bddbdc..27930603c4 100644 --- a/crates/rbitcoin-query/tests/batch_parents.rs +++ b/crates/rbitcoin-query/tests/batch_parents.rs @@ -1,12 +1,8 @@ -use arc_swap::ArcSwap; use rbitcoin_primitives::Fk; use rbitcoin_query::batch_parents::*; -use rbitcoin_store::{FkMap, FkSet, U32Map, U64Map, U64Set}; -use rbitcoin_store::{OutputRecord, StoreError, TxRecord}; -use std::cell::RefCell; -use std::hash::BuildHasherDefault; -use std::sync::atomic::{AtomicU8, Ordering}; -use std::sync::{Arc, OnceLock}; +use rbitcoin_store::U64Map; +use rbitcoin_store::{OutputRecord, TxRecord}; +use std::sync::Arc; use rbitcoin_store::U64IdentityHasher; diff --git a/crates/rbitcoin-query/tests/bip68_store_tests.rs b/crates/rbitcoin-query/tests/bip68_store_tests.rs index 8858f1fa41..276b38e038 100644 --- a/crates/rbitcoin-query/tests/bip68_store_tests.rs +++ b/crates/rbitcoin-query/tests/bip68_store_tests.rs @@ -1,79 +1,7 @@ //! BIP68 checks that read a confirmed median from the store. #![cfg(test)] use bitcoin::absolute::LockTime; -use bitcoin::block::{Header as BlockHeader, Version as BlockVersion}; -use bitcoin::hashes::Hash; -use bitcoin::transaction::Version as TxVersion; -use bitcoin::{ - Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, - TxMerkleNode, TxOut, Witness, -}; -use rbitcoin_consensus::{ - block_wire_len_from_pres, decode_block_precomputes, pres_for_tip, IdMap, OutPointHasher, - OutPointSet, TxPrecompute, TxidHasher, TxidMap, TxidSet, -}; -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::archive::{ - input_records_from_wire, ArchiveWritePlan, CreatePin, CreatePinArc, CreatePinInner, - WirePlanNeed, -}; -use rbitcoin_query::batch_parents::FkSet; -use rbitcoin_query::batch_parents::{ - layout_covers_need, sparse_spender_rels, BatchParents, FkMap, ParentPinView, - SharedPrevoutScript, U32Map, U64Map, U64Set, -}; -use rbitcoin_query::block_filter::{basic_filter_from_scripts, basic_filter_of}; -use rbitcoin_query::catchup::IndexMode; -use rbitcoin_query::chain_view::{header_lookup_count, ChainView, ChainViewKind}; -use rbitcoin_query::combined_stage::{load_creates_once, CombinedCreate}; -use rbitcoin_query::confirm_error::ConfirmError; -use rbitcoin_query::confirm_load::SpendEdges; -use rbitcoin_query::confirm_stats::{ - add as note_confirm, add_dur as note_confirm_dur, ConfirmStats, ConfirmWindow, LastPinPhases, - LastPlanBatch, LastUnionMiss, LastWritePhases, TipShSnap, -}; -use rbitcoin_query::connect::{spawn_sh_writebehind, ConfirmPrepared}; -use rbitcoin_query::connect_facade::*; -use rbitcoin_query::convert::header_to_record; -use rbitcoin_query::header_read::{ - expected_next_bits, median_time_past, median_time_past_store, validate_header, - validate_header_hashed, -}; -use rbitcoin_query::in_flight::InFlight; -use rbitcoin_query::index_writebehind::{ - build_indexes_released, index_tip_entry, prepare_live_indexes, spawn_index_writebehind, - IndexTipEntry, INDEX_STARTUP_GAP_HEIGHTS, -}; -use rbitcoin_query::reconstruct::{BlockTxStatRows, StampedTxstatBlock}; -use rbitcoin_query::regtest_pad::pad_empty_from; -use rbitcoin_query::resolved_wire::{BlockQueueWaveIntake, ResolvedWire}; -use rbitcoin_query::scripthash::{ - BlockTouch, FilteredHistory, HistoryFilter, HistoryOrder, ScriptHashBalance, - ScriptHashChainStats, ScriptHashHistoryItem, ScriptHashTxSummary, ScriptHashUtxo, ShJoinSlot, -}; -use rbitcoin_query::soft_densify::{ - bq_assign_stop_bytes, soft_ahead_quarter_full, soft_assign_restricted, - soft_confirm_window_covered, soft_confirm_window_n, soft_densify_band_hi, BQ_SOFT_FREE_BYTES, - TIP_HOLE_MIN_AHEAD_BLOCKS, -}; -use rbitcoin_query::sp_read::{tweaks_at_height, tweaks_for_height, tweaks_from_thin_and_body}; -use rbitcoin_query::sp_tweaks::{ThinTweakRangeLimits, ThinTweakRow}; -use rbitcoin_query::spend_sync::SpendSync; -use rbitcoin_query::stamp::{ - fill_missing_parent_ranges, stamp_external_parents, BatchParentIds, ExternalParentStamp, - ParentIdent, -}; -use rbitcoin_query::wave_prevout::SpendEdge; -use rbitcoin_store::{ - script_hash, HeaderRecord, InputRecord, OutputRecord, PointRecord, ScriptHashRecord, - SpTweaksTable, Store, StoreError, StoreLayout, TxRecord, -}; -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; -use std::path::Path; -use std::sync::atomic::{ - AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering as AtomicOrdering, -}; -use std::sync::{Arc, Condvar, Mutex}; +use bitcoin::{Amount, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Witness}; use rbitcoin_consensus::ValidationContext; diff --git a/crates/rbitcoin-query/tests/block_filter.rs b/crates/rbitcoin-query/tests/block_filter.rs index 2445b7736a..981e4cd377 100644 --- a/crates/rbitcoin-query/tests/block_filter.rs +++ b/crates/rbitcoin-query/tests/block_filter.rs @@ -1,16 +1,7 @@ use bitcoin::absolute::LockTime; -use bitcoin::bip158::{BlockFilter, FilterHash, FilterHeader, GcsFilterWriter}; use bitcoin::block::{Header, Version as BlockVersion}; use bitcoin::hashes::Hash; use bitcoin::{Block, OutPoint}; -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::{Query, QueryError}; -use rbitcoin_store::{ - read_index_window, BlockFilterRecord, BlockFilterSlot, BlockFilterTable, IndexHeight, - IndexWindow, StoreError, -}; -use std::sync::atomic::Ordering; -use std::sync::{Condvar, Mutex}; use bitcoin::transaction::Version; use bitcoin::{Amount, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Txid, Witness}; diff --git a/crates/rbitcoin-query/tests/block_pipeline/mod.rs b/crates/rbitcoin-query/tests/block_pipeline/mod.rs index 48a7be040c..fe06e6312b 100644 --- a/crates/rbitcoin-query/tests/block_pipeline/mod.rs +++ b/crates/rbitcoin-query/tests/block_pipeline/mod.rs @@ -1,15 +1,2 @@ -use bitcoin::block::Block; -use bitcoin::hashes::Hash; -use bitcoin::ScriptBuf; -use bitcoin::{Amount, OutPoint, Transaction, TxOut}; -use rbitcoin_consensus::block::{ - JobPrevouts, PendingCreates, ScriptCheckJob, ScriptVerifyFlags, TxidMap, -}; -use rbitcoin_consensus::ChainParams; -use rbitcoin_primitives::Height; -use rbitcoin_query::{ConfirmError, FkMap, Query, U32Map, U64Map}; -use std::hash::BuildHasherDefault; -use std::sync::Arc; -use std::time::Instant; mod overlay_meta_skip_tests; mod run_create_height_tests; diff --git a/crates/rbitcoin-query/tests/block_pipeline/overlay_meta_skip_tests.rs b/crates/rbitcoin-query/tests/block_pipeline/overlay_meta_skip_tests.rs index 3162c2b8e0..9c0918ae8a 100644 --- a/crates/rbitcoin-query/tests/block_pipeline/overlay_meta_skip_tests.rs +++ b/crates/rbitcoin-query/tests/block_pipeline/overlay_meta_skip_tests.rs @@ -1,18 +1,6 @@ -use bitcoin::block::Block; -use bitcoin::hashes::Hash; -use bitcoin::ScriptBuf; -use bitcoin::{Amount, OutPoint, Transaction, TxOut}; -use rbitcoin_consensus::block::{ - JobPrevouts, PendingCreates, ScriptCheckJob, ScriptVerifyFlags, TxidMap, -}; -use rbitcoin_consensus::ChainParams; use rbitcoin_primitives::Fk; -use rbitcoin_primitives::Height; use rbitcoin_query::block_pipeline::*; -use rbitcoin_query::{ConfirmError, FkMap, Query, U32Map, U64Map}; -use std::hash::BuildHasherDefault; -use std::sync::Arc; -use std::time::Instant; +use rbitcoin_query::FkMap; fn spends(rows: &[(u32, Fk, Fk, u32)]) -> Vec<([u8; 32], u32, Fk, Fk, u32)> { rows.iter() diff --git a/crates/rbitcoin-query/tests/block_pipeline/run_create_height_tests.rs b/crates/rbitcoin-query/tests/block_pipeline/run_create_height_tests.rs index 3a3f90512a..ecf16b9753 100644 --- a/crates/rbitcoin-query/tests/block_pipeline/run_create_height_tests.rs +++ b/crates/rbitcoin-query/tests/block_pipeline/run_create_height_tests.rs @@ -1,18 +1,5 @@ -use bitcoin::block::Block; -use bitcoin::hashes::Hash; -use bitcoin::ScriptBuf; -use bitcoin::{Amount, OutPoint, Transaction, TxOut}; -use rbitcoin_consensus::block::{ - JobPrevouts, PendingCreates, ScriptCheckJob, ScriptVerifyFlags, TxidMap, -}; -use rbitcoin_consensus::ChainParams; use rbitcoin_primitives::Fk; -use rbitcoin_primitives::Height; use rbitcoin_query::block_pipeline::RunCreateHeight; -use rbitcoin_query::{ConfirmError, FkMap, Query, U32Map, U64Map}; -use std::hash::BuildHasherDefault; -use std::sync::Arc; -use std::time::Instant; fn fk(id: u64) -> Fk { Fk(id) diff --git a/crates/rbitcoin-query/tests/bq_lock_pin.rs b/crates/rbitcoin-query/tests/bq_lock_pin.rs index bc5aa57e41..07599133c7 100644 --- a/crates/rbitcoin-query/tests/bq_lock_pin.rs +++ b/crates/rbitcoin-query/tests/bq_lock_pin.rs @@ -1,79 +1,7 @@ //! Pins: getdata→BQ does not take lookup's decoded-stash lock, and queue //! ids stay unique in enqueue order. -use bitcoin::absolute::LockTime; -use bitcoin::block::{Header as BlockHeader, Version as BlockVersion}; -use bitcoin::hashes::Hash; -use bitcoin::transaction::Version as TxVersion; -use bitcoin::{ - Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, - TxMerkleNode, TxOut, Witness, -}; -use rbitcoin_consensus::{ - block_wire_len_from_pres, decode_block_precomputes, pres_for_tip, IdMap, OutPointHasher, - OutPointSet, TxPrecompute, TxidHasher, TxidMap, TxidSet, -}; -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::archive::{ - input_records_from_wire, ArchiveWritePlan, CreatePin, CreatePinArc, CreatePinInner, - WirePlanNeed, -}; -use rbitcoin_query::batch_parents::FkSet; -use rbitcoin_query::batch_parents::{ - layout_covers_need, sparse_spender_rels, BatchParents, FkMap, ParentPinView, - SharedPrevoutScript, U32Map, U64Map, U64Set, -}; -use rbitcoin_query::block_filter::{basic_filter_from_scripts, basic_filter_of}; -use rbitcoin_query::catchup::IndexMode; -use rbitcoin_query::chain_view::{header_lookup_count, ChainView, ChainViewKind}; -use rbitcoin_query::combined_stage::{load_creates_once, CombinedCreate}; -use rbitcoin_query::confirm_error::ConfirmError; -use rbitcoin_query::confirm_load::SpendEdges; -use rbitcoin_query::confirm_stats::{ - add as note_confirm, add_dur as note_confirm_dur, ConfirmStats, ConfirmWindow, LastPinPhases, - LastPlanBatch, LastUnionMiss, LastWritePhases, TipShSnap, -}; -use rbitcoin_query::connect::{spawn_sh_writebehind, ConfirmPrepared}; -use rbitcoin_query::connect_facade::*; -use rbitcoin_query::convert::header_to_record; -use rbitcoin_query::header_read::{ - expected_next_bits, median_time_past, median_time_past_store, validate_header, - validate_header_hashed, -}; -use rbitcoin_query::in_flight::InFlight; -use rbitcoin_query::index_writebehind::{ - build_indexes_released, index_tip_entry, prepare_live_indexes, spawn_index_writebehind, - IndexTipEntry, INDEX_STARTUP_GAP_HEIGHTS, -}; -use rbitcoin_query::reconstruct::{BlockTxStatRows, StampedTxstatBlock}; -use rbitcoin_query::regtest_pad::pad_empty_from; -use rbitcoin_query::resolved_wire::{BlockQueueWaveIntake, ResolvedWire}; -use rbitcoin_query::scripthash::{ - BlockTouch, FilteredHistory, HistoryFilter, HistoryOrder, ScriptHashBalance, - ScriptHashChainStats, ScriptHashHistoryItem, ScriptHashTxSummary, ScriptHashUtxo, ShJoinSlot, -}; -use rbitcoin_query::soft_densify::{ - bq_assign_stop_bytes, soft_ahead_quarter_full, soft_assign_restricted, - soft_confirm_window_covered, soft_confirm_window_n, soft_densify_band_hi, BQ_SOFT_FREE_BYTES, - TIP_HOLE_MIN_AHEAD_BLOCKS, -}; -use rbitcoin_query::sp_read::{tweaks_at_height, tweaks_for_height, tweaks_from_thin_and_body}; -use rbitcoin_query::sp_tweaks::{ThinTweakRangeLimits, ThinTweakRow}; -use rbitcoin_query::spend_sync::SpendSync; -use rbitcoin_query::stamp::{ - fill_missing_parent_ranges, stamp_external_parents, BatchParentIds, ExternalParentStamp, - ParentIdent, -}; -use rbitcoin_query::wave_prevout::SpendEdge; -use rbitcoin_store::{ - script_hash, HeaderRecord, InputRecord, OutputRecord, PointRecord, ScriptHashRecord, - SpTweaksTable, Store, StoreError, StoreLayout, TxRecord, -}; -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; -use std::path::Path; -use std::sync::atomic::{ - AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering as AtomicOrdering, -}; -use std::sync::{Arc, Condvar, Mutex}; +use std::sync::atomic::AtomicU64; +use std::sync::Arc; use std::panic::AssertUnwindSafe; use std::sync::atomic::Ordering; diff --git a/crates/rbitcoin-query/tests/catchup.rs b/crates/rbitcoin-query/tests/catchup.rs index 0a7a64f83e..73f3a8acb1 100644 --- a/crates/rbitcoin-query/tests/catchup.rs +++ b/crates/rbitcoin-query/tests/catchup.rs @@ -3,10 +3,8 @@ use rbitcoin_query::catchup::*; use rbitcoin_query::sh_builder::{load_seal, sh_force_rebuild, store_seal}; use rbitcoin_query::testutil::FixtureChain; use rbitcoin_query::Query; -use rbitcoin_query::*; use rbitcoin_store::StoreError; use rbitcoin_store::{HeaderRecord, InputRecord, OutputRecord, TxRecord}; -use std::sync::atomic::Ordering; use std::sync::Mutex; /// Serialize FORCE_REBUILD env mutations (parallel tests share process env). diff --git a/crates/rbitcoin-query/tests/combined_stage.rs b/crates/rbitcoin-query/tests/combined_stage.rs index 5f94845661..04e27701ba 100644 --- a/crates/rbitcoin-query/tests/combined_stage.rs +++ b/crates/rbitcoin-query/tests/combined_stage.rs @@ -1,10 +1,7 @@ use rbitcoin_primitives::Fk; use rbitcoin_query::combined_stage::*; use rbitcoin_query::Query; -use rbitcoin_store::{ - decode_packed_tx_outs_with_spender_rels_secret, decode_packed_tx_with_spender_rels_secret, - IdxBodyJob, IdxBodyMode, Store, StoreError, StoreSecret, -}; +use rbitcoin_store::{decode_packed_tx_with_spender_rels_secret, IdxBodyMode}; use rbitcoin_store::{InputRecord, OutputRecord, TxRecord}; fn temp_query() -> (rbitcoin_query::testutil::TempDir, Query) { diff --git a/crates/rbitcoin-query/tests/confirm_error.rs b/crates/rbitcoin-query/tests/confirm_error.rs index abb9143466..c85faa3ef9 100644 --- a/crates/rbitcoin-query/tests/confirm_error.rs +++ b/crates/rbitcoin-query/tests/confirm_error.rs @@ -1,8 +1,6 @@ use rbitcoin_consensus::ConsensusError; -use rbitcoin_query::confirm_error::*; use rbitcoin_query::ConfirmError; use rbitcoin_store::StoreError; -use std::fmt; #[test] fn uring_session_fault_covers_leftover_and_submit() { diff --git a/crates/rbitcoin-query/tests/confirm_parent_cache.rs b/crates/rbitcoin-query/tests/confirm_parent_cache.rs index f6ae0da9ff..fd1bf1fd7f 100644 --- a/crates/rbitcoin-query/tests/confirm_parent_cache.rs +++ b/crates/rbitcoin-query/tests/confirm_parent_cache.rs @@ -1,9 +1,6 @@ use rbitcoin_primitives::Fk; use rbitcoin_query::confirm_parent_cache::*; -use rbitcoin_query::U32Map; use rbitcoin_store::HeaderRecord; -use std::collections::HashMap; -use std::sync::{Arc, Mutex}; fn header_rec(hash: [u8; 32]) -> HeaderRecord { HeaderRecord { diff --git a/crates/rbitcoin-query/tests/confirm_run/bq_resolve.rs b/crates/rbitcoin-query/tests/confirm_run/bq_resolve.rs index 55051597a1..e8c78e2f96 100644 --- a/crates/rbitcoin-query/tests/confirm_run/bq_resolve.rs +++ b/crates/rbitcoin-query/tests/confirm_run/bq_resolve.rs @@ -10,18 +10,13 @@ use bitcoin::{ }; use rbitcoin_consensus::mine_empty_regtest; use rbitcoin_consensus::{ChainParams, Milestone}; -use rbitcoin_primitives::Fk; use rbitcoin_primitives::Height; use rbitcoin_query::accept_and_connect_block; use rbitcoin_query::confirm_run::bq_resolve::*; -use rbitcoin_query::confirm_run::*; use rbitcoin_query::Query; -use rbitcoin_query::{ - BatchParentIds, IdMap, ResolvedWire, TxPrecompute, TxidHasher, U32Map, U64Map, -}; -use std::collections::{HashMap, HashSet}; +use rbitcoin_query::{TxPrecompute, TxidHasher}; +use std::collections::HashSet; use std::hash::BuildHasherDefault; -use std::sync::Arc; fn tmp_query() -> (rbitcoin_query::testutil::TempDir, Query) { rbitcoin_query::testutil::tiny_query_labeled("bq-resolve") } diff --git a/crates/rbitcoin-query/tests/confirm_run/index.rs b/crates/rbitcoin-query/tests/confirm_run/index.rs index 40e69e4145..93aed28336 100644 --- a/crates/rbitcoin-query/tests/confirm_run/index.rs +++ b/crates/rbitcoin-query/tests/confirm_run/index.rs @@ -1,17 +1,12 @@ use bitcoin::hashes::Hash; -use bitcoin::{Amount, Block, ScriptBuf, Transaction, TxOut}; +use bitcoin::{Amount, Transaction, TxOut}; use rbitcoin_consensus::silent_payments::tweak_from_tx; -use rbitcoin_consensus::ConsensusError; use rbitcoin_primitives::{Fk, Height}; use rbitcoin_query::confirm_run::index::*; use rbitcoin_query::confirm_run::{LoadedBatch, Prepared}; -use rbitcoin_query::index_rows::{self, IndexRows}; use rbitcoin_query::testutil::tiny_query_labeled; -use rbitcoin_query::{ConfirmError, ParentPinView, Query}; -use rbitcoin_store::StoreError; -use std::collections::HashMap; -use std::sync::{Arc, OnceLock}; -use std::time::Instant; +use rbitcoin_query::Query; +use std::sync::Arc; use bitcoin::absolute::LockTime; use bitcoin::hashes::hash160; diff --git a/crates/rbitcoin-query/tests/confirm_run/lookup.rs b/crates/rbitcoin-query/tests/confirm_run/lookup.rs index 29867bc959..d735958968 100644 --- a/crates/rbitcoin-query/tests/confirm_run/lookup.rs +++ b/crates/rbitcoin-query/tests/confirm_run/lookup.rs @@ -6,7 +6,6 @@ use bitcoin::{ TxOut, Txid, Witness, }; use rbitcoin_consensus::{ChainParams, ConsensusError, Milestone}; -use rbitcoin_primitives::Fk; use rbitcoin_primitives::Height; use rbitcoin_query::confirm_run::lookup::*; use rbitcoin_query::confirm_run::*; diff --git a/crates/rbitcoin-query/tests/confirm_run/mod.rs b/crates/rbitcoin-query/tests/confirm_run/mod.rs index 0a135bae72..8130f7b5ae 100644 --- a/crates/rbitcoin-query/tests/confirm_run/mod.rs +++ b/crates/rbitcoin-query/tests/confirm_run/mod.rs @@ -1,33 +1,3 @@ -use bitcoin::hashes::Hash; -use bitcoin::Block; -use rbitcoin_consensus::block::{block_has_witness_from_pres, ScriptCheckJob, ValidationContext}; -use rbitcoin_consensus::header::pow_hash_meets_target; -use rbitcoin_consensus::{ChainParams, ConsensusError, Milestone}; -use rbitcoin_primitives::Height; -use rbitcoin_query::block_pipeline::{assemble_block_prevouts, structural_validate_spends}; -use rbitcoin_query::confirm_run::bq_resolve::{ - confirm_bq_resolve_wave_capped, take_wave_items_for_load, BqResolveWave, - BQ_RESOLVE_WAVE_MAX_BLOCKS, BQ_RESOLVE_WAVE_MAX_INPUTS, -}; -use rbitcoin_query::confirm_run::lookup::{ - confirm_wire_load_from_plan, confirm_wire_lookup_stamp, parent_missing_from_chain, - ParentPinStamp, PlanStampOutcome, WireBlockIn, -}; -use rbitcoin_query::confirm_run::phases::{assemble_run, Assembled}; -use rbitcoin_query::confirm_run::pin::{collect_spend_abs_after_fill, pin_for_wire_batch}; -use rbitcoin_query::confirm_run::scripts::{confirm_scripts_phase, drive_script_waves_with}; -use rbitcoin_query::confirm_run::write::finish_post_commit; -use rbitcoin_query::confirm_run::write::{ - confirm_write_phase, confirm_write_phase_or_return, finish_post_commit_hashes, - replay_spend_annotations, -}; -use rbitcoin_query::header_read::validate_header_hashed; -use rbitcoin_query::ConfirmError; -use rbitcoin_query::{FkMap, Query, U32Map, U64Map}; -use rbitcoin_store::{StoreError, WriteIoBackend}; -use std::sync::atomic::Ordering; -use std::sync::Arc; -use std::time::Instant; mod bq_resolve; mod index; mod lookup; diff --git a/crates/rbitcoin-query/tests/confirm_run/phases.rs b/crates/rbitcoin-query/tests/confirm_run/phases.rs index a59674d73e..c9c881974c 100644 --- a/crates/rbitcoin-query/tests/confirm_run/phases.rs +++ b/crates/rbitcoin-query/tests/confirm_run/phases.rs @@ -1,7 +1,5 @@ use bitcoin::hashes::Hash; use rbitcoin_query::confirm_run::*; -use rbitcoin_query::FkMap; -use rbitcoin_query::Query; use bitcoin::blockdata::constants; use bitcoin::ScriptBuf; diff --git a/crates/rbitcoin-query/tests/confirm_run/spend_durable_tests.rs b/crates/rbitcoin-query/tests/confirm_run/spend_durable_tests.rs index a6764e7456..9b1c4d15b8 100644 --- a/crates/rbitcoin-query/tests/confirm_run/spend_durable_tests.rs +++ b/crates/rbitcoin-query/tests/confirm_run/spend_durable_tests.rs @@ -1,34 +1,9 @@ //! Spend annotations lost after the tip seal must not make that output spendable. use bitcoin::hashes::Hash; use bitcoin::Block; -use rbitcoin_consensus::block::{block_has_witness_from_pres, ScriptCheckJob, ValidationContext}; -use rbitcoin_consensus::header::pow_hash_meets_target; use rbitcoin_consensus::{ChainParams, ConsensusError, Milestone}; use rbitcoin_primitives::Height; -use rbitcoin_query::block_pipeline::{assemble_block_prevouts, structural_validate_spends}; -use rbitcoin_query::confirm_run::bq_resolve::{ - confirm_bq_resolve_wave_capped, take_wave_items_for_load, BqResolveWave, - BQ_RESOLVE_WAVE_MAX_BLOCKS, BQ_RESOLVE_WAVE_MAX_INPUTS, -}; -use rbitcoin_query::confirm_run::lookup::{ - confirm_wire_load_from_plan, confirm_wire_lookup_stamp, parent_missing_from_chain, - ParentPinStamp, PlanStampOutcome, WireBlockIn, -}; -use rbitcoin_query::confirm_run::phases::{assemble_run, Assembled}; -use rbitcoin_query::confirm_run::pin::{collect_spend_abs_after_fill, pin_for_wire_batch}; -use rbitcoin_query::confirm_run::scripts::{confirm_scripts_phase, drive_script_waves_with}; -use rbitcoin_query::confirm_run::write::finish_post_commit; -use rbitcoin_query::confirm_run::write::{ - confirm_write_phase, confirm_write_phase_or_return, finish_post_commit_hashes, - replay_spend_annotations, -}; -use rbitcoin_query::header_read::validate_header_hashed; use rbitcoin_query::ConfirmError; -use rbitcoin_query::{FkMap, Query, U32Map, U64Map}; -use rbitcoin_store::{StoreError, WriteIoBackend}; -use std::sync::atomic::Ordering; -use std::sync::Arc; -use std::time::Instant; use std::io::{Seek, SeekFrom, Write}; diff --git a/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs b/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs index b8a2146b83..297e63742d 100644 --- a/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs +++ b/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs @@ -1,34 +1,5 @@ //! Confirm_run unit tests (peeled from confirm_run.rs). -use bitcoin::hashes::Hash; -use bitcoin::Block; -use rbitcoin_consensus::block::{block_has_witness_from_pres, ScriptCheckJob, ValidationContext}; -use rbitcoin_consensus::header::pow_hash_meets_target; -use rbitcoin_consensus::{ChainParams, ConsensusError, Milestone}; -use rbitcoin_primitives::Height; -use rbitcoin_query::block_pipeline::{assemble_block_prevouts, structural_validate_spends}; -use rbitcoin_query::confirm_run::bq_resolve::{ - confirm_bq_resolve_wave_capped, take_wave_items_for_load, BqResolveWave, - BQ_RESOLVE_WAVE_MAX_BLOCKS, BQ_RESOLVE_WAVE_MAX_INPUTS, -}; -use rbitcoin_query::confirm_run::lookup::{ - confirm_wire_load_from_plan, confirm_wire_lookup_stamp, parent_missing_from_chain, - ParentPinStamp, PlanStampOutcome, WireBlockIn, -}; -use rbitcoin_query::confirm_run::phases::{assemble_run, Assembled}; -use rbitcoin_query::confirm_run::pin::{collect_spend_abs_after_fill, pin_for_wire_batch}; -use rbitcoin_query::confirm_run::scripts::{confirm_scripts_phase, drive_script_waves_with}; -use rbitcoin_query::confirm_run::write::finish_post_commit; -use rbitcoin_query::confirm_run::write::{ - confirm_write_phase, confirm_write_phase_or_return, finish_post_commit_hashes, - replay_spend_annotations, -}; -use rbitcoin_query::header_read::validate_header_hashed; -use rbitcoin_query::ConfirmError; -use rbitcoin_query::{FkMap, Query, U32Map, U64Map}; -use rbitcoin_store::{StoreError, WriteIoBackend}; -use std::sync::atomic::Ordering; -use std::sync::Arc; -use std::time::Instant; +use rbitcoin_consensus::{ChainParams, Milestone}; use rbitcoin_query::confirm_run::{ confirm_archive_kind, write_batch_vs_tip, write_height_needed, ConfirmArchiveKind, diff --git a/crates/rbitcoin-query/tests/confirm_stats.rs b/crates/rbitcoin-query/tests/confirm_stats.rs index 7c2f6857e6..14fb15a6f9 100644 --- a/crates/rbitcoin-query/tests/confirm_stats.rs +++ b/crates/rbitcoin-query/tests/confirm_stats.rs @@ -1,6 +1,4 @@ use rbitcoin_query::confirm_stats::*; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::time::Duration; #[test] fn last_union_miss_roundtrips_miss_on_codes() { diff --git a/crates/rbitcoin-query/tests/connect_facade/coverage_tests.rs b/crates/rbitcoin-query/tests/connect_facade/coverage_tests.rs index b4615f735e..5974d3c417 100644 --- a/crates/rbitcoin-query/tests/connect_facade/coverage_tests.rs +++ b/crates/rbitcoin-query/tests/connect_facade/coverage_tests.rs @@ -1,26 +1,10 @@ use bitcoin::hashes::Hash; -use bitcoin::Block; -use rbitcoin_consensus::block::{validate_block_structure_hashed, ValidationContext}; -use rbitcoin_consensus::unpark_script_publisher; use rbitcoin_consensus::{ChainParams, Milestone}; -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::confirm_run; -use rbitcoin_query::confirm_run::{ - confirm_bq_resolve_wave_capped, confirm_scripts_phase, confirm_wire_load_from_plan, - confirm_wire_load_phase, confirm_wire_load_phase_pipelined, confirm_wire_lookup_stamp, - confirm_wire_run, confirm_wire_run_preverified, confirm_write_phase, - confirm_write_phase_or_return, drive_script_waves_with, finish_post_commit_hashes, - parent_missing_from_chain, replay_spend_annotations, take_wave_items_for_load, BqResolveWave, - ConfirmLoadOutcome, ConfirmScriptOutcome, LoadedBatch, PlanStampOutcome, ScriptOkBatch, - ScriptPreverified, WireBlockIn, WireLoadPipeline, BQ_RESOLVE_WAVE_MAX_BLOCKS, - BQ_RESOLVE_WAVE_MAX_INPUTS, -}; +use rbitcoin_primitives::Height; +use rbitcoin_query::confirm_run::confirm_wire_run; use rbitcoin_query::connect_facade::*; -use rbitcoin_query::convert::{block_to_apply, block_to_apply_with_txids_prev, header_to_record}; use rbitcoin_query::ConfirmError; -use rbitcoin_query::{Query, TxApply, TxPrecompute, WirePlanNeed}; -use rbitcoin_store::HeaderRecord; -use std::sync::Arc; +use rbitcoin_query::Query; use bitcoin::absolute::LockTime; use bitcoin::block::Version; diff --git a/crates/rbitcoin-query/tests/connect_facade/mod.rs b/crates/rbitcoin-query/tests/connect_facade/mod.rs index dab9a8636b..33b5bb4cf6 100644 --- a/crates/rbitcoin-query/tests/connect_facade/mod.rs +++ b/crates/rbitcoin-query/tests/connect_facade/mod.rs @@ -1,23 +1 @@ -use bitcoin::hashes::Hash; -use bitcoin::Block; -use rbitcoin_consensus::block::{validate_block_structure_hashed, ValidationContext}; -use rbitcoin_consensus::unpark_script_publisher; -use rbitcoin_consensus::{ChainParams, Milestone}; -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::confirm_run; -use rbitcoin_query::confirm_run::{ - confirm_bq_resolve_wave_capped, confirm_scripts_phase, confirm_wire_load_from_plan, - confirm_wire_load_phase, confirm_wire_load_phase_pipelined, confirm_wire_lookup_stamp, - confirm_wire_run, confirm_wire_run_preverified, confirm_write_phase, - confirm_write_phase_or_return, drive_script_waves_with, finish_post_commit_hashes, - parent_missing_from_chain, replay_spend_annotations, take_wave_items_for_load, BqResolveWave, - ConfirmLoadOutcome, ConfirmScriptOutcome, LoadedBatch, PlanStampOutcome, ScriptOkBatch, - ScriptPreverified, WireBlockIn, WireLoadPipeline, BQ_RESOLVE_WAVE_MAX_BLOCKS, - BQ_RESOLVE_WAVE_MAX_INPUTS, -}; -use rbitcoin_query::convert::{block_to_apply, block_to_apply_with_txids_prev, header_to_record}; -use rbitcoin_query::ConfirmError; -use rbitcoin_query::{Query, TxApply, TxPrecompute, WirePlanNeed}; -use rbitcoin_store::HeaderRecord; -use std::sync::Arc; mod coverage_tests; diff --git a/crates/rbitcoin-query/tests/convert.rs b/crates/rbitcoin-query/tests/convert.rs index ac8d5dcacc..d8680ca76f 100644 --- a/crates/rbitcoin-query/tests/convert.rs +++ b/crates/rbitcoin-query/tests/convert.rs @@ -12,8 +12,6 @@ use rbitcoin_consensus::ConsensusError; use rbitcoin_primitives::Fk; use rbitcoin_query::convert::*; use rbitcoin_query::ConfirmError; -use rbitcoin_query::{Query, TxApply}; -use rbitcoin_store::{HeaderRecord, InputRecord, OutputRecord, TxRecord}; #[test] fn header_to_record_stores_caller_hash() { diff --git a/crates/rbitcoin-query/tests/header_store_tests.rs b/crates/rbitcoin-query/tests/header_store_tests.rs index 9ba14bcdb3..c0a5b39ba4 100644 --- a/crates/rbitcoin-query/tests/header_store_tests.rs +++ b/crates/rbitcoin-query/tests/header_store_tests.rs @@ -1,79 +1,13 @@ //! Store-backed header reads. Rule rejects stay in `rbitcoin_consensus::check_header`. #![cfg(test)] -use bitcoin::absolute::LockTime; -use bitcoin::block::{Header as BlockHeader, Version as BlockVersion}; use bitcoin::hashes::Hash; -use bitcoin::transaction::Version as TxVersion; -use bitcoin::{ - Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, - TxMerkleNode, TxOut, Witness, -}; -use rbitcoin_consensus::{ - block_wire_len_from_pres, decode_block_precomputes, pres_for_tip, IdMap, OutPointHasher, - OutPointSet, TxPrecompute, TxidHasher, TxidMap, TxidSet, -}; +use bitcoin::CompactTarget; use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::archive::{ - input_records_from_wire, ArchiveWritePlan, CreatePin, CreatePinArc, CreatePinInner, - WirePlanNeed, -}; -use rbitcoin_query::batch_parents::FkSet; -use rbitcoin_query::batch_parents::{ - layout_covers_need, sparse_spender_rels, BatchParents, FkMap, ParentPinView, - SharedPrevoutScript, U32Map, U64Map, U64Set, -}; -use rbitcoin_query::block_filter::{basic_filter_from_scripts, basic_filter_of}; -use rbitcoin_query::catchup::IndexMode; -use rbitcoin_query::chain_view::{header_lookup_count, ChainView, ChainViewKind}; -use rbitcoin_query::combined_stage::{load_creates_once, CombinedCreate}; use rbitcoin_query::confirm_error::ConfirmError; -use rbitcoin_query::confirm_load::SpendEdges; -use rbitcoin_query::confirm_stats::{ - add as note_confirm, add_dur as note_confirm_dur, ConfirmStats, ConfirmWindow, LastPinPhases, - LastPlanBatch, LastUnionMiss, LastWritePhases, TipShSnap, -}; -use rbitcoin_query::connect::{spawn_sh_writebehind, ConfirmPrepared}; -use rbitcoin_query::connect_facade::*; -use rbitcoin_query::convert::header_to_record; use rbitcoin_query::header_read::{ expected_next_bits, median_time_past, median_time_past_store, validate_header, - validate_header_hashed, -}; -use rbitcoin_query::in_flight::InFlight; -use rbitcoin_query::index_writebehind::{ - build_indexes_released, index_tip_entry, prepare_live_indexes, spawn_index_writebehind, - IndexTipEntry, INDEX_STARTUP_GAP_HEIGHTS, -}; -use rbitcoin_query::reconstruct::{BlockTxStatRows, StampedTxstatBlock}; -use rbitcoin_query::regtest_pad::pad_empty_from; -use rbitcoin_query::resolved_wire::{BlockQueueWaveIntake, ResolvedWire}; -use rbitcoin_query::scripthash::{ - BlockTouch, FilteredHistory, HistoryFilter, HistoryOrder, ScriptHashBalance, - ScriptHashChainStats, ScriptHashHistoryItem, ScriptHashTxSummary, ScriptHashUtxo, ShJoinSlot, -}; -use rbitcoin_query::soft_densify::{ - bq_assign_stop_bytes, soft_ahead_quarter_full, soft_assign_restricted, - soft_confirm_window_covered, soft_confirm_window_n, soft_densify_band_hi, BQ_SOFT_FREE_BYTES, - TIP_HOLE_MIN_AHEAD_BLOCKS, -}; -use rbitcoin_query::sp_read::{tweaks_at_height, tweaks_for_height, tweaks_from_thin_and_body}; -use rbitcoin_query::sp_tweaks::{ThinTweakRangeLimits, ThinTweakRow}; -use rbitcoin_query::spend_sync::SpendSync; -use rbitcoin_query::stamp::{ - fill_missing_parent_ranges, stamp_external_parents, BatchParentIds, ExternalParentStamp, - ParentIdent, -}; -use rbitcoin_query::wave_prevout::SpendEdge; -use rbitcoin_store::{ - script_hash, HeaderRecord, InputRecord, OutputRecord, PointRecord, ScriptHashRecord, - SpTweaksTable, Store, StoreError, StoreLayout, TxRecord, -}; -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; -use std::path::Path; -use std::sync::atomic::{ - AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering as AtomicOrdering, }; -use std::sync::{Arc, Condvar, Mutex}; +use rbitcoin_store::{HeaderRecord, InputRecord, OutputRecord, TxRecord}; use rbitcoin_query::testutil::FixtureChain; diff --git a/crates/rbitcoin-query/tests/in_flight.rs b/crates/rbitcoin-query/tests/in_flight.rs index 289cca78eb..0a10cae3aa 100644 --- a/crates/rbitcoin-query/tests/in_flight.rs +++ b/crates/rbitcoin-query/tests/in_flight.rs @@ -2,12 +2,7 @@ use rbitcoin_primitives::Fk; use rbitcoin_query::archive::CreatePin; use rbitcoin_query::archive::CreatePinInner; use rbitcoin_query::in_flight::*; -use rbitcoin_query::TxidHasher; -use rbitcoin_query::U64Map; use rbitcoin_store::{OutputRecord, TxRecord}; -use std::collections::{BTreeMap, HashMap}; -use std::hash::BuildHasherDefault; -use std::sync::Arc; fn pin(id: u64) -> CreatePin { let mut txid = [0u8; 32]; diff --git a/crates/rbitcoin-query/tests/index_writebehind.rs b/crates/rbitcoin-query/tests/index_writebehind.rs index 5a71d74ec7..9c70b638ee 100644 --- a/crates/rbitcoin-query/tests/index_writebehind.rs +++ b/crates/rbitcoin-query/tests/index_writebehind.rs @@ -1,16 +1,11 @@ -use rbitcoin_consensus::ConsensusError; use rbitcoin_log::progress; use rbitcoin_primitives::Fk; use rbitcoin_primitives::Height; -use rbitcoin_query::index_rows::{self, IndexHeightOut, IndexRows}; use rbitcoin_query::index_writebehind::*; -use rbitcoin_query::sp_read::tweak_records_from_window; -use rbitcoin_query::ConfirmError; use rbitcoin_query::Query; -use rbitcoin_store::IndexWindow; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; -use std::sync::mpsc::{sync_channel, Receiver}; -use std::sync::{Arc, Mutex}; +use std::sync::mpsc::sync_channel; +use std::sync::Arc; use std::time::{Duration, Instant}; /// Info lines from one `io_loop`. A loop that waits out `budget` is the diff --git a/crates/rbitcoin-query/tests/overlay_csv_tests.rs b/crates/rbitcoin-query/tests/overlay_csv_tests.rs index c3718af061..de44db81f5 100644 --- a/crates/rbitcoin-query/tests/overlay_csv_tests.rs +++ b/crates/rbitcoin-query/tests/overlay_csv_tests.rs @@ -1,79 +1,10 @@ //! CSV activation overlay changes confirm, not only the height getter. #![cfg(test)] use bitcoin::absolute::LockTime; -use bitcoin::block::{Header as BlockHeader, Version as BlockVersion}; -use bitcoin::hashes::Hash; use bitcoin::transaction::Version as TxVersion; -use bitcoin::{ - Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, - TxMerkleNode, TxOut, Witness, -}; -use rbitcoin_consensus::{ - block_wire_len_from_pres, decode_block_precomputes, pres_for_tip, IdMap, OutPointHasher, - OutPointSet, TxPrecompute, TxidHasher, TxidMap, TxidSet, -}; -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::archive::{ - input_records_from_wire, ArchiveWritePlan, CreatePin, CreatePinArc, CreatePinInner, - WirePlanNeed, -}; -use rbitcoin_query::batch_parents::FkSet; -use rbitcoin_query::batch_parents::{ - layout_covers_need, sparse_spender_rels, BatchParents, FkMap, ParentPinView, - SharedPrevoutScript, U32Map, U64Map, U64Set, -}; -use rbitcoin_query::block_filter::{basic_filter_from_scripts, basic_filter_of}; -use rbitcoin_query::catchup::IndexMode; -use rbitcoin_query::chain_view::{header_lookup_count, ChainView, ChainViewKind}; -use rbitcoin_query::combined_stage::{load_creates_once, CombinedCreate}; -use rbitcoin_query::confirm_error::ConfirmError; -use rbitcoin_query::confirm_load::SpendEdges; -use rbitcoin_query::confirm_stats::{ - add as note_confirm, add_dur as note_confirm_dur, ConfirmStats, ConfirmWindow, LastPinPhases, - LastPlanBatch, LastUnionMiss, LastWritePhases, TipShSnap, -}; -use rbitcoin_query::connect::{spawn_sh_writebehind, ConfirmPrepared}; -use rbitcoin_query::connect_facade::*; -use rbitcoin_query::convert::header_to_record; -use rbitcoin_query::header_read::{ - expected_next_bits, median_time_past, median_time_past_store, validate_header, - validate_header_hashed, -}; -use rbitcoin_query::in_flight::InFlight; -use rbitcoin_query::index_writebehind::{ - build_indexes_released, index_tip_entry, prepare_live_indexes, spawn_index_writebehind, - IndexTipEntry, INDEX_STARTUP_GAP_HEIGHTS, -}; -use rbitcoin_query::reconstruct::{BlockTxStatRows, StampedTxstatBlock}; +use bitcoin::{Amount, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Witness}; +use rbitcoin_primitives::Height; use rbitcoin_query::regtest_pad::pad_empty_from; -use rbitcoin_query::resolved_wire::{BlockQueueWaveIntake, ResolvedWire}; -use rbitcoin_query::scripthash::{ - BlockTouch, FilteredHistory, HistoryFilter, HistoryOrder, ScriptHashBalance, - ScriptHashChainStats, ScriptHashHistoryItem, ScriptHashTxSummary, ScriptHashUtxo, ShJoinSlot, -}; -use rbitcoin_query::soft_densify::{ - bq_assign_stop_bytes, soft_ahead_quarter_full, soft_assign_restricted, - soft_confirm_window_covered, soft_confirm_window_n, soft_densify_band_hi, BQ_SOFT_FREE_BYTES, - TIP_HOLE_MIN_AHEAD_BLOCKS, -}; -use rbitcoin_query::sp_read::{tweaks_at_height, tweaks_for_height, tweaks_from_thin_and_body}; -use rbitcoin_query::sp_tweaks::{ThinTweakRangeLimits, ThinTweakRow}; -use rbitcoin_query::spend_sync::SpendSync; -use rbitcoin_query::stamp::{ - fill_missing_parent_ranges, stamp_external_parents, BatchParentIds, ExternalParentStamp, - ParentIdent, -}; -use rbitcoin_query::wave_prevout::SpendEdge; -use rbitcoin_store::{ - script_hash, HeaderRecord, InputRecord, OutputRecord, PointRecord, ScriptHashRecord, - SpTweaksTable, Store, StoreError, StoreLayout, TxRecord, -}; -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; -use std::path::Path; -use std::sync::atomic::{ - AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering as AtomicOrdering, -}; -use std::sync::{Arc, Condvar, Mutex}; use bitcoin::blockdata::constants; diff --git a/crates/rbitcoin-query/tests/reconstruct/encode_witness_tests.rs b/crates/rbitcoin-query/tests/reconstruct/encode_witness_tests.rs index 0f57f144e9..f1b95e32ff 100644 --- a/crates/rbitcoin-query/tests/reconstruct/encode_witness_tests.rs +++ b/crates/rbitcoin-query/tests/reconstruct/encode_witness_tests.rs @@ -1,9 +1,6 @@ use rbitcoin_primitives::Fk; use rbitcoin_query::reconstruct::*; -use rbitcoin_query::U64Map; -use rbitcoin_query::*; use rbitcoin_store::{InputRecord, OutputRecord, StoreError, TxRecord}; -use std::time::Instant; #[test] fn encode_class_a_tx_emits_segwit_marker_when_input_has_witness() { diff --git a/crates/rbitcoin-query/tests/reconstruct/mod.rs b/crates/rbitcoin-query/tests/reconstruct/mod.rs index 6bb5b08467..5ec1a7e969 100644 --- a/crates/rbitcoin-query/tests/reconstruct/mod.rs +++ b/crates/rbitcoin-query/tests/reconstruct/mod.rs @@ -1,4 +1 @@ -use rbitcoin_query::U64Map; -use rbitcoin_query::*; -use std::time::Instant; mod encode_witness_tests; diff --git a/crates/rbitcoin-query/tests/resolved_wire.rs b/crates/rbitcoin-query/tests/resolved_wire.rs index 94af638832..3b4431feb6 100644 --- a/crates/rbitcoin-query/tests/resolved_wire.rs +++ b/crates/rbitcoin-query/tests/resolved_wire.rs @@ -1,4 +1,3 @@ -use bitcoin::Block; use rbitcoin_query::resolved_wire::*; use rbitcoin_query::TxPrecompute; use std::sync::Arc; diff --git a/crates/rbitcoin-query/tests/root.rs b/crates/rbitcoin-query/tests/root.rs index 9d6685283d..f28c5a81b5 100644 --- a/crates/rbitcoin-query/tests/root.rs +++ b/crates/rbitcoin-query/tests/root.rs @@ -1,81 +1,16 @@ -use bitcoin::absolute::LockTime; -use bitcoin::block::{Header as BlockHeader, Version as BlockVersion}; use bitcoin::hashes::Hash; -use bitcoin::transaction::Version as TxVersion; -use bitcoin::{ - Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, - TxMerkleNode, TxOut, Witness, -}; -use rbitcoin_consensus::{ - block_wire_len_from_pres, decode_block_precomputes, pres_for_tip, IdMap, OutPointHasher, - OutPointSet, TxPrecompute, TxidHasher, TxidMap, TxidSet, -}; use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::archive::{ - input_records_from_wire, ArchiveWritePlan, CreatePin, CreatePinArc, CreatePinInner, - WirePlanNeed, -}; -use rbitcoin_query::batch_parents::FkSet; -use rbitcoin_query::batch_parents::{ - layout_covers_need, sparse_spender_rels, BatchParents, FkMap, ParentPinView, - SharedPrevoutScript, U32Map, U64Map, U64Set, -}; -use rbitcoin_query::block_filter::{basic_filter_from_scripts, basic_filter_of}; +use rbitcoin_query::archive::{ArchiveWritePlan, CreatePinInner}; +use rbitcoin_query::batch_parents::BatchParents; use rbitcoin_query::catchup::IndexMode; -use rbitcoin_query::chain_view::{header_lookup_count, ChainView, ChainViewKind}; -use rbitcoin_query::combined_stage::{load_creates_once, CombinedCreate}; -use rbitcoin_query::confirm_error::ConfirmError; -use rbitcoin_query::confirm_load::SpendEdges; -use rbitcoin_query::confirm_stats::{ - add as note_confirm, add_dur as note_confirm_dur, ConfirmStats, ConfirmWindow, LastPinPhases, - LastPlanBatch, LastUnionMiss, LastWritePhases, TipShSnap, -}; -use rbitcoin_query::connect::{spawn_sh_writebehind, ConfirmPrepared}; -use rbitcoin_query::connect_facade::*; -use rbitcoin_query::convert::header_to_record; -use rbitcoin_query::header_read::{ - expected_next_bits, median_time_past, median_time_past_store, validate_header, - validate_header_hashed, -}; -use rbitcoin_query::in_flight::InFlight; -use rbitcoin_query::index_writebehind::{ - build_indexes_released, index_tip_entry, prepare_live_indexes, spawn_index_writebehind, - IndexTipEntry, INDEX_STARTUP_GAP_HEIGHTS, -}; -use rbitcoin_query::reconstruct::{BlockTxStatRows, StampedTxstatBlock}; -use rbitcoin_query::regtest_pad::pad_empty_from; -use rbitcoin_query::resolved_wire::{BlockQueueWaveIntake, ResolvedWire}; -use rbitcoin_query::scripthash::{ - BlockTouch, FilteredHistory, HistoryFilter, HistoryOrder, ScriptHashBalance, - ScriptHashChainStats, ScriptHashHistoryItem, ScriptHashTxSummary, ScriptHashUtxo, ShJoinSlot, -}; -use rbitcoin_query::soft_densify::{ - bq_assign_stop_bytes, soft_ahead_quarter_full, soft_assign_restricted, - soft_confirm_window_covered, soft_confirm_window_n, soft_densify_band_hi, BQ_SOFT_FREE_BYTES, - TIP_HOLE_MIN_AHEAD_BLOCKS, -}; -use rbitcoin_query::sp_read::{tweaks_at_height, tweaks_for_height, tweaks_from_thin_and_body}; -use rbitcoin_query::sp_tweaks::{ThinTweakRangeLimits, ThinTweakRow}; -use rbitcoin_query::spend_sync::SpendSync; -use rbitcoin_query::stamp::{ - fill_missing_parent_ranges, stamp_external_parents, BatchParentIds, ExternalParentStamp, - ParentIdent, -}; +use rbitcoin_query::chain_view::{ChainView, ChainViewKind}; +use rbitcoin_query::confirm_stats::LastPinPhases; +use rbitcoin_query::connect::ConfirmPrepared; use rbitcoin_query::testutil::FixtureChain; -use rbitcoin_query::wave_prevout::SpendEdge; use rbitcoin_query::Query; use rbitcoin_query::*; use rbitcoin_store::TxStatRow; -use rbitcoin_store::{ - script_hash, HeaderRecord, InputRecord, OutputRecord, PointRecord, ScriptHashRecord, - SpTweaksTable, Store, StoreError, StoreLayout, TxRecord, -}; -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; -use std::path::Path; -use std::sync::atomic::{ - AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering as AtomicOrdering, -}; -use std::sync::{Arc, Condvar, Mutex}; +use rbitcoin_store::{script_hash, HeaderRecord, InputRecord, OutputRecord, StoreError, TxRecord}; #[test] fn query_open_clears_strong_above_tip() { diff --git a/crates/rbitcoin-query/tests/run_builder_core.rs b/crates/rbitcoin-query/tests/run_builder_core.rs index 6ff33d81c6..9dd88c3e9d 100644 --- a/crates/rbitcoin-query/tests/run_builder_core.rs +++ b/crates/rbitcoin-query/tests/run_builder_core.rs @@ -1,6 +1,4 @@ use rbitcoin_query::run_builder_core::*; -use std::path::{Path, PathBuf}; -use std::sync::{Arc, Mutex}; #[test] fn clear_runs_dir_keeps_seal() { diff --git a/crates/rbitcoin-query/tests/scripthash/history_filter_tests.rs b/crates/rbitcoin-query/tests/scripthash/history_filter_tests.rs index dccd8d6cf3..7f07aee6ca 100644 --- a/crates/rbitcoin-query/tests/scripthash/history_filter_tests.rs +++ b/crates/rbitcoin-query/tests/scripthash/history_filter_tests.rs @@ -1,8 +1,5 @@ use rbitcoin_primitives::Fk; use rbitcoin_query::scripthash::*; -use rbitcoin_query::*; -use rbitcoin_store::{output_flags, script_hash, spent_abs, IdxBodyMode, SpendSlotRun}; -use std::sync::Arc; fn item(height: i64, txid0: u8) -> ScriptHashHistoryItem { let mut txid = [0u8; 32]; diff --git a/crates/rbitcoin-query/tests/scripthash/mod.rs b/crates/rbitcoin-query/tests/scripthash/mod.rs index dc89a16f62..2e50eb6f66 100644 --- a/crates/rbitcoin-query/tests/scripthash/mod.rs +++ b/crates/rbitcoin-query/tests/scripthash/mod.rs @@ -1,4 +1 @@ -use rbitcoin_query::*; -use rbitcoin_store::{output_flags, script_hash, spent_abs, IdxBodyMode, SpendSlotRun}; -use std::sync::Arc; mod history_filter_tests; diff --git a/crates/rbitcoin-query/tests/sh_builder.rs b/crates/rbitcoin-query/tests/sh_builder.rs index 173da5b568..7a986cf330 100644 --- a/crates/rbitcoin-query/tests/sh_builder.rs +++ b/crates/rbitcoin-query/tests/sh_builder.rs @@ -1,13 +1,5 @@ -use rbitcoin_log::info; -use rbitcoin_query::run_builder_core::{ - clear_runs_dir, on_disk_run_count, runs_dir_io, RunControl, -}; use rbitcoin_query::sh_builder::*; -use rbitcoin_store::{materialize_sh_unsorted_from_class_a, ColdProgress, Store, StoreError}; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; -use std::sync::{Arc, Mutex}; -use std::time::Instant; +use rbitcoin_store::Store; use std::time::{SystemTime, UNIX_EPOCH}; diff --git a/crates/rbitcoin-query/tests/sp_read/classifier_record_tests.rs b/crates/rbitcoin-query/tests/sp_read/classifier_record_tests.rs index 848d9781ed..93fc8dfd19 100644 --- a/crates/rbitcoin-query/tests/sp_read/classifier_record_tests.rs +++ b/crates/rbitcoin-query/tests/sp_read/classifier_record_tests.rs @@ -1,12 +1,6 @@ -use bitcoin::hashes::Hash; -use bitcoin::{OutPoint, Transaction, TxOut, Witness}; -use rbitcoin_consensus::silent_payments::{tweak_from_tx, TaprootOut, TxTweak}; -use rbitcoin_consensus::ChainParams; -use rbitcoin_primitives::{Fk, Height}; +use rbitcoin_primitives::Fk; use rbitcoin_query::sp_read::{build_tx_and_prevouts, taproot_outs_from_records}; -use rbitcoin_query::{ConfirmError, Query}; -use rbitcoin_store::{IndexWindow, InputRecord, LoadedTweakTx, OutputRecord, StoreError}; -use std::collections::{BTreeMap, HashMap}; +use rbitcoin_store::{InputRecord, OutputRecord}; #[test] fn taproot_record_keeps_a_zero_value_and_skips_other_scripts() { diff --git a/crates/rbitcoin-query/tests/sp_read/mod.rs b/crates/rbitcoin-query/tests/sp_read/mod.rs index ef1e173e1e..7781472311 100644 --- a/crates/rbitcoin-query/tests/sp_read/mod.rs +++ b/crates/rbitcoin-query/tests/sp_read/mod.rs @@ -1,9 +1 @@ -use bitcoin::hashes::Hash; -use bitcoin::{OutPoint, Transaction, TxOut, Witness}; -use rbitcoin_consensus::silent_payments::{tweak_from_tx, TaprootOut, TxTweak}; -use rbitcoin_consensus::ChainParams; -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::{ConfirmError, Query}; -use rbitcoin_store::{IndexWindow, InputRecord, LoadedTweakTx, OutputRecord, StoreError}; -use std::collections::{BTreeMap, HashMap}; mod classifier_record_tests; diff --git a/crates/rbitcoin-query/tests/sp_store_tests.rs b/crates/rbitcoin-query/tests/sp_store_tests.rs index 82a1b2a181..f6c00bd3ca 100644 --- a/crates/rbitcoin-query/tests/sp_store_tests.rs +++ b/crates/rbitcoin-query/tests/sp_store_tests.rs @@ -1,79 +1,10 @@ //! Store-backed silent-payment tweak reads. #![cfg(test)] -use bitcoin::absolute::LockTime; -use bitcoin::block::{Header as BlockHeader, Version as BlockVersion}; use bitcoin::hashes::Hash; -use bitcoin::transaction::Version as TxVersion; -use bitcoin::{ - Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, - TxMerkleNode, TxOut, Witness, -}; -use rbitcoin_consensus::{ - block_wire_len_from_pres, decode_block_precomputes, pres_for_tip, IdMap, OutPointHasher, - OutPointSet, TxPrecompute, TxidHasher, TxidMap, TxidSet, -}; +use bitcoin::{Amount, ScriptBuf, TxOut}; use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::archive::{ - input_records_from_wire, ArchiveWritePlan, CreatePin, CreatePinArc, CreatePinInner, - WirePlanNeed, -}; -use rbitcoin_query::batch_parents::FkSet; -use rbitcoin_query::batch_parents::{ - layout_covers_need, sparse_spender_rels, BatchParents, FkMap, ParentPinView, - SharedPrevoutScript, U32Map, U64Map, U64Set, -}; -use rbitcoin_query::block_filter::{basic_filter_from_scripts, basic_filter_of}; -use rbitcoin_query::catchup::IndexMode; -use rbitcoin_query::chain_view::{header_lookup_count, ChainView, ChainViewKind}; -use rbitcoin_query::combined_stage::{load_creates_once, CombinedCreate}; -use rbitcoin_query::confirm_error::ConfirmError; -use rbitcoin_query::confirm_load::SpendEdges; -use rbitcoin_query::confirm_stats::{ - add as note_confirm, add_dur as note_confirm_dur, ConfirmStats, ConfirmWindow, LastPinPhases, - LastPlanBatch, LastUnionMiss, LastWritePhases, TipShSnap, -}; -use rbitcoin_query::connect::{spawn_sh_writebehind, ConfirmPrepared}; -use rbitcoin_query::connect_facade::*; -use rbitcoin_query::convert::header_to_record; -use rbitcoin_query::header_read::{ - expected_next_bits, median_time_past, median_time_past_store, validate_header, - validate_header_hashed, -}; -use rbitcoin_query::in_flight::InFlight; -use rbitcoin_query::index_writebehind::{ - build_indexes_released, index_tip_entry, prepare_live_indexes, spawn_index_writebehind, - IndexTipEntry, INDEX_STARTUP_GAP_HEIGHTS, -}; -use rbitcoin_query::reconstruct::{BlockTxStatRows, StampedTxstatBlock}; -use rbitcoin_query::regtest_pad::pad_empty_from; -use rbitcoin_query::resolved_wire::{BlockQueueWaveIntake, ResolvedWire}; -use rbitcoin_query::scripthash::{ - BlockTouch, FilteredHistory, HistoryFilter, HistoryOrder, ScriptHashBalance, - ScriptHashChainStats, ScriptHashHistoryItem, ScriptHashTxSummary, ScriptHashUtxo, ShJoinSlot, -}; -use rbitcoin_query::soft_densify::{ - bq_assign_stop_bytes, soft_ahead_quarter_full, soft_assign_restricted, - soft_confirm_window_covered, soft_confirm_window_n, soft_densify_band_hi, BQ_SOFT_FREE_BYTES, - TIP_HOLE_MIN_AHEAD_BLOCKS, -}; -use rbitcoin_query::sp_read::{tweaks_at_height, tweaks_for_height, tweaks_from_thin_and_body}; -use rbitcoin_query::sp_tweaks::{ThinTweakRangeLimits, ThinTweakRow}; -use rbitcoin_query::spend_sync::SpendSync; -use rbitcoin_query::stamp::{ - fill_missing_parent_ranges, stamp_external_parents, BatchParentIds, ExternalParentStamp, - ParentIdent, -}; -use rbitcoin_query::wave_prevout::SpendEdge; -use rbitcoin_store::{ - script_hash, HeaderRecord, InputRecord, OutputRecord, PointRecord, ScriptHashRecord, - SpTweaksTable, Store, StoreError, StoreLayout, TxRecord, -}; -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; -use std::path::Path; -use std::sync::atomic::{ - AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering as AtomicOrdering, -}; -use std::sync::{Arc, Condvar, Mutex}; +use rbitcoin_query::index_writebehind::{build_indexes_released, prepare_live_indexes}; +use rbitcoin_store::{HeaderRecord, InputRecord, OutputRecord, StoreError, TxRecord}; use rbitcoin_query::sp_read::tweak_records_from_window; use rbitcoin_query::testutil::FixtureChain; diff --git a/crates/rbitcoin-query/tests/sp_tweaks.rs b/crates/rbitcoin-query/tests/sp_tweaks.rs index 438e6199ee..78dd9ce38b 100644 --- a/crates/rbitcoin-query/tests/sp_tweaks.rs +++ b/crates/rbitcoin-query/tests/sp_tweaks.rs @@ -4,7 +4,6 @@ use rbitcoin_query::sp_tweaks::*; use rbitcoin_query::Query; use rbitcoin_query::*; use rbitcoin_store::{HeaderRecord, InputRecord, OutputRecord, TxRecord}; -use rbitcoin_store::{SpTweaksTable, TrimLast}; use rbitcoin_query::testutil::FixtureChain; fn tmp_q() -> (rbitcoin_query::testutil::TempDir, Query) { diff --git a/crates/rbitcoin-query/tests/spend_sync.rs b/crates/rbitcoin-query/tests/spend_sync.rs index 23ff4f3263..dd2d279ae2 100644 --- a/crates/rbitcoin-query/tests/spend_sync.rs +++ b/crates/rbitcoin-query/tests/spend_sync.rs @@ -1,8 +1,4 @@ -use rbitcoin_query::Query; -use rbitcoin_store::{elapsed_after_checkpoint, SPEND_DURABLE_INTERVAL_MS}; -use std::sync::{Arc, Condvar, Mutex}; -use std::thread::JoinHandle; -use std::time::{Duration, Instant}; +use std::sync::Arc; use rbitcoin_primitives::{Fk, Height}; diff --git a/crates/rbitcoin-query/tests/stamp.rs b/crates/rbitcoin-query/tests/stamp.rs index 71605543b9..a9e7ffa07f 100644 --- a/crates/rbitcoin-query/tests/stamp.rs +++ b/crates/rbitcoin-query/tests/stamp.rs @@ -1,12 +1,8 @@ use rbitcoin_primitives::Fk; use rbitcoin_query::stamp::*; -use rbitcoin_query::{CreatePin, InFlight, QueryError, U64Map}; -use rbitcoin_query::{IdMap, TxidHasher}; -use rbitcoin_store::Store; -use std::collections::HashMap; -use std::hash::BuildHasherDefault; +use rbitcoin_query::IdMap; +use rbitcoin_query::{CreatePin, InFlight, U64Map}; use std::sync::Arc; -use std::time::Instant; fn tmp_store() -> (rbitcoin_query::testutil::TempDir, rbitcoin_query::Query) { rbitcoin_query::testutil::tiny_query_labeled("stamp") diff --git a/crates/rbitcoin-query/tests/structure_rule_tests.rs b/crates/rbitcoin-query/tests/structure_rule_tests.rs index af6c6543ba..ffbcd6b3fa 100644 --- a/crates/rbitcoin-query/tests/structure_rule_tests.rs +++ b/crates/rbitcoin-query/tests/structure_rule_tests.rs @@ -1,79 +1,14 @@ //! structure_rule_tests (peeled from block.rs). use bitcoin::absolute::LockTime; -use bitcoin::block::{Header as BlockHeader, Version as BlockVersion}; use bitcoin::hashes::Hash; use bitcoin::transaction::Version as TxVersion; use bitcoin::{ Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, TxMerkleNode, TxOut, Witness, }; -use rbitcoin_consensus::{ - block_wire_len_from_pres, decode_block_precomputes, pres_for_tip, IdMap, OutPointHasher, - OutPointSet, TxPrecompute, TxidHasher, TxidMap, TxidSet, -}; -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::archive::{ - input_records_from_wire, ArchiveWritePlan, CreatePin, CreatePinArc, CreatePinInner, - WirePlanNeed, -}; -use rbitcoin_query::batch_parents::FkSet; -use rbitcoin_query::batch_parents::{ - layout_covers_need, sparse_spender_rels, BatchParents, FkMap, ParentPinView, - SharedPrevoutScript, U32Map, U64Map, U64Set, -}; -use rbitcoin_query::block_filter::{basic_filter_from_scripts, basic_filter_of}; -use rbitcoin_query::catchup::IndexMode; -use rbitcoin_query::chain_view::{header_lookup_count, ChainView, ChainViewKind}; -use rbitcoin_query::combined_stage::{load_creates_once, CombinedCreate}; +use rbitcoin_consensus::TxPrecompute; +use rbitcoin_primitives::Height; use rbitcoin_query::confirm_error::ConfirmError; -use rbitcoin_query::confirm_load::SpendEdges; -use rbitcoin_query::confirm_stats::{ - add as note_confirm, add_dur as note_confirm_dur, ConfirmStats, ConfirmWindow, LastPinPhases, - LastPlanBatch, LastUnionMiss, LastWritePhases, TipShSnap, -}; -use rbitcoin_query::connect::{spawn_sh_writebehind, ConfirmPrepared}; -use rbitcoin_query::connect_facade::*; -use rbitcoin_query::convert::header_to_record; -use rbitcoin_query::header_read::{ - expected_next_bits, median_time_past, median_time_past_store, validate_header, - validate_header_hashed, -}; -use rbitcoin_query::in_flight::InFlight; -use rbitcoin_query::index_writebehind::{ - build_indexes_released, index_tip_entry, prepare_live_indexes, spawn_index_writebehind, - IndexTipEntry, INDEX_STARTUP_GAP_HEIGHTS, -}; -use rbitcoin_query::reconstruct::{BlockTxStatRows, StampedTxstatBlock}; -use rbitcoin_query::regtest_pad::pad_empty_from; -use rbitcoin_query::resolved_wire::{BlockQueueWaveIntake, ResolvedWire}; -use rbitcoin_query::scripthash::{ - BlockTouch, FilteredHistory, HistoryFilter, HistoryOrder, ScriptHashBalance, - ScriptHashChainStats, ScriptHashHistoryItem, ScriptHashTxSummary, ScriptHashUtxo, ShJoinSlot, -}; -use rbitcoin_query::soft_densify::{ - bq_assign_stop_bytes, soft_ahead_quarter_full, soft_assign_restricted, - soft_confirm_window_covered, soft_confirm_window_n, soft_densify_band_hi, BQ_SOFT_FREE_BYTES, - TIP_HOLE_MIN_AHEAD_BLOCKS, -}; -use rbitcoin_query::sp_read::{tweaks_at_height, tweaks_for_height, tweaks_from_thin_and_body}; -use rbitcoin_query::sp_tweaks::{ThinTweakRangeLimits, ThinTweakRow}; -use rbitcoin_query::spend_sync::SpendSync; -use rbitcoin_query::stamp::{ - fill_missing_parent_ranges, stamp_external_parents, BatchParentIds, ExternalParentStamp, - ParentIdent, -}; -use rbitcoin_query::wave_prevout::SpendEdge; -use rbitcoin_query::Query; -use rbitcoin_store::{ - script_hash, HeaderRecord, InputRecord, OutputRecord, PointRecord, ScriptHashRecord, - SpTweaksTable, Store, StoreError, StoreLayout, TxRecord, -}; -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; -use std::path::Path; -use std::sync::atomic::{ - AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering as AtomicOrdering, -}; -use std::sync::{Arc, Condvar, Mutex}; use rbitcoin_query::block_pipeline::{ assemble_block_prevouts, resolve_prevout, structural_validate_spends, AsmPrevoutAcc, diff --git a/crates/rbitcoin-query/tests/suite.rs b/crates/rbitcoin-query/tests/suite.rs index a4c3275920..e934e7ee5a 100644 --- a/crates/rbitcoin-query/tests/suite.rs +++ b/crates/rbitcoin-query/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod archive; mod batch_parents; mod bip68_store_tests; diff --git a/crates/rbitcoin-query/tests/wire_agree_tests.rs b/crates/rbitcoin-query/tests/wire_agree_tests.rs index 2b0ebc4abb..046fe88046 100644 --- a/crates/rbitcoin-query/tests/wire_agree_tests.rs +++ b/crates/rbitcoin-query/tests/wire_agree_tests.rs @@ -1,79 +1,8 @@ //! Store wire walk and consensus decode agree on every truncation. #![cfg(test)] use bitcoin::absolute::LockTime; -use bitcoin::block::{Header as BlockHeader, Version as BlockVersion}; use bitcoin::hashes::Hash; -use bitcoin::transaction::Version as TxVersion; -use bitcoin::{ - Amount, Block, BlockHash, CompactTarget, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, - TxMerkleNode, TxOut, Witness, -}; -use rbitcoin_consensus::{ - block_wire_len_from_pres, decode_block_precomputes, pres_for_tip, IdMap, OutPointHasher, - OutPointSet, TxPrecompute, TxidHasher, TxidMap, TxidSet, -}; -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_query::archive::{ - input_records_from_wire, ArchiveWritePlan, CreatePin, CreatePinArc, CreatePinInner, - WirePlanNeed, -}; -use rbitcoin_query::batch_parents::FkSet; -use rbitcoin_query::batch_parents::{ - layout_covers_need, sparse_spender_rels, BatchParents, FkMap, ParentPinView, - SharedPrevoutScript, U32Map, U64Map, U64Set, -}; -use rbitcoin_query::block_filter::{basic_filter_from_scripts, basic_filter_of}; -use rbitcoin_query::catchup::IndexMode; -use rbitcoin_query::chain_view::{header_lookup_count, ChainView, ChainViewKind}; -use rbitcoin_query::combined_stage::{load_creates_once, CombinedCreate}; -use rbitcoin_query::confirm_error::ConfirmError; -use rbitcoin_query::confirm_load::SpendEdges; -use rbitcoin_query::confirm_stats::{ - add as note_confirm, add_dur as note_confirm_dur, ConfirmStats, ConfirmWindow, LastPinPhases, - LastPlanBatch, LastUnionMiss, LastWritePhases, TipShSnap, -}; -use rbitcoin_query::connect::{spawn_sh_writebehind, ConfirmPrepared}; -use rbitcoin_query::connect_facade::*; -use rbitcoin_query::convert::header_to_record; -use rbitcoin_query::header_read::{ - expected_next_bits, median_time_past, median_time_past_store, validate_header, - validate_header_hashed, -}; -use rbitcoin_query::in_flight::InFlight; -use rbitcoin_query::index_writebehind::{ - build_indexes_released, index_tip_entry, prepare_live_indexes, spawn_index_writebehind, - IndexTipEntry, INDEX_STARTUP_GAP_HEIGHTS, -}; -use rbitcoin_query::reconstruct::{BlockTxStatRows, StampedTxstatBlock}; -use rbitcoin_query::regtest_pad::pad_empty_from; -use rbitcoin_query::resolved_wire::{BlockQueueWaveIntake, ResolvedWire}; -use rbitcoin_query::scripthash::{ - BlockTouch, FilteredHistory, HistoryFilter, HistoryOrder, ScriptHashBalance, - ScriptHashChainStats, ScriptHashHistoryItem, ScriptHashTxSummary, ScriptHashUtxo, ShJoinSlot, -}; -use rbitcoin_query::soft_densify::{ - bq_assign_stop_bytes, soft_ahead_quarter_full, soft_assign_restricted, - soft_confirm_window_covered, soft_confirm_window_n, soft_densify_band_hi, BQ_SOFT_FREE_BYTES, - TIP_HOLE_MIN_AHEAD_BLOCKS, -}; -use rbitcoin_query::sp_read::{tweaks_at_height, tweaks_for_height, tweaks_from_thin_and_body}; -use rbitcoin_query::sp_tweaks::{ThinTweakRangeLimits, ThinTweakRow}; -use rbitcoin_query::spend_sync::SpendSync; -use rbitcoin_query::stamp::{ - fill_missing_parent_ranges, stamp_external_parents, BatchParentIds, ExternalParentStamp, - ParentIdent, -}; -use rbitcoin_query::wave_prevout::SpendEdge; -use rbitcoin_store::{ - script_hash, HeaderRecord, InputRecord, OutputRecord, PointRecord, ScriptHashRecord, - SpTweaksTable, Store, StoreError, StoreLayout, TxRecord, -}; -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; -use std::path::Path; -use std::sync::atomic::{ - AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering as AtomicOrdering, -}; -use std::sync::{Arc, Condvar, Mutex}; +use bitcoin::{Amount, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Witness}; use bitcoin::transaction::Version; diff --git a/crates/rbitcoin-query/tests/write_create_loc.rs b/crates/rbitcoin-query/tests/write_create_loc.rs index 18dc6a67c1..891c9f6b39 100644 --- a/crates/rbitcoin-query/tests/write_create_loc.rs +++ b/crates/rbitcoin-query/tests/write_create_loc.rs @@ -1,9 +1,6 @@ use rbitcoin_primitives::Fk; use rbitcoin_query::write_create_loc::*; -use rbitcoin_query::Query; use rbitcoin_store::CreateLocPair; -use std::cell::{Cell, RefCell}; -use std::collections::BTreeMap; fn pair(n: u64) -> CreateLocPair { CreateLocPair { diff --git a/crates/rbitcoin-rpc/tests/auth.rs b/crates/rbitcoin-rpc/tests/auth.rs index 168daaaffc..13972685aa 100644 --- a/crates/rbitcoin-rpc/tests/auth.rs +++ b/crates/rbitcoin-rpc/tests/auth.rs @@ -1,6 +1,5 @@ use rbitcoin_rpc::auth::*; use std::fs; -use std::io::{Read, Write}; use std::path::{Path, PathBuf}; use std::time::{SystemTime, UNIX_EPOCH}; diff --git a/crates/rbitcoin-rpc/tests/blockstats/mod.rs b/crates/rbitcoin-rpc/tests/blockstats/mod.rs index 57324975d1..f28d4edc77 100644 --- a/crates/rbitcoin-rpc/tests/blockstats/mod.rs +++ b/crates/rbitcoin-rpc/tests/blockstats/mod.rs @@ -1,11 +1 @@ -use bitcoin::hashes::Hash; -use bitcoin::{Amount, Block, BlockHash, OutPoint, ScriptBuf, TxOut}; -use rbitcoin_primitives::Height; -use rbitcoin_query::StampedTxstatBlock; -use rbitcoin_rpc::methods::{ - map_query, parse_hash32_display, rpc_error, RpcContext, RpcParams, ERR_INVALID_ADDRESS_OR_KEY, - ERR_INVALID_PARAMETER, ERR_MISC, -}; -use rbitcoin_store::{HeaderRecord, TxStatRow}; -use serde_json::{json, Map, Value}; mod unit_tests; diff --git a/crates/rbitcoin-rpc/tests/blockstats/unit_tests.rs b/crates/rbitcoin-rpc/tests/blockstats/unit_tests.rs index 854af7a431..2759f7d45f 100644 --- a/crates/rbitcoin-rpc/tests/blockstats/unit_tests.rs +++ b/crates/rbitcoin-rpc/tests/blockstats/unit_tests.rs @@ -1,14 +1,5 @@ -use bitcoin::hashes::Hash; -use bitcoin::{Amount, Block, BlockHash, OutPoint, ScriptBuf, TxOut}; -use rbitcoin_primitives::Height; -use rbitcoin_query::StampedTxstatBlock; +use bitcoin::ScriptBuf; use rbitcoin_rpc::blockstats::*; -use rbitcoin_rpc::methods::{ - map_query, parse_hash32_display, rpc_error, RpcContext, RpcParams, ERR_INVALID_ADDRESS_OR_KEY, - ERR_INVALID_PARAMETER, ERR_MISC, -}; -use rbitcoin_store::{HeaderRecord, TxStatRow}; -use serde_json::{json, Map, Value}; #[test] fn truncated_median_even_averages_two_middles() { diff --git a/crates/rbitcoin-rpc/tests/methods/chain/core_double_tests.rs b/crates/rbitcoin-rpc/tests/methods/chain/core_double_tests.rs index 08519945df..cefaa10e28 100644 --- a/crates/rbitcoin-rpc/tests/methods/chain/core_double_tests.rs +++ b/crates/rbitcoin-rpc/tests/methods/chain/core_double_tests.rs @@ -1,12 +1,4 @@ -use bitcoin::consensus::{deserialize, Encodable}; -use bitcoin::hashes::Hash; -use bitcoin::{Amount, Block, BlockHash, ScriptBuf, Txid}; -use rbitcoin_primitives::{median_time_past_times, Height}; use rbitcoin_rpc::methods::chain::format_core_double; -use rbitcoin_rpc::methods::*; -use serde_json::{json, Value}; -use std::sync::atomic::Ordering; -use std::time::Instant; #[test] fn sixteen_significant_digits() { diff --git a/crates/rbitcoin-rpc/tests/methods/chain/mod.rs b/crates/rbitcoin-rpc/tests/methods/chain/mod.rs index dd260a2cc7..63c36134ca 100644 --- a/crates/rbitcoin-rpc/tests/methods/chain/mod.rs +++ b/crates/rbitcoin-rpc/tests/methods/chain/mod.rs @@ -1,10 +1,2 @@ -use bitcoin::consensus::{deserialize, Encodable}; -use bitcoin::hashes::Hash; -use bitcoin::{Amount, Block, BlockHash, ScriptBuf, Txid}; -use rbitcoin_primitives::{median_time_past_times, Height}; -use rbitcoin_rpc::methods::*; -use serde_json::{json, Value}; -use std::sync::atomic::Ordering; -use std::time::Instant; mod core_double_tests; mod wait_tests; diff --git a/crates/rbitcoin-rpc/tests/methods/chain/wait_tests.rs b/crates/rbitcoin-rpc/tests/methods/chain/wait_tests.rs index f8dbe2d345..dd332c678b 100644 --- a/crates/rbitcoin-rpc/tests/methods/chain/wait_tests.rs +++ b/crates/rbitcoin-rpc/tests/methods/chain/wait_tests.rs @@ -1,12 +1,6 @@ -use bitcoin::consensus::{deserialize, Encodable}; -use bitcoin::hashes::Hash; -use bitcoin::{Amount, Block, BlockHash, ScriptBuf, Txid}; -use rbitcoin_primitives::{median_time_past_times, Height}; use rbitcoin_rpc::methods::chain::*; use rbitcoin_rpc::methods::*; -use serde_json::{json, Value}; -use std::sync::atomic::Ordering; -use std::time::Instant; +use serde_json::json; #[test] fn wait_timeout_ms_caps_at_two_minutes() { diff --git a/crates/rbitcoin-rpc/tests/methods/mempool/fee_look_tests.rs b/crates/rbitcoin-rpc/tests/methods/mempool/fee_look_tests.rs index b02e7a148a..e211bf4471 100644 --- a/crates/rbitcoin-rpc/tests/methods/mempool/fee_look_tests.rs +++ b/crates/rbitcoin-rpc/tests/methods/mempool/fee_look_tests.rs @@ -1,13 +1,6 @@ -use bitcoin::consensus::encode::serialize_hex; -use bitcoin::hashes::Hash; -use bitcoin::{OutPoint, Transaction, Txid}; -use rbitcoin_net::MempoolHub; -use rbitcoin_primitives::Height; use rbitcoin_rpc::methods::mempool::{ fold_tx_fee_sat, package_dialect_from_env, submitpackage_topology_disallowed, TxFeeLook, }; -use rbitcoin_rpc::methods::*; -use serde_json::{json, Value}; #[test] fn package_dialect_from_env_only_one_and_true() { diff --git a/crates/rbitcoin-rpc/tests/methods/mempool/mod.rs b/crates/rbitcoin-rpc/tests/methods/mempool/mod.rs index ef409fe995..afeaf09311 100644 --- a/crates/rbitcoin-rpc/tests/methods/mempool/mod.rs +++ b/crates/rbitcoin-rpc/tests/methods/mempool/mod.rs @@ -1,9 +1,2 @@ -use bitcoin::consensus::encode::serialize_hex; -use bitcoin::hashes::Hash; -use bitcoin::{OutPoint, Transaction, Txid}; -use rbitcoin_net::MempoolHub; -use rbitcoin_primitives::Height; -use rbitcoin_rpc::methods::*; -use serde_json::{json, Value}; mod fee_look_tests; mod smart_fee_tests; diff --git a/crates/rbitcoin-rpc/tests/methods/mempool/smart_fee_tests.rs b/crates/rbitcoin-rpc/tests/methods/mempool/smart_fee_tests.rs index 1ad0a15939..3a0b467925 100644 --- a/crates/rbitcoin-rpc/tests/methods/mempool/smart_fee_tests.rs +++ b/crates/rbitcoin-rpc/tests/methods/mempool/smart_fee_tests.rs @@ -1,11 +1,4 @@ -use bitcoin::consensus::encode::serialize_hex; -use bitcoin::hashes::Hash; -use bitcoin::{OutPoint, Transaction, Txid}; -use rbitcoin_net::MempoolHub; -use rbitcoin_primitives::Height; use rbitcoin_rpc::methods::mempool::*; -use rbitcoin_rpc::methods::*; -use serde_json::{json, Value}; /// A session answers only once fee history or flow is warm (thousands /// of blocks or a minute of relay), so the success shape is pinned here. diff --git a/crates/rbitcoin-rpc/tests/methods/mod.rs b/crates/rbitcoin-rpc/tests/methods/mod.rs index 1e1c1b3431..ad9da9066c 100644 --- a/crates/rbitcoin-rpc/tests/methods/mod.rs +++ b/crates/rbitcoin-rpc/tests/methods/mod.rs @@ -1,28 +1,15 @@ use bitcoin::consensus::{deserialize, encode::serialize_hex}; use bitcoin::hashes::Hash; use bitcoin::{Block, BlockHash, ScriptBuf, Transaction}; -use chain::*; -use decode::*; -use mempool::*; -use mine::*; -use net::*; use rbitcoin_net::MempoolHub; use rbitcoin_primitives::Network; use rbitcoin_query::Query; -use rbitcoin_rpc::methods::chain::difficulty_rpc_f64; use rbitcoin_rpc::methods::chain::*; -use rbitcoin_rpc::methods::chain::{tip_hash_height, wait_timeout_ms}; -use rbitcoin_rpc::methods::decode::*; use rbitcoin_rpc::methods::mempool::*; -use rbitcoin_rpc::methods::mine::gbt_longpoll_id; use rbitcoin_rpc::methods::mine::*; -use rbitcoin_rpc::methods::mine::{gbt_template, submit_received_block}; -use rbitcoin_rpc::methods::net::*; -use rbitcoin_rpc::methods::rest::{dispatch_rest, RestReply}; +use rbitcoin_rpc::methods::rest::dispatch_rest; use rbitcoin_rpc::methods::*; use serde_json::{json, Value}; -use std::cell::Cell; -use std::collections::HashMap; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::Arc; use std::time::Instant; diff --git a/crates/rbitcoin-rpc/tests/root.rs b/crates/rbitcoin-rpc/tests/root.rs index 4020db5428..f0e2d6fdf6 100644 --- a/crates/rbitcoin-rpc/tests/root.rs +++ b/crates/rbitcoin-rpc/tests/root.rs @@ -1,13 +1,3 @@ -use rbitcoin_rpc::auth::{ - default_socket_path, default_token_path, read_cookie_file, RpcAuth, RpcCookiePerms, -}; -use rbitcoin_rpc::methods::{ - difficulty_rpc_f64, gbt_template, submit_received_block, HubRegtest, RpcActive, RpcContext, - RpcRegtest, SubmitBlockOutcome, -}; -use rbitcoin_rpc::server::{ - run_rpc, RpcConfig, RpcHandle, DEFAULT_RPC_WORK_QUEUE, RPC_MAX_HTTP_BODY, -}; #[test] fn node_rpc_path_is_root() { assert_eq!(rbitcoin_rpc::node_rpc_path(), "/"); diff --git a/crates/rbitcoin-rpc/tests/server.rs b/crates/rbitcoin-rpc/tests/server.rs index 04d5f73690..b9c6ea28f5 100644 --- a/crates/rbitcoin-rpc/tests/server.rs +++ b/crates/rbitcoin-rpc/tests/server.rs @@ -1,32 +1,16 @@ use axum::body::Bytes; -use axum::extract::{DefaultBodyLimit, State}; -use axum::http::{header, HeaderMap, StatusCode}; -use axum::middleware::{from_fn_with_state, Next}; -use axum::response::{IntoResponse, Response}; -use axum::routing::{get, post}; -use axum::Router; -use rbitcoin_log::info; -use rbitcoin_log::warn; -use rbitcoin_net::{BlockingRegion, MempoolHub}; +use axum::extract::State; +use axum::http::StatusCode; +use rbitcoin_net::MempoolHub; use rbitcoin_primitives::Network; use rbitcoin_query::Query; -use rbitcoin_rpc::auth::{ - parse_basic_auth, parse_bearer_auth, read_cookie_file, resolve_rpc_auth, RpcAuth, RpcCookie, - RpcCookiePerms, -}; -use rbitcoin_rpc::methods::{RpcContext, RpcRegtest}; +use rbitcoin_rpc::auth::{RpcAuth, RpcCookiePerms}; use rbitcoin_rpc::server::*; use std::net::SocketAddr; -use std::path::PathBuf; -use std::pin::Pin; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::Arc; -use std::task::{Context, Poll}; use std::time::Instant; -use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; -use tokio::net::TcpListener; -use tokio::sync::{OwnedSemaphorePermit, Semaphore}; -use tokio::task::JoinHandle; +use tokio::sync::Semaphore; #[test] fn work_queue_zero_and_omitted_are_the_default() { diff --git a/crates/rbitcoin-rpc/tests/suite.rs b/crates/rbitcoin-rpc/tests/suite.rs index 608096458f..0f86089b7c 100644 --- a/crates/rbitcoin-rpc/tests/suite.rs +++ b/crates/rbitcoin-rpc/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod auth; mod blockstats; mod methods; diff --git a/crates/rbitcoin-store/tests/address_head.rs b/crates/rbitcoin-store/tests/address_head.rs index 05ed023c6b..068e042172 100644 --- a/crates/rbitcoin-store/tests/address_head.rs +++ b/crates/rbitcoin-store/tests/address_head.rs @@ -1,11 +1,11 @@ -use rbitcoin_primitives::{Fk, TableKind}; +use rbitcoin_primitives::Fk; use rbitcoin_store::address_head::*; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, TRAILING_FOOTER_LEN}; +use rbitcoin_store::file::TRAILING_FOOTER_LEN; use rbitcoin_store::hashhead::HeadScale; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; +use std::sync::atomic::AtomicU64; use std::sync::atomic::Ordering as AtomicOrdering; -use std::sync::atomic::{AtomicU64, Ordering}; fn tmp(name: &str) -> PathBuf { static N: AtomicU64 = AtomicU64::new(0); diff --git a/crates/rbitcoin-store/tests/array_table.rs b/crates/rbitcoin-store/tests/array_table.rs index c5566b7885..b8eae93704 100644 --- a/crates/rbitcoin-store/tests/array_table.rs +++ b/crates/rbitcoin-store/tests/array_table.rs @@ -1,10 +1,8 @@ use rbitcoin_primitives::TableKind; use rbitcoin_store::array_table::*; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; -use std::path::Path; +use rbitcoin_store::file::FILE_HEADER_LEN; use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{Mutex, RwLock}; fn tmp_path() -> std::path::PathBuf { std::env::temp_dir().join(format!( diff --git a/crates/rbitcoin-store/tests/bdz.rs b/crates/rbitcoin-store/tests/bdz.rs index c58d47c010..8d63a1d00c 100644 --- a/crates/rbitcoin-store/tests/bdz.rs +++ b/crates/rbitcoin-store/tests/bdz.rs @@ -1,11 +1,5 @@ use rbitcoin_store::bdz::*; use rbitcoin_store::error::StoreError; -use rbitcoin_store::io_handle::IoHandle; -use rbitcoin_store::readonly_map::ReadonlyMap; -use std::fs::File; -use std::io::Write; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicU64, Ordering}; #[test] fn read_packed_zero_modulus_or_vertices_is_corrupt() { diff --git a/crates/rbitcoin-store/tests/binary_fuse8.rs b/crates/rbitcoin-store/tests/binary_fuse8.rs index 7e9f696b97..d85d9156ac 100644 --- a/crates/rbitcoin-store/tests/binary_fuse8.rs +++ b/crates/rbitcoin-store/tests/binary_fuse8.rs @@ -1,5 +1,4 @@ use rbitcoin_store::binary_fuse8::*; -use rbitcoin_store::readonly_map::ReadonlyMap; #[test] fn single_key_and_small_set_no_false_negatives() { diff --git a/crates/rbitcoin-store/tests/block_filter.rs b/crates/rbitcoin-store/tests/block_filter.rs index 371817f507..572e593889 100644 --- a/crates/rbitcoin-store/tests/block_filter.rs +++ b/crates/rbitcoin-store/tests/block_filter.rs @@ -1,12 +1,10 @@ -use rbitcoin_primitives::{Fk, Height, TableKind}; +use rbitcoin_primitives::{Fk, Height}; use rbitcoin_store::block_filter::*; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; -use rbitcoin_store::seg_pair::{locate, SegDirs, SegPair}; +use rbitcoin_store::file::FILE_HEADER_LEN; use std::fs; use std::io::{Read, Seek, SeekFrom, Write}; -use std::path::{Path, PathBuf}; -use std::sync::{Mutex, RwLock}; +use std::path::Path; fn tmp_dir() -> rbitcoin_store::testutil::TempDir { rbitcoin_store::testutil::TempDir::labeled("blockfilter").unwrap() diff --git a/crates/rbitcoin-store/tests/block_queue.rs b/crates/rbitcoin-store/tests/block_queue.rs index d0866530cc..4f4a72b41d 100644 --- a/crates/rbitcoin-store/tests/block_queue.rs +++ b/crates/rbitcoin-store/tests/block_queue.rs @@ -1,7 +1,4 @@ use rbitcoin_store::block_queue::*; -use rbitcoin_store::error::StoreError; -use std::collections::{BTreeMap, HashMap, HashSet}; -use std::path::Path; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Arc; diff --git a/crates/rbitcoin-store/tests/block_wire.rs b/crates/rbitcoin-store/tests/block_wire.rs index 86a338aa67..5ff54bc8c7 100644 --- a/crates/rbitcoin-store/tests/block_wire.rs +++ b/crates/rbitcoin-store/tests/block_wire.rs @@ -1,4 +1,3 @@ -use rbitcoin_primitives::read_compact_size; use rbitcoin_store::block_wire::*; fn header() -> Vec { diff --git a/crates/rbitcoin-store/tests/bulk_io.rs b/crates/rbitcoin-store/tests/bulk_io.rs index 4adbc0f2cf..bc3da91a9e 100644 --- a/crates/rbitcoin-store/tests/bulk_io.rs +++ b/crates/rbitcoin-store/tests/bulk_io.rs @@ -1,7 +1,6 @@ use rbitcoin_store::bulk_io::*; use rbitcoin_store::error::StoreError; use rbitcoin_store::io_handle::IoHandle; -use std::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering}; #[test] fn unset_io_env_opens_a_session_except_on_darwin() { diff --git a/crates/rbitcoin-store/tests/chain/chain_table_tests.rs b/crates/rbitcoin-store/tests/chain/chain_table_tests.rs index 551f66fc1b..ae51283751 100644 --- a/crates/rbitcoin-store/tests/chain/chain_table_tests.rs +++ b/crates/rbitcoin-store/tests/chain/chain_table_tests.rs @@ -1,8 +1,6 @@ -use rbitcoin_primitives::{Fk, Height, TableKind}; -use rbitcoin_store::array_table::ArrayTable; +use rbitcoin_primitives::{Fk, Height}; use rbitcoin_store::chain::*; use rbitcoin_store::error::StoreError; -use std::path::Path; fn tmp() -> std::path::PathBuf { let p = std::env::temp_dir().join(format!( diff --git a/crates/rbitcoin-store/tests/chain/mod.rs b/crates/rbitcoin-store/tests/chain/mod.rs index 8de5e3257c..9df6bfebf0 100644 --- a/crates/rbitcoin-store/tests/chain/mod.rs +++ b/crates/rbitcoin-store/tests/chain/mod.rs @@ -1,6 +1,2 @@ -use rbitcoin_primitives::{Fk, Height, TableKind}; -use rbitcoin_store::array_table::ArrayTable; -use rbitcoin_store::error::StoreError; -use std::path::Path; mod chain_table_tests; mod strong_tests; diff --git a/crates/rbitcoin-store/tests/chain/strong_tests.rs b/crates/rbitcoin-store/tests/chain/strong_tests.rs index 04ed3937d9..8bc9e33cc2 100644 --- a/crates/rbitcoin-store/tests/chain/strong_tests.rs +++ b/crates/rbitcoin-store/tests/chain/strong_tests.rs @@ -1,8 +1,6 @@ -use rbitcoin_primitives::{Fk, Height, TableKind}; -use rbitcoin_store::array_table::ArrayTable; +use rbitcoin_primitives::Fk; use rbitcoin_store::chain::*; use rbitcoin_store::error::StoreError; -use std::path::Path; fn tmp() -> std::path::PathBuf { let p = std::env::temp_dir().join(format!( diff --git a/crates/rbitcoin-store/tests/compact.rs b/crates/rbitcoin-store/tests/compact.rs index 0149012ece..3cd849d31a 100644 --- a/crates/rbitcoin-store/tests/compact.rs +++ b/crates/rbitcoin-store/tests/compact.rs @@ -1,6 +1,4 @@ -use rbitcoin_primitives::{read_compact_size, read_uleb128, write_compact_size}; use rbitcoin_store::compact::*; -use rbitcoin_store::error::StoreError; #[test] fn amount_exp_mantissa_strips_trailing_tens() { diff --git a/crates/rbitcoin-store/tests/create_loc.rs b/crates/rbitcoin-store/tests/create_loc.rs index 93fcf38a71..d566d72bd8 100644 --- a/crates/rbitcoin-store/tests/create_loc.rs +++ b/crates/rbitcoin-store/tests/create_loc.rs @@ -1,17 +1,10 @@ -use rbitcoin_primitives::{deinterleave_pairs_u8x8, inclusive_u8x8_times_8, Fk, TableKind}; -use rbitcoin_store::bulk_io::ReadOp; +use rbitcoin_primitives::Fk; use rbitcoin_store::create_loc::*; -use rbitcoin_store::delta_loc::{ - create_table_file, decode_create_pair, encode_create_ovf_row, load_create_ovf, loc_file_off, - loc_window, loc_within, migrate_create_ovf_v22_if_needed, open_table_file, pack_create_pair, - strides_from_aligned_len, CREATE_OVF_SLOT, IDX_STRIDE, LOC_WINDOW, -}; +use rbitcoin_store::delta_loc::IDX_STRIDE; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; +use rbitcoin_store::file::FILE_HEADER_LEN; use rbitcoin_store::IoCtx; use std::path::Path; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::RwLock; use rbitcoin_store::testutil::TempDir; diff --git a/crates/rbitcoin-store/tests/delta_loc.rs b/crates/rbitcoin-store/tests/delta_loc.rs index 5840cfd4e4..779764cb63 100644 --- a/crates/rbitcoin-store/tests/delta_loc.rs +++ b/crates/rbitcoin-store/tests/delta_loc.rs @@ -1,13 +1,8 @@ -use rbitcoin_primitives::{Fk, TableKind, SCHEMA_VERSION}; +use rbitcoin_primitives::Fk; use rbitcoin_store::delta_loc::*; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{ - leading_header_bytes, write_synced_tmp_rename, GrowPolicy, TableFile, FILE_HEADER_LEN, -}; +use rbitcoin_store::file::FILE_HEADER_LEN; use rbitcoin_store::testutil::TempDir; -use std::path::Path; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::RwLock; #[test] fn window_and_within() { diff --git a/crates/rbitcoin-store/tests/error.rs b/crates/rbitcoin-store/tests/error.rs index b93184270b..9291620b4b 100644 --- a/crates/rbitcoin-store/tests/error.rs +++ b/crates/rbitcoin-store/tests/error.rs @@ -1,7 +1,6 @@ use rbitcoin_primitives::PackError; use rbitcoin_store::error::*; use std::error::Error; -use std::fmt; use std::io; use std::path::PathBuf; diff --git a/crates/rbitcoin-store/tests/file/advise_tests.rs b/crates/rbitcoin-store/tests/file/advise_tests.rs index 9d48275ac8..5e9cccd8d6 100644 --- a/crates/rbitcoin-store/tests/file/advise_tests.rs +++ b/crates/rbitcoin-store/tests/file/advise_tests.rs @@ -1,12 +1,7 @@ -use rbitcoin_primitives::{schema_file_openable, TableKind, SCHEMA_VERSION, STORE_MAGIC}; +use rbitcoin_primitives::{TableKind, SCHEMA_VERSION, STORE_MAGIC}; use rbitcoin_store::error::StoreError; use rbitcoin_store::file::*; -use rbitcoin_store::io_handle::IoHandle; -use std::fs::{File, OpenOptions}; -use std::io::Write; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicBool, AtomicU64, AtomicU8, Ordering}; -use std::sync::Mutex; +use std::sync::atomic::{AtomicU64, Ordering}; #[test] fn grow_tight_adds_one_mib_not_slab() { diff --git a/crates/rbitcoin-store/tests/file/mod.rs b/crates/rbitcoin-store/tests/file/mod.rs index a6bab7bcfc..73d5d6b0b9 100644 --- a/crates/rbitcoin-store/tests/file/mod.rs +++ b/crates/rbitcoin-store/tests/file/mod.rs @@ -1,9 +1 @@ -use rbitcoin_primitives::{schema_file_openable, TableKind, SCHEMA_VERSION, STORE_MAGIC}; -use rbitcoin_store::error::StoreError; -use rbitcoin_store::io_handle::IoHandle; -use std::fs::{File, OpenOptions}; -use std::io::Write; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicBool, AtomicU64, AtomicU8, Ordering}; -use std::sync::Mutex; mod advise_tests; diff --git a/crates/rbitcoin-store/tests/fuse8_filter.rs b/crates/rbitcoin-store/tests/fuse8_filter.rs index a2248462c9..e22f932a81 100644 --- a/crates/rbitcoin-store/tests/fuse8_filter.rs +++ b/crates/rbitcoin-store/tests/fuse8_filter.rs @@ -1,10 +1,6 @@ use rbitcoin_store::binary_fuse8::{BinaryFuse8, Fingerprints}; use rbitcoin_store::error::StoreError; use rbitcoin_store::fuse8_filter::*; -use rbitcoin_store::readonly_map::ReadonlyMap; -use std::fs::File; -use std::io::Write; -use std::path::Path; use std::time::{SystemTime, UNIX_EPOCH}; fn tmp() -> std::path::PathBuf { diff --git a/crates/rbitcoin-store/tests/hashhead.rs b/crates/rbitcoin-store/tests/hashhead.rs index 2024458eab..c35b5d910c 100644 --- a/crates/rbitcoin-store/tests/hashhead.rs +++ b/crates/rbitcoin-store/tests/hashhead.rs @@ -1,11 +1,6 @@ -use rbitcoin_primitives::{Fk, TableKind}; +use rbitcoin_primitives::Fk; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; use rbitcoin_store::hashhead::*; -use rbitcoin_store::open_address::{self, MAX_LOAD_DEN, MAX_LOAD_NUM}; -use std::collections::BTreeMap; -use std::path::{Path, PathBuf}; -use std::sync::Mutex; #[test] fn create_defaults_to_fd_only() { diff --git a/crates/rbitcoin-store/tests/head_resolve_denserels.rs b/crates/rbitcoin-store/tests/head_resolve_denserels.rs index b6d48dd41f..e988965a45 100644 --- a/crates/rbitcoin-store/tests/head_resolve_denserels.rs +++ b/crates/rbitcoin-store/tests/head_resolve_denserels.rs @@ -2,15 +2,10 @@ use rbitcoin_primitives::Fk; use rbitcoin_store::error::StoreError; use rbitcoin_store::head_resolve_denserels::*; use rbitcoin_store::height_fence::HeightFence; -use rbitcoin_store::io_backend::{self, ReadIoBackend}; -use rbitcoin_store::segmented_head::HeadProbeWave; use rbitcoin_store::tx_table::TxTable; use rbitcoin_store::tx_table::{InputRecord, OutputRecord, TxRecord}; -use rbitcoin_store::txid_body::TxidBody; -use rbitcoin_store::uring_session::UringSession; use std::path::PathBuf; use std::sync::atomic::{AtomicU64, Ordering}; -use std::time::Instant; fn tmp(name: &str) -> PathBuf { static N: AtomicU64 = AtomicU64::new(0); diff --git a/crates/rbitcoin-store/tests/head_resolve_pick.rs b/crates/rbitcoin-store/tests/head_resolve_pick.rs index 8dfecb7ff9..46915e4683 100644 --- a/crates/rbitcoin-store/tests/head_resolve_pick.rs +++ b/crates/rbitcoin-store/tests/head_resolve_pick.rs @@ -2,7 +2,7 @@ use rbitcoin_primitives::Fk; use rbitcoin_store::head_resolve_pick::*; use rbitcoin_store::height_fence::FenceRun; use rbitcoin_store::height_fence::HeightFence; -use rbitcoin_store::int_map::{U64Map, U64Set}; +use rbitcoin_store::int_map::U64Map; fn fence_on(fks: &[u64]) -> HeightFence { let runs: Vec = fks diff --git a/crates/rbitcoin-store/tests/head_resolve_stats.rs b/crates/rbitcoin-store/tests/head_resolve_stats.rs index a86e92eaaa..633b754b50 100644 --- a/crates/rbitcoin-store/tests/head_resolve_stats.rs +++ b/crates/rbitcoin-store/tests/head_resolve_stats.rs @@ -1,6 +1,5 @@ use rbitcoin_store::head_resolve_pick::LeftoverMissOn; use rbitcoin_store::head_resolve_stats::*; -use std::sync::atomic::{AtomicU64, Ordering}; /// Pure Sample math (no process atomics — safe under parallel cargo test). #[test] diff --git a/crates/rbitcoin-store/tests/header_table.rs b/crates/rbitcoin-store/tests/header_table.rs index 7f121ece96..b2f15e2118 100644 --- a/crates/rbitcoin-store/tests/header_table.rs +++ b/crates/rbitcoin-store/tests/header_table.rs @@ -1,11 +1,8 @@ -use bitcoin_hashes::{sha256, Hash, HashEngine}; use rbitcoin_primitives::{Fk, TableKind}; use rbitcoin_store::error::StoreError; use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; use rbitcoin_store::hashhead::{initial_slots_for, HashHead, HeadScale}; use rbitcoin_store::header_table::*; -use std::path::{Path, PathBuf}; -use std::sync::{Mutex, RwLock}; fn tmp() -> std::path::PathBuf { let p = std::env::temp_dir().join(format!( diff --git a/crates/rbitcoin-store/tests/height_fence.rs b/crates/rbitcoin-store/tests/height_fence.rs index 263d310b13..2bbb37cdbe 100644 --- a/crates/rbitcoin-store/tests/height_fence.rs +++ b/crates/rbitcoin-store/tests/height_fence.rs @@ -1,8 +1,5 @@ -use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_store::chain::{ConfirmedTable, HeaderTxsTable}; -use rbitcoin_store::error::StoreError; +use rbitcoin_primitives::Fk; use rbitcoin_store::height_fence::*; -use std::sync::Arc; fn run(first: u64, count: u32, height: u32) -> FenceRun { FenceRun { diff --git a/crates/rbitcoin-store/tests/idx_body_pipeline.rs b/crates/rbitcoin-store/tests/idx_body_pipeline.rs index 1672e6e2a8..fabb6599c6 100644 --- a/crates/rbitcoin-store/tests/idx_body_pipeline.rs +++ b/crates/rbitcoin-store/tests/idx_body_pipeline.rs @@ -1,12 +1,8 @@ use rbitcoin_primitives::Fk; -use rbitcoin_store::bulk_io::{self, ReadOp}; -use rbitcoin_store::error::StoreError; use rbitcoin_store::idx_body_pipeline::*; -use rbitcoin_store::io_backend::ReadIoBackend; use rbitcoin_store::tx_table::{ decode_packed_tx_outs_with_spender_rels, InputRecord, OutputRecord, TxRecord, TxTable, }; -use rbitcoin_store::var_table::VarTable; use std::sync::atomic::{AtomicU64, Ordering}; diff --git a/crates/rbitcoin-store/tests/index_build_uring.rs b/crates/rbitcoin-store/tests/index_build_uring.rs index 38afa27908..43608ccec1 100644 --- a/crates/rbitcoin-store/tests/index_build_uring.rs +++ b/crates/rbitcoin-store/tests/index_build_uring.rs @@ -1,20 +1,9 @@ use rbitcoin_primitives::{Fk, Height}; -use rbitcoin_store::create_loc::CreateLocPair; use rbitcoin_store::error::StoreError; use rbitcoin_store::index_build_uring::{ read_index_window, require_body_hwm, IndexHeight, IndexWindow, ReadJob, }; -use rbitcoin_store::input::{decode_edges_span, EdgesPlan, InputEdge}; -use rbitcoin_store::io_handle::IoHandle; -use rbitcoin_store::sp_tweaks_uring::LoadedTweakTx; -use rbitcoin_store::tx_table::{ - apply_input_edges, decode_packed_tx_outs_with_spender_rels_secret, decode_seqsigwit_secret, - OutputRecord, TxTable, -}; -use rbitcoin_store::txid_body::{TxidBody, TXID_ENTRY_LEN}; -use rbitcoin_store::uring_session::{self, UringSession}; -use rbitcoin_store::U64Map; -use std::path::Path; +use rbitcoin_store::tx_table::{OutputRecord, TxTable}; use rbitcoin_store::tx_table::{InputRecord, TxRecord}; diff --git a/crates/rbitcoin-store/tests/input.rs b/crates/rbitcoin-store/tests/input.rs index 998dc696f3..52d7b359c9 100644 --- a/crates/rbitcoin-store/tests/input.rs +++ b/crates/rbitcoin-store/tests/input.rs @@ -1,12 +1,7 @@ -use rbitcoin_primitives::{Fk, TableKind}; -use rbitcoin_store::delta_loc::{loc_window, loc_within, LOC_WINDOW}; +use rbitcoin_primitives::Fk; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; use rbitcoin_store::input::*; use rbitcoin_store::testutil::TempDir; -use std::path::Path; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::RwLock; fn edge(parent: u64, vout: u32) -> InputEdge { InputEdge { diff --git a/crates/rbitcoin-store/tests/int_map.rs b/crates/rbitcoin-store/tests/int_map.rs index 68963b2ef6..d262a729cb 100644 --- a/crates/rbitcoin-store/tests/int_map.rs +++ b/crates/rbitcoin-store/tests/int_map.rs @@ -1,7 +1,6 @@ use rbitcoin_primitives::Fk; use rbitcoin_store::int_map::*; -use std::collections::{HashMap, HashSet}; -use std::hash::{BuildHasherDefault, Hasher}; +use std::hash::Hasher; #[test] fn u64_identity_hasher_is_raw_key_and_map_roundtrips_pack_scale() { diff --git a/crates/rbitcoin-store/tests/integrity.rs b/crates/rbitcoin-store/tests/integrity.rs index 98031eab3f..781be6c9ba 100644 --- a/crates/rbitcoin-store/tests/integrity.rs +++ b/crates/rbitcoin-store/tests/integrity.rs @@ -1,16 +1,10 @@ use rbitcoin_primitives::{merkle_branch, merkle_root_from_branch, merkle_root_mutated}; -use rbitcoin_primitives::{ - merkle_root_from_txids, schema_file_openable, Fk, Height, SCHEMA_VERSION, STORE_MAGIC, -}; -use rbitcoin_store::error::StoreError; +use rbitcoin_primitives::{merkle_root_from_txids, Fk, Height}; use rbitcoin_store::header_table::block_header_hash; use rbitcoin_store::header_table::HeaderRecord; use rbitcoin_store::integrity::*; use rbitcoin_store::store::Store; use rbitcoin_store::tx_table::{InputRecord, OutputRecord, TxRecord}; -use std::fs::OpenOptions; -use std::io::{Read, Write}; -use std::path::Path; use std::path::PathBuf; use std::time::{SystemTime, UNIX_EPOCH}; diff --git a/crates/rbitcoin-store/tests/io_backend.rs b/crates/rbitcoin-store/tests/io_backend.rs index 14897767dc..f2ea51d07e 100644 --- a/crates/rbitcoin-store/tests/io_backend.rs +++ b/crates/rbitcoin-store/tests/io_backend.rs @@ -1,7 +1,5 @@ -use rbitcoin_store::bulk_io; use rbitcoin_store::io_backend::*; use std::sync::Mutex; -use std::sync::OnceLock; static ENV_LOCK: Mutex<()> = Mutex::new(()); diff --git a/crates/rbitcoin-store/tests/io_session_iocp.rs b/crates/rbitcoin-store/tests/io_session_iocp.rs index 9bbd255eab..5e453a13a9 100644 --- a/crates/rbitcoin-store/tests/io_session_iocp.rs +++ b/crates/rbitcoin-store/tests/io_session_iocp.rs @@ -1,11 +1,8 @@ #![cfg(windows)] -use rbitcoin_store::error::StoreError; use rbitcoin_store::io_handle::IoHandle; use rbitcoin_store::io_session_iocp::*; -use std::collections::{HashSet, VecDeque}; use std::os::windows::fs::OpenOptionsExt; use std::path::Path; -use std::ptr::null_mut; const FILE_FLAG_OVERLAPPED: u32 = 0x4000_0000; diff --git a/crates/rbitcoin-store/tests/public_surface.rs b/crates/rbitcoin-store/tests/public_surface.rs index 9a90f82549..796123f8ee 100644 --- a/crates/rbitcoin-store/tests/public_surface.rs +++ b/crates/rbitcoin-store/tests/public_surface.rs @@ -2,30 +2,19 @@ //! This test only asserts those names still resolve. Dropped names //! (`AddressHead`, `NetConfig`, `P2PHandle`, `LiveShardTable`, …) are //! denied by `lint/ast-grep/rules/crate-root-dropped-pub.yml`. -use rbitcoin_primitives::{ - merkle_branch, merkle_root_from_branch, merkle_root_from_txids, merkle_root_mutated, -}; +use rbitcoin_primitives::{merkle_branch, merkle_root_from_txids, merkle_root_mutated}; use rbitcoin_store::address_head::{is_probe_exhausted_error, is_store_corrupt_display}; -use rbitcoin_store::block_filter::{ - BlockFilterRecord, BlockFilterSlot, BlockFilterTable, StoredBlockFilter, -}; use rbitcoin_store::block_queue::{BlockQueue, QueuedBlockMeta, TakenRaw}; use rbitcoin_store::block_wire::block_wire_input_count; -use rbitcoin_store::chain::HeaderTxsTable; use rbitcoin_store::compact::output_flags; -use rbitcoin_store::create_loc::CreateLocPair; use rbitcoin_store::error::StoreError; use rbitcoin_store::file::ensure_nofile_budget; use rbitcoin_store::hashhead::{HeadOpenOpts, HeadScale}; use rbitcoin_store::head_resolve_stats::{leftover_probe_diag_ready, leftover_probe_diag_recorded}; use rbitcoin_store::header_table::{block_header_hash, HeaderRecord}; use rbitcoin_store::height_fence::HeightFence; -use rbitcoin_store::idx_body_pipeline::run_idx_body_pipeline; -use rbitcoin_store::idx_body_pipeline::{BodyMode as IdxBodyMode, IdxBodyJob, SpendSlotRun}; -use rbitcoin_store::index_build_uring::{read_index_window, IndexBlock, IndexHeight, IndexWindow}; -use rbitcoin_store::input::InputEdge; +use rbitcoin_store::idx_body_pipeline::{BodyMode as IdxBodyMode, IdxBodyJob}; use rbitcoin_store::int_map::{FkMap, FkSet, U32Map, U64IdentityHasher, U64Map, U64Set}; -use rbitcoin_store::integrity::VERIFY_TIP_BLOCKS; use rbitcoin_store::io_backend::{ReadIoBackend, WriteIoBackend}; use rbitcoin_store::point_table::PointRecord; use rbitcoin_store::scripthash::{ @@ -38,27 +27,17 @@ use rbitcoin_store::scripthash_materialize::{ unsorted_collect_workers, unsorted_done_last_fk, unsorted_pack_workers, unsorted_shard_dir, }; use rbitcoin_store::sorted_run::free_gib_label; -use rbitcoin_store::sorted_run::host_mem_available_bytes; -use rbitcoin_store::sp_tweaks::{SpTweaksTable, TrimLast}; -use rbitcoin_store::sp_tweaks_uring::{load_tweak_wave, LoadedTweakTx}; +use rbitcoin_store::sp_tweaks::SpTweaksTable; +use rbitcoin_store::sp_tweaks_uring::load_tweak_wave; use rbitcoin_store::spend_annotate_uring::spend_ann_backend; -use rbitcoin_store::spend_durable::{ - elapsed_after_checkpoint, spend_sync_due, SPEND_DURABLE_INTERVAL_MS, SPEND_DURABLE_NAME, -}; -use rbitcoin_store::store::{keep_unspent_vout_subsequence, SpindleHold, Store, StoreLayout}; +use rbitcoin_store::store::{Store, StoreLayout}; use rbitcoin_store::store_secret::StoreSecret; use rbitcoin_store::tx_table::HeadResizeSizeSnapshot; use rbitcoin_store::tx_table::{ decode_packed_tx_outs_with_spender_rels, decode_packed_tx_outs_with_spender_rels_secret, decode_packed_tx_with_spender_rels_secret, decode_seqsigwit_secret, encode_packed_tx, - encode_packed_tx_with_secret, encode_seqsigwit_with_secret, encode_txout_meta_and_outs, - encode_unspent_output_into_secret, encode_wire_seqsigwit_input, seqsigwit_input_len_upper, - spend_meta_backend, spent_abs, InputParent, InputRecord, OutputRecord, PackedCreate, TxRecord, -}; -use rbitcoin_store::txstat::TxStatRow; -use rbitcoin_store::uring_session::IoCtx; -use rbitcoin_store::uring_session::{ - abort_uring_unusable, note_uring_recover, uring_recover_count, uring_slow_drain_count, + encode_packed_tx_with_secret, encode_txout_meta_and_outs, encode_unspent_output_into_secret, + spend_meta_backend, spent_abs, InputRecord, OutputRecord, PackedCreate, TxRecord, }; #[test] diff --git a/crates/rbitcoin-store/tests/readonly_map.rs b/crates/rbitcoin-store/tests/readonly_map.rs index 5191dbc2e5..dd7d9d3fd8 100644 --- a/crates/rbitcoin-store/tests/readonly_map.rs +++ b/crates/rbitcoin-store/tests/readonly_map.rs @@ -1,8 +1,5 @@ use rbitcoin_store::error::StoreError; use rbitcoin_store::readonly_map::*; -use std::fs::File; -use std::path::Path; -use std::ptr; fn tmp() -> std::path::PathBuf { let p = std::env::temp_dir().join(format!( diff --git a/crates/rbitcoin-store/tests/scripthash.rs b/crates/rbitcoin-store/tests/scripthash.rs index c0c61cf97a..25b7e48719 100644 --- a/crates/rbitcoin-store/tests/scripthash.rs +++ b/crates/rbitcoin-store/tests/scripthash.rs @@ -1,34 +1,21 @@ -use bitcoin_hashes::{sha256, Hash}; -use rbitcoin_primitives::{uleb128_len, Fk, TableKind}; +use rbitcoin_primitives::{Fk, TableKind}; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{GrowPolicy, TableFile, FILE_HEADER_LEN}; +use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; use rbitcoin_store::fuse8_filter::SealedFuse8; -use rbitcoin_store::hashhead::{sh_main_shard_count, HeadScale}; -use rbitcoin_store::io_backend::ReadIoBackend; +use rbitcoin_store::hashhead::HeadScale; use rbitcoin_store::scripthash::*; -use rbitcoin_store::scripthash_head::{prefix_shard_of, ScriptHashHead}; +use rbitcoin_store::scripthash_head::prefix_shard_of; use rbitcoin_store::scripthash_layout::{ - head_key_from_full, pack8, pack8_bytes, payload_start, slab_bytes, ShHeadValue, - SH_ALLOC_HEADER_LEN, SH_ALLOC_MAGIC, SH_ALLOC_VERSION, SH_INLINE_CAP, SH_MAX_CLASS, - SH_MAX_SLAB_CLASS, SH_PAGE_SLAB_CLASS, + head_key_from_full, pack8_bytes, payload_start, ShHeadValue, SH_ALLOC_HEADER_LEN, + SH_ALLOC_MAGIC, SH_ALLOC_VERSION, SH_MAX_CLASS, SH_PAGE_SLAB_CLASS, }; use rbitcoin_store::scripthash_mphf::{mix_key16, MphfHead}; -use rbitcoin_store::scripthash_overflow::wipe_legacy_fullsize_overflow; use rbitcoin_store::scripthash_pages::{ - sh_page_as_array, sh_page_chunk_ranges, sh_page_decode_slice_into, sh_page_extent, - sh_page_first_off, sh_page_is_last, sh_page_last_fk, sh_page_next, - sh_page_pack_extent_last_fks, sh_page_pack_fks, sh_page_set_next, sh_page_try_append, - SH_PAGE_SIZE, SH_PAGE_STREAM_MAX, + sh_page_as_array, sh_page_extent, sh_page_set_next, SH_PAGE_SIZE, SH_PAGE_STREAM_MAX, }; -use rbitcoin_store::scripthash_slabs::{ - decode_slab_payload_into, encode_slab_payload_into, slab_class_for_n_fks_with_slack, - slab_class_for_packed_len, SH_MEGAKEY_MIN_FKS, -}; -use rbitcoin_store::scripthash_sorted_head::SortedHead; -use std::collections::{HashMap, HashSet}; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Mutex, RwLock}; +use std::collections::HashMap; +use std::path::PathBuf; +use std::sync::atomic::AtomicBool; use rbitcoin_store::scripthash_layout::SH_HEAD_VALUE_LEN; use rbitcoin_store::scripthash_materialize::{ diff --git a/crates/rbitcoin-store/tests/scripthash_head.rs b/crates/rbitcoin-store/tests/scripthash_head.rs index ebebfd942e..c2171a9b1d 100644 --- a/crates/rbitcoin-store/tests/scripthash_head.rs +++ b/crates/rbitcoin-store/tests/scripthash_head.rs @@ -1,16 +1,8 @@ use rbitcoin_primitives::Fk; -use rbitcoin_primitives::TableKind; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; -use rbitcoin_store::open_address::{self, MAX_LOAD_DEN, MAX_LOAD_NUM}; +use rbitcoin_store::file::FILE_HEADER_LEN; use rbitcoin_store::scripthash_head::*; -use rbitcoin_store::scripthash_layout::{ - head_key_from_full, pack8_bytes, unpack8_bytes, ShHeadKey, ShHeadValue, SH_HEAD_KEY_LEN, - SH_HEAD_SLOT_SIZE, SH_HEAD_VALUE_LEN, -}; -use std::collections::BTreeMap; -use std::path::{Path, PathBuf}; -use std::sync::Mutex; +use rbitcoin_store::scripthash_layout::{ShHeadValue, SH_HEAD_SLOT_SIZE}; use std::time::Instant; #[test] diff --git a/crates/rbitcoin-store/tests/scripthash_materialize.rs b/crates/rbitcoin-store/tests/scripthash_materialize.rs index 846f453507..5a2db67289 100644 --- a/crates/rbitcoin-store/tests/scripthash_materialize.rs +++ b/crates/rbitcoin-store/tests/scripthash_materialize.rs @@ -1,25 +1,14 @@ -use rbitcoin_primitives::{read_uleb128, write_uleb128, Fk}; +use rbitcoin_primitives::Fk; use rbitcoin_store::error::StoreError; use rbitcoin_store::fuse8_filter::SealedFuse8; -use rbitcoin_store::scripthash::{ - sorted_main_shard_path, ColdProgress, ScriptHashTable, ShShardPack, -}; -use rbitcoin_store::scripthash_head::prefix_shard_of; -use rbitcoin_store::scripthash_layout::{head_key_from_full, ShHeadKey, SH_HEAD_KEY_LEN}; +use rbitcoin_store::scripthash_layout::ShHeadKey; use rbitcoin_store::scripthash_materialize::*; -use rbitcoin_store::scripthash_mphf::{mix_key16, mphf_path, val_path, MphfHead}; -use rbitcoin_store::store::Store; -use rbitcoin_store::tx_table::TxTable; -use std::collections::hash_map::Entry; -use std::collections::{HashMap, HashSet, VecDeque}; -use std::fs::{self, OpenOptions}; -use std::hash::{BuildHasherDefault, Hasher}; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering}; +use rbitcoin_store::scripthash_mphf::{mix_key16, MphfHead}; +use std::fs::{self}; +use std::hash::Hasher; +use std::sync::atomic::{AtomicU32, AtomicU64, Ordering}; use std::sync::mpsc; -use std::sync::mpsc::{Receiver, SyncSender}; -use std::sync::{Arc, Mutex}; -use std::time::{Duration, Instant}; +use std::sync::Mutex; use std::hash::Hash; diff --git a/crates/rbitcoin-store/tests/scripthash_mphf.rs b/crates/rbitcoin-store/tests/scripthash_mphf.rs index e08ac635fb..3b9988d88f 100644 --- a/crates/rbitcoin-store/tests/scripthash_mphf.rs +++ b/crates/rbitcoin-store/tests/scripthash_mphf.rs @@ -1,10 +1,9 @@ use rbitcoin_store::bdz::BdzMphf; use rbitcoin_store::error::StoreError; -use rbitcoin_store::scripthash_layout::{pack8, unpack8, ShHeadKey, ShHeadValue, SH_HEAD_KEY_LEN}; +use rbitcoin_store::scripthash_layout::{pack8, ShHeadKey, ShHeadValue, SH_HEAD_KEY_LEN}; use rbitcoin_store::scripthash_mphf::*; -use std::fs::{File, OpenOptions}; -use std::io::Write; -use std::path::{Path, PathBuf}; +use std::fs::OpenOptions; +use std::path::PathBuf; use rbitcoin_primitives::Fk; diff --git a/crates/rbitcoin-store/tests/scripthash_pages.rs b/crates/rbitcoin-store/tests/scripthash_pages.rs index cac44489a4..2fd82c202b 100644 --- a/crates/rbitcoin-store/tests/scripthash_pages.rs +++ b/crates/rbitcoin-store/tests/scripthash_pages.rs @@ -1,8 +1,7 @@ -use rbitcoin_primitives::{read_uleb128, uleb128_len, write_uleb128_into, Fk}; +use rbitcoin_primitives::Fk; use rbitcoin_store::error::StoreError; -use rbitcoin_store::scripthash_layout::SH_ENTRY_LEN; use rbitcoin_store::scripthash_pages::*; -use rbitcoin_store::scripthash_slabs::{decode_fk_delta_stream_into, encode_fk_delta_stream_into}; +use rbitcoin_store::scripthash_slabs::encode_fk_delta_stream_into; fn raw(fks: &[Fk]) -> Vec { fks.iter().map(|fk| fk.0).collect() diff --git a/crates/rbitcoin-store/tests/scripthash_slabs.rs b/crates/rbitcoin-store/tests/scripthash_slabs.rs index 443b0dd850..7f03f5f4e1 100644 --- a/crates/rbitcoin-store/tests/scripthash_slabs.rs +++ b/crates/rbitcoin-store/tests/scripthash_slabs.rs @@ -1,6 +1,6 @@ -use rbitcoin_primitives::{read_uleb128, write_uleb128_into, Fk}; +use rbitcoin_primitives::Fk; use rbitcoin_store::error::StoreError; -use rbitcoin_store::scripthash_layout::{slab_bytes, slab_cap, SH_INLINE_CAP, SH_MAX_SLAB_CLASS}; +use rbitcoin_store::scripthash_layout::slab_bytes; use rbitcoin_store::scripthash_pages::SH_FLAG_BIT; use rbitcoin_store::scripthash_slabs::*; diff --git a/crates/rbitcoin-store/tests/scripthash_sorted_head.rs b/crates/rbitcoin-store/tests/scripthash_sorted_head.rs index d689e0bcfd..dc26b4ca6c 100644 --- a/crates/rbitcoin-store/tests/scripthash_sorted_head.rs +++ b/crates/rbitcoin-store/tests/scripthash_sorted_head.rs @@ -1,16 +1,9 @@ use rbitcoin_primitives::Fk; use rbitcoin_store::error::StoreError; -use rbitcoin_store::fuse8_filter::{fuse_key_from_mixed, SealedFuse8}; -use rbitcoin_store::io_handle::IoHandle; -use rbitcoin_store::scripthash_layout::{ - pack8_bytes, unpack8_bytes, ShHeadKey, ShHeadValue, SH_HEAD_KEY_LEN, SH_HEAD_SLOT_SIZE, - SH_HEAD_VALUE_LEN, -}; +use rbitcoin_store::scripthash_layout::{pack8_bytes, ShHeadKey, ShHeadValue, SH_HEAD_VALUE_LEN}; use rbitcoin_store::scripthash_sorted_head::*; -use std::fs::{File, OpenOptions}; -use std::io::Write; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicU64, Ordering}; +use std::path::PathBuf; +use std::sync::atomic::Ordering; fn tmp() -> PathBuf { let p = std::env::temp_dir().join(format!( diff --git a/crates/rbitcoin-store/tests/segmented_head.rs b/crates/rbitcoin-store/tests/segmented_head.rs index ef0bcfbd96..af8cf13e65 100644 --- a/crates/rbitcoin-store/tests/segmented_head.rs +++ b/crates/rbitcoin-store/tests/segmented_head.rs @@ -1,14 +1,10 @@ -use rbitcoin_primitives::{Fk, SCHEMA_VERSION, STORE_MAGIC}; -use rbitcoin_store::address_head::{AddressHead, HeadLayout, HEAD_LOAD_START, MAINNET_BITS}; +use rbitcoin_primitives::Fk; +use rbitcoin_store::address_head::HeadLayout; use rbitcoin_store::error::StoreError; -use rbitcoin_store::fuse8_filter::{fuse_key_from_mixed, open_file, SealedFuse8}; +use rbitcoin_store::fuse8_filter::fuse_key_from_mixed; use rbitcoin_store::segmented_head::*; -use rbitcoin_store::tx_head_mphf::TxHeadMphf; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicU32, AtomicU64, Ordering}; -use std::sync::mpsc::{self, Receiver}; -use std::sync::{Arc, Mutex, RwLock}; -use std::time::Instant; +use std::path::PathBuf; +use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; diff --git a/crates/rbitcoin-store/tests/sp_tweaks.rs b/crates/rbitcoin-store/tests/sp_tweaks.rs index 6f026de2fb..0a66c93132 100644 --- a/crates/rbitcoin-store/tests/sp_tweaks.rs +++ b/crates/rbitcoin-store/tests/sp_tweaks.rs @@ -1,12 +1,10 @@ -use rbitcoin_primitives::{Height, TableKind}; +use rbitcoin_primitives::Height; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; -use rbitcoin_store::seg_pair::{locate, SegDirs, SegPair as Seg}; +use rbitcoin_store::file::FILE_HEADER_LEN; use rbitcoin_store::sp_tweaks::*; use std::fs; use std::io::{Read, Seek, SeekFrom, Write}; -use std::path::{Path, PathBuf}; -use std::sync::Mutex; +use std::path::Path; fn tmp_dir() -> rbitcoin_store::testutil::TempDir { rbitcoin_store::testutil::TempDir::labeled("sptweaks").unwrap() diff --git a/crates/rbitcoin-store/tests/sp_tweaks_uring.rs b/crates/rbitcoin-store/tests/sp_tweaks_uring.rs index 1a3805fb5f..58a6359a6a 100644 --- a/crates/rbitcoin-store/tests/sp_tweaks_uring.rs +++ b/crates/rbitcoin-store/tests/sp_tweaks_uring.rs @@ -1,15 +1,7 @@ use rbitcoin_primitives::Fk; use rbitcoin_store::address_head::HeadLayout; -use rbitcoin_store::error::StoreError; -use rbitcoin_store::io_handle::IoHandle; use rbitcoin_store::sp_tweaks_uring::*; -use rbitcoin_store::tx_table::{ - decode_packed_tx_outs_with_spender_rels_secret, decode_seqsigwit_secret, InputRecord, - OutputRecord, TxRecord, TxTable, -}; -use rbitcoin_store::uring_session::{self, UringSession}; -use rbitcoin_store::U64Map; -use std::path::Path; +use rbitcoin_store::tx_table::{InputRecord, OutputRecord, TxRecord, TxTable}; fn tmp_dir() -> rbitcoin_store::testutil::TempDir { rbitcoin_store::testutil::TempDir::labeled("sp-uring").unwrap() diff --git a/crates/rbitcoin-store/tests/spend_annotate_uring.rs b/crates/rbitcoin-store/tests/spend_annotate_uring.rs index 5dfc1ebb0f..93cb4a136f 100644 --- a/crates/rbitcoin-store/tests/spend_annotate_uring.rs +++ b/crates/rbitcoin-store/tests/spend_annotate_uring.rs @@ -1,13 +1,10 @@ use rbitcoin_primitives::Fk; use rbitcoin_store::compact::output_flags; use rbitcoin_store::error::StoreError; -use rbitcoin_store::io_handle::IoHandle; use rbitcoin_store::spend_annotate_uring::*; use rbitcoin_store::spender_table::SpenderTable; -use rbitcoin_store::tx_table::{decode_spent_slot, encode_spent_slot, OutputRecord, TxTable}; use rbitcoin_store::tx_table::{InputRecord, TxRecord}; -use rbitcoin_store::uring_session::{self, UringSession}; -use std::collections::VecDeque; +use rbitcoin_store::tx_table::{OutputRecord, TxTable}; use std::sync::atomic::{AtomicU64, Ordering}; fn temp_table() -> (std::path::PathBuf, TxTable, SpenderTable) { diff --git a/crates/rbitcoin-store/tests/spend_durable.rs b/crates/rbitcoin-store/tests/spend_durable.rs index 7c96624ba5..d14cdb69a9 100644 --- a/crates/rbitcoin-store/tests/spend_durable.rs +++ b/crates/rbitcoin-store/tests/spend_durable.rs @@ -1,8 +1,4 @@ -use rbitcoin_primitives::{schema_file_openable, SCHEMA_VERSION, STORE_MAGIC}; -use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::write_synced_tmp_rename; use rbitcoin_store::spend_durable::*; -use std::path::Path; #[test] fn spend_sync_due_is_ten_minutes_elapsed_only() { diff --git a/crates/rbitcoin-store/tests/spender_table.rs b/crates/rbitcoin-store/tests/spender_table.rs index de3b0807c3..a008472259 100644 --- a/crates/rbitcoin-store/tests/spender_table.rs +++ b/crates/rbitcoin-store/tests/spender_table.rs @@ -1,10 +1,7 @@ -use rbitcoin_primitives::{Fk, TableKind}; +use rbitcoin_primitives::Fk; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; +use rbitcoin_store::file::FILE_HEADER_LEN; use rbitcoin_store::spender_table::*; -use rbitcoin_store::tx_table::{pack_spent_field, unpack_spent_field}; -use std::path::Path; -use std::sync::atomic::{AtomicU64, Ordering}; #[test] fn append_get_chain() { diff --git a/crates/rbitcoin-store/tests/store/legacy_rename_tests.rs b/crates/rbitcoin-store/tests/store/legacy_rename_tests.rs index 392c47662a..4e7e980b19 100644 --- a/crates/rbitcoin-store/tests/store/legacy_rename_tests.rs +++ b/crates/rbitcoin-store/tests/store/legacy_rename_tests.rs @@ -1,17 +1,5 @@ -use rbitcoin_primitives::{schema_file_openable, Fk, Height, SCHEMA_VERSION, STORE_MAGIC}; -use rbitcoin_store::chain::{ConfirmedTable, HeaderTxsTable, StrongTxTable}; use rbitcoin_store::error::StoreError; -use rbitcoin_store::hashhead::{HeadOpenOpts, HeadScale}; -use rbitcoin_store::header_table::{HeaderRecord, HeaderTable}; -use rbitcoin_store::height_fence::{HeightFence, MtpRing}; -use rbitcoin_store::point_table::{self, PointRecord}; -use rbitcoin_store::scripthash::ScriptHashTable; -use rbitcoin_store::spender_table::SpenderTable; use rbitcoin_store::store::*; -use rbitcoin_store::tx_table::{InputRecord, OutputRecord, TxRecord, TxTable}; -use std::fs::OpenOptions; -use std::io::Write; -use std::path::{Path, PathBuf}; #[test] fn legacy_names_rename_and_both_exist_errors() { diff --git a/crates/rbitcoin-store/tests/store/mod.rs b/crates/rbitcoin-store/tests/store/mod.rs index 31338c9315..cf37ba1a89 100644 --- a/crates/rbitcoin-store/tests/store/mod.rs +++ b/crates/rbitcoin-store/tests/store/mod.rs @@ -1,18 +1,12 @@ -use rbitcoin_primitives::{schema_file_openable, Fk, Height, SCHEMA_VERSION, STORE_MAGIC}; -use rbitcoin_store::chain::{ConfirmedTable, HeaderTxsTable, StrongTxTable}; +use rbitcoin_primitives::{Fk, Height, SCHEMA_VERSION, STORE_MAGIC}; use rbitcoin_store::error::StoreError; -use rbitcoin_store::hashhead::{HeadOpenOpts, HeadScale}; +use rbitcoin_store::hashhead::HeadScale; use rbitcoin_store::head_resolve_pick::LeftoverMissOn; -use rbitcoin_store::header_table::{HeaderRecord, HeaderTable}; -use rbitcoin_store::height_fence::{HeightFence, MtpRing}; -use rbitcoin_store::point_table::{self, PointRecord}; -use rbitcoin_store::scripthash::ScriptHashTable; -use rbitcoin_store::spender_table::SpenderTable; +use rbitcoin_store::header_table::HeaderRecord; +use rbitcoin_store::point_table::{self}; use rbitcoin_store::store::*; -use rbitcoin_store::tx_table::{InputRecord, OutputRecord, TxRecord, TxTable}; -use std::fs::OpenOptions; -use std::io::Write; -use std::path::{Path, PathBuf}; +use rbitcoin_store::tx_table::{InputRecord, OutputRecord, TxRecord}; +use std::path::Path; mod legacy_rename_tests; diff --git a/crates/rbitcoin-store/tests/store_secret.rs b/crates/rbitcoin-store/tests/store_secret.rs index b6c87c7860..2efef4aefe 100644 --- a/crates/rbitcoin-store/tests/store_secret.rs +++ b/crates/rbitcoin-store/tests/store_secret.rs @@ -1,9 +1,5 @@ -use bitcoin_hashes::{sha256, Hash}; use rbitcoin_store::error::StoreError; use rbitcoin_store::store_secret::*; -use std::fs::OpenOptions; -use std::io::{Read, Write}; -use std::path::{Path, PathBuf}; fn temp_dir() -> rbitcoin_store::testutil::TempDir { rbitcoin_store::testutil::TempDir::labeled("secret").unwrap() diff --git a/crates/rbitcoin-store/tests/suite.rs b/crates/rbitcoin-store/tests/suite.rs index c912c0902b..b51d7f9972 100644 --- a/crates/rbitcoin-store/tests/suite.rs +++ b/crates/rbitcoin-store/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod address_head; mod array_table; mod bdz; diff --git a/crates/rbitcoin-store/tests/testutil.rs b/crates/rbitcoin-store/tests/testutil.rs index 2a4952859f..31ab05f23f 100644 --- a/crates/rbitcoin-store/tests/testutil.rs +++ b/crates/rbitcoin-store/tests/testutil.rs @@ -1,8 +1,4 @@ use rbitcoin_store::testutil::*; -use rbitcoin_store::Store; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::time::{SystemTime, UNIX_EPOCH}; #[test] fn copy_store_tree_copies_nested_files() { diff --git a/crates/rbitcoin-store/tests/tx_head_mphf.rs b/crates/rbitcoin-store/tests/tx_head_mphf.rs index fbfb8eb400..d59d8040fe 100644 --- a/crates/rbitcoin-store/tests/tx_head_mphf.rs +++ b/crates/rbitcoin-store/tests/tx_head_mphf.rs @@ -1,8 +1,7 @@ use rbitcoin_store::bdz::BdzMphf; use rbitcoin_store::error::StoreError; use rbitcoin_store::tx_head_mphf::*; -use std::collections::HashMap; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use rbitcoin_store::uring_session::{IoCtx, SessionKind, UringSession}; diff --git a/crates/rbitcoin-store/tests/tx_table/mod.rs b/crates/rbitcoin-store/tests/tx_table/mod.rs index b4c6d60789..8650c32460 100644 --- a/crates/rbitcoin-store/tests/tx_table/mod.rs +++ b/crates/rbitcoin-store/tests/tx_table/mod.rs @@ -1,18 +1,13 @@ //! Tx table unit tests (peeled). -use rbitcoin_primitives::{read_uleb128, write_uleb128, Fk, TableKind}; +use rbitcoin_primitives::{read_uleb128, write_uleb128, Fk}; use rbitcoin_store::address_head::HeadLayout; use rbitcoin_store::compact::{ - amount_exp_mantissa, decode_output_amount, decode_script_kind_v17, encode_script_kind_v17, - input_flags, output_flags, script_kind_v17_disk_used, split_output_flags, + decode_script_kind_v17, encode_script_kind_v17, input_flags, output_flags, }; use rbitcoin_store::error::StoreError; use rbitcoin_store::hashhead::HeadOpenOpts; -use rbitcoin_store::segmented_head::SegmentedTxHead; use rbitcoin_store::tx_table::packed::*; -use rbitcoin_store::tx_table::pending_head::PENDING_HEAD_CAP; -use rbitcoin_store::var_table::VarTable; use std::path::Path; -use std::sync::Arc; use rbitcoin_primitives::write_compact_size; use rbitcoin_store::compact::{ diff --git a/crates/rbitcoin-store/tests/tx_table/packed/borrowed_input_encode_tests.rs b/crates/rbitcoin-store/tests/tx_table/packed/borrowed_input_encode_tests.rs index d13deb79c5..835c1010ef 100644 --- a/crates/rbitcoin-store/tests/tx_table/packed/borrowed_input_encode_tests.rs +++ b/crates/rbitcoin-store/tests/tx_table/packed/borrowed_input_encode_tests.rs @@ -1,7 +1,5 @@ use rbitcoin_primitives::Fk; -use rbitcoin_primitives::{read_compact_size, write_compact_size}; use rbitcoin_store::tx_table::packed::*; -use rbitcoin_store::tx_table::*; fn witness_refs(items: &[Vec]) -> Vec<&[u8]> { items.iter().map(|i| i.as_slice()).collect() diff --git a/crates/rbitcoin-store/tests/tx_table/packed/mod.rs b/crates/rbitcoin-store/tests/tx_table/packed/mod.rs index e3cc277e9e..457882041e 100644 --- a/crates/rbitcoin-store/tests/tx_table/packed/mod.rs +++ b/crates/rbitcoin-store/tests/tx_table/packed/mod.rs @@ -1,4 +1,2 @@ -use rbitcoin_primitives::{read_compact_size, write_compact_size}; -use rbitcoin_store::tx_table::*; mod borrowed_input_encode_tests; mod scan_p2tr_tests; diff --git a/crates/rbitcoin-store/tests/tx_table/packed/scan_p2tr_tests.rs b/crates/rbitcoin-store/tests/tx_table/packed/scan_p2tr_tests.rs index c6db047723..23c08b80cb 100644 --- a/crates/rbitcoin-store/tests/tx_table/packed/scan_p2tr_tests.rs +++ b/crates/rbitcoin-store/tests/tx_table/packed/scan_p2tr_tests.rs @@ -1,6 +1,5 @@ use rbitcoin_primitives::write_uleb128; use rbitcoin_primitives::Fk; -use rbitcoin_primitives::{read_compact_size, write_compact_size}; use rbitcoin_store::compact::{amount_exp_mantissa, SCRIPT_KIND_V17_P2TR}; use rbitcoin_store::tx_table::packed::*; use rbitcoin_store::tx_table::*; diff --git a/crates/rbitcoin-store/tests/txid_body.rs b/crates/rbitcoin-store/tests/txid_body.rs index a43335ff1a..9a4637a564 100644 --- a/crates/rbitcoin-store/tests/txid_body.rs +++ b/crates/rbitcoin-store/tests/txid_body.rs @@ -1,9 +1,6 @@ -use rbitcoin_primitives::{Fk, TableKind}; +use rbitcoin_primitives::Fk; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; use rbitcoin_store::txid_body::*; -use std::collections::HashMap; -use std::path::{Path, PathBuf}; use std::time::{SystemTime, UNIX_EPOCH}; fn tmp() -> std::path::PathBuf { diff --git a/crates/rbitcoin-store/tests/txstat.rs b/crates/rbitcoin-store/tests/txstat.rs index e08330914f..d11c953fa2 100644 --- a/crates/rbitcoin-store/tests/txstat.rs +++ b/crates/rbitcoin-store/tests/txstat.rs @@ -1,10 +1,7 @@ -use rbitcoin_primitives::{read_uleb128, uleb128_len, write_uleb128, Fk, TableKind}; +use rbitcoin_primitives::Fk; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{GrowPolicy, TableFile, FILE_HEADER_LEN}; use rbitcoin_store::testutil::TempDir; use rbitcoin_store::txstat::*; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicU64, Ordering}; fn tiny(fee: u64, base: u32, wit: u32) -> TxStatRow { TxStatRow { diff --git a/crates/rbitcoin-store/tests/uring_session.rs b/crates/rbitcoin-store/tests/uring_session.rs index 158500dbe1..1a0a2fdc7c 100644 --- a/crates/rbitcoin-store/tests/uring_session.rs +++ b/crates/rbitcoin-store/tests/uring_session.rs @@ -1,11 +1,7 @@ use rbitcoin_store::error::StoreError; -use rbitcoin_store::io_handle::IoHandle; -use rbitcoin_store::io_session_pool::PoolEngine; use rbitcoin_store::uring_session::*; -use std::cell::Cell; use std::path::Path; -use std::sync::OnceLock; -use std::time::{Duration, Instant}; +use std::time::Duration; #[test] fn enter_failure_with_pending_matches_the_hard_cap() { diff --git a/crates/rbitcoin-store/tests/var_table.rs b/crates/rbitcoin-store/tests/var_table.rs index 65db52fdb2..4fae6e5039 100644 --- a/crates/rbitcoin-store/tests/var_table.rs +++ b/crates/rbitcoin-store/tests/var_table.rs @@ -1,10 +1,8 @@ use rbitcoin_primitives::{Fk, TableKind}; use rbitcoin_store::error::StoreError; -use rbitcoin_store::file::{TableFile, FILE_HEADER_LEN}; -use rbitcoin_store::io_handle::IoHandle; +use rbitcoin_store::file::FILE_HEADER_LEN; use rbitcoin_store::var_table::*; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::atomic::AtomicU64; #[test] fn class_a_body_waves_serial_is_one_stem_each() { diff --git a/crates/rbitcoin-sv2/tests/listener_tests.rs b/crates/rbitcoin-sv2/tests/listener_tests.rs index fc9582d6ae..511b67b592 100644 --- a/crates/rbitcoin-sv2/tests/listener_tests.rs +++ b/crates/rbitcoin-sv2/tests/listener_tests.rs @@ -1,23 +1,17 @@ use crate::test_chain::shared_regtest; -use bitcoin::secp256k1::{Keypair, Secp256k1}; use common_messages_sv2::{ SetupConnectionError, SetupConnectionSuccess, MESSAGE_TYPE_SETUP_CONNECTION_ERROR, MESSAGE_TYPE_SETUP_CONNECTION_SUCCESS, }; -use rbitcoin_net::{ChainHub, RequestMeter}; use rbitcoin_sv2::testutil::TpClient; -use rbitcoin_sv2::transport::Frame; use rbitcoin_sv2::{ run_sv2_tp, Sv2TpConfig, FEE_DELTA, MAX_SESSIONS, MAX_STALE_GRACE, MAX_TEMPLATE_INTERVAL, MIN_TEMPLATE_INTERVAL, SETUP_TIMEOUT, TEMPLATE_INTERVAL, WRITE_TIMEOUT, }; use std::io; use std::net::SocketAddr; -use std::sync::{Arc, Mutex}; +use std::sync::Arc; use std::time::Duration; -use tokio::net::TcpListener; -use tokio::sync::Semaphore; -use tokio::task::JoinHandle; use std::time::Instant; use template_distribution_sv2::MESSAGE_TYPE_REQUEST_TRANSACTION_DATA_ERROR; diff --git a/crates/rbitcoin-sv2/tests/session.rs b/crates/rbitcoin-sv2/tests/session.rs index f578803677..3cc23b8fdc 100644 --- a/crates/rbitcoin-sv2/tests/session.rs +++ b/crates/rbitcoin-sv2/tests/session.rs @@ -1,38 +1,6 @@ -use binary_sv2::{Seq064K, Str0255, B016M, B064K}; -use bitcoin::hashes::Hash; -use bitcoin::{block, Block, BlockHash, CompactTarget, Transaction, TxMerkleNode, Witness}; -use common_messages_sv2::{ - Protocol, SetupConnection, SetupConnectionError, SetupConnectionSuccess, - ERROR_CODE_SETUP_CONNECTION_PROTOCOL_VERSION_MISMATCH, - ERROR_CODE_SETUP_CONNECTION_UNSUPPORTED_FEATURE_FLAGS, - ERROR_CODE_SETUP_CONNECTION_UNSUPPORTED_PROTOCOL, MESSAGE_TYPE_SETUP_CONNECTION, - MESSAGE_TYPE_SETUP_CONNECTION_ERROR, MESSAGE_TYPE_SETUP_CONNECTION_SUCCESS, -}; -use noise_sv2::Responder; -use rbitcoin_net::{BlockingRegion, ChainHub}; use rbitcoin_sv2::session::{constraints_rebuild_at, Templates}; -use rbitcoin_sv2::template; -use rbitcoin_sv2::transport::{Frame, NoiseConn, NoiseWriter}; -use rbitcoin_sv2::Sv2TpStats; use rbitcoin_sv2::CONSTRAINTS_COOLDOWN; -use std::collections::VecDeque; -use std::io; -use std::sync::Arc; use std::time::Duration; -use template_distribution_sv2::{ - CoinbaseOutputConstraints, RequestTransactionData, RequestTransactionDataError, - RequestTransactionDataSuccess, SubmitSolution, - ERROR_CODE_REQUEST_TRANSACTION_DATA_STALE_TEMPLATE_ID, - ERROR_CODE_REQUEST_TRANSACTION_DATA_TEMPLATE_ID_NOT_FOUND, - MESSAGE_TYPE_COINBASE_OUTPUT_CONSTRAINTS, MESSAGE_TYPE_NEW_TEMPLATE, - MESSAGE_TYPE_REQUEST_TRANSACTION_DATA, MESSAGE_TYPE_REQUEST_TRANSACTION_DATA_ERROR, - MESSAGE_TYPE_REQUEST_TRANSACTION_DATA_SUCCESS, MESSAGE_TYPE_SET_NEW_PREV_HASH, - MESSAGE_TYPE_SUBMIT_SOLUTION, -}; -use tokio::net::TcpStream; -use tokio::sync::broadcast::error::RecvError; -use tokio::sync::mpsc; -use tokio::task::JoinSet; use tokio::time::Instant; #[test] diff --git a/crates/rbitcoin-sv2/tests/suite.rs b/crates/rbitcoin-sv2/tests/suite.rs index 59eedcb064..dec16b4639 100644 --- a/crates/rbitcoin-sv2/tests/suite.rs +++ b/crates/rbitcoin-sv2/tests/suite.rs @@ -1,4 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] mod listener_tests; mod session; mod template_tests; diff --git a/crates/rbitcoin-sv2/tests/template_tests.rs b/crates/rbitcoin-sv2/tests/template_tests.rs index 1093e9e8e9..f281bcca6b 100644 --- a/crates/rbitcoin-sv2/tests/template_tests.rs +++ b/crates/rbitcoin-sv2/tests/template_tests.rs @@ -1,8 +1,6 @@ use crate::test_chain::{padded_chain_with, shared_regtest, TestChain}; -use binary_sv2::{Seq0255, B0255, B064K, U256}; use bitcoin::consensus::encode::serialize; use bitcoin::hashes::{sha256d, Hash}; -use bitcoin::secp256k1::{Keypair, Secp256k1}; use bitcoin::{ absolute::LockTime, transaction::Version, Amount, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Txid, Witness, @@ -12,23 +10,16 @@ use rbitcoin_consensus::{ bip34_height_script, block_subsidy, mine_empty_regtest, mine_regtest_paying, witness_commitment_script, ChainParams, }; -use rbitcoin_net::{ChainHub, RequestMeter}; use rbitcoin_primitives::Height; use rbitcoin_query::{confirm_scripts_phase, expected_next_bits, median_time_past}; use rbitcoin_store::merkle_root_from_txids; use rbitcoin_sv2::testutil::TpClient; -use rbitcoin_sv2::transport::Frame; use rbitcoin_sv2::{ run_sv2_tp, Sv2TpConfig, CONSTRAINTS_COOLDOWN, FEE_DELTA, SETUP_TIMEOUT, TEMPLATE_INTERVAL, WRITE_TIMEOUT, }; -use std::io; -use std::net::SocketAddr; -use std::sync::{Arc, Mutex}; +use std::sync::Arc; use std::time::Duration; -use tokio::net::TcpListener; -use tokio::sync::Semaphore; -use tokio::task::JoinHandle; use template_distribution_sv2::{ NewTemplate, SetNewPrevHash, MESSAGE_TYPE_NEW_TEMPLATE, MESSAGE_TYPE_SET_NEW_PREV_HASH, diff --git a/crates/rbitcoin-sv2/tests/test_chain.rs b/crates/rbitcoin-sv2/tests/test_chain.rs index a338e8fe22..15a679162d 100644 --- a/crates/rbitcoin-sv2/tests/test_chain.rs +++ b/crates/rbitcoin-sv2/tests/test_chain.rs @@ -1,20 +1,12 @@ -use bitcoin::secp256k1::{Keypair, Secp256k1}; use bitcoin::{Network, Txid}; use rbitcoin_consensus::{ChainParams, Milestone}; +use rbitcoin_net::ChainHub; use rbitcoin_net::MempoolHub; -use rbitcoin_net::{ChainHub, RequestMeter}; use rbitcoin_primitives::Height; use rbitcoin_query::testutil::{tiny_query_labeled, TempDir}; use rbitcoin_query::{accept_and_connect_block, pad_empty_from}; -use rbitcoin_sv2::transport::Frame; -use std::io; -use std::net::SocketAddr; use std::path::Path; -use std::sync::{Arc, Mutex}; -use std::time::Duration; -use tokio::net::TcpListener; -use tokio::sync::Semaphore; -use tokio::task::JoinHandle; +use std::sync::Arc; pub(crate) struct TestChain { pub _dir: TempDir, diff --git a/crates/rbitcoin-test/tests/suite.rs b/crates/rbitcoin-test/tests/suite.rs index be1578549d..7b4e4d7a19 100644 --- a/crates/rbitcoin-test/tests/suite.rs +++ b/crates/rbitcoin-test/tests/suite.rs @@ -1,5 +1,3 @@ -#![allow(unused_imports, dead_code, unused_variables)] - mod asmap_journey; mod consensus_rules; mod core_analogs; From 3e7ded3ff71032e334d632788d28d173de55bc6c Mon Sep 17 00:00:00 2001 From: "rearden-grok[bot]" <317016512+rearden-grok[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:06:09 -0700 Subject: [PATCH 04/10] coverage: badge gate follows the 91% floor; stale paths after the layout move #1097 set the floor to 89 and then 91; the badge kept `--gate 89` in coverage.sh and as the coverage-badge.py default, so a run between 89 and 91 would draw a passing badge on a failing gate. coverage.test.sh now reads FLOOR_PCT from coverage-gate.py and pins both to it. The IGNORE regex fixtures in coverage.test.sh name current files (tests/ and rbitcoin-ibd) instead of the src/*_tests.rs they described before the move. docs/concurrency.md links perf_log.rs where it lives now. Five rustdoc links to ChainHub and IndexMode, which rpc and node cannot resolve since IBD moved to rbitcoin-ibd, are plain code spans. Co-authored-by: Cursor --- crates/rbitcoin-node/src/regtest_rpc.rs | 2 +- crates/rbitcoin-node/src/run.rs | 2 +- crates/rbitcoin-rpc/src/methods/mod.rs | 6 +++--- docs/concurrency.md | 2 +- scripts/coverage-badge.py | 2 +- scripts/coverage.sh | 2 +- scripts/coverage.test.sh | 17 +++++++++++------ 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/crates/rbitcoin-node/src/regtest_rpc.rs b/crates/rbitcoin-node/src/regtest_rpc.rs index 91d8be4387..6bcfd43aee 100644 --- a/crates/rbitcoin-node/src/regtest_rpc.rs +++ b/crates/rbitcoin-node/src/regtest_rpc.rs @@ -1,4 +1,4 @@ //! Regtest generate / `submitblock`: mine locally; `submitblock` uses the -//! same [`ChainHub::accept_received_block`] path as P2P `block` messages. +//! same `ChainHub::accept_received_block` path as P2P `block` messages. pub use rbitcoin_rpc::HubRegtest; diff --git a/crates/rbitcoin-node/src/run.rs b/crates/rbitcoin-node/src/run.rs index c780a8c7c3..bd3ba29f3f 100644 --- a/crates/rbitcoin-node/src/run.rs +++ b/crates/rbitcoin-node/src/run.rs @@ -2306,7 +2306,7 @@ pub fn sh_tip_ready_gates(query: &Query) -> TipModeGates { /// max tip age with no heavier local header chain. /// /// **SH methods (exactly two):** -/// - Durable head: stay/flip [`IndexMode::Tip`], discard leftover runs; +/// - Durable head: stay/flip `IndexMode::Tip`, discard leftover runs; /// catch-up / follow use write-behind. `sh_tip_ready` only when inclusion /// already covers the tip. /// - No head: Class A collect + unsorted pack **while Direct** (write-behind diff --git a/crates/rbitcoin-rpc/src/methods/mod.rs b/crates/rbitcoin-rpc/src/methods/mod.rs index ad1cb7d5f8..66eec292d9 100644 --- a/crates/rbitcoin-rpc/src/methods/mod.rs +++ b/crates/rbitcoin-rpc/src/methods/mod.rs @@ -84,14 +84,14 @@ pub struct RpcContext { pub stop: Arc, /// Best-effort live peer count (updated by node; 0 if unknown). pub connections: Arc, - /// Fallback IBD flag when no [`ChainHub`] is attached (tests / smoke RPC). - /// `getblockchaininfo` prefers [`ChainHub::in_ibd`] (relay-inhibited: + /// Fallback IBD flag when no `ChainHub` is attached (tests / smoke RPC). + /// `getblockchaininfo` prefers `ChainHub::in_ibd` (relay-inhibited: /// `--min-chain-work` + `--max-tip-age` after densify; Core RPC name /// `initialblockdownload`). pub initial_block_download: Arc, /// `getnetworkinfo.subversion` (BIP14 / Core `-uacomment` shape). pub subversion: String, - /// Regtest generate/submitblock. Node attaches [`ChainHub`] via this trait. + /// Regtest generate/submitblock. Node attaches `ChainHub` via this trait. pub regtest: Option>, /// Live P2P sessions (`getpeerinfo` / `addnode` / `disconnectnode`). pub peers: Option>, diff --git a/docs/concurrency.md b/docs/concurrency.md index d1aa5e2599..3853be084e 100644 --- a/docs/concurrency.md +++ b/docs/concurrency.md @@ -21,7 +21,7 @@ Short map of who may write which tables. **Format is unstable until 1.0.** **IBD lookup resolve wave:** TipOnly `head_fk` bounded by remaining loadq slots × load pack (safety cap **1080** heights / soft **64000** inputs; include-overshoot; 256 k unique-key safety cap). Decode parks as resolved BQ rows; `taken_hi` bumps **per load-batch send**. Unsent tail stays on the BQ (no re-decode). Hard **min 8000** inputs per wave when more unresolved heights can still join — including `ready=0` / load-frontier / unknown window. Last available thin wave still emits. Each load chunk carries a `BatchParentIds` skeleton (shared wave ids/spent + per-chunk need-vouts). Same-wave creates are omitted from TipOnly need. When `ready >` half the 1-min BQ window, lookup waits for a full wave instead of minting a 1-block layer — unless the first unresolved height is within `path_lo + win/2` **and** the collect is already ≥8000 inputs (load is about to claim it; O(1) from the already-sorted unresolved list). Pack/hold uses enqueue-stamped `n_inputs` (peer CompactSize walk). `wave_intake` does **not** clone raw payloads; decode clones `raw_payload(height)` only on emit. Hold is `decode=0` / `precompute=0`. `lookup_thr wave=(decode= precompute= collect= head= loc=)`: `precompute=` is `from_tx_wire` on payload slices (`sighash` midstates only when scripts run); `head=` is TipOnly `get_fk_by_txid_batch`, not load stamp; `loc=` is create.loc fill inside that TipOnly. -**`ibd: perf`:** one DEBUG line, `ibd: perf` plus a JSON object of `IbdPerfSample` (`ts` is unix milliseconds; zeros are included). A change on lookup, load, scripts, or write, or on a sidecar the write thread joins, adds a field on that struct in [`perf_log.rs`](../crates/rbitcoin-net/src/ibd/perf_log.rs) in the same commit. The field shows up because the struct serializes. JSON keys are the field names (`load_ms`, not a hand-written `load=` token). `load=` is pin+assemble only. Load OS-thread `stamp=` nests `pack=` (plan HashMap) vs `head=` (leftover TipOnly `prep_head_fk_ns`). IBD skeleton keeps `head=` ~0. `stamp_sub struct_txid=` must be **0** on IBD (loadq `pres`). Non-zero means load dropped lookup hashes and `from_tx`'d again. Post-stamp in-flight drop on the last load batch of a wave is `prune=` (height-index remove; IBD has no pstore Weak walk). A lone block's missing-parent check after a stamp miss (the wait for its parent to be the tip, the TipOnly read, and the unsynced-head scan) is `reject=`, not `prune=` ([089](./external_findings/089-missing-parent-verdict.md)). Lookup-wave `decode=` / `precompute=` / `collect=` / `head=` / `spent=` nest under `lookup_thr wave=`. Pin names `thin=` for the vout-map prefix. `script=` is per-batch verify wall on `ibd-confirm` (`jobs=`/`skip=`), the script-wave completion offset. `idx_asm=` is filter and tweak execution on the index wave (first index job through that wave's completion). It is not time queued behind scripts and it is not inside `script=`. `thr script work` is the stage wall: the later of those two completion offsets from batch start, not their sum. `idx_put=` is the write-thread index append and is inside `write=`. `tip_flush_wait=` is the commit waiting for the previous batch's `rbtc-tip-flush`; it is not inside `class_c_join=`. Steal claim is an `ArcSwap` snapshot + `fetch_add(32)` (no `WAVES` mutex per job; `in_wave` counts in-flight chunks). The scripts thread publishes another `scriptq` batch when both waves have nothing left to claim (up to 4 in-flight, matching `scriptq`) and parks until a worker unparks it on wave complete (load also unparks on `scriptq` send). `script=` stamps when script verify completes, not at write-queue pop. Write snapshot-drains the whole **writeq** (cap 14) so one `flush_class_c_tip` covers the queued run. `append_contiguous` stops when `archive_plan` polarity differs (`Some` vs `None`); leftover is the next meta-batch. `ready>0` + `scriptq=1` + high `stamp=` `head=` means leftover on load, not a hungry script pool. High `stamp=` `pack=` with `head=0` is HashMap CPU on load (leave it there; lookup is already the wave). Do not retune steal or borrow `rbtc-scripts-*` for decode. Process restart leftover is empty RAM identity (horizon does not survive). +**`ibd: perf`:** one DEBUG line, `ibd: perf` plus a JSON object of `IbdPerfSample` (`ts` is unix milliseconds; zeros are included). A change on lookup, load, scripts, or write, or on a sidecar the write thread joins, adds a field on that struct in [`perf_log.rs`](../crates/rbitcoin-ibd/src/ibd/perf_log.rs) in the same commit. The field shows up because the struct serializes. JSON keys are the field names (`load_ms`, not a hand-written `load=` token). `load=` is pin+assemble only. Load OS-thread `stamp=` nests `pack=` (plan HashMap) vs `head=` (leftover TipOnly `prep_head_fk_ns`). IBD skeleton keeps `head=` ~0. `stamp_sub struct_txid=` must be **0** on IBD (loadq `pres`). Non-zero means load dropped lookup hashes and `from_tx`'d again. Post-stamp in-flight drop on the last load batch of a wave is `prune=` (height-index remove; IBD has no pstore Weak walk). A lone block's missing-parent check after a stamp miss (the wait for its parent to be the tip, the TipOnly read, and the unsynced-head scan) is `reject=`, not `prune=` ([089](./external_findings/089-missing-parent-verdict.md)). Lookup-wave `decode=` / `precompute=` / `collect=` / `head=` / `spent=` nest under `lookup_thr wave=`. Pin names `thin=` for the vout-map prefix. `script=` is per-batch verify wall on `ibd-confirm` (`jobs=`/`skip=`), the script-wave completion offset. `idx_asm=` is filter and tweak execution on the index wave (first index job through that wave's completion). It is not time queued behind scripts and it is not inside `script=`. `thr script work` is the stage wall: the later of those two completion offsets from batch start, not their sum. `idx_put=` is the write-thread index append and is inside `write=`. `tip_flush_wait=` is the commit waiting for the previous batch's `rbtc-tip-flush`; it is not inside `class_c_join=`. Steal claim is an `ArcSwap` snapshot + `fetch_add(32)` (no `WAVES` mutex per job; `in_wave` counts in-flight chunks). The scripts thread publishes another `scriptq` batch when both waves have nothing left to claim (up to 4 in-flight, matching `scriptq`) and parks until a worker unparks it on wave complete (load also unparks on `scriptq` send). `script=` stamps when script verify completes, not at write-queue pop. Write snapshot-drains the whole **writeq** (cap 14) so one `flush_class_c_tip` covers the queued run. `append_contiguous` stops when `archive_plan` polarity differs (`Some` vs `None`); leftover is the next meta-batch. `ready>0` + `scriptq=1` + high `stamp=` `head=` means leftover on load, not a hungry script pool. High `stamp=` `pack=` with `head=0` is HashMap CPU on load (leave it there; lookup is already the wave). Do not retune steal or borrow `rbtc-scripts-*` for decode. Process restart leftover is empty RAM identity (horizon does not survive). **Tip follow / reorg:** peer reconstructs on the session task, then offers the body to the process-wide **`tip-accept`** OS thread (bounded queue 8, oneshot wait). That thread is the sole production owner of `connect_lock` / `accept_and_connect_block_preverified` / `confirm_wire_run_preverified` at tip (1-block, or one `accept_branch` run). Scripts still publish via `start_for_each_owned` → `rbtc-scripts-*` steal — same as IBD’s publisher, not a second interpreter. Disconnect keeps Class A archive; re-extension always supplies **wire** from the peer, not hash-only load. **IBD most-work reorg** rewinds the tip to the LCA (`rewind_to_height`) from the **IBD orchestration task only** — never from confirm lookup/load/scripts/write threads — then the confirm pipeline connects the winner as a linear extension. `accept_branch` remains for tip-follow / held-body apply (also on `tip-accept`). Selector / rewind / invalid-heavy: [`architecture.md`](./architecture.md#most-work-chain-selection-ibd--tip-follow). diff --git a/scripts/coverage-badge.py b/scripts/coverage-badge.py index 15f8f66f67..00a760200b 100755 --- a/scripts/coverage-badge.py +++ b/scripts/coverage-badge.py @@ -115,7 +115,7 @@ def main() -> None: p = argparse.ArgumentParser(description=__doc__) p.add_argument("--lh", type=int, required=True) p.add_argument("--lf", type=int, required=True) - p.add_argument("--gate", type=int, default=89) + p.add_argument("--gate", type=int, default=91) p.add_argument("--sha", default="") p.add_argument("--scope", default="production") p.add_argument("--date", default="") diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 5b9d6ec920..4a7e7fa6cb 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -148,7 +148,7 @@ PY fi SHA="${GITHUB_SHA:-$(git rev-parse HEAD)}" python3 "$ROOT/scripts/coverage-badge.py" \ - --lh "$LCOV_HIT" --lf "$LCOV_TOT" --gate 89 \ + --lh "$LCOV_HIT" --lf "$LCOV_TOT" --gate 91 \ --sha "$SHA" --scope production \ --lcov "$ROOT/coverage/lcov.info" \ --out "$ROOT/coverage/badge.json" diff --git a/scripts/coverage.test.sh b/scripts/coverage.test.sh index 4036cef60e..6c7308561a 100755 --- a/scripts/coverage.test.sh +++ b/scripts/coverage.test.sh @@ -23,22 +23,22 @@ python3 - "$IGNORE" <<'PY' || exit 1 import re, sys rx = re.compile(sys.argv[1]) excluded = [ - "/repo/crates/rbitcoin-store/src/scripthash_tests.rs", - "/repo/crates/rbitcoin-net/src/ibd/confirm/tests.rs", - "/repo/crates/rbitcoin-net/src/peer_tests.rs", - "/repo/crates/rbitcoin-net/tests/ibd_smoke.rs", + "/repo/crates/rbitcoin-store/tests/scripthash.rs", + "/repo/crates/rbitcoin-ibd/tests/ibd/confirm.rs", + "/repo/crates/rbitcoin-net/tests/peer/mod.rs", + "/repo/crates/rbitcoin-ibd/tests/ibd_smoke.rs", "/repo/crates/rbitcoin-test/src/lib.rs", "/repo/crates/rbitcoin-test/tests/integration_multinode.rs", "/repo/crates/rbitcoin-bench/src/suite.rs", "/repo/crates/rbitcoin-store/src/testutil.rs", "/repo/crates/rbitcoin-query/src/testutil.rs", - "/repo/crates/rbitcoin-consensus/src/script/tests_verify.rs", + "/repo/crates/rbitcoin-consensus/tests/script/tests_verify.rs", "/repo/crates/rbitcoin-node/src/main.rs", ] kept = [ "/repo/crates/rbitcoin-store/src/scripthash.rs", "/repo/crates/rbitcoin-net/src/peer.rs", - "/repo/crates/rbitcoin-net/src/ibd/mod.rs", + "/repo/crates/rbitcoin-ibd/src/ibd/mod.rs", "/repo/crates/rbitcoin-node/src/regtest_rpc.rs", "/repo/crates/rbitcoin-consensus/src/regtest_pad.rs", "/repo/crates/rbitcoin-node/src/run.rs", @@ -79,6 +79,11 @@ assert_ok "required test job still pins the bench scripthash" \ grep -q 'cargo test -p rbitcoin-bench --lib hot_corpus_includes_p2a' "$ROOT/.github/workflows/ci.yml" # Suites link cfg(debug_assertions) hooks, so release is check-only. Without # this step a debug-only import on a production path ships uncompiled. +FLOOR="$(python3 -c 'import re,sys; print(re.search(r"^FLOOR_PCT = (\d+)", open(sys.argv[1]).read(), re.M).group(1))' "$ROOT/scripts/coverage-gate.py")" +assert_ok "coverage.sh passes the gate floor ($FLOOR) to the badge" \ + grep -q -- "--gate $FLOOR " "$COV" +assert_ok "coverage-badge.py defaults to the gate floor ($FLOOR)" \ + grep -q "\"--gate\", type=int, default=$FLOOR)" "$ROOT/scripts/coverage-badge.py" assert_ok "qc checks the release profile compiles" \ grep -q 'cargo check --release --workspace --exclude rbitcoin-bench' "$ROOT/.github/workflows/ci.yml" assert_ok "gitignore ignores apilog jsonl" \ From b2f99f569753a70ddcdaa71bd181336bb3827579 Mon Sep 17 00:00:00 2001 From: "rearden-grok[bot]" <317016512+rearden-grok[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:06:10 -0700 Subject: [PATCH 05/10] docs: principle 11 describes the suite's doc(hidden) surface and opt-in hooks After #1097 the suite reaches internals through `#[doc(hidden)] pub` and test hooks are `cfg(debug_assertions)`, but CONTRIBUTING principle 11 still said to drop to `pub(crate)`, that `-D warnings` would report dead `pub`, and that a `cfg(test)` hook is a smell. The rule now states the convention and its two limits: a hook is off until a test arms it, and a debug gate never covers an import production code uses (the release check in `qc` pins that). code-shape points at it from the lint section and notes suite roots carry no blanket allow. TESTING.md records that the suites build in dev/test only. rbitcoin-ibd gets the AGENTS.md the other crates have. Co-authored-by: Cursor --- CONTRIBUTING.md | 48 ++++++++++++++++++++--------------- TESTING.md | 8 ++++-- crates/rbitcoin-ibd/AGENTS.md | 31 ++++++++++++++++++++++ docs/code-shape.md | 6 +++++ 4 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 crates/rbitcoin-ibd/AGENTS.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index da347a9407..1dbd2b0ec1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -230,23 +230,29 @@ engineering. [`docs/code-shape.md`](./docs/code-shape.md). Named 0.6.0 extracts (**Q-61**) are Completed; residual peels: [`docs/quality.md`](./docs/quality.md) **R-10**. -11. **Crate visibility is the production graph.** `pub` and crate-root - `pub use` exist only for names another crate actually imports, or for - a **documented** public library API (we do not have one). Unused `pub` - is forbidden: drop to `pub(crate)` or delete; workspace `-D warnings` - then reports truly dead items — delete those too (`#[allow(dead_code)]` - is not a fix). If we ever ship an out-of-tree library surface, write - the allowlist in the owner crate rustdoc and then unused `pub` on - **that** surface is intentional. `#[cfg(test)]` on production items - is a smell: tests drive the shipped function (principle 8), not a - second test-only wrapper or `*_for_test` backdoor. IO-shape pins use - session/table instance stats or on-disk file state, not thread-local - `test_take_*` probes on the hot path. A tiny `#[cfg(test)]` take on - those instance counters is fine. Fuzz-only `pub` is the same - smell — prefer the in-crate `pub(crate)` graph or the published - **binary** surface (`rbitcoin-node` / CLI) even if the harness pays - a little extra setup, rather than exporting helpers solely for - `fuzz/`. +11. **Crate visibility is the production graph; the suite reads it through + `#[doc(hidden)]`.** Library tests live in `tests/suite` and link the + normal rlib, so an item a test reaches is `pub` with `#[doc(hidden)]`. + Plain `pub` (no hidden) and crate-root `pub use` exist only for names + another crate actually imports, or for a **documented** public library + API (we do not have one). If we ever ship an out-of-tree library + surface, write the allowlist in the owner crate rustdoc and then unused + `pub` on **that** surface is intentional. rustc does not report a dead + hidden item, so a change that removes the last caller removes the + callee in the same change (code-shape rule 9); `#[allow(dead_code)]` + is not a fix, in `src/` or in a suite root. Test hooks in production + files are `#[cfg(debug_assertions)]` and **opt-in**: off until the test + arms them on its thread, and a no-op on the hot path otherwise, because + every debug node runs that code. A release build must still compile + (`cargo check --release` in `qc`), so a `cfg(debug_assertions)` gate + never covers an import or re-export that production code uses. Tests + drive the shipped function (principle 8), not a second test-only + wrapper or `*_for_test` backdoor. IO-shape pins use session/table + instance stats or on-disk file state, not thread-local `test_take_*` + probes on the hot path. Fuzz-only `pub` is the same smell — prefer the + in-crate graph or the published **binary** surface (`rbitcoin-node` / + CLI) even if the harness pays a little extra setup, rather than + exporting helpers solely for `fuzz/`. ## Workflow @@ -311,9 +317,11 @@ IO; they do not package zips. GitHub Releases: ([`TESTING.md`](./TESTING.md#true-journeys)). - [ ] Core-facing RPC / P2P / Electrum / Esplora: [`COMPAT.md`](./COMPAT.md) - [ ] No new silent dead branches -- [ ] No unused crate-root `pub` / `pub use` (principle 11). Tests drive - shipped functions, not `#[cfg(test)]` wrappers or `*_for_test` - backdoors. Fuzz does not grow `pub` without considering the binary +- [ ] No unused crate-root `pub` / `pub use`; suite-only items are + `#[doc(hidden)]`; a removed caller removes its callee (principle 11). + Tests drive shipped functions, not `*_for_test` backdoors. A + `cfg(debug_assertions)` hook is opt-in and gates no production + import. Fuzz does not grow `pub` without considering the binary surface. - [ ] Store changes respect Class A/B/C and allocate-then-publish - [ ] Experimental / milestone honesty preserved in user-facing docs when relevant diff --git a/TESTING.md b/TESTING.md index 1b9090bf11..cdf208a46e 100644 --- a/TESTING.md +++ b/TESTING.md @@ -212,8 +212,12 @@ a production line already counts that line, so a second in-crate `#[test]` is not required to make LCOV see it. Library tests live in each crate's `tests/suite` and link the normal rlib, so a `#[cfg(test)]` arm in `src/` is no longer how those tests compile. `#[cfg(debug_assertions)]` hooks in -production files still count. llvm-cov hit counts jitter tens of lines on the same -tree; the floor is the gate, not a never-falls ratchet vs master. +production files still count. Those hooks also mean the suites link only in +the `dev` / `test` profiles: `cargo test --release` does not build. Release +correctness is `cargo check --release --workspace --exclude rbitcoin-bench` +(`qc`) plus the labeled harnesses that run the shipped binaries. llvm-cov +hit counts jitter tens of lines on the same tree; the floor is the gate, +not a never-falls ratchet vs master. The README badge and rbitcoin.org figure are the last **green `master`** `coverage` job (`badges` branch `coverage.json`, Shields endpoint). The diff --git a/crates/rbitcoin-ibd/AGENTS.md b/crates/rbitcoin-ibd/AGENTS.md new file mode 100644 index 0000000000..1c6841577f --- /dev/null +++ b/crates/rbitcoin-ibd/AGENTS.md @@ -0,0 +1,31 @@ +# rbitcoin-ibd + +Multi-peer initial block download and the confirm pipeline. Depends on +net, query, store, consensus, log, and primitives. Only `rbitcoin-node` +and `rbitcoin-test` depend on this crate; RPC, Electrum, Esplora, and SV2 +do not. Tip follow and relay stay in `rbitcoin-net`. + +## Read first + +Open the row that matches the change. Leave the other owners closed. + +| Change | Read | +|--------|------| +| Roles, body queue, publish order, `ibd: perf` fields | [`docs/concurrency.md`](../../docs/concurrency.md) | +| Confirm stage IO, leftover union, pin identity | [`docs/invariants.md`](../../docs/invariants.md) | +| Process RAM, body-queue caps, evict | [`docs/ibd-memory.md`](../../docs/ibd-memory.md) | +| IO machines | [`docs/io-modality.md`](../../docs/io-modality.md) | + +## Where + +- Assign and densify: `src/ibd/assign.rs`, `src/ibd/assign_plan.rs`, `src/ibd/body.rs` +- Peers and dial: `src/ibd/dial.rs`, `src/ibd/peer_io.rs`, `src/ibd/events/` +- Confirm: `src/ibd/confirm/` +- Exit, reorg, archive: `src/ibd/exit.rs`, `src/ibd/reorg.rs`, `src/ibd/archive.rs` +- Progress and perf lines: `src/ibd/progress.rs`, `src/ibd/perf_log.rs` + +## Verify + +`cargo test -p rbitcoin-ibd --test suite` + +Core functional (labeled job only): [`.agents/skills/core-functional/SKILL.md`](../../.agents/skills/core-functional/SKILL.md). diff --git a/docs/code-shape.md b/docs/code-shape.md index d0c61bb8a8..e4021f1805 100644 --- a/docs/code-shape.md +++ b/docs/code-shape.md @@ -90,6 +90,12 @@ Complexity still drops because the types got better, not because clippy denied a Core-faithful loop. That is a **site** allow on that function, not a standing workspace `cognitive_complexity` allow. +Suite roots (`tests/suite.rs`) carry no `#![allow(...)]` either: the test +tree is linted like `src/`. Visibility for the suite is `#[doc(hidden)] +pub`, and test hooks in production files are opt-in +`#[cfg(debug_assertions)]`; the rule and its limits are +[`CONTRIBUTING.md`](../CONTRIBUTING.md) principle 11. + The workspace allow list is empty. `cognitive_complexity` is workspace `warn` (nursery opt-in). A leftover Core-faithful loop or dense surface test is a **site** allow — do not peel **R-10**, flatten io_uring, or From 66f4a4adfaa1cc3bc984aeb3bfd600fb91e55b24 Mon Sep 17 00:00:00 2001 From: "rearden-grok[bot]" <317016512+rearden-grok[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:06:11 -0700 Subject: [PATCH 06/10] changelog: release build, spindle trace, badge gate, suite lint after the layout move Co-authored-by: Cursor --- changelog.d/release-build-after-layout.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog.d/release-build-after-layout.md diff --git a/changelog.d/release-build-after-layout.md b/changelog.d/release-build-after-layout.md new file mode 100644 index 0000000000..c3dfc28649 --- /dev/null +++ b/changelog.d/release-build-after-layout.md @@ -0,0 +1,6 @@ +Fixed + +- **Release builds compile again.** The crate-layout move gated a `rbitcoin-store` import and two `rbitcoin-query` re-exports behind `cfg(debug_assertions)` while production code used them, so `cargo build --release`, `release.yml`, and the nix package failed. `qc` now runs `cargo check --release --workspace --exclude rbitcoin-bench`; the suites themselves build in the dev and test profiles only. +- **A debug node no longer grows the confirm spindle trace.** `spindle_mark` records only after a test arms it on that thread. Before, every debug build appended to a thread-local on each confirm batch for the life of the process. +- **The coverage badge gate is the 91% floor.** The badge still said 89 after the floor moved, so a run between 89 and 91 would have drawn a passing badge on a failing gate. `coverage.test.sh` pins the badge to `FLOOR_PCT`. +- **Suite roots are linted like `src/`.** The `#![allow(unused_imports, dead_code, unused_variables)]` on every `tests/suite.rs` is gone; the imports the move left behind and one dead env-lock helper went with it. From 44bc3d62d6f2c80571160ed479a2634e90ac586c Mon Sep 17 00:00:00 2001 From: "rearden-grok[bot]" <317016512+rearden-grok[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:49:23 -0700 Subject: [PATCH 07/10] docs: rustdoc links resolve in doc(hidden) modules The layout move turned private modules into `#[doc(hidden)] pub mod`, so rustdoc began checking 37 links it had never resolved. Those modules do not render, so a link there has no reader: they become plain code spans. The four in rendered modules (block flags, script_pool, query::testutil) get a resolving path or drop a target that no longer exists. `cargo doc --workspace --no-deps` exits 0 again. Co-authored-by: Cursor --- crates/rbitcoin-consensus/src/block/mod.rs | 2 +- crates/rbitcoin-consensus/src/header.rs | 2 +- crates/rbitcoin-consensus/src/script/mod.rs | 6 +++--- crates/rbitcoin-consensus/src/script_pool.rs | 2 +- crates/rbitcoin-ibd/src/ibd/confirm/mod.rs | 2 +- crates/rbitcoin-ibd/src/ibd/mod.rs | 4 ++-- crates/rbitcoin-ibd/src/ibd/state.rs | 2 +- crates/rbitcoin-mempool/src/accept.rs | 6 +++--- crates/rbitcoin-mempool/src/graph.rs | 4 ++-- crates/rbitcoin-mempool/src/orphanage.rs | 2 +- crates/rbitcoin-mempool/src/store.rs | 2 +- crates/rbitcoin-net/src/chain.rs | 2 +- crates/rbitcoin-query/src/catchup.rs | 2 +- crates/rbitcoin-query/src/confirm_run/bq_resolve.rs | 6 +++--- crates/rbitcoin-query/src/confirm_run/mod.rs | 2 +- crates/rbitcoin-query/src/connect.rs | 2 +- crates/rbitcoin-query/src/header_read.rs | 2 +- crates/rbitcoin-query/src/soft_densify.rs | 2 +- crates/rbitcoin-query/src/testutil.rs | 2 +- crates/rbitcoin-store/src/address_head.rs | 2 +- crates/rbitcoin-store/src/array_table.rs | 4 ++-- crates/rbitcoin-store/src/binary_fuse8.rs | 4 ++-- crates/rbitcoin-store/src/scripthash_head.rs | 2 +- crates/rbitcoin-store/src/sp_tweaks_uring.rs | 4 ++-- crates/rbitcoin-store/src/store.rs | 4 ++-- 25 files changed, 37 insertions(+), 37 deletions(-) diff --git a/crates/rbitcoin-consensus/src/block/mod.rs b/crates/rbitcoin-consensus/src/block/mod.rs index d97771211b..d955bc0624 100644 --- a/crates/rbitcoin-consensus/src/block/mod.rs +++ b/crates/rbitcoin-consensus/src/block/mod.rs @@ -773,7 +773,7 @@ impl AsRef for JobTx { /// /// Field reads in the interpreter stay a direct bool test (no extra per-opcode /// branch). Production confirm uses [`Self::consensus_at`]; Core JSON fixtures -/// use [`Self::ALL`] or an explicit struct literal. +/// use an explicit struct literal. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct ScriptVerifyFlags { pub bip65_active: bool, diff --git a/crates/rbitcoin-consensus/src/header.rs b/crates/rbitcoin-consensus/src/header.rs index 1816f0d089..37e142c76b 100644 --- a/crates/rbitcoin-consensus/src/header.rs +++ b/crates/rbitcoin-consensus/src/header.rs @@ -124,7 +124,7 @@ pub fn pow_hash_meets_target( /// BIP34/66/65 `nVersion` floors and the 2-hour future-time cap (wall clock). /// /// Core `ContextualCheckBlockHeader`. Assemble uses this instead of a second -/// [`validate_header`] (MTP walk + header rehash). +/// `validate_header` (MTP walk + header rehash). pub fn check_header_version_and_future_time( params: &ChainParams, height: Height, diff --git a/crates/rbitcoin-consensus/src/script/mod.rs b/crates/rbitcoin-consensus/src/script/mod.rs index ddaa91cf27..43a525ce29 100644 --- a/crates/rbitcoin-consensus/src/script/mod.rs +++ b/crates/rbitcoin-consensus/src/script/mod.rs @@ -300,7 +300,7 @@ pub mod crypto { /// Parse DER signature + **raw** sighash type byte (as `u32`). /// - /// Important: do **not** run the type through [`EcdsaSighashType::from_consensus`] + /// Important: do **not** run the type through `EcdsaSighashType::from_consensus` /// before legacy `SignatureHash`. That maps `0 → SIGHASH_ALL(1)`, but mainnet /// has historical spends signed with hashtype **0** (block 110300 and others). /// Core hashes with the raw byte; we must too. (**RB-002** in @@ -522,8 +522,8 @@ pub mod crypto { /// P2WPKH BIP143 hash: `script_pubkey` is native spk **or** nested redeem (`00 14 <20>`). /// - /// Fast path: when `raw_ty` round-trips through [`EcdsaSighashType`] (standard - /// 0x01/02/03/81/82/83), use rust-bitcoin's [`SighashCache`] midstate + /// Fast path: when `raw_ty` round-trips through `EcdsaSighashType` (standard + /// 0x01/02/03/81/82/83), use rust-bitcoin's `SighashCache` midstate /// (hashPrevouts/hashSequence/hashOutputs once per tx). Slow path: non-standard /// raw types (e.g. mainnet `0x65`) need our raw-uint32 encoder. pub fn bip143_p2wpkh_signature_hash( diff --git a/crates/rbitcoin-consensus/src/script_pool.rs b/crates/rbitcoin-consensus/src/script_pool.rs index a33e315ac5..ba4609fbbc 100644 --- a/crates/rbitcoin-consensus/src/script_pool.rs +++ b/crates/rbitcoin-consensus/src/script_pool.rs @@ -6,7 +6,7 @@ //! from the stage thread — steal workers must not `wait_done` on this pool. //! //! Idle steal workers [`thread::park`]. A new wave or detached job bumps an -//! epoch and [`Thread::unpark`]s every worker (unpark-before-park leaves a +//! epoch and [`thread::Thread::unpark`]s every worker (unpark-before-park leaves a //! permit, so a worker cannot miss work by parking after the wake). The jobs //! mutex is only the detached-job queue, never the steal wake path. //! diff --git a/crates/rbitcoin-ibd/src/ibd/confirm/mod.rs b/crates/rbitcoin-ibd/src/ibd/confirm/mod.rs index da084328a2..73aa4ad82f 100644 --- a/crates/rbitcoin-ibd/src/ibd/confirm/mod.rs +++ b/crates/rbitcoin-ibd/src/ibd/confirm/mod.rs @@ -205,7 +205,7 @@ pub struct ConfirmFeedInner { pub ready: std::collections::BTreeMap, /// Claimed by load; not yet written or released. Offer must not re-note. pub inflight: std::collections::HashSet, - /// Height → lookup epoch when load claimed it (survives [`Self::clear`]). + /// Height → lookup epoch when load claimed it (survives `Self::clear`). pub claimed_epoch: HashMap, } diff --git a/crates/rbitcoin-ibd/src/ibd/mod.rs b/crates/rbitcoin-ibd/src/ibd/mod.rs index 603f904e3f..4c53273785 100644 --- a/crates/rbitcoin-ibd/src/ibd/mod.rs +++ b/crates/rbitcoin-ibd/src/ibd/mod.rs @@ -165,9 +165,9 @@ pub const PRE_HOLE_MAX_PEERS: usize = 2; /// /// Mainnet DNS seeds already return ~300–400 addrs. 256 refused all getaddr /// once the seed book was larger than the cap. [`rbitcoin_net::seeds::MAX_ADDR_MAN`] -/// holds seeds plus learned addrs; [`AddrMan::add_learned`] evicts +/// holds seeds plus learned addrs; `AddrMan::add_learned` evicts /// incompatible/failed then oldest new when full so discovery continues. -/// `--connect` / DNS [`AddrMan::add`] may briefly exceed the cap when only +/// `--connect` / DNS `AddrMan::add` may briefly exceed the cap when only /// tried addrs remain. pub const MAX_PEER_POOL: usize = rbitcoin_net::seeds::MAX_ADDR_MAN; /// Pending (framed, not Class A) longer than this → re-getdata. diff --git a/crates/rbitcoin-ibd/src/ibd/state.rs b/crates/rbitcoin-ibd/src/ibd/state.rs index f871022f42..8c2f7e1391 100644 --- a/crates/rbitcoin-ibd/src/ibd/state.rs +++ b/crates/rbitcoin-ibd/src/ibd/state.rs @@ -4,7 +4,7 @@ //! //! - `ordered` + `ordered_set` track headers after the local tip for getdata. //! - Middle completions leave **ghost** deque entries (see [`super::assign_plan::remove_from_ordered`]); -//! [`Self::hygiene`] compacts when the deque bloats. +//! `Self::hygiene` compacts when the deque bloats. //! - `hash_height` / `header_fks` are bounded to live ordered hashes (+ tip seed) //! so they do not grow unbounded past `MAX_ORDERED_HEADERS`. diff --git a/crates/rbitcoin-mempool/src/accept.rs b/crates/rbitcoin-mempool/src/accept.rs index cf8f22b243..2e70bc7416 100644 --- a/crates/rbitcoin-mempool/src/accept.rs +++ b/crates/rbitcoin-mempool/src/accept.rs @@ -1079,7 +1079,7 @@ impl ActiveMempool { }) } - /// Park `tx` waiting on `missing` parent txids (from [`prepare_admit`]). + /// Park `tx` waiting on `missing` parent txids (from `prepare_admit`). pub fn park_orphan(&mut self, tx: &Transaction, missing: BTreeSet) -> AcceptError { self.park_orphan_from(tx, missing, None) } @@ -2041,7 +2041,7 @@ impl ActiveMempool { /// /// Also drops orphanage entries that are confirmed or conflict with the block, /// and best-effort re-accepts orphans whose parent just confirmed (caller must - /// pass a UTXO view that includes the new tip — use [`remove_for_block_with_utxo`]). + /// pass a UTXO view that includes the new tip — use `remove_for_block_with_utxo`). pub fn remove_for_block(&mut self, block_txids: &[Txid]) -> Result { self.remove_for_block_with_utxo( block_txids, @@ -2096,7 +2096,7 @@ impl ActiveMempool { Ok((n, gone)) } - /// Like [`remove_for_block`], then promote orphans of confirmed parents via `utxos`. + /// Like `remove_for_block`, then promote orphans of confirmed parents via `utxos`. pub fn remove_for_block_with_utxo( &mut self, block_txids: &[Txid], diff --git a/crates/rbitcoin-mempool/src/graph.rs b/crates/rbitcoin-mempool/src/graph.rs index 670c5360c3..e1f124f55b 100644 --- a/crates/rbitcoin-mempool/src/graph.rs +++ b/crates/rbitcoin-mempool/src/graph.rs @@ -585,7 +585,7 @@ impl TxGraph { } /// Insert entry and wire parent/child edges. Does **not** enforce cluster limits - /// (caller checks via [`cluster_of`] after insert, and may remove). + /// (caller checks via `cluster_of` after insert, and may remove). pub fn insert(&mut self, entry: TxEntry, tx: &Transaction) { self.invalidate_chunk_cache(); let txid = entry.txid; @@ -763,7 +763,7 @@ impl TxGraph { self.connected_weight_except(seeds, &BTreeSet::new()) } - /// [`connected_weight`] that does not enter `except` (RBF conflicts still linked). + /// `connected_weight` that does not enter `except` (RBF conflicts still linked). pub fn connected_weight_except( &self, seeds: &BTreeSet, diff --git a/crates/rbitcoin-mempool/src/orphanage.rs b/crates/rbitcoin-mempool/src/orphanage.rs index 5df81bd672..ec428884bb 100644 --- a/crates/rbitcoin-mempool/src/orphanage.rs +++ b/crates/rbitcoin-mempool/src/orphanage.rs @@ -555,7 +555,7 @@ impl Orphanage { /// Drop orphans that are themselves included in a confirmed block. /// /// Children of confirmed parents are **not** erased here — callers should - /// [`take_children_of`] and re-accept (Core `AddChildrenToWorkSet` path). + /// `take_children_of` and re-accept (Core `AddChildrenToWorkSet` path). /// Spending a parent in the block does not invalidate the orphan; the parent /// create is now a chain UTXO. pub fn erase_for_block(&mut self, block_txids: &[Txid]) { diff --git a/crates/rbitcoin-mempool/src/store.rs b/crates/rbitcoin-mempool/src/store.rs index 43e1e26021..b9e8d230c2 100644 --- a/crates/rbitcoin-mempool/src/store.rs +++ b/crates/rbitcoin-mempool/src/store.rs @@ -450,7 +450,7 @@ impl Mempool { /// /// Copies existing packed payload ranges (does not re-serialize). Returns /// `(live_after, body_bytes_after)`. Callers must rebuild RAM indexes with - /// the new slot numbers from [`load_live_txs`]. + /// the new slot numbers from `load_live_txs`. pub fn compact(&mut self) -> Result<(u32, usize), MempoolError> { let logical = body_logical_len(&self.body)?; let mut new_body = vec![0u8; BODY_HEADER]; diff --git a/crates/rbitcoin-net/src/chain.rs b/crates/rbitcoin-net/src/chain.rs index 6ef4e0dc33..f2f1dc3e39 100644 --- a/crates/rbitcoin-net/src/chain.rs +++ b/crates/rbitcoin-net/src/chain.rs @@ -1497,7 +1497,7 @@ impl ChainHub { self.ensure_header(header).map_err(|e| e.to_string()) } - /// Like [`ensure_header`], but returns the header fk for the archive writer + /// Like `ensure_header`, but returns the header fk for the archive writer /// (avoids a second hash-head probe on the hot write path). /// /// **Fail closed:** non-genesis headers require the parent row to already diff --git a/crates/rbitcoin-query/src/catchup.rs b/crates/rbitcoin-query/src/catchup.rs index 7b702816e1..e2aeedb7d2 100644 --- a/crates/rbitcoin-query/src/catchup.rs +++ b/crates/rbitcoin-query/src/catchup.rs @@ -14,7 +14,7 @@ use std::sync::atomic::Ordering; /// | [`Direct`](IndexMode::Direct) | archive live | confirm batch after Class C | Class A collect → unsorted shards → seal at tip | /// | [`Tip`](IndexMode::Tip) | live | confirm batch after Class C | durable write-through after bulk | /// -/// Open defaults to [`Tip`] until the node calls [`Query::enter_direct_index_mode`]. +/// Open defaults to `Tip` until the node calls [`Query::enter_direct_index_mode`]. #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[repr(u8)] pub enum IndexMode { diff --git a/crates/rbitcoin-query/src/confirm_run/bq_resolve.rs b/crates/rbitcoin-query/src/confirm_run/bq_resolve.rs index fbba2b6fe6..0f50157772 100644 --- a/crates/rbitcoin-query/src/confirm_run/bq_resolve.rs +++ b/crates/rbitcoin-query/src/confirm_run/bq_resolve.rs @@ -1,7 +1,7 @@ //! BQ-ahead TipOnly parent resolve (lookup wave). //! //! Pack/hold uses enqueue-stamped Σ inputs (no `Block` decode). Emit runs one -//! [`Store::get_fk_by_txid_batch`] (TipOnly) across the selected heights +//! `Store::get_fk_by_txid_batch` (TipOnly) across the selected heights //! (soft **64000** inputs / hard **1080** blocks). Hits ride the wave as //! [`crate::BatchParentIds`] (fk + body_range + spent_range). Does not //! claim, structure, or stamp. Same-wave creates are omitted from TipOnly need. @@ -50,7 +50,7 @@ pub fn wave_more_remain(selected: usize, requested: usize, filling: bool) -> boo selected < requested || filling } -/// Same include-overshoot rule as load [`pack_stop_after`]: stop after the +/// Same include-overshoot rule as load `pack_stop_after`: stop after the /// block that crosses the soft input budget or hits the hard height cap. #[inline] pub fn bq_resolve_wave_stop_after( @@ -68,7 +68,7 @@ pub fn bq_resolve_wave_stop_after( /// /// `ready` is BQ depth. `soft_win` is the 1-min confirm window (`bq soft=n/win`). /// `path_lo` is the load frontier (store tip+1). `first_unresolved` is the -/// lowest collected height (already sorted by [`BlockQueue::unresolved_heights`]). +/// lowest collected height (already sorted by `BlockQueue::unresolved_heights`). /// /// Never hold (above the input floor) when the first unresolved height sits /// in the load-facing half of the window (`first - path_lo ≤ win/2`) — that diff --git a/crates/rbitcoin-query/src/confirm_run/mod.rs b/crates/rbitcoin-query/src/confirm_run/mod.rs index 9be8267313..3f4b7f2933 100644 --- a/crates/rbitcoin-query/src/confirm_run/mod.rs +++ b/crates/rbitcoin-query/src/confirm_run/mod.rs @@ -175,7 +175,7 @@ pub struct WireLoadPipeline<'a> { /// /// `Send` so IBD can hand off load → scripts threads. /// Sparse spent-filtered parents ride on the batch (not tip-GCed). -/// When [`archive_plan`] is `Some`, commit stage appends Class A before +/// When `archive_plan` is `Some`, commit stage appends Class A before /// structural / annotate (single ordered commit era). pub struct LoadedBatch { pub prepared: Vec, diff --git a/crates/rbitcoin-query/src/connect.rs b/crates/rbitcoin-query/src/connect.rs index c12a33bc56..b79c5fdc7a 100644 --- a/crates/rbitcoin-query/src/connect.rs +++ b/crates/rbitcoin-query/src/connect.rs @@ -653,7 +653,7 @@ impl Query { /// Apply queued SH write-behind jobs in height order (one Class B appender). /// - /// Production: the tip-follow worker. Tests / [`Self::connect_block`]: drain + /// Production: the tip-follow worker. Tests / `Self::connect_block`: drain /// so SH history is visible immediately after the fixture connect. pub fn apply_sh_pending(&self) -> Result<(), QueryError> { self.release_queued_sh_writebehind(); diff --git a/crates/rbitcoin-query/src/header_read.rs b/crates/rbitcoin-query/src/header_read.rs index a81c381ba2..c6ef2a2fee 100644 --- a/crates/rbitcoin-query/src/header_read.rs +++ b/crates/rbitcoin-query/src/header_read.rs @@ -81,7 +81,7 @@ pub fn median_time_past(query: &Query, height: Height) -> Result Result, ConfirmError> { if let Some((n, buf)) = query.store().mtp_times_at(height) { return Ok(buf[..n as usize].to_vec()); diff --git a/crates/rbitcoin-query/src/soft_densify.rs b/crates/rbitcoin-query/src/soft_densify.rs index 4cc8955dcc..f9f5046488 100644 --- a/crates/rbitcoin-query/src/soft_densify.rs +++ b/crates/rbitcoin-query/src/soft_densify.rs @@ -72,7 +72,7 @@ pub fn bq_assign_stop_bytes() -> u64 { /// `path_lo .. path_lo+window-1` (clamped to `densify_hi`). Rate cold → /// only `path_lo` (tip-adjacent). /// -/// **Never** gates peer TCP reads or [`Query::block_queue_offer`]. +/// **Never** gates peer TCP reads or `Query::block_queue_offer`. pub fn soft_densify_band_hi( path_lo: u32, densify_hi: u32, diff --git a/crates/rbitcoin-query/src/testutil.rs b/crates/rbitcoin-query/src/testutil.rs index 201c73220e..819576d8c1 100644 --- a/crates/rbitcoin-query/src/testutil.rs +++ b/crates/rbitcoin-query/src/testutil.rs @@ -1,4 +1,4 @@ -//! Drop-cleaning Tiny [`Query`](crate::Query) for tests. Not an operator API. +//! Drop-cleaning Tiny [`crate::Query`] for tests. Not an operator API. //! //! TxApply → dummy [`bitcoin::Block`] conversion lives here (Q-21), not in //! production [`Query`] archive. diff --git a/crates/rbitcoin-store/src/address_head.rs b/crates/rbitcoin-store/src/address_head.rs index 4ba81cd8e3..d8d52dc3a7 100644 --- a/crates/rbitcoin-store/src/address_head.rs +++ b/crates/rbitcoin-store/src/address_head.rs @@ -5,7 +5,7 @@ //! Callers verify identity via Class A body txid on **lookup**. The spare high //! bits of each slot hold a fingerprint of the mixed key, so a probe skips most //! foreign occupants before identity. Probes read the slots through a read-only -//! `MAP_SHARED` map ([`AddressHead::slots`]); the page cache keeps it coherent +//! `MAP_SHARED` map (`AddressHead::slots`); the page cache keeps it coherent //! with the sole writer's `pwrite`s. //! //! **Insert (sole writer):** probe until the **same fk** is already present diff --git a/crates/rbitcoin-store/src/array_table.rs b/crates/rbitcoin-store/src/array_table.rs index 0c861c940b..4f14d97e78 100644 --- a/crates/rbitcoin-store/src/array_table.rs +++ b/crates/rbitcoin-store/src/array_table.rs @@ -1,6 +1,6 @@ //! Growable dense array of little-endian `u64` values. //! -//! 0-based indexing. Used for Class C: confirmed[height], header_txs arrays, etc. +//! 0-based indexing. Used for Class C: `confirmed[height]`, `header_txs` arrays, etc. //! //! # L2 write-behind (phase 6) //! @@ -8,7 +8,7 @@ //! [`class_c_inram_max_bytes`]) load fully into process RAM on open. //! `strong_tx` is always L2 (see [`crate::chain::StrongTxTable`]). //! Mutates update the `Vec` only and mark dirty. Disk is updated on -//! [`Self::flush`] / barrier: +//! `Self::flush` / barrier: //! //! - **Append-only** (dirty only at indices ≥ last flushed len): write the new //! **suffix** only, then extend HWM — never overwrites published prefix bytes. diff --git a/crates/rbitcoin-store/src/binary_fuse8.rs b/crates/rbitcoin-store/src/binary_fuse8.rs index d17ab258dd..1e5488cbe2 100644 --- a/crates/rbitcoin-store/src/binary_fuse8.rs +++ b/crates/rbitcoin-store/src/binary_fuse8.rs @@ -5,8 +5,8 @@ //! remain readable. //! //! References: -//! - https://arxiv.org/abs/1907.04749 -//! - https://github.com/ayazhafiz/xorf (MIT) +//! - +//! - (MIT) use crate::readonly_map::ReadonlyMap; diff --git a/crates/rbitcoin-store/src/scripthash_head.rs b/crates/rbitcoin-store/src/scripthash_head.rs index b29a6cb645..2b66f590ab 100644 --- a/crates/rbitcoin-store/src/scripthash_head.rs +++ b/crates/rbitcoin-store/src/scripthash_head.rs @@ -1,4 +1,4 @@ -//! Open-addressed head for hybrid scripthash: key[16] → pack8 value (24 B slots). +//! Open-addressed head for hybrid scripthash: `key[16]` → pack8 value (24 B slots). //! //! Key is the first 16 bytes of Electrum SHA256(spk). Public APIs take full 32 B //! hashes and truncate. Values are [`ShHeadValue`] pack8 encodings. diff --git a/crates/rbitcoin-store/src/sp_tweaks_uring.rs b/crates/rbitcoin-store/src/sp_tweaks_uring.rs index ee28a4965b..fbc0ae4192 100644 --- a/crates/rbitcoin-store/src/sp_tweaks_uring.rs +++ b/crates/rbitcoin-store/src/sp_tweaks_uring.rs @@ -5,7 +5,7 @@ //! for P2TR creates. //! //! Writes are **not** this machine: consecutive heights go through -//! [`SpTweaksTable::put_blocks`] (one body pwrite + one idx pwrite). +//! `SpTweaksTable::put_blocks` (one body pwrite + one idx pwrite). use crate::error::StoreError; use crate::io_handle::IoHandle; @@ -178,7 +178,7 @@ pub fn empty_rec(txid: [u8; 32]) -> TxRecord { /// Load outs for `fks`; seqsigwit + extra parents only for P2TR creates. /// -/// Idx resolve ([`crate::var_table::VarTable::record_range_batch`]) runs +/// Idx resolve (`crate::var_table::VarTable::record_range_batch`) runs /// **outside** the TLS ring. Body preads are the machine. pub fn load_tweak_wave(table: &TxTable, fks: &[Fk]) -> Result { if fks.is_empty() { diff --git a/crates/rbitcoin-store/src/store.rs b/crates/rbitcoin-store/src/store.rs index a83541885b..1f3ed9991f 100644 --- a/crates/rbitcoin-store/src/store.rs +++ b/crates/rbitcoin-store/src/store.rs @@ -32,7 +32,7 @@ pub const COLD_INDEX_DIRS: &[&str] = &[ /// and (once enabled) `blockfilter.*` and `sp_tweaks.*`. The pin set stays /// in `dir`. /// -/// [`Self::single`] / [`Self::with_cold`] are **Mainnet** scale (production). +/// [`Self::single`] / `Self::with_cold` are **Mainnet** scale (production). /// Tests use [`Self::tiny`]. Scale is not read from `RBITCOIN_HEAD_SCALE`. #[derive(Clone, Debug, PartialEq, Eq)] pub struct StoreLayout { @@ -1645,7 +1645,7 @@ impl Store { /// skips those heights and `repair_class_c_above_tip` only clears leftover /// strong not on the fence — permanent unstrong tip txs. /// - /// After confirmed is durable, publish soft [`crate::TIP_SEAL_NAME`] so open + /// After confirmed is durable, publish soft `crate::TIP_SEAL_NAME` so open /// can clamp an incomplete extension that never finished this barrier. /// Height whose spend annotations were `sync_data`'d. Missing means none. pub fn spend_annotated_through(&self) -> Result, StoreError> { From d3f399d54ed476a3cba2028ecfd2a652c91f394a Mon Sep 17 00:00:00 2001 From: "rearden-grok[bot]" <317016512+rearden-grok[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:49:23 -0700 Subject: [PATCH 08/10] ci: qc checks both release shapes and rustdoc; gate.json owns the badge floor `cargo check --release --workspace` unifies the consensus `corpus` default onto every crate; nix/rbitcoin.nix and release.yml build `-p rbitcoin-node -p rbitcoin-cli -p rbitcoin-store` without it, so qc checks that shape too. `--exclude rbitcoin-bench` is gone: the bench lib checks in release and its bin needs the `cli` feature, which cargo skips. `cargo doc --workspace --no-deps` runs after, so a hidden-module link cannot rot again. The badge gate had three copies (gate.py, coverage.sh, badge.py) kept in sync by a grep. coverage-gate.py writes `floor` to gate.json; coverage.sh reads it from there and the badge takes `--gate` as required. coverage.test.sh pins each, and now also fails when a fixture path no longer exists instead of matching a regex against a string. Co-authored-by: Cursor --- .github/workflows/ci.yml | 11 ++++++++--- scripts/coverage-badge.py | 2 +- scripts/coverage.sh | 3 ++- scripts/coverage.test.sh | 32 +++++++++++++++++++++----------- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9311f14ac9..3503d22268 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,10 +109,15 @@ jobs: workspaces: ". -> target/dev" - name: cargo clippy run: cargo clippy --workspace --all-targets -- -D warnings - # Suites link cfg(debug_assertions) hooks and cannot run in release, so - # this is the only PR check that compiles what release.yml and nix ship. + # Both shapes TESTING.md names: workspace, and the product set that + # nix/rbitcoin.nix and release.yml build (consensus without `corpus`). - name: cargo check --release - run: cargo check --release --workspace --exclude rbitcoin-bench + run: | + cargo check --release --workspace + cargo check --release -p rbitcoin-node -p rbitcoin-cli -p rbitcoin-store + # doc(hidden) pub modules are rustdoc-visible; a broken link is an error. + - name: cargo doc + run: cargo doc --workspace --no-deps - uses: cachix/install-nix-action@448cde739abec1eaf0646249e3d25bb8d9bc7702 # v31.11.2 with: github_access_token: ${{ github.token }} diff --git a/scripts/coverage-badge.py b/scripts/coverage-badge.py index 00a760200b..f98e877658 100755 --- a/scripts/coverage-badge.py +++ b/scripts/coverage-badge.py @@ -115,7 +115,7 @@ def main() -> None: p = argparse.ArgumentParser(description=__doc__) p.add_argument("--lh", type=int, required=True) p.add_argument("--lf", type=int, required=True) - p.add_argument("--gate", type=int, default=91) + p.add_argument("--gate", type=int, required=True, help="floor from coverage-gate.py") p.add_argument("--sha", default="") p.add_argument("--scope", default="production") p.add_argument("--date", default="") diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 4a7e7fa6cb..eca38420c5 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -147,8 +147,9 @@ PY exit 1 fi SHA="${GITHUB_SHA:-$(git rev-parse HEAD)}" + GATE_FLOOR="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["floor"])' "$GATE_JSON")" python3 "$ROOT/scripts/coverage-badge.py" \ - --lh "$LCOV_HIT" --lf "$LCOV_TOT" --gate 91 \ + --lh "$LCOV_HIT" --lf "$LCOV_TOT" --gate "$GATE_FLOOR" \ --sha "$SHA" --scope production \ --lcov "$ROOT/coverage/lcov.info" \ --out "$ROOT/coverage/badge.json" diff --git a/scripts/coverage.test.sh b/scripts/coverage.test.sh index 6c7308561a..0ba35833dd 100755 --- a/scripts/coverage.test.sh +++ b/scripts/coverage.test.sh @@ -19,9 +19,10 @@ fi echo "ok - coverage.sh defines IGNORE" PASS=$((PASS + 1)) -python3 - "$IGNORE" <<'PY' || exit 1 -import re, sys +python3 - "$IGNORE" "$ROOT" <<'PY' || exit 1 +import os, re, sys rx = re.compile(sys.argv[1]) +root = sys.argv[2] excluded = [ "/repo/crates/rbitcoin-store/tests/scripthash.rs", "/repo/crates/rbitcoin-ibd/tests/ibd/confirm.rs", @@ -45,6 +46,11 @@ kept = [ "/repo/crates/rbitcoin-rpc/src/methods/chain.rs", ] fail = 0 +# Fixtures are real paths, so a crate move fails here instead of rotting. +for p in excluded + kept: + if not os.path.exists(os.path.join(root, p.removeprefix("/repo/"))): + print(f"not ok - fixture path is gone {p}", file=sys.stderr) + fail += 1 for p in excluded: if rx.search(p) is None: print(f"not ok - should ignore {p}", file=sys.stderr) @@ -77,15 +83,19 @@ assert_ok "required test job excludes rbitcoin-bench" \ grep -q 'cargo test --workspace --exclude rbitcoin-bench' "$ROOT/.github/workflows/ci.yml" assert_ok "required test job still pins the bench scripthash" \ grep -q 'cargo test -p rbitcoin-bench --lib hot_corpus_includes_p2a' "$ROOT/.github/workflows/ci.yml" -# Suites link cfg(debug_assertions) hooks, so release is check-only. Without -# this step a debug-only import on a production path ships uncompiled. -FLOOR="$(python3 -c 'import re,sys; print(re.search(r"^FLOOR_PCT = (\d+)", open(sys.argv[1]).read(), re.M).group(1))' "$ROOT/scripts/coverage-gate.py")" -assert_ok "coverage.sh passes the gate floor ($FLOOR) to the badge" \ - grep -q -- "--gate $FLOOR " "$COV" -assert_ok "coverage-badge.py defaults to the gate floor ($FLOOR)" \ - grep -q "\"--gate\", type=int, default=$FLOOR)" "$ROOT/scripts/coverage-badge.py" -assert_ok "qc checks the release profile compiles" \ - grep -q 'cargo check --release --workspace --exclude rbitcoin-bench' "$ROOT/.github/workflows/ci.yml" +# coverage-gate.py owns the floor (FLOOR_PCT, written to gate.json). The badge +# takes it from there; neither script carries a second copy of the number. +assert_ok "coverage.sh reads the badge gate from gate.json, not a literal" \ + bash -c 'grep -q -- "--gate \"\$GATE_FLOOR\"" "$1" && grep -q "GATE_FLOOR=.*gate.json\|GATE_FLOOR=.*GATE_JSON" "$1" && ! grep -qE -- "--gate [0-9]+" "$1"' _ "$COV" +assert_ok "coverage-badge.py has no default gate" \ + bash -c 'grep -q "\"--gate\", type=int, required=True" "$1" && ! grep -qE "default=[0-9]{2}" "$1"' _ "$ROOT/scripts/coverage-badge.py" +# TESTING.md (Coverage): release is check-only, in both shapes CI names. +assert_ok "qc checks the release profile compiles (workspace shape)" \ + grep -q 'cargo check --release --workspace$' "$ROOT/.github/workflows/ci.yml" +assert_ok "qc checks the release profile compiles (product shape)" \ + grep -q 'cargo check --release -p rbitcoin-node -p rbitcoin-cli -p rbitcoin-store$' "$ROOT/.github/workflows/ci.yml" +assert_ok "qc builds rustdoc for the workspace" \ + grep -q 'cargo doc --workspace --no-deps$' "$ROOT/.github/workflows/ci.yml" assert_ok "gitignore ignores apilog jsonl" \ bash -c 'grep -q "apilog\\*\\.jsonl" "$1/.gitignore" && git -C "$1" check-ignore -q -- apilog.jsonl && git -C "$1" check-ignore -q -- apilog-old.jsonl' _ "$ROOT" From 18032d1d100ef6e412a022cc6802c88278a4ac32 Mon Sep 17 00:00:00 2001 From: "rearden-grok[bot]" <317016512+rearden-grok[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:49:24 -0700 Subject: [PATCH 09/10] test: spindle red test pins the default-off state The test cleared the flag before the first mark, so flipping the initializer to `true` would still pass. libtest gives each test a fresh thread; the first assertion now reads the default. The why-comment on the thread-locals folds into `spindle_trace_arm`'s rustdoc. Co-authored-by: Cursor --- crates/rbitcoin-query/src/confirm_run/write.rs | 6 +++--- .../tests/confirm_run/write_idempotent_tests.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/rbitcoin-query/src/confirm_run/write.rs b/crates/rbitcoin-query/src/confirm_run/write.rs index 0e550872d8..a000096908 100644 --- a/crates/rbitcoin-query/src/confirm_run/write.rs +++ b/crates/rbitcoin-query/src/confirm_run/write.rs @@ -9,8 +9,6 @@ thread_local! { RefCell::new(super::phases::StructuralReuse::default()); } -// Opt-in: a debug node runs `spindle_mark` on every batch and nothing -// reads the trace, so it records only after `spindle_trace_arm`. #[cfg(debug_assertions)] thread_local! { static SPINDLE_TRACE_ON: std::cell::Cell = const { std::cell::Cell::new(false) }; @@ -25,7 +23,9 @@ pub fn spindle_mark(_ev: &'static str) { } } -/// Start recording on this thread, from an empty trace. +/// Start recording on this thread, from an empty trace. A debug node runs +/// `spindle_mark` on every batch and nothing in the node reads the trace, so +/// it records only after this call. #[cfg(debug_assertions)] pub fn spindle_trace_arm() { SPINDLE_TRACE.with(|trace| trace.borrow_mut().clear()); diff --git a/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs b/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs index 297e63742d..6892fc13c8 100644 --- a/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs +++ b/crates/rbitcoin-query/tests/confirm_run/write_idempotent_tests.rs @@ -3470,7 +3470,7 @@ fn spindle_mark_records_only_while_armed() { spindle_mark, spindle_trace_arm, spindle_trace_clear, spindle_trace_snapshot, }; - spindle_trace_clear(); + // Fresh test thread: the default state must already be off. spindle_mark("unarmed"); assert!(spindle_trace_snapshot().is_empty()); From 16b7afeed24f830e4727cd141048959a263b1d51 Mon Sep 17 00:00:00 2001 From: "rearden-grok[bot]" <317016512+rearden-grok[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:49:25 -0700 Subject: [PATCH 10/10] docs: principle 11 matches the tree; one owner for the release-check fact Principle 11 claimed every debug hook is opt-in; the tree has ~12 always-on bounded counters, which the rule now allows, and three debug-only timing constants, which it names as exceptions to retire. TESTING.md owns how CI compiles the release profile (both check shapes, no job runs a release binary; the harnesses build dev). CONTRIBUTING, code-shape, ci.yml, and coverage.test.sh point there instead of restating it. Two TESTING.md neighbours still said `pub(crate)` and `#[cfg(test)]`. rbitcoin-ibd/AGENTS.md notes the net dev-dependency. The changelog fragment splits Fixed from Changed and adds the rustdoc fix. Co-authored-by: Cursor --- CONTRIBUTING.md | 27 ++++++++++++++--------- TESTING.md | 20 ++++++++++------- changelog.d/release-build-after-layout.md | 9 ++++++-- crates/rbitcoin-ibd/AGENTS.md | 7 +++--- docs/code-shape.md | 4 +--- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1dbd2b0ec1..430941d74f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -241,15 +241,19 @@ engineering. hidden item, so a change that removes the last caller removes the callee in the same change (code-shape rule 9); `#[allow(dead_code)]` is not a fix, in `src/` or in a suite root. Test hooks in production - files are `#[cfg(debug_assertions)]` and **opt-in**: off until the test - arms them on its thread, and a no-op on the hot path otherwise, because - every debug node runs that code. A release build must still compile - (`cargo check --release` in `qc`), so a `cfg(debug_assertions)` gate - never covers an import or re-export that production code uses. Tests - drive the shipped function (principle 8), not a second test-only - wrapper or `*_for_test` backdoor. IO-shape pins use session/table - instance stats or on-disk file state, not thread-local `test_take_*` - probes on the hot path. Fuzz-only `pub` is the same smell — prefer the + files are `#[cfg(debug_assertions)]`, and every debug node runs that + code, so a hook is either a bounded counter (`Cell` / atomic increment) + or **opt-in**: off until the test arms it on its thread. Nothing + accumulates unarmed (`spindle_mark` is the pattern). A + `cfg(debug_assertions)` gate never covers an import or re-export that + production code uses, and it never changes a production constant or + code path (the debug-only `REDIAL_INTERVAL`, `SAM_RETRY`, and + `CONSTRAINTS_COOLDOWN` values are the known exceptions to retire); how + CI compiles the release profile is in + [`TESTING.md`](TESTING.md#coverage). Tests drive the shipped function + (principle 8), not a second test-only wrapper or `*_for_test` backdoor. + IO-shape pins prefer session/table instance stats or on-disk file state + over a thread-local probe. Fuzz-only `pub` is the same smell — prefer the in-crate graph or the published **binary** surface (`rbitcoin-node` / CLI) even if the harness pays a little extra setup, rather than exporting helpers solely for `fuzz/`. @@ -320,8 +324,9 @@ IO; they do not package zips. GitHub Releases: - [ ] No unused crate-root `pub` / `pub use`; suite-only items are `#[doc(hidden)]`; a removed caller removes its callee (principle 11). Tests drive shipped functions, not `*_for_test` backdoors. A - `cfg(debug_assertions)` hook is opt-in and gates no production - import. Fuzz does not grow `pub` without considering the binary + `cfg(debug_assertions)` hook is a bounded counter or opt-in, and + gates no production import, constant, or code path. Fuzz does not + grow `pub` without considering the binary surface. - [ ] Store changes respect Class A/B/C and allocate-then-publish - [ ] Experimental / milestone honesty preserved in user-facing docs when relevant diff --git a/TESTING.md b/TESTING.md index cdf208a46e..2e78267404 100644 --- a/TESTING.md +++ b/TESTING.md @@ -213,9 +213,12 @@ is not required to make LCOV see it. Library tests live in each crate's `tests/suite` and link the normal rlib, so a `#[cfg(test)]` arm in `src/` is no longer how those tests compile. `#[cfg(debug_assertions)]` hooks in production files still count. Those hooks also mean the suites link only in -the `dev` / `test` profiles: `cargo test --release` does not build. Release -correctness is `cargo check --release --workspace --exclude rbitcoin-bench` -(`qc`) plus the labeled harnesses that run the shipped binaries. llvm-cov +the `dev` / `test` profiles: `cargo test --release` does not build. The +release profile is compiled on every PR by `cargo check --release` in `qc` +(workspace shape and the `-p rbitcoin-node -p rbitcoin-cli -p rbitcoin-store` +product shape that `nix/rbitcoin.nix` and `release.yml` build) and built for +real only at tag time. The labeled harnesses build `rbitcoin-node` in the +`dev` profile, so no CI job executes a release binary. llvm-cov hit counts jitter tens of lines on the same tree; the floor is the gate, not a never-falls ratchet vs master. @@ -279,11 +282,12 @@ counts that line. 2. Prefer extending that journey over a new small test. A caller of other tests is not a journey. 3. If a branch is unreachable from any real session, **delete it** or hit it - through a **shipped** config / error / CLI path. Do not add a `pub` or - `*_for_test` injector so a unit can see it + through a **shipped** config / error / CLI path. Do not add a + `#[doc(hidden)] pub` or `*_for_test` injector so a unit can see it ([`CONTRIBUTING.md`](./CONTRIBUTING.md) principle 11). 4. A small unit only for the narrow case in [True journeys](#true-journeys). - Drive the shipped function, not a `#[cfg(test)]` wrapper around it. + Drive the shipped function, not a `#[cfg(debug_assertions)]` wrapper + around it. ### Closing a red region @@ -453,8 +457,8 @@ overrides that choice; unset keeps it. A Sunday (or `workflow_dispatch`) job runs `asmap` and `block_wire` for 120s with `--sanitizer undefined`. Miri stays `rbitcoin-primitives` only. Treat crate-root `pub` that exists only so a fuzz target can call it as -the same smell as a test-only export: prefer `pub(crate)` plus an in-crate -harness, or the published `rbitcoin-node` / CLI binary, even if that costs +the same smell as a test-only export: prefer the in-crate graph, or the +published `rbitcoin-node` / CLI binary, even if that costs a little setup time, rather than growing helpers solely for fuzz. Allowlist what must stay `pub` for a target; do not treat `fuzz/` as a second public API. diff --git a/changelog.d/release-build-after-layout.md b/changelog.d/release-build-after-layout.md index c3dfc28649..7ab9b07229 100644 --- a/changelog.d/release-build-after-layout.md +++ b/changelog.d/release-build-after-layout.md @@ -1,6 +1,11 @@ Fixed -- **Release builds compile again.** The crate-layout move gated a `rbitcoin-store` import and two `rbitcoin-query` re-exports behind `cfg(debug_assertions)` while production code used them, so `cargo build --release`, `release.yml`, and the nix package failed. `qc` now runs `cargo check --release --workspace --exclude rbitcoin-bench`; the suites themselves build in the dev and test profiles only. +- **Release builds compile again.** The crate-layout move gated a `rbitcoin-store` import and two `rbitcoin-query` re-exports behind `cfg(debug_assertions)` while production code used them, so `cargo build --release`, `release.yml`, and the nix package failed. The suites themselves build in the dev and test profiles only. - **A debug node no longer grows the confirm spindle trace.** `spindle_mark` records only after a test arms it on that thread. Before, every debug build appended to a thread-local on each confirm batch for the life of the process. -- **The coverage badge gate is the 91% floor.** The badge still said 89 after the floor moved, so a run between 89 and 91 would have drawn a passing badge on a failing gate. `coverage.test.sh` pins the badge to `FLOOR_PCT`. +- **The coverage badge gate is the 91% floor.** The badge still said 89 after the floor moved, so a run between 89 and 91 would have drawn a passing badge on a failing gate. `coverage-gate.py` is now the only place the number lives; the badge reads it from `gate.json`. +- **`cargo doc --workspace` builds.** The layout move made private modules `#[doc(hidden)] pub`, so rustdoc began resolving 37 links in them that had never been checked. + +Changed + +- **`qc` compiles the release profile and the workspace rustdoc.** `cargo check --release` runs in the workspace shape and in the product shape nix and `release.yml` build; `cargo doc --workspace --no-deps` runs after it. - **Suite roots are linted like `src/`.** The `#![allow(unused_imports, dead_code, unused_variables)]` on every `tests/suite.rs` is gone; the imports the move left behind and one dead env-lock helper went with it. diff --git a/crates/rbitcoin-ibd/AGENTS.md b/crates/rbitcoin-ibd/AGENTS.md index 1c6841577f..a049b6ebff 100644 --- a/crates/rbitcoin-ibd/AGENTS.md +++ b/crates/rbitcoin-ibd/AGENTS.md @@ -1,9 +1,10 @@ # rbitcoin-ibd Multi-peer initial block download and the confirm pipeline. Depends on -net, query, store, consensus, log, and primitives. Only `rbitcoin-node` -and `rbitcoin-test` depend on this crate; RPC, Electrum, Esplora, and SV2 -do not. Tip follow and relay stay in `rbitcoin-net`. +net, query, store, consensus, log, and primitives. In the production +graph only `rbitcoin-node` and `rbitcoin-test` depend on this crate; RPC, +Electrum, Esplora, and SV2 do not (`rbitcoin-net` dev-depends on it for +`peer_header_sync_journey`). Tip follow and relay stay in `rbitcoin-net`. ## Read first diff --git a/docs/code-shape.md b/docs/code-shape.md index e4021f1805..9128d02483 100644 --- a/docs/code-shape.md +++ b/docs/code-shape.md @@ -91,9 +91,7 @@ denied a Core-faithful loop. That is a **site** allow on that function, not a standing workspace `cognitive_complexity` allow. Suite roots (`tests/suite.rs`) carry no `#![allow(...)]` either: the test -tree is linted like `src/`. Visibility for the suite is `#[doc(hidden)] -pub`, and test hooks in production files are opt-in -`#[cfg(debug_assertions)]`; the rule and its limits are +tree is linted like `src/`. Suite visibility and test-hook gating: [`CONTRIBUTING.md`](../CONTRIBUTING.md) principle 11. The workspace allow list is empty. `cognitive_complexity` is workspace