Skip to content

Conversation

TheBlueMatt
Copy link
Contributor

@TheBlueMatt TheBlueMatt commented Jun 11, 2018

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.

@maflcko
Copy link
Member

maflcko commented Jun 11, 2018

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).
@TheBlueMatt TheBlueMatt force-pushed the 2018-06-marcos-submitblock-fix branch from 2437c42 to f748944 Compare June 11, 2018 21:21
@@ -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;
Copy link
Contributor

@promag promag Jun 12, 2018

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?

Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Member

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

@luke-jr
Copy link
Member

luke-jr commented Jun 12, 2018

I can't tell what this PR is trying to do. It's "duplicate-inconclusive" when the full block checks have not been executed. For example, if the block is not on tip, but a shorter forked chain, we don't complete validation of it.

@maflcko
Copy link
Member

maflcko commented Jun 12, 2018

@luke-jr

  • Create fresh invalid block
  • Submit it's header somehow
  • Submitblock should not return "duplicate" for this fresh invalid block

@DrahtBot
Copy link
Contributor

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.

@sipa
Copy link
Member

sipa commented Jun 14, 2018

utACK f748944

@luke-jr
Copy link
Member

luke-jr commented Jun 15, 2018

@MarcoFalke It already shouldn't... BlockChecked should get called with the validation failure.

@maflcko
Copy link
Member

maflcko commented Jun 15, 2018

Added original description to OP

@maflcko
Copy link
Member

maflcko commented Jun 15, 2018

@luke-jr Sorry I wasn't clear that you had to submit the header first.

@maflcko
Copy link
Member

maflcko commented Jun 15, 2018

utACK f748944

Copy link
Contributor

@jonasschnelli jonasschnelli left a comment

Choose a reason for hiding this comment

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

utACK f748944

@jonasschnelli jonasschnelli merged commit f748944 into bitcoin:master Jun 19, 2018
jonasschnelli added a commit that referenced this pull request Jun 19, 2018
…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
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 16, 2020
…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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 18, 2020
…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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 18, 2020
…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
@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.

7 participants