Skip to content

Conversation

@jtimon
Copy link
Contributor

@jtimon jtimon commented Jan 25, 2017

These are unused variables that can be removed.
And IncrementExtraNonce() should be never called with uint256() == pblock->hashPrevBlock.

Should be easy review for @instagibbs @luke-jr and @morcos.

I assume this was added to prevent deanonymization, but that
doesn't matter anymore since its only used on regtest.
@gmaxwell
Copy link
Contributor

There is no unused variable here.

True, resetting the nonce hardly matters for regtest, but that won't stop others from looking at that code when writing their own mining software.

I also don't understand why the assert is being added, all it is checking is that the block template header is filled out correctly. Sure. It is, though nothing in that function depends on it being so.

If someone believed that it wasn't possible to call Increment twice with the same prior block, that is not true: the caller can hit the nInnerLoopCount comparison, continue the loop without solving a block and call IncrementExtraNonce to do its job while staying on the same block.

Actually, I think that assert would introduce an infrequently triggered crash in the regtest miner code. CS_MAIN is not held during the entire duration of the mining. If you have two regtest nodes mining at once, you might accept a block between the CreateNewBlock and the IncrementExtraNonce, resulting in the template and the pindexPrev disagreeing on the identity of the prior block.

@jtimon
Copy link
Contributor Author

jtimon commented Jan 25, 2017

I meant the variable hashPrevBlock is not needed, but I missed it is static. I was only wondering why the assert wasn't simply assert(pblock->hashPrevBlock != uint256());.
Sorry, it seems I misunderstood the changes and should probably not have opened this PR.

In the commmit description, @TheBlueMatt says:

I assume this was added to prevent deanonymization, but that
doesn't matter anymore since its only used on regtest.

@TheBlueMatt
Copy link
Contributor

I dont recall the point here (I believe it was something to do with cleaning up code for later refactors in elements), but the point of the code block, I'm pretty sure was to prevent the walking extranonce patterns which appear to deanonymize (or at least allow you to bucket) early miners.

@jtimon
Copy link
Contributor Author

jtimon commented Jan 25, 2017

Thanks for clarifying and sorry for the distraction. Closing.

@jtimon jtimon closed this Jan 25, 2017
@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.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants