Pages of this audit: Overview · tower_sim (32) · turbine (8) · bunker_coin (4) · dts02-6502-signer (133)
| Audited | aeyakovenko/turbine at commit 40c08faacd29984de3db7701767b85fe19071a10 |
|---|---|
| Date | 15 November 2026; suggested fixes written 16 November 2026 |
| How it ran | local run on our workstation, full audit, Standard review |
| Verdict after review | Pass with notes (Fail if a High finding remains after review, otherwise Pass with notes) The verdict is for the whole audit: 177 findings in 4 repositories, counted once. |
The suggested fixes were written by a reviewer after the audit, with the code open. They were not compiled or run.
This page holds 8 of the 177 findings of the audit: the findings in turbine. No finding is on two pages.
This audit uses a fuller method than our first audit of 4 November 2026 (page removed 9 November 2026): the whole code was read file by file, then checked against our written rules, then against our detection checks. Because the method differs, the totals of the two audits are not comparable. All 4 Medium findings of the audit were checked again by a second reviewer, and so were 7 of its 124 Low findings; the other Low and Info findings are shown as first rated. This page: its 1 Medium finding was checked again by a second reviewer, and 1 of its 4 Low findings was checked again. The code was read at the commit named above; it was not built or run.
How far the reading reached. Each reading reports the line ranges it covered, and a script checks every report against the file:
- turbine: 2 non-empty files, read in 8 line ranges. The reading of every range was confirmed by script.
Each finding keeps the number it has in the audit. It is shown with its rating, its location, the evidence it quotes and a suggested fix. Each location links to the file and line at the audited commit; evidence is quoted from the code as it stands there.
Compared with the first audit
Same commit as the first audit: on 17 November 2026 the default branch of each repository had no later commit. Each finding that our first audit of 4 November 2026 (page removed 9 November 2026) reported in this repository was checked again against the code. 4 findings in the first audit: 3 still in the code; 1 cannot tell; 4 reported again in this audit, 0 not re-reported. This page has 8 findings, 4 of them new. This audit uses a fuller method, so the totals of the two audits are not comparable.
Still in the code = the code at the audited commit, the same commit the first audit read, still has the defect. Reported again = this audit lists it under the number shown. Not re-reported = this audit does not list it as a finding of its own. Cannot tell = it could not be decided from the code.
| First audit | Finding | Rating then, after review | In the code now | In this audit |
|---|---|---|---|---|
| #3004 | RNG seed product collapses to a constant and collides across blocks.src/main.rs:56 | Medium | Still in the code | Reported again: #6002 |
| #3005 | Parallel near-identical simulation functions with diverging recovery threshold.src/main.rs:35 | Low | Still in the code | Reported again: #6601 |
| #3006 | Dead code that implies a design that does not exist.src/main.rs:12 | Low | Still in the code | Reported again: #6707 |
| #3009 | Runtime currency: NOT EXAMINED.Cargo.toml:4Whether these dependency versions are still supported was not checked in either audit. | Info | Cannot tell | Reported again: #6031 |
Medium after review (1)
src/main.rs:56let mut rng = ChaCha8Rng::seed_from_u64(shred as u64 * block as u64);
turbine_recoverable_duplicate_blocks seeds the shuffle for each shred with shred as u64 * block as u64 (src/main.rs line 56). That product is 0 for shred 0 in every block, so shred 0 always travels through the same tree, and different pairs share a seed whenever their products are equal (block 2 shred 3 and block 3 shred 2, for example), so the samples behind the printed statistics are not independent. Give every (block, shred) pair its own seed: shred is below BATCH_SIZE = 64, so (block as u64) << 6 | shred as u64 is unique per pair; combine it with an explicit base seed, for example a module-level constant or a command-line value XORed into it, and print the base seed at start so a run can be repeated. Apply the same change to the three copies of the line at lines 159, 282 and 382 for as long as those functions exist. To confirm, add a test that collects the seed for every pair over a small range of blocks and all 64 shreds and asserts that all are distinct and that shred 0 gets different seeds in blocks 1 and 2; run grep -cF 'shred as u64 * block as u64' src/main.rs in the repository root, which prints 4 today and must print 0; then compare the printed r1, r2 and mixed figures of the first blocks before and after, which are expected to differ. Not compiled or run.
Low after review (4)
src/main.rs:202let recover: bool = node.shreds.into_iter().sum::<u8>() > RECOVER_SIZE as u8;
Node::check_recovered (src/main.rs lines 34-36) says a node has recovered when at least RECOVER_SIZE shreds are present (>=), but turbine_recoverable, turbine and turbine_recoverable_data_only repeat the test inline as a strict comparison of the shred sum (> RECOVER_SIZE at lines 202, 217, 320, 425 and 440, and its negation <= at lines 248, 344 and 464), so those three functions need one shred more than the live simulation does. First decide which boundary is correct for the coding scheme being modelled (whether RECOVER_SIZE shreds are enough or one more is needed) and write that once in check_recovered. Then call node.check_recovered() at the five > sites and its negation at the three <= sites, and move the retransmit-and-recover loop that the four functions share into one function that takes the scenario's constants as parameters. To confirm, add a test that a Node with exactly RECOVER_SIZE non-zero shreds and one with RECOVER_SIZE - 1 give the decided answers, and run grep -c 'RECOVER_SIZE as u8' src/main.rs in the repository root: it prints 9 today and must print 1 (the line inside check_recovered) afterwards. The figures printed by the three functions change at the boundary if >= is kept. Not compiled or run.
src/main.rs:132const NUM_NODES: usize = 10_000;
The four simulation functions in src/main.rs each declare their own copies of the same constants: NUM_NODES at lines 40, 132, 263 and 359, NUM_PACKETS at lines 42, 135, 265 and 361, L0_SIZE at lines 43, 136, 266 and 362 and L1_SIZE at lines 44, 137, 267 and 363. Declare these four once at module level beside BATCH_SIZE and RECOVER_SIZE (lines 4-5) and delete the local copies. BAD_NODES is different in kind: its value is a property of the scenario (lines 41, 133, 264 and 360 hold three different values), so pass it to each function as a parameter or give each scenario its own clearly named constant instead of reusing one name. To confirm, run grep -c 'const NUM_NODES' src/main.rs and grep -c 'const L0_SIZE' src/main.rs in the repository root: each prints 4 today and must print 1 afterwards. Not compiled or run.
src/main.rs:168if *node < BAD_NODES {
The behaviour of a bad node and the skip for an empty relay are spelt out as separate guards throughout the four simulation functions in src/main.rs: a bad receiver stores nothing (lines 168, 189, 291, 311, 391, 412), a relay without the shred is skipped (lines 76, 180, 302, 403), a bad first-level sender does not send (lines 166, 289, 389), a bad second-level sender does not send (lines 184, 306, 407), and a bad node does not recover (lines 199, 422). Move the two-level delivery of one shred into a single helper that all four simulations call, taking the node array, the shuffled index, the shred number, the number of bad nodes and the bad-node behaviour as parameters; the behaviour must be an explicit choice, because the live simulation makes bad nodes send a second block to even-numbered nodes (lines 64 and 82) instead of dropping. Re-count the guard sites before editing and report any difference from the list above. To confirm, run grep -c '< BAD_NODES' src/main.rs in the repository root: it prints 13 today and afterwards must print only the number of lines inside the helper; and compare the output of the first blocks of each simulation before and after the change, which must be identical. Not compiled or run.
src/main.rs:131fn turbine_recoverable() {
Three simulation functions in src/main.rs are never called: turbine_recoverable (lines 131-260), turbine (lines 262-356) and turbine_recoverable_data_only (lines 358-476). main (lines 11-14) calls only turbine_recoverable_duplicate_blocks and keeps //turbine_recoverable(); as a comment at line 12. Either delete the three functions and the comment in one edit, or make them reachable by choosing the simulation from a command-line argument in main; do not keep them selected by editing comments. Deleting them also removes the inline shred-sum comparisons that exist only in those functions. To confirm, run grep -cE '^fn (turbine|turbine_recoverable|turbine_recoverable_data_only)\(' src/main.rs in the repository root: it prints 3 today and must print 0 after deletion; if the functions are kept, starting the program with each scenario name must run that scenario and the owner's build must show no dead-code warning. Not compiled or run.
Info after review (3)
src/main.rs:79let start = 200 + x * L1_SIZE;
In src/main.rs the start of a level-1 slice is written as 200 + x * L1_SIZE at line 79 (and again at lines 187, 309 and 410) although the constant L0_SIZE holds that value, and the node array is sized with the literal 10_000 at lines 50, 153, 280 and 376 although its type says NUM_NODES. Replace 200 with L0_SIZE and 10_000 with NUM_NODES at those eight lines. The slice index[start..start + L1_SIZE] stays inside the array only because L0_SIZE + L0_SIZE * L1_SIZE does not exceed NUM_NODES; state that as an assert! at the top of each simulation function so a changed constant fails at once instead of panicking deep in the loop. Also remove the variables that are assigned and never read in the live function (ix at line 91 and rounds at lines 51 and 105) or print them. To confirm, in the repository root run grep -cF '200 + x * L1_SIZE' src/main.rs and grep -cF '}; 10_000];' src/main.rs: each prints 4 today and must print 0 afterwards. Not compiled or run.
src/main.rs:47 for block in 1..100_000_000 {
The loop at src/main.rs line 47 runs for up to 100,000,000 blocks and prints cumulative figures after each one, and neither the block count, the seed nor BAD_NODES can be set without recompiling. Read the block count (and, if wanted, the number of bad nodes and a base seed) from the command line in main (lines 11-14) with std::env::args, keep the present values as defaults, and pass them into turbine_recoverable_duplicate_blocks as parameters; print one final summary when the loop ends. Inside the loop the 64 shuffles are rebuilt with the same seeds on every pass of while recovered (lines 53-58): build the 64 index vectors once per block before line 53 and reuse them in each pass. To confirm, start the program with a block count of 3 and observe exactly three total: blocks followed by a normal exit; and check that the figures printed for the first blocks are identical before and after the shuffles are cached. Not compiled or run.
Cargo.toml:9rand = "0.7.0" rand_chacha = "0.2.2"
Cargo.toml states rand and rand_chacha as open version ranges (lines 9-10), names no minimum compiler, and the repository holds no Cargo.lock, so the shuffles the simulation depends on can change with whatever versions a build resolves. Commit the Cargo.lock that cargo generates, add a rust-version key under [package] (after edition at line 4) set to the toolchain the owner really builds with, and check on each crate's own release page whether the release lines named at lines 9-10 are still maintained; if they are not, move both crates together to a maintained pair and expect the printed statistics to change, because the generator and shuffle code may differ between lines. This audit read only the manifest: it did not read the maintainers' support pages and did not observe which compiler or dependency versions are in use. To confirm, run grep -c '^rust-version' Cargo.toml in the repository root (prints 0 today, must print 1), check that Cargo.lock is tracked by git, and run cargo build --locked and rustc --version on the machine that builds the simulator. Not compiled or run.