-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc: Avoid "duplicate" return value for invalid submitblock #13439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rpc: Avoid "duplicate" return value for invalid submitblock #13439
Conversation
utACK fa6e497. (Haven't looked at the second commit) |
The only affect this should have is fixing the return code in submitblock in cases where a block fails ContextualCheckBlock and not setting nLastBlockTime on peers that provide blocks which fail ContextualCheckBlock (which is only used in eviction and cosmetic).
2437c42
to
f748944
Compare
@@ -3530,6 +3529,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CVali | |||
GetMainSignals().NewPoWValidBlock(pindex, pblock); | |||
|
|||
// Write block to history file | |||
if (fNewBlock) *fNewBlock = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, can't this be just before return true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this could be anywhere between this line and the line you mentioned. Though, since this went through more than a week of bike-shedding, I'd prefer if we just fixed the bug and then followed up with nits in later pull requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a nit? Is it a new block if anything fails below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anything below fails, the node is supposed to shut down immediately
I can't tell what this PR is trying to do. It's |
|
Note to reviewers: This pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
utACK f748944 |
@MarcoFalke It already shouldn't... BlockChecked should get called with the validation failure. |
Added original description to OP |
@luke-jr Sorry I wasn't clear that you had to submit the header first. |
utACK f748944 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK f748944
…lock f748944 Only set fNewBlock to true in AcceptBlock when we write to disk (Matt Corallo) fa6e497 rpc: Avoid "duplicate" return value for invalid submitblock (MarcoFalke) Pull request description: This is #13395 with one more commit tacked on. MarcoFalke got tired of dealing with the stupidity of fixing a return code with too many rounds of review (not that I blame him). Honestly we should probably have no return whatsoever, but for now, this fixes it (as well as nLastBlockTime for eviction purposes). Original description: When `submitblock` of an invalid block, the return value should not be `"duplicate"`. This is only seen when the header was previously found (denoted by the incorrectly named boolean `fBlockPresent`). Fix this bug by removing `fBlockPresent`. Tree-SHA512: 0ce3092655d5d904b4c8c5ff7479f73ce387144a738f20472b8af132564005c6db5594ae366e589508f6258506ee7a28b1c7995a83a8328b334f99316006bf2d
…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
…submitblock f748944 Only set fNewBlock to true in AcceptBlock when we write to disk (Matt Corallo) fa6e497 rpc: Avoid "duplicate" return value for invalid submitblock (MarcoFalke) Pull request description: This is bitcoin#13395 with one more commit tacked on. MarcoFalke got tired of dealing with the stupidity of fixing a return code with too many rounds of review (not that I blame him). Honestly we should probably have no return whatsoever, but for now, this fixes it (as well as nLastBlockTime for eviction purposes). Original description: When `submitblock` of an invalid block, the return value should not be `"duplicate"`. This is only seen when the header was previously found (denoted by the incorrectly named boolean `fBlockPresent`). Fix this bug by removing `fBlockPresent`. Tree-SHA512: 0ce3092655d5d904b4c8c5ff7479f73ce387144a738f20472b8af132564005c6db5594ae366e589508f6258506ee7a28b1c7995a83a8328b334f99316006bf2d
…submitblock f748944 Only set fNewBlock to true in AcceptBlock when we write to disk (Matt Corallo) fa6e497 rpc: Avoid "duplicate" return value for invalid submitblock (MarcoFalke) Pull request description: This is bitcoin#13395 with one more commit tacked on. MarcoFalke got tired of dealing with the stupidity of fixing a return code with too many rounds of review (not that I blame him). Honestly we should probably have no return whatsoever, but for now, this fixes it (as well as nLastBlockTime for eviction purposes). Original description: When `submitblock` of an invalid block, the return value should not be `"duplicate"`. This is only seen when the header was previously found (denoted by the incorrectly named boolean `fBlockPresent`). Fix this bug by removing `fBlockPresent`. Tree-SHA512: 0ce3092655d5d904b4c8c5ff7479f73ce387144a738f20472b8af132564005c6db5594ae366e589508f6258506ee7a28b1c7995a83a8328b334f99316006bf2d
…submitblock f748944 Only set fNewBlock to true in AcceptBlock when we write to disk (Matt Corallo) fa6e497 rpc: Avoid "duplicate" return value for invalid submitblock (MarcoFalke) Pull request description: This is bitcoin#13395 with one more commit tacked on. MarcoFalke got tired of dealing with the stupidity of fixing a return code with too many rounds of review (not that I blame him). Honestly we should probably have no return whatsoever, but for now, this fixes it (as well as nLastBlockTime for eviction purposes). Original description: When `submitblock` of an invalid block, the return value should not be `"duplicate"`. This is only seen when the header was previously found (denoted by the incorrectly named boolean `fBlockPresent`). Fix this bug by removing `fBlockPresent`. Tree-SHA512: 0ce3092655d5d904b4c8c5ff7479f73ce387144a738f20472b8af132564005c6db5594ae366e589508f6258506ee7a28b1c7995a83a8328b334f99316006bf2d
This is #13395 with one more commit tacked on. MarcoFalke got tired of dealing with the stupidity of fixing a return code with too many rounds of review (not that I blame him). Honestly we should probably have no return whatsoever, but for now, this fixes it (as well as nLastBlockTime for eviction purposes).
Original description:
When
submitblock
of an invalid block, the return value should not be"duplicate"
.This is only seen when the header was previously found (denoted by the incorrectly named boolean
fBlockPresent
). Fix this bug by removingfBlockPresent
.