Skip to content

net: PeerHub uses NodeClock, drop second mock battery - #837

Open
Hero-Gamer wants to merge 6 commits into
reardencode:masterfrom
Hero-Gamer:clock-step2-single-source
Open

Hero-Gamer wants to merge 6 commits into
reardencode:masterfrom
Hero-Gamer:clock-step2-single-source

Conversation

@Hero-Gamer

@Hero-Gamer Hero-Gamer commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

#821 Step 2 only. Not the whole issue.

PeerHub no longer has its own mock clock. NodeClock::new() returns Arc<Self>. PeerHub::new(clock) holds pub clock. mock_now / set_mock_now are gone. on_clock_jump() requests tx INVs, runs the heartbeat, and queues a due addr self-announcement on each live peer.

TxRelay still has its own mock clock. setmocktime still notifies it. That is Step 3.

Ctors migrated to PeerHub::new(NodeClock::new()) / hub.clock.set_mock: chain.rs, ephemeral.rs, overlay_addrman_journey.rs, peer_*_journey.rs, service.rs, rbitcoin-node/src/run.rs, rbitcoin-rpc/src/methods_tests.rs, rbitcoin-test/tests/integration_multinode.rs.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • ./scripts/ast-grep.sh
  • cargo test -p rbitcoin-net --lib
  • self_announce_due_on_peerhub_clock_jump: next send is start+24h; a 25h jump queues Addr. A jump that does not pass that deadline must not.

HEAD: 886463e Merge reardencode#823 (latest master)
- clock.rs:44 root wall source = LEAVE
- tx_relay.rs:928 manual mock check = node-time MIGRATE to NodeClock
- tx_relay.rs:3753 tmp uniqueness = log/perf LEAVE
- bulk_io 10, bdz 5, etc = log/perf LEAVE
- peers.rs 3, service.rs 3, peer.rs 4 = node-time MIGRATE for Steps 2/3

No prod change. Tracks reardencode#688 item 2.1, part of reardencode#821, follows reardencode#740
- peers.rs:1249 AtomicU64 0=wall, Acquire/Release
- tx_relay.rs:625 AtomicU64 0=wall, Relaxed/Relaxed
- chain.rs: hub.clock.set_mock() third clock
- split-brain enables INV freeze and peer timeout bypass

No prod change, adversarial review for reardencode#821
…6463e

repro: rg -n SystemTime::now crates/ --type rust -g '!*tests*' | cut -d: -f1,2 = 100/100 match
- PeerHub::new(clock: Arc<NodeClock>) where NodeClock::new()->Arc<Self>
- Remove mock_now/set_mock_now second battery from PeerHub, CLEAN
- Add on_clock_jump() explicit reaction to clock jump (INV + heartbeat)
- setmocktime writes ChainHub clock once, fanout removed
- Migrate methods_tests.rs + integration_multinode.rs: hub.clock.set_mock(x as i64)
- Fix run.rs proxy_seed test ctor and all journey tests
- QC: fmt OK, clippy workspace all-targets -D warnings OK, ast-grep 12 passed
- Verified: rbitcoin-net --lib 588 passed, no bare PeerHub::new()
@Hero-Gamer
Hero-Gamer force-pushed the clock-step2-single-source branch from 0fdc367 to 5af26ba Compare September 30, 2026 19:22
@Hero-Gamer Hero-Gamer changed the title net, rpc, test: clock Step 2 - single NodeClock source net: single NodeClock source, remove second mock battery Sep 30, 2026

@rearden-grok rearden-grok Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shared-clock wiring looks sound for #821 Step 2, and the required checks are green. I found one behavior regression that should be fixed before merge (see inline comment).

Scope note: TxRelay still owns its separate mock clock and setmocktime still notifies it, as expected for the planned Step 3. Please keep the PR and changelog wording scoped to PeerHub / Step 2; ‘Clock is single NodeClock source’ can read as if the whole node has been consolidated.

Comment thread crates/rbitcoin-net/src/peers.rs
@Hero-Gamer
Hero-Gamer force-pushed the clock-step2-single-source branch from 184ac8c to ae96744 Compare October 2, 2026 15:56
@Hero-Gamer Hero-Gamer changed the title net: single NodeClock source, remove second mock battery net: PeerHub uses NodeClock, drop second mock battery Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant