Drop unnecessary merkle mutation checks #14716

pull Empact wants to merge 2 commits into bitcoin:master from Empact:unnecessary-merkle-mutation-checks changing 3 files +4 −6
  1. Empact commented at 9:39 AM on November 13, 2018: member

    Ok this is consensus code so I'm prepared to see this rejected, but I figure I'd bring it up just in case:

    • Don't publish ComputeMerkleRoot declaration in consensus/merkle.h, it's only used in the bench.
    • Don't continue checking for mutations in ComputeMerkleRoot if one has already been found.
    • Compare mutated to nullptr to clarify that it's a pointer rather than a bool.

    I saw a ~3% MerkleRoot bench improvement due either to random chance or the dropped mutation checks.

  2. Don't declare ComputeMerkleRoot in consensus/merkle.h
    This reduces surface area, given it's not used anywhere other than bench.
    a892420061
  3. Don't continue checking for merkle mutation if we've found one c23df9d805
  4. fanquake added the label Consensus on Nov 13, 2018
  5. MarcoFalke commented at 5:05 PM on November 13, 2018: member

    Slightly tend to NACK. If an attacker wants to waste some CPU-milliseconds, they can already achieve it way easier.

  6. gmaxwell commented at 5:51 PM on November 13, 2018: contributor

    I don't think we care about making it ever so slightly faster in the presence of a mutated block as that is an exceptionally uncommon case (and one that results in the peer giving us the block being banned). @MarcoFalke mutation is a type of invalidity that doesn't require the attacker make a pow valid block.

  7. Empact commented at 5:56 PM on November 13, 2018: member

    Alright I'll close to spare the other reviewers. Thanks, and on to other things.

  8. Empact closed this on Nov 13, 2018

  9. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-26 03:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me