From 16c5f7f7ad3f52c51595dcc13f35573e957d9c1d Mon Sep 17 00:00:00 2001 From: Dendi Suhubdy <4477337+dendisuhubdy@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:28:45 +0800 Subject: [PATCH 1/2] PRIV-601: leave the legacy signed transaction topic by default from v0.9.0, and a first-spy test in process A node reads its own version for the default: a v0.8.x node still subscribes and relays on the legacy signed topic, a node of v0.9.0 or later gossips transactions on the anonymous lane only. --legacy-tx-relay (new) or --legacy-tx-publish keeps the topic on such a release; --anonymous-tx-only leaves it on any release. Every node since v0.8.3 speaks the anonymous lane, so the two defaults interoperate and the release rolls host by host. tests/dandelion.rs gains the first-spy measurement in process: an observer connected to all five nodes guesses each transaction's origin as the peer that first forwarded it. Without Dandelion it must name the submitter for at least 8 of 10; with it, over a fleet mixing anonymous-only and both-lane nodes, for at most 10 of 20; no copy may reach it on the signed topic. docs/deploy.md says what the in-process test shows and what it does not, and what the fleet run has to record. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01YGaYNQ4cvFtg2UmokVgrAN --- crates/randprotocol-node/src/main.rs | 21 ++- crates/randprotocol-node/src/network/mod.rs | 46 +++++++ crates/randprotocol-node/tests/dandelion.rs | 142 +++++++++++++++++++- docs/architecture.md | 2 +- docs/cli.md | 3 +- docs/deploy.md | 43 +++++- 6 files changed, 241 insertions(+), 16 deletions(-) diff --git a/crates/randprotocol-node/src/main.rs b/crates/randprotocol-node/src/main.rs index 88d0fd83..8a29995b 100644 --- a/crates/randprotocol-node/src/main.rs +++ b/crates/randprotocol-node/src/main.rs @@ -763,8 +763,16 @@ enum Cmd { /// subscribing to and relaying on the legacy signed topic `rand/{chain}/tx` as well. /// Since audit v12 (PRIV-601) a node never publishes its own transactions there unless /// `--legacy-tx-publish`; this flag also stops it hearing and relaying older nodes' copies. + /// The default from v0.9.0 on (`--legacy-tx-relay` keeps the topic there). #[arg(long)] anonymous_tx_only: bool, + /// Keep subscribing to and relaying on the legacy signed topic `rand/{chain}/tx` on a + /// release that leaves it by default (v0.9.0 on), for a chain that still runs nodes from + /// before v0.8.3. No effect before v0.9.0, where the topic is kept anyway, nor under + /// `--anonymous-tx-only`. This node's own transactions still go on the anonymous lane only + /// unless `--legacy-tx-publish`. + #[arg(long)] + legacy_tx_relay: bool, /// Also publish this node's transactions, signed, on the legacy topic `rand/{chain}/tx` /// (audit v12, PRIV-601). Each copy there names this node as its publisher, which is what /// the anonymous lane and the stem exist to hide, so it is off by default. Only for a @@ -3058,6 +3066,7 @@ async fn main() -> Result<()> { reserved_peer, strict_gossip, anonymous_tx_only, + legacy_tx_relay, legacy_tx_publish, dandelion, dandelion_fluff_prob, @@ -3164,7 +3173,7 @@ async fn main() -> Result<()> { }, rpc_options, node::NetOptions { reserved_peers: reserved_peer, strict_gossip, - anonymous_tx_only, + anonymous_tx_only: randprotocol_node::network::anonymous_tx_only(anonymous_tx_only, legacy_tx_relay || legacy_tx_publish, env!("CARGO_PKG_VERSION")), legacy_tx_publish, dandelion: randprotocol_node::dandelion::DandelionConfig { enabled: dandelion == "on", @@ -4627,13 +4636,15 @@ mod tests { let run = |extra: &[&str]| { let args = ["rand-node", "run", "--datadir", "d", "--key", "k.json"].into_iter().chain(extra.iter().copied()); match Cli::try_parse_from(args).map(|c| c.cmd) { - Ok(Cmd::Run { legacy_tx_publish, anonymous_tx_only, .. }) => (legacy_tx_publish, anonymous_tx_only), + Ok(Cmd::Run { legacy_tx_publish, anonymous_tx_only, legacy_tx_relay, .. }) => (legacy_tx_publish, anonymous_tx_only, legacy_tx_relay), _ => unreachable!("a run"), } }; - assert_eq!(run(&[]), (false, false), "no signed legacy copy by default"); - assert_eq!(run(&["--legacy-tx-publish"]), (true, false)); - assert_eq!(run(&["--anonymous-tx-only"]), (false, true)); + assert_eq!(run(&[]), (false, false, false), "no signed legacy copy by default"); + assert_eq!(run(&["--legacy-tx-publish"]), (true, false, false)); + assert_eq!(run(&["--anonymous-tx-only"]), (false, true, false)); + // monorepo#27: the flag that keeps the legacy topic on a release that leaves it by default. + assert_eq!(run(&["--legacy-tx-relay"]), (false, false, true)); } /// Issue #145: Dandelion++ is on by default at q = 0.1 and a 3 s embargo; each flag parses, diff --git a/crates/randprotocol-node/src/network/mod.rs b/crates/randprotocol-node/src/network/mod.rs index e622033d..3b98d075 100644 --- a/crates/randprotocol-node/src/network/mod.rs +++ b/crates/randprotocol-node/src/network/mod.rs @@ -1028,6 +1028,29 @@ fn dial_bootstrap(swarm: &mut Swarm, cfg: &NetworkConfig, peers: } } +/// Whether a node gossips transactions on the anonymous lane only +/// ([`EdgeConfig::anonymous_tx_only`]), from its flags and the release it is (`version`, the +/// crate's `major.minor.patch[-pre]`). `--anonymous-tx-only` leaves the legacy signed topic on any +/// release; `--legacy-tx-relay` or `--legacy-tx-publish` keeps it on any release. With none of +/// them a release before v0.9.0 still subscribes and relays there (the v0.8.3 rolling upgrade, +/// issue #146) and v0.9.0 or later does not: the last phase of that roll, taken by the version so +/// it needs no flag on any unit and no edit at the bump (monorepo#27, PRIV-601). Every node since +/// v0.8.3 speaks the anonymous lane, so the two defaults interoperate. A version that does not +/// parse takes the private default. +pub fn anonymous_tx_only(anonymous_only: bool, keep_legacy: bool, version: &str) -> bool { + if anonymous_only { + return true; + } + if keep_legacy { + return false; + } + let mut parts = version.split(['.', '-']).map(|p| p.parse::().ok()); + match (parts.next().flatten(), parts.next().flatten()) { + (Some(major), Some(minor)) => (major, minor) >= (0, 9), + _ => true, + } +} + /// How transactions leave this node besides the anonymous lane (issues #145, #146). struct TxPaths { /// Subscribe and relay on the legacy signed topic too ([`EdgeConfig::anonymous_tx_only`] off). @@ -2635,6 +2658,29 @@ mod tests { assert!(none.admit(p, 0, t), "but an empty frame costs nothing"); } + /// monorepo#27 (PRIV-601): which lanes a node gossips transactions on follows its release. A + /// v0.8.x node keeps the legacy signed topic unless `--anonymous-tx-only`; from v0.9.0 a node + /// leaves it unless `--legacy-tx-relay` or `--legacy-tx-publish` keeps it. The explicit + /// anonymous-only flag wins on every release, and an unreadable version is anonymous-only. + #[test] + fn the_legacy_transaction_topic_is_left_by_default_from_v0_9_0() { + for v in ["0.8.6", "0.8.99", "0.8.7-rc1", "0.1.0"] { + assert!(!anonymous_tx_only(false, false, v), "{v}: both lanes by default"); + assert!(anonymous_tx_only(true, false, v), "{v}: --anonymous-tx-only"); + assert!(anonymous_tx_only(true, true, v), "{v}: --anonymous-tx-only wins"); + } + for v in ["0.9.0", "0.9.0-rc1", "0.10.2", "1.0.0"] { + assert!(anonymous_tx_only(false, false, v), "{v}: the anonymous lane only by default"); + assert!(!anonymous_tx_only(false, true, v), "{v}: kept on request"); + assert!(anonymous_tx_only(true, true, v), "{v}: --anonymous-tx-only wins"); + } + assert!(anonymous_tx_only(false, false, "not a version")); + assert!(anonymous_tx_only(false, false, "1")); + // This build. + let v = env!("CARGO_PKG_VERSION"); + assert_eq!(anonymous_tx_only(false, false, v), !v.starts_with("0.8.")); + } + /// `EdgeConfig::default()` is what `start` passes: no reserved or bound peers, permissive /// gossip, both transaction lanes. The `--strict-gossip`, `--reserved-peer` and /// `--anonymous-tx-only` paths are opt-in. diff --git a/crates/randprotocol-node/tests/dandelion.rs b/crates/randprotocol-node/tests/dandelion.rs index 92cbd17c..f7af20a5 100644 --- a/crates/randprotocol-node/tests/dandelion.rs +++ b/crates/randprotocol-node/tests/dandelion.rs @@ -34,7 +34,9 @@ struct Net { next: u64, } -async fn start(gen: &Genesis, seed: u8, bootstrap: Vec, dandelion: DandelionConfig) -> TestNode { +/// One node. `anonymous_tx_only` is what a node of v0.9.0 or later runs by default; off is a +/// v0.8.x node's default (both transaction lanes subscribed and relayed). +async fn start_on_lanes(gen: &Genesis, seed: u8, bootstrap: Vec, dandelion: DandelionConfig, anonymous_tx_only: bool) -> TestNode { let dir = tempfile::tempdir().unwrap(); std::fs::write(dir.path().join("genesis.json"), gen.to_json()).unwrap(); let key = Keypair::from_seed([seed; 32]).unwrap(); @@ -62,7 +64,7 @@ async fn start(gen: &Genesis, seed: u8, bootstrap: Vec, dande msauth: Default::default(), }, RpcOptions::default(), - NetOptions { dandelion, ..NetOptions::default() }, + NetOptions { dandelion, anonymous_tx_only, ..NetOptions::default() }, ) .await .expect("node starts"); @@ -75,13 +77,19 @@ impl Net { /// is connected to all the others — and, where its config speaks the stem, until it knows /// every other stem-capable node as a stem peer — plus two gossip heartbeats for the mesh. async fn start(configs: Vec) -> Net { + Net::start_on_lanes(configs, &[]).await + } + + /// [`Net::start`] with the nodes whose index is in `anonymous_only` on the anonymous + /// transaction lane only, the rest on both lanes. + async fn start_on_lanes(configs: Vec, anonymous_only: &[usize]) -> Net { common::cluster::init_tracing(); let gen = common::genesis(&minter()); let executor = node::executor_for_profile(&gen.fri_profile).unwrap(); let mut nodes: Vec = Vec::new(); for (i, cfg) in configs.iter().enumerate() { let boot = nodes.iter().map(common::cluster::bootstrap_addr).collect(); - nodes.push(start(&gen, 1 + i as u8, boot, cfg.clone()).await); + nodes.push(start_on_lanes(&gen, 1 + i as u8, boot, cfg.clone(), anonymous_only.contains(&i)).await); } let n = nodes.len(); let capable = configs.iter().filter(|c| c.enabled).count(); @@ -371,3 +379,131 @@ async fn dandelion_latency_against_publishing_at_once() { } eprintln!("dandelion added {:.1} ms to the mean time to every mempool on loopback", report[1] - report[0]); } + +/// A first spy: a bare network node connected to every node of `net`, on both transaction lanes, +/// speaking no stem (so no node ever stems to it), that relays nothing and records, for each +/// transaction, the peer that first forwarded it — the first-spy estimator's guess at its origin — +/// and the lane each copy arrived on. +struct Spy { + handle: network::NetworkHandle, + seen: Arc>>, +} + +impl Spy { + async fn join(net: &Net) -> Spy { + let (handle, mut rx) = network::start_with( + NetworkConfig { + chain_id: net.gen.chain_id, + listen: vec!["/ip4/127.0.0.1/tcp/0".parse().unwrap()], + bootstrap: net.nodes.iter().map(common::cluster::bootstrap_addr).collect(), + enable_mdns: false, + limits: WireLimits::default(), + }, + [98; 32], + EdgeConfig::default(), + ) + .await + .unwrap(); + let seen = Arc::new(std::sync::Mutex::new(Vec::new())); + let connected = Arc::new(std::sync::atomic::AtomicUsize::new(0)); + let (record, count, reporter) = (seen.clone(), connected.clone(), handle.clone()); + tokio::spawn(async move { + while let Some(ev) = rx.recv().await { + match ev { + NetworkEvent::PeerConnected(_) => { + count.fetch_add(1, Ordering::Relaxed); + } + NetworkEvent::Gossip { from, msg, id } => { + if let network::GossipMessage::Transaction(tx) = &msg { + record.lock().unwrap().push((tx.hash(), from, id.lane)); + } + // Every delivery is answered; `Ignore`: the spy relays nothing. + reporter.report_validation(id, libp2p::gossipsub::MessageAcceptance::Ignore).await; + } + _ => {} + } + } + }); + let n = net.nodes.len(); + common::cluster::wait_for("the spy is connected to every node", Duration::from_secs(30), || connected.load(Ordering::Relaxed) >= n).await; + // Three gossip heartbeats, so every node has grafted the spy into its transaction mesh. + tokio::time::sleep(Duration::from_millis(3000)).await; + Spy { handle, seen } + } + + /// The node (by index in `net`) that first forwarded `tx` to the spy. + fn first_forwarder(&self, net: &Net, tx: &Hash) -> Option { + let from = self.seen.lock().unwrap().iter().find(|(h, ..)| h == tx).map(|(_, from, _)| *from)?; + net.nodes.iter().position(|n| n.handle.network.local_peer_id == from) + } + + /// How many transaction copies reached the spy on the legacy signed topic. + fn signed_copies(&self) -> usize { + self.seen.lock().unwrap().iter().filter(|(.., lane)| *lane == network::GossipLane::Signed).count() + } +} + +/// The first-spy test (monorepo#27, PRIV-601), in process: the measurement that found the +/// submitter first in 27 of 27 traces on chain 21, re-run against this build's defaults with an +/// observer that is connected to every node and guesses each transaction's origin as the peer +/// that first forwarded it. +/// +/// * Control, Dandelion off (how a node published before v0.8.3): the spy's guess is the +/// submitter for at least 8 of 10 transactions — the estimator works, so the next result means +/// something. +/// * Dandelion on at the defaults (q = 0.1, 3 s embargo), 20 transactions from rotating +/// submitters over a mixed fleet — two nodes on the anonymous lane only (a v0.9.0 node's +/// default), three on both lanes (a v0.8.x node's): the spy's guess is the submitter for at most +/// half of them, every mempool still gets every transaction, and both counts are printed. +/// * In both runs no copy reaches the spy on the legacy signed topic: nothing names a publisher. +/// +/// Five nodes on loopback bound what this shows: with five nodes a stem ends back at the +/// submitter about one time in five. The fleet measurement is `docs/deploy.md`'s to record. +#[tokio::test(flavor = "multi_thread", worker_threads = 8)] +async fn a_first_spy_names_the_submitter_without_dandelion_and_rarely_with_it() { + // (label, configs, nodes on the anonymous lane only, transactions) + let runs: [(&str, Vec, &[usize], usize); 2] = [ + ("off", (0..5).map(|_| DandelionConfig::off()).collect(), &[], 10), + ("on (q = 0.1, b = 3 s)", (0..5).map(|i| DandelionConfig { seed: Some(60 + i), ..DandelionConfig::default() }).collect(), &[1, 3], 20), + ]; + let mut named = Vec::new(); + for (label, configs, anonymous_only, txs) in runs { + let mut net = Net::start_on_lanes(configs, anonymous_only).await; + let spy = Spy::join(&net).await; + let (mut spy_named_submitter, mut submitter_published, mut unheard) = (0, 0, 0); + for k in 1..=txs { + let tx = net.mint(); + let at_node = (k - 1) % 5; + let before = net.all_fluffs(); + net.submit_and_watch(at_node, &tx, k, Duration::from_secs(30)).await; + submitter_published += usize::from(published_by(&before, &net.all_fluffs()).contains(&at_node)); + let hash = tx.hash(); + let heard = tokio::time::timeout(Duration::from_secs(10), async { + loop { + if let Some(first) = spy.first_forwarder(&net, &hash) { + return first; + } + tokio::time::sleep(Duration::from_millis(5)).await; + } + }) + .await; + match heard { + Ok(first) => spy_named_submitter += usize::from(first == at_node), + Err(_) => unheard += 1, + } + tokio::time::sleep(Duration::from_millis(250)).await; + } + eprintln!( + "first spy, dandelion {label}: the spy named the submitter for {spy_named_submitter}/{txs}; the submitter itself published {submitter_published}/{txs}; unheard by the spy {unheard}; copies on the signed legacy topic {}", + spy.signed_copies() + ); + assert_eq!(unheard, 0, "dandelion {label}: the spy missed a transaction, so its count means nothing"); + assert_eq!(spy.signed_copies(), 0, "dandelion {label}: a transaction reached the spy on the signed legacy topic"); + named.push((spy_named_submitter, txs)); + spy.handle.shutdown().await; + net.stop().await; + } + let ((off, off_txs), (on, on_txs)) = (named[0], named[1]); + assert!(off * 10 >= off_txs * 8, "without Dandelion the first spy should name the submitter nearly always: {off}/{off_txs}"); + assert!(on * 2 <= on_txs, "with Dandelion the first spy named the submitter for more than half: {on}/{on_txs}"); +} diff --git a/docs/architecture.md b/docs/architecture.md index b70593b7..b416adba 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -397,7 +397,7 @@ libp2p 0.54 over TCP with Noise and Yamux. Behaviours: **gossipsub**, twice — legacy `/tx`) and anonymous (`MessageAuthenticity::Anonymous` under `ValidationMode::Anonymous`, on its own protocol `/rand//txsub`, topic `rand//tx/2`: a transaction names no author, issue #146; a node publishes its own transactions on the anonymous lane only and merely -relays the legacy `/tx`, unless `--legacy-tx-publish`, audit v12 PRIV-601) — **Kademlia** (protocol `/rand//kad/1`) +relays the legacy `/tx`, unless `--legacy-tx-publish`, audit v12 PRIV-601; from v0.9.0 a node leaves the legacy `/tx` by default, `--legacy-tx-relay` keeps it) — **Kademlia** (protocol `/rand//kad/1`) seeded from `--bootstrap`, **identify**, optional **mDNS** for LAN discovery, **request-response** (`/rand/sync/1`, CBOR) for block sync, and **ping** every 15 s. A node remembers every address it dialled or learnt through identify and redials disconnected known peers every 30 s, in addition to diff --git a/docs/cli.md b/docs/cli.md index 1f4d4209..94ceceb8 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -390,7 +390,8 @@ one the cut announced; a mismatch on one node is almost always an old binary. | `--bootstrap ` | none, repeatable | peer to dial at start and every 30 s while disconnected: `/ip4//tcp//p2p/` | | `--reserved-peer ` | none, repeatable | a peer admitted past the inbound connection cap and served from the validators' share of the sync budget (audit v6, NET-1). Bootstrap peers and every validator whose signed peer binding this node has seen are reserved without it; list the fleet's validators here for a freshly cut chain, whose store holds no bindings yet (`docs/deploy.md`, "Reserved peers") | | `--strict-gossip` | off | gossipsub's strict validation (audit v6, CH-7): accept only messages with a valid author signature, sequence number and source. Every node signs what it publishes, so this drops only forged unsigned messages, and strict and permissive nodes interoperate — it rolls node by node (`docs/deploy.md`) | -| `--anonymous-tx-only` | off | gossip transactions only on the anonymous lane `rand//tx/2` (issue #146): no subscription to, and no relay on, the legacy signed topic `rand//tx`. Off, a node subscribes and relays on both lanes, so older nodes' transactions still reach it; what it publishes itself goes on the anonymous lane only unless `--legacy-tx-publish` (`docs/deploy.md`, "The anonymous transaction lane") | +| `--anonymous-tx-only` | off before v0.9.0, on from v0.9.0 | gossip transactions only on the anonymous lane `rand//tx/2` (issue #146): no subscription to, and no relay on, the legacy signed topic `rand//tx`. Off, a node subscribes and relays on both lanes, so older nodes' transactions still reach it; what it publishes itself goes on the anonymous lane only unless `--legacy-tx-publish`. The default follows the node's own version: a v0.8.x node keeps both lanes, a node of v0.9.0 or later leaves the legacy topic unless `--legacy-tx-relay` or `--legacy-tx-publish` (`docs/deploy.md`, "The anonymous transaction lane") | +| `--legacy-tx-relay` | off | keep subscribing to and relaying on the legacy signed topic on a release that leaves it by default (v0.9.0 on), for a chain that still runs nodes from before v0.8.3. No effect before v0.9.0, nor under `--anonymous-tx-only`. The node's own transactions still go on the anonymous lane only | | `--legacy-tx-publish` | off | also publish this node's own transactions, signed, on the legacy topic `rand//tx` (audit v12, PRIV-601). Each such copy names this node as its publisher, so it is off by default; only for a chain that still runs nodes from before v0.8.3 that must hear this node's transactions over gossip. Ignored under `--anonymous-tx-only` | | `--dandelion ` | `on` | Dandelion++ stem relay for transactions (issue #145): a transaction this node's RPC accepts, or a peer stems to it, goes to one stem successor over `/rand//stem/1` instead of being published, and a relay a few hops on publishes it (the fluff), so the first node to hold or publish it is not the one it was submitted to. Until then no node shows it over RPC or serves it to a peer. Only peers that advertise the stem protocol are sent a stem; with none (a fleet of older nodes) a transaction is published at once, as before. `off`: no stem sent or accepted, and the protocol is not advertised (`docs/deploy.md`, "Dandelion++") | | `--dandelion-fluff-prob ` | `0.1` | q: the probability that a stem relay publishes instead of passing the transaction on; a stem runs about 1/q hops. In `[0, 1]` | diff --git a/docs/deploy.md b/docs/deploy.md index 06e4dfe0..0e185b10 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -207,7 +207,14 @@ describe the v0.8.3/v0.8.4 roll, when that copy was still on by default. still hears every transaction on `tx/2` from the others, and a not-yet-flagged node still publishes on both. A node from before v0.8.3 left on the chain would stop hearing the flagged nodes' transactions (it would still get them in blocks). -3. The next release can make `--anonymous-tx-only` the default and drop the legacy topic. +3. **From v0.9.0 `--anonymous-tx-only` is the default** (monorepo#27): a node reads its own + version, so the legacy topic is left with the version bump, with no flag on any unit and no + flag day. A v0.9.0 node and a v0.8.3–v0.8.x node exchange every transaction on `tx/2`, which + both speak, so the release rolls one host at a time in any order. A chain that still has a node + from before v0.8.3 runs its v0.9.0 nodes with `--legacy-tx-relay` (keep subscribing and + relaying there) and, where that old node must hear a node's own transactions over gossip, + `--legacy-tx-publish`. Chain 21 has had no such node since the v0.8.5 roll. Before v0.9.0 the + flag stays what step 2 says: optional, per host. (Audit v12 made the step in between: the legacy topic is still subscribed and relayed by default, but a node's own transactions go there only under `--legacy-tx-publish`. A node from before v0.8.3 left on the chain then hears a new node's transactions in blocks, and over gossip @@ -232,10 +239,34 @@ fluff no node shows it over RPC, serves it to a peer or proposes it (`docs/archi | `--dandelion-fluff-prob` | `0.1` | q; a stem runs about 1/q relays | | `--dandelion-embargo-ms` | `3000` | b; every holder, the submitter included, waits b + min(Exp(b/4), b) (audit v12, PRIV-604); keep it at or above 3000, twice the 1.5 s stem acknowledgement timeout | -**Origin hiding is design intent until it is measured again.** The first-spy test that found the -submitter first in 27 of 27 traces has not been re-run against v0.8.3 or later, and until audit v12 -every fluff was also published on the signed legacy topic, naming its fluffer (PRIV-601). Treat -the stem's protection as unmeasured until that test is re-run on a fleet with the v12 fixes. +**Origin hiding is design intent until it is measured again on the fleet.** The first-spy test +that found the submitter first in 27 of 27 traces has not been re-run against a fleet of v0.8.3 or +later, and until audit v12 every fluff was also published on the signed legacy topic, naming its +fluffer (PRIV-601). Treat the stem's protection on chain 21 as unmeasured until that run is +recorded. + +What is measured, in process, on every CI run (`tests/dandelion.rs`, +`a_first_spy_names_the_submitter_without_dandelion_and_rarely_with_it`; monorepo#27): five nodes +on loopback and an observer connected to all of them that guesses each transaction's origin as the +peer that first forwarded it. With Dandelion off the test requires the guess to be the submitter +for at least 8 of 10 transactions; with it on at the defaults, over a fleet that mixes nodes on +the anonymous lane only with nodes on both lanes, at most 10 of 20; and no copy may reach the +observer on the signed legacy topic. It prints both counts. Five loopback nodes are not the +fleet: a stem among five nodes ends back at its submitter about one time in five, and loopback has +no link delay. Run it with + +``` +cargo test -p randprotocol-node --release --test dandelion a_first_spy -- --nocapture +``` + +**The fleet run, to record** (owner; it needs hosts, so no test here does it): with every +validator's `rand_getMempoolInfo` sampled at 20 Hz or faster, as in the 27-trace run, submit at +least 27 transactions through one node's RPC, one at a time, and for each note the host whose +mempool counted it first. Record the count of traces in which that host was the entry node, the +release and `git_sha` the fleet ran (`rand_getVersion`), and that no unit carried +`--legacy-tx-publish` (`systemctl cat rand-node | grep -c legacy-tx-publish` is 0 on every host). +The stem hides which node a transaction entered at from the *gossip*; a node that is itself the +entry node's stem successor still sees the stem, so sample mempools, not stem traffic. **Rollout.** Nothing to coordinate: it is on by default and rolls with the binary, in any order. A node sends a stem only to a peer whose identify lists the stem protocol, so a node that predates @@ -251,7 +282,7 @@ connection is re-established at the restart). the legacy `tx` topic. The legacy copy names its publisher, which is now the fluffing relay, not the submitter: Dandelion already moves what the signature gives away off the submitter in this phase. -2. *Phase 2, `--anonymous-tx-only`.* Nothing names a publisher at all; what remains is timing, +2. *Phase 2, `--anonymous-tx-only` (the default from v0.9.0).* Nothing names a publisher at all; what remains is timing, which the stem moves a random walk away from the submitter. 3. The legacy topic gone, the transaction lane is anonymous gossip without `flood_publish`, fed only by fluffs. From da42a025a4bd1cca3a3a9e1bfeea58d776f89f32 Mon Sep 17 00:00:00 2001 From: Dendi Suhubdy <4477337+dendisuhubdy@users.noreply.github.com> Date: Wed, 18 Nov 2026 14:17:52 +0800 Subject: [PATCH 2/2] tests/dandelion: keep the plain start() helper beside start_on_lanes Other tests start a node on the default lanes with it. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01YGaYNQ4cvFtg2UmokVgrAN --- crates/randprotocol-node/tests/dandelion.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/randprotocol-node/tests/dandelion.rs b/crates/randprotocol-node/tests/dandelion.rs index f7af20a5..fd9690ef 100644 --- a/crates/randprotocol-node/tests/dandelion.rs +++ b/crates/randprotocol-node/tests/dandelion.rs @@ -34,8 +34,12 @@ struct Net { next: u64, } -/// One node. `anonymous_tx_only` is what a node of v0.9.0 or later runs by default; off is a -/// v0.8.x node's default (both transaction lanes subscribed and relayed). +async fn start(gen: &Genesis, seed: u8, bootstrap: Vec, dandelion: DandelionConfig) -> TestNode { + start_on_lanes(gen, seed, bootstrap, dandelion, false).await +} + +/// [`start`], choosing the node's transaction lanes: `anonymous_tx_only` is what a node of v0.9.0 +/// or later runs by default, off is a v0.8.x node's default (both lanes subscribed and relayed). async fn start_on_lanes(gen: &Genesis, seed: u8, bootstrap: Vec, dandelion: DandelionConfig, anonymous_tx_only: bool) -> TestNode { let dir = tempfile::tempdir().unwrap(); std::fs::write(dir.path().join("genesis.json"), gen.to_json()).unwrap(); @@ -89,7 +93,12 @@ impl Net { let mut nodes: Vec = Vec::new(); for (i, cfg) in configs.iter().enumerate() { let boot = nodes.iter().map(common::cluster::bootstrap_addr).collect(); - nodes.push(start_on_lanes(&gen, 1 + i as u8, boot, cfg.clone(), anonymous_only.contains(&i)).await); + let node = if anonymous_only.contains(&i) { + start_on_lanes(&gen, 1 + i as u8, boot, cfg.clone(), true).await + } else { + start(&gen, 1 + i as u8, boot, cfg.clone()).await + }; + nodes.push(node); } let n = nodes.len(); let capable = configs.iter().filter(|c| c.enabled).count();