diwakergupta / stacks-blockchain-tob-audit

GNU General Public License v3.0
0 stars 0 forks source link

`has_attachable_staging_blocks` claims in a comment to choose randomly, but the implementation does not #31

Open bradlarsen opened 3 years ago

bradlarsen commented 3 years ago

The has_attachable_staging_blocks function, which appears to be unused, claims to choose from possible candidates randomly, but the implementation does not.

https://github.com/trailofbits/x-audit-blockstack-core/blob/0c6c1d9dd8e47e79643c1edea6dc95de404ed262/src/chainstate/stacks/db/blocks.rs#L2546-L2553

In comparison, several other functions in the same file have similar comments and do choose randomly, such as process_next_orphaned_staging_block, which uses SQL to make the random selection:

https://github.com/trailofbits/x-audit-blockstack-core/blob/0c6c1d9dd8e47e79643c1edea6dc95de404ed262/src/chainstate/stacks/db/blocks.rs#L2521-L2544