Pages of this audit: Overview · tower_sim (32) · turbine (8) · bunker_coin (4) · dts02-6502-signer (133)
| Audited | aeyakovenko/tower_sim at commit b972ccba3f6f2178defe15d826b117f80fcbc09a |
|---|---|
| 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 32 of the 177 findings of the audit: the findings in tower_sim. 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 2 of its 23 Low findings were 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:
- tower_sim: 10 non-empty files, read in 50 line ranges. The reading of 1 of the 50 ranges could not be confirmed by script; all 10 files are covered by at least one confirmed range.
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. 5 findings in the first audit: 4 still in the code; 1 cannot tell; 5 reported again in this audit, 0 not re-reported. This page has 32 findings, 25 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 |
|---|---|---|---|---|
| #3001 | Switch-proof threshold compares primary-subcommittee vote counts against NUM_NODES/3 and double-counts cumulative fork weights.src/node.rs:94 | Medium | Still in the code | Reported again: #6001 |
| #3002 | Secondary super root indexed with the primary group's length.src/bank.rs:144 | Low (first rated Medium) | Still in the code | Reported again: #6602 |
| #3003 | Missing-slot sentinel makes the lockout assertion always fire.src/tower.rs:106 | Low (first rated Medium) | Still in the code | Reported again: #6012 |
| #3007 | Dead code that implies a design that does not exist.src/main.rs:9 | Low | Still in the code | Reported again: #6706, #6016, #6021 |
| #3008 | Runtime currency: NOT EXAMINED.Cargo.toml:4Whether these dependency versions are still supported was not checked in either audit. | Info | Cannot tell | Reported again: #6030 |
Medium after review (1)
src/node.rs:94total > NUM_NODES / 3
Node::optimistic_conf_check (src/node.rs lines 62-95) decides whether a node may switch forks by summing fork weights and testing total > NUM_NODES / 3 at line 94. The two sides are not the same quantity. The weights it receives are the cumulative per-slot weights built in Forks::build_fork_weights (src/forks.rs lines 160-170), where every slot inherits its parent's weight, so adding them over several slots of one fork (lines 76-93) counts the same validators many times; and those weights count only primary committee members, while the threshold is a third of all NUM_NODES nodes. Change the check so that each primary validator is counted once, by its latest vote: keep the per-validator latest-vote map that build_fork_weights already computes locally (src/forks.rs lines 150-153) as a field of Forks, pass it to optimistic_conf_check, and count the validators whose latest voted slot is visible to this node (self.blocks), is newer than last_vote.slot, and lies on a fork that neither contains last_vote.slot nor is an ancestor of it. Compare that count with one third of the primary committee of the bank being voted on, bank.subcom.primary.len() / 3, taken from the bank fetched at src/node.rs line 167, and name both operands as validator counts. To confirm, add a hand-countable test: a small fork tree in which k primary validators have their latest vote on the competing fork, one of them on a fork three slots long, asserting that the validator on the long fork is counted once and that the check returns false for k equal to a third of the primary and true for one more; then compare the number of OC CHECK FAILED lines and the root progress of a fixed-length run before and after the change. Not compiled or run.
Low after review (23)
src/bank.rs:123//check if the node has a higher vote with at least 1/2 the lockout
In Bank::primary_calc_threshold_slot (src/bank.rs) the comment at line 123 says a higher vote needs at least 1/2 of the lockout, but the test at lines 124-125 accepts v.lockout >= vote.lockout / mult, and the only deciding caller, primary_threshold_slot at line 137, passes mult = 1 << 4, which is 1/16 (src/node.rs lines 214 and 216 pass 1 and 2 only for debug printing). The owner must decide which fraction is intended. If 1/16 is intended, rewrite the comment to "at least 1/mult of the lockout" and give 1 << 4 at line 137 a named constant whose comment states the fraction. If 1/2 is intended, pass 2 at line 137 and keep the comment; this makes the threshold check in Node::threshold_check (src/node.rs line 52) stricter, so simulation results change. To confirm, add a unit test that builds a Bank in which a primary node holds a vote on the same slot with exactly 1/16 and then exactly 1/2 of the proposed lockout and asserts the count returned by primary_calc_threshold_slot for the chosen fraction on both sides of the boundary. Not compiled or run.
src/subcommittee.rs:100set.insert(rng.gen_range(0..NUM_NODES));
Subcommittee::calc_subcommittee (src/subcommittee.rs lines 96-103) inserts SUBCOMMITTEE_SIZE random ids into a HashSet, so repeated draws collapse and the committee ends up smaller than the constant says, by a different amount each epoch. Draw until the set is full: replace the for loop at lines 99-101 with while set.len() < SUBCOMMITTEE_SIZE { set.insert(rng.gen_range(0..NUM_NODES)); } and assert SUBCOMMITTEE_SIZE <= NUM_NODES before the loop so it cannot spin forever. This changes the membership of every committee, so printed results will differ from earlier runs. If an approximate size is what the owner wants, keep the code and say so in a comment on SUBCOMMITTEE_SIZE at line 11. To confirm, add a test in this module asserting calc_subcommittee(e).len() == SUBCOMMITTEE_SIZE for several epochs e; that test fails on the present code. Not compiled or run.
src/subcommittee.rs:98let mut rng = StdRng::seed_from_u64(epoch as u64);
Committee membership comes from StdRng (src/subcommittee.rs line 98) and the block-producer schedule from std's DefaultHasher (hash, lines 46-50, called at src/network.rs line 82). Neither algorithm is promised to stay the same across library or compiler releases, so the same source can give different simulation results after an update. Replace StdRng with a generator whose algorithm is fixed by its name (a ChaCha generator from the rand_chacha crate would be a new dependency in Cargo.toml), replace the body of hash with a small integer hash written out in the crate (for example splitmix64), and commit Cargo.lock. To confirm, add a test that pins golden values: hash(0), hash(1) and the sorted members of calc_subcommittee(0) compared with constants recorded once; the test must fail whenever a dependency or toolchain update changes either sequence. Not compiled or run.
vote_subcommittee.md:31nodes. `slow_hash(penultimate snapshot hash, voting epoch number)`
vote_subcommittee.md defines the committee seed at lines 30-31 as slow_hash(penultimate snapshot hash, voting epoch number), but the simulation seeds its generator from the epoch counter alone (src/subcommittee.rs line 98, in calc_subcommittee). The owner must choose which side moves. Either add a sentence below the definition in the note saying that the simulator uses the epoch number only and does not model the snapshot hash; or model it: give calc_subcommittee a second input that stands for the snapshot hash, mix it with the epoch into the seed, and pass it from the two callers at src/subcommittee.rs lines 33 and 74, which means forks with different history can then select different committees. To confirm the first option, the definition and the new sentence must sit next to each other in the note (grep -n 'slow_hash' vote_subcommittee.md in the repository root lists line 31 today); to confirm the second, add a test showing that two different snapshot values with the same epoch give different committees and the same value gives the same committee. Not compiled or run.
vote_subcommittee.md:79BOTH **primary** and **secondary** must have 2/3+ votes on the same
vote_subcommittee.md says at lines 79-80 that both committees must have 2/3+ votes on the same fork, but Bank::check_group_oc (src/bank.rs lines 88-106) counts a node only for the exact slot of its latest vote, so a committee split between a slot and that slot's child confirms neither. The owner must decide which is intended. If the exact-slot test is intended, change the sentence in the note to say that more than 2/3 of each committee must have their latest vote on the same slot. If the note is right, change check_group_oc so that a latest vote on a slot also counts for that slot's ancestors; Bank does not hold ancestry, so pass the fork set that Bank::apply already receives (src/bank.rs line 56) or do the counting in Forks with compute_fork (src/forks.rs line 110). The second option confirms more slots and so changes simulation results. To confirm it, add a test in which more than 2/3 of a committee is split between slot X and its child Y and assert that X is reported as confirmed and Y is not; for the first option, read the corrected sentence beside lines 88-106. Not compiled or run.
src/forks.rs:86self.roots.extend(&new_roots);
Forks.roots (src/forks.rs line 11) receives every rooted slot at line 86 and is never pruned, because the retain call in Forks::gc at line 142 is commented out, so memory grows for the whole run. Restore bounded retention in gc: copy self.lowest_root.slot into a local variable and keep only roots at or above that slot minus a window. The window is the owner's decision and must be large enough for the two readers of the set: the assertions at lines 66 and 69, which look up super roots that lie below the lowest root, and the pruning of optimistically confirmed slots at src/network.rs line 75. The 1000 slots in the commented line have not been shown to satisfy either reader, so derive the window from how far behind the lowest root those lookups can reach. To confirm, add a test that calls Network::step(1) for a few thousand slots and asserts that forks.roots.len() stays below the window plus a small margin while none of the existing assertions fires, and print the set size in the periodic output so growth is visible. Not compiled or run.
src/tower.rs:99 if *set.get(&tower.root.slot).unwrap() < tower.root.lockout {
Tower::get_incrased_lockouts (src/tower.rs line 92) looks up the proposed tower's root slot in the receiver's own root and votes and unwraps the result at line 99, so it panics whenever the proposed root is a slot the receiver does not hold. Replace the unwrap with an explicit default: treat a missing root slot as lockout 0, for example set.get(&tower.root.slot).copied().unwrap_or(0) < tower.root.lockout, so that an unknown root is reported as an increase and inserted into the returned map at line 100. To confirm, add a unit test in src/tower.rs in which the receiver is Tower::default() and the proposed tower has its root at a slot the receiver never voted on (for example slot 5), and assert that the returned map contains that slot with the proposed lockout instead of panicking. Not compiled or run.
src/tower.rs:106 let lockout = *set.get(&e.slot).unwrap_or(&u64::MAX);
assert!(lockout <= e.lockout, "proposed lockout somehow decreased");
In Tower::get_incrased_lockouts (src/tower.rs) line 106 gives a slot the receiver does not hold the default lockout u64::MAX, so the assertion at line 107 (lockout <= e.lockout) fails for every such slot that passes the skip_lockout filter at line 103. Default to 0 instead (unwrap_or(&0)): a slot the receiver has never seen then counts as an increase and is recorded by the branch at line 108, and the assertion keeps its meaning for a slot the receiver does hold with a higher lockout. To confirm, add two unit tests in src/tower.rs: one where the proposed tower has a vote on an unseen slot with a lockout of at least skip_lockout and the returned map contains it, and one marked should_panic(expected = "proposed lockout somehow decreased") where a slot the receiver holds is proposed with a lower lockout. Not compiled or run.
src/network.rs:94assert_eq!(partitions.last().unwrap().1, NUM_NODES);
Network::step (src/network.rs line 81) is public and accepts any num_partitions. With 0 the loop at line 84 never runs and partitions.last().unwrap() at line 94 panics with a message that does not name the cause. Add a check as the first statement of step: assert!(num_partitions >= 1 && num_partitions <= NUM_NODES, "num_partitions must be between 1 and NUM_NODES, got {}", num_partitions), and remove the assert inside the loop at line 86, which the new check makes redundant. To confirm, add a test marked should_panic(expected = "num_partitions must be") that calls Network::default().step(0), and a second one that passes NUM_NODES + 1. Not compiled or run.
src/network.rs:113 for (r, (s, e)) in active.iter().zip(partitions) {
check_same_partition (src/network.rs line 113) and vote (line 138) walk active and partitions with zip, which stops silently at the shorter slice, so a caller that passes fewer flags than partitions gets some partitions ignored without any error. Check the lengths once at the two public entry points, partition_step (line 35) and repair_partitions (line 127), with assert_eq!(active.len(), partitions.len(), "one active flag per partition is required"). Use assert_eq and not debug_assert_eq, because the debug form is removed in release builds; the private functions vote and check_same_partition are reached only through these two entry points and need no check of their own. To confirm, add a test marked should_panic(expected = "one active flag per partition") that calls partition_step with four partitions and three flags. Not compiled or run.
src/forks.rs:33let parent = self.fork_map.get_mut(&block.parent).unwrap();
Forks::apply (src/forks.rs line 31) is a public library function and panics through a bare unwrap at line 33 when the block's parent is unknown; Bank::apply (src/bank.rs line 56) does the same at line 60 for an empty fork set. The owner must choose one of two contracts. Either return a Result from both functions with an error value that names the missing parent slot or the empty fork, and handle it in the caller Network::partition_step (src/network.rs line 59); or keep the panics as stated invariants by replacing each unwrap with expect and a message that names the slot, and by adding a Panics section to the doc comment of every public function that can panic. The first option lets a caller recover from a bad block, the second only makes the failure readable. To confirm, add a test that applies a Block whose parent is not in fork_map and expects the error value (first option) or uses should_panic with the expected message text (second option). Not compiled or run.
src/main.rs:40let bp_1a = partitions[3].0;
In partition_test_1 (src/main.rs) the comment at line 24 lists the groups in the order 66, 32, 1_A, 1_B, so group 1A is partitions[2], but line 40 sets bp_1a from partitions[3], the same index that line 50 uses for bp_1b, and bp_1a is never read. Either change line 40 to partitions[2].0 and use the variable where group 1A should produce a block, or delete line 40; deleting is the smaller change because no step of the scenario lets group 1A produce a block. To confirm, run grep -c 'bp_1a' src/main.rs in the repository root: it prints 1 today and must print 0 after deletion, or at least 2 if the variable is corrected and used; the unused-variable warning for bp_1a must be gone when the owner builds. Not compiled or run.
src/bank.rs:144roots[self.subcom.primary.len() / 3]
In Bank::group_super_root (src/bank.rs lines 140-145) the index is taken from the primary committee, roots[self.subcom.primary.len() / 3], although the roots come from the set passed in, so secondary_super_root (lines 151-153) is ranked by the wrong group size and can index past the end when the secondary is smaller. Change line 144 to roots[set.len() / 3] and reject an empty set with a clear panic message before indexing. Then put the two-thirds arithmetic in one small function that takes the group length and use it at lines 103, 137 and 144, so the size always comes from the group being counted. To confirm, add a unit test in which primary and secondary have different sizes and known roots (for example 3 and 6 nodes) and assert that secondary_super_root returns the hand-computed root; and run grep -cF 'subcom.primary.len() / 3' src/bank.rs in the repository root, which prints 1 today and must print 0 afterwards. Not compiled or run.
src/subcommittee.rs:46pub fn hash(val: u64) -> u64 {
The general helper pub fn hash(val: u64) -> u64 sits in src/subcommittee.rs (lines 46-50) but nothing in that file calls it; its only user is src/network.rs (import at line 5, call at line 82). Move the function, together with the imports only it needs (DefaultHasher at line 6 and Hash and Hasher at line 8), into src/network.rs as a private function, or into a small utility module declared in src/lib.rs if a second user is expected, and delete the import at src/network.rs line 5. Do not leave a re-export in subcommittee.rs. To confirm, run grep -rn 'subcommittee::hash' src in the repository root: it lists 1 line today and must list none afterwards, and grep -n 'fn hash' src/subcommittee.rs must also list nothing. Not compiled or run.
src/network.rs:114if *r && a >= *s && a < *e {
The test "index lies in the half-open range s..e" is written out three times in src/network.rs: at line 97 in step and at lines 114 and 117 in check_same_partition. Add one private helper to impl Network that takes an index and a (start, end) pair and returns index >= start && index < end, and call it at the three sites, so the inclusive start and exclusive end are decided in one place. To confirm, run grep -cE '>= \*s && .* < \*e' src/network.rs in the repository root: it prints 3 today and must print 0 afterwards; add a unit test for the helper that checks the start value (inside), the end value (outside) and end minus one (inside). Not compiled or run.
src/node.rs:53if self.id < 4 {
The debug-print condition self.id < 4 is written out six times in src/node.rs, at lines 53, 189, 207, 226, 231 and 244. Declare one named constant for the number of nodes that log (for example LOG_NODES next to THRESHOLD at line 7), add one private method on Node that returns self.id < LOG_NODES, and call that method at the six sites; the println! calls in the other modules print for every node and are not affected. To confirm, run grep -cF 'self.id < 4' src/node.rs in the repository root: it prints 6 today and must print 0 afterwards; a short run must still print the voting lines for nodes 0 to 3 only. Not compiled or run.
src/node.rs:177let vote = Vote {
slot: heaviest_slot,
lockout: 2,
Node::vote builds its vote field by field at src/node.rs lines 177-180 although the constructor Vote::new (src/tower.rs line 15) produces exactly that value and is called nowhere; Tower::default likewise spells out the root at src/tower.rs lines 36-39 instead of calling Vote::zero (line 18). Replace lines 177-180 with Vote::new(heaviest_slot), use Vote::zero() for the root in Tower::default, and build the test votes in src/tower.rs with Vote::new as well. Then give the starting lockout one named constant in src/tower.rs and use it in Vote::new (line 16), in the assertion at line 46 and at src/node.rs lines 99 and 200, which today repeat the literal 2. To confirm, run grep -rn 'lockout: 2,' src in the repository root: it lists 8 lines today (node.rs 179 and seven in the tower.rs tests) and must list none afterwards, and grep -rn 'Vote::new' src must list the new call sites instead of nothing; the three existing tests in tower.rs must still pass. Not compiled or run.
src/bank.rs:92let s = self.nodes[*p]
.votes
.front()
Tower::latest_vote (src/tower.rs line 121) already answers "which is this node's newest vote", and src/bank.rs line 170 uses it, but the same choice is made by hand with votes.front() in Bank::check_group_oc (src/bank.rs lines 92-96) and in src/node.rs at lines 43, 64 and 67, and with votes.last() on the serialised list at src/node.rs line 109. Replace the four front() uses with latest_vote(), add one Tower method that returns the newest vote or the root when the tower is empty and call it at src/bank.rs lines 92-96 and line 170, and add a helper beside Tower::votes (src/tower.rs line 115) that returns the newest entry of the serialised list for src/node.rs line 109, so that the front/back orientation is known in tower.rs only. To confirm, run grep -rn '\.front()' src in the repository root: it lists 5 lines today (bank.rs 94, node.rs 43, 64, 67, tower.rs 122) and must list only the one inside Tower::latest_vote afterwards; the existing tests in tower.rs must still pass. Not compiled or run.
src/bank.rs:1use crate::node::THRESHOLD;
src/bank.rs imports THRESHOLD from node.rs (line 1) while src/node.rs imports Bank and Block from bank.rs (line 1), and src/subcommittee.rs imports ID and NUM_NODES from bank.rs (line 1) while bank.rs imports Subcommittee (line 2): two import cycles. Move the shared definitions NUM_NODES and ID (src/bank.rs lines 7-8) and THRESHOLD (src/node.rs line 7) into a module that imports nothing from the crate, either a new src/config.rs declared in src/lib.rs or src/tower.rs, which already holds DEPTH and Slot and imports only std. Update the use lines that name them (src/bank.rs line 1, src/node.rs line 1, src/subcommittee.rs line 1, src/network.rs lines 1-2, src/forks.rs line 1, src/main.rs line 4) and do not re-export the names from their old files, because that would keep the cycle. To confirm, run in the repository root grep -c 'use crate::node' src/bank.rs and grep -c 'use crate::bank' src/subcommittee.rs: each prints 1 today and must print 0 afterwards. Not compiled or run.
src/bank.rs:177pub fn check_primary(&self, id: ID) -> bool {
Several items of the tower_sim library are declared pub although nothing outside their own type uses them. Remove pub (or narrow to pub(crate)) on Bank::check_group_oc (src/bank.rs line 88), Bank::group_super_root (line 140), Forks::build_fork_weights (src/forks.rs line 148), Node::lockout_check (src/node.rs line 123) and on the fields Bank.frozen (src/bank.rs line 14), Node.id and Node.heaviest_fork (src/node.rs lines 10 and 14) and Subcommittee.num_super_roots, parent_num_super_roots, super_root and parent_super_root (src/subcommittee.rs lines 19-22). Bank::check_primary (src/bank.rs line 177) and Vote::new (src/tower.rs line 15) have no caller at all: delete them or start using them. Before narrowing each name, re-count its uses with grep -rn '<name>' src and report any use outside the declaring file; the only consumer of the library in the repository is src/main.rs. To confirm, run grep -rn 'check_primary' src in the repository root: it lists exactly one line today (the declaration) and must list none after deletion; the owner then builds the crate and its binary to show nothing else depended on the narrowed names. Not compiled or run.
src/tower.rs:15pub fn new(slot: Slot) -> Self {
Vote::new (src/tower.rs lines 15-17) has no caller: a search for Vote::new over the sources finds nothing, while src/node.rs lines 177-180 and the tests in src/tower.rs build the same value by hand. Choose one: delete lines 15-17, or keep the constructor and call it where a vote with the starting lockout is built (src/node.rs line 177 and the test votes in src/tower.rs). Do not keep it unused. To confirm, in the repository root run grep -rn 'Vote::new' src, which lists nothing today and must list the call sites if the constructor is kept, or grep -c 'pub fn new' src/tower.rs, which prints 1 today and must print 0 if it is deleted. Not compiled or run.
src/main.rs:13fn partition_test_1() {
partition_test_1 (src/main.rs lines 13-81) and random_partitions (lines 103-125) have no caller; main at lines 8-11 calls only four_partitions and keeps //partition_test_1() as a comment at line 9. Either delete both functions, the comment at line 9 and the imports that only they use (rand at lines 1-3 and DEPTH at line 6), or make them reachable: select the scenario from a command-line argument in main, or move partition_test_1 into a test, since it ends with an assertion at line 80. Do not leave them commented out. To confirm, run grep -cE 'partition_test_1|random_partitions' src/main.rs in the repository root: it prints 3 today and must print 0 after deletion; if the functions are kept, each name must appear in a real call or a test attribute and the owner's build must show no dead-code warning. Not compiled or run.
src/bank.rs:11pub nodes: Vec<Tower>,
The state-holding structs expose their fields as pub and other modules read them directly: Bank.nodes (src/bank.rs line 11) is read at src/node.rs lines 46 and 170 and src/forks.rs line 77, and the same holds for Bank.slot, parent, children and subcom, Tower.votes and Tower.root (src/tower.rs lines 28-29), Forks.fork_map, primary_fork_weights, lowest_root and roots (src/forks.rs lines 8-11), Network.forks (src/network.rs line 14) and Subcommittee.primary and secondary (src/subcommittee.rs lines 15-16). Make these fields private and give each owner a method for the question the outside code really asks, for example a Bank method returning one node's tower by id, a Bank method returning the highest root, and a Network method that returns the latest primary set so src/main.rs line 25 stops reaching through network.forks. Vote and Block are plain data records and may keep public fields. No outside write to these fields was found; re-check that with grep before editing and report any write. To confirm, run grep -n 'bank\.nodes' src/node.rs src/forks.rs in the repository root: it lists 3 lines today and must list none afterwards; the owner then builds the crate. Not compiled or run.
Info after review (8)
src/network.rs:107 fn check_same_partition(partitions: &[(usize, usize)], active: &[bool], a: ID, b: ID) -> bool {
Network::check_same_partition (src/network.rs lines 107-125) returns true when a and b each lie in some active partition, not when they lie in the same one. The callers in src/main.rs at lines 51 and 68 pass two active flags and rely on that merged behaviour, so the code is the intended side and the name is wrong. Rename the function to say what it tests (for example both_in_active_partitions) at its declaration at line 107 and at its three calls at lines 51, 63 and 130, and add a doc comment stating that several active partitions are treated as one merged group. To confirm, run grep -c 'check_same_partition' src/network.rs in the repository root: it prints 4 today and must print 0 afterwards, and the same command with the new name must print 4. Not compiled or run.
src/main.rs:93num_partitions = 3;
four_partitions (src/main.rs line 83, called from main at line 10) sets num_partitions = 3 at line 93 and then repairs down to one, so the name and the behaviour disagree. Either rename the function at lines 10 and 83 to say three partitions, or set the count to 4 at line 93 if four was meant; the second option changes the scenario, because Network::step divides the nodes by that number. In the same edit give the loop at line 88 a slot count taken from a command-line argument read with std::env::args, with the present TIME * 100_000 as the default, so that a run can end; today it prints several lines for each of 25,600,000 slots. To confirm, run grep -c 'four_partitions' src/main.rs in the repository root: it prints 2 today and must print 0 after a rename; then start the program with a small slot count and observe that it prints that many LOWEST ROOT lines and exits. Not compiled or run.
src/tower.rs:92 pub fn get_incrased_lockouts(&self, skip_lockout: u64, tower: &Tower) -> HashMap<Slot, u64> {
Rename the public method get_incrased_lockouts to get_increased_lockouts at its declaration (src/tower.rs line 92) and at its only call (src/node.rs line 46) in one edit. In the same pass correct the misspelt words in comments: comming (src/bank.rs line 64), alredy (src/bank.rs line 115), decendant and decending (src/node.rs lines 68 and 73), visibile (src/node.rs line 147), thershold (src/node.rs line 203), subcomittee (src/subcommittee.rs line 58 and src/main.rs line 24) and reparied (src/main.rs line 75). To confirm, run grep -rn 'incrased' src in the repository root: it lists 2 lines today and must list none afterwards, and grep -rn 'get_increased_lockouts' src must then list 2 lines. Not compiled or run.
src/network.rs:8use rayon::prelude::*;
The import use rayon::prelude::*; at src/network.rs line 8 is unused: the only parallel call, .par_iter_mut() at line 141, is commented out, so the rayon entry at Cargo.toml line 9 is a dependency no code uses. Delete line 8, the commented line 141 and the rayon line in Cargo.toml in one edit. The alternative is to switch the loop in Network::vote (lines 140-143) to the parallel iterator; that is a design change the owner must check, because every node then reads self.forks from several threads at once and the order of the debug printing changes. To confirm, run grep -rn 'rayon' src Cargo.toml in the repository root: it lists 2 lines today and must list none after the deletion. Not compiled or run.
src/main.rs:4use tower_sim::bank::NUM_NODES;
Delete the import use tower_sim::bank::NUM_NODES at src/main.rs line 4: the name is not used anywhere else in the file. The functions partition_test_1 (line 13) and random_partitions (line 103) are never called, and the rand imports at lines 1-3 serve only random_partitions and the DEPTH import at line 6 serves only partition_test_1. Decide per function: delete it together with the imports only it uses, or make it reachable, for example by turning partition_test_1 into a test (it already ends with an assertion at line 80) and selecting random_partitions with a command-line argument. To confirm, run grep -c 'NUM_NODES' src/main.rs in the repository root: it prints 1 today and must print 0 afterwards; the owner's build must then report no unused-import and no dead-code warning for this file. Not compiled or run.
src/bank.rs:8pub type ID = usize;
No change is required for correctness: no function in the crate accepts a value that could be either a node identifier or a slot and then guesses which it is. As optional hardening, turn the two aliases pub type ID = usize (src/bank.rs line 8) and pub type Slot = u64 (src/tower.rs line 6) into single-field wrapper structs that derive Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord and Debug, and update the places that index a vector with an ID (for example self.nodes[*p] at src/bank.rs line 92) and that do arithmetic on a Slot. The compiler then rejects a slot passed where a node identifier is expected. To confirm, after the change write one deliberate mix-up, such as passing a Slot to Bank::check_subcommittee, and observe that it no longer compiles; then remove it. Not compiled or run.
src/main.rs:10four_partitions()
No code change is needed here: the sources contain no file, process, environment or network write, and the program only prints to standard output from main (src/main.rs line 10) and the functions it calls. Keep it that way: if result files are added later, write them into a directory the program receives as an argument and never beside the sources. To confirm, run grep -rnE 'std::fs|std::process|std::env|std::net|File::|OpenOptions' src in the repository root; it prints nothing today and should be re-run whenever output handling changes. Not compiled or run.
Cargo.toml:9rayon = "1.5.3" rand = "0.8.3"
Cargo.toml states the dependencies rayon and rand as open version ranges (lines 9-10), names no minimum compiler, and the repository holds no Cargo.lock, so two builds can resolve different dependency versions. 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 rand and rayon lines named at lines 9-10 are still maintained; if one is not, raise that requirement to a maintained line and rebuild. 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.