Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Aug 15, 2018

The second commit in #13439 made the TODO in the first commit impossible to solve.

The meaning of fNewBlock changed from "This is the first time we process this block" to "We are about to write the new valid block".

So whenever fNewBlock is true, the block was valid. And whenever the fNewBlock is false, the block is either valid or invalid. If it was valid and not new, we know it is a "duplicate". In all other cases, the BIP22ValidationResult() will return the reason why it is invalid.

@maflcko maflcko force-pushed the Mf1808-rpcSubmitBlockInvalidReturn branch from fa3d2b3 to facb100 Compare August 15, 2018 18:05
@maflcko maflcko changed the title rpc: Return more reject reject reason for submitblock rpc: Return more specific reject reason for submitblock Aug 15, 2018
@maflcko maflcko force-pushed the Mf1808-rpcSubmitBlockInvalidReturn branch from facb100 to fa6ab8a Compare August 15, 2018 18:09
@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 15, 2018

No more conflicts as of last run.

@laanwj
Copy link
Member

laanwj commented Aug 21, 2018

Concept ACK, don't know enough of the submit logic here to be confident that this is correct but the tests look convincing.

@laanwj laanwj added the Mining label Aug 21, 2018
@maflcko
Copy link
Member Author

maflcko commented Aug 22, 2018

Yeah, submitblock had zero test coverage previously, which is why this was missed during review I guess.

Personally I don't care about the specificness of the return code for invalid blocks (since in normal operation you'd never submit invalid blocks), but we might want to backport this if some miner cares.

CC @TheBlueMatt @luke-jr

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK fa6ab8a. I'm not very familiar with this logic, but the code change is simple and matches the description, and the new test coverage is good.

Two possible suggestions:

  • Maybe add the new test cases in one commit, and then make the code change in a second commit so the test diff can reflect the changed behavior.
  • Maybe add release note mentioning the change.

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Sep 13, 2018
…itblock

fa6ab8a rpc: Return more specific reject reason for submitblock (MarcoFalke)

Pull request description:

  The second commit in bitcoin#13439 made the `TODO` in the first commit impossible to solve.

  The meaning of `fNewBlock` changed from "This is the first time we process this block" to "We are about to write the new *valid* block".

  So whenever `fNewBlock` is true, the block was valid. And whenever the `fNewBlock` is false, the block is either valid or invalid. If it was valid and not new, we know it is a `"duplicate"`. In all other cases, the `BIP22ValidationResult()` will return the reason why it is invalid.

Tree-SHA512: 4b6edf7a912339c3acb0fccfabbdd6d812a0321fb1639c244c2714e58dc119aa2b8c6bf8f7d61ea609a1b861bbc23f920370fcf989c48452721e259a8ce93d24
@maflcko maflcko merged commit fa6ab8a into bitcoin:master Sep 13, 2018
@maflcko maflcko deleted the Mf1808-rpcSubmitBlockInvalidReturn branch September 13, 2018 13:33
@ryanofsky
Copy link
Contributor

@MarcoFalke, are you planning on adding release notes for this change or is it too minor to mention?

@maflcko
Copy link
Member Author

maflcko commented Sep 14, 2018

@ryanofsky I believe the changes here only affect the return value of invalid blocks. I'd be surprised to see someone submitting invalid blocks in production. Also, I believe this restores the behavior that existed before 0.17.0.

If someone feels strongly they could backport that to 0.17.0, but at this point it might be too late to get in.

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants