The definition of enum BlockStatus has a bug #10813

Closed
zhoushouchang opened this Issue Jul 13, 2017 · 2 comments

Comments

Projects
None yet
3 participants

This issue tracker is only for technical issues related to bitcoin-core.

General bitcoin questions and/or support requests and are best directed to the Bitcoin StackExchange.

For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/.

Describe the issue

Can you reliably reproduce the issue?

If so, please list the steps to reproduce below:

1.BLOCK_VALID_MASK = BLOCK_VALID_HEADER | BLOCK_VALID_TREE | BLOCK_VALID_TRANSACTIONS |
BLOCK_VALID_CHAIN | BLOCK_VALID_SCRIPTS,
2.This is a bit or operation,so every element must be 1, 2, 4, 8, ...,but BLOCK_VALID_TRANSACTIONS = 3
3.

Expected behaviour

Tell us what should happen

Actual behaviour

Tell us what happens instead

Screenshots.

If the issue is related to the GUI, screenshots can be added to this issue via drag & drop.

What version of bitcoin-core are you using?

List the version number/commit ID, and if it is an official binary, self compiled or a distribution package such as PPA.

Machine specs:

  • OS:
  • CPU:
  • RAM:
  • Disk size:
  • Disk Type (HD/SDD):

Any extra information that might be useful in the debugging process.

This is normally the contents of a debug.log or config.log file. Raw text or a link to a pastebin type site are preferred.

Contributor

achow101 commented Jul 13, 2017

In what way is this a bug? Bitwise OR'ing an odd number (except for 1) means that you are setting multiple bits, not just one bit. That is not a problem as BLOCK_VALID_MASK is just a bit mask for all of the bits that must be set for a block to be valid. The same effect would be achieved by not including BLOCK_VALID_TRANSACTIONS in the bitwise OR since BLOCK_VALID_HEADER and BLOCK_VALID_TREE already set bits 1 and 2. But having BLOCK_VALID_TRANSACTIONS there is not wrong and makes it easier for people to understand what enums are part of BLOCK_VALID_MASK.

Owner

laanwj commented Jul 13, 2017

Agree with @achow101 - it seems you misunderstand bitwise operations. If this is really a bug, please describe how it affects the behavior of the software (and don't ignore those questions in the template!)

laanwj closed this Jul 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment