Skip to content
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

Unexplained 1 million block height in mempool code #15080

Closed
instagibbs opened this issue Jan 2, 2019 · 6 comments
Closed

Unexplained 1 million block height in mempool code #15080

instagibbs opened this issue Jan 2, 2019 · 6 comments

Comments

@instagibbs
Copy link
Member

Where is this magic number from?

UpdateCoins(tx, mempoolDuplicate, 1000000);

@fanquake
Copy link
Member

fanquake commented Jan 3, 2019

Looks like it was introduced by @TheBlueMatt in #5267.

@promag
Copy link
Member

promag commented Jan 28, 2019

A block far far away?

@instagibbs
Copy link
Member Author

instagibbs commented Jan 28, 2019 via email

@instagibbs
Copy link
Member Author

I'm having a really difficult time convincing myself this behavior could not lead to incorrect results. But this can only be hit when -checkmempool is non-0, aka -regtest by default so it's not used in production.

I think here the spendheight is the correct height since that is where this duplicate mempool is actually at.

I'll think a little more how a false assertion or validation failure could hit if unchanged.

@instagibbs instagibbs reopened this Apr 6, 2019
@mzumsande
Copy link
Contributor

I think that the height currently specified as a magic number is never accessed:

In check(), the ancestor tx of the mempool are "spent" in the UpdateCoins() function (adding new UTXOs to the local cache mempoolDuplicate), providing the inputs for subsequent spending of the dependent tx, and thereby allowing to check that all tx in the mempool can be mined in some order (no orphans).

While all ancestors need to be added to mempoolDuplicate, the height at which they are added is not checked in mempoolDuplicate.HaveInputs(), just their COutPoint.

I did some testing with a height of 0 instead of 1E6 and didn't see any effect.
So I don't see how the current implementation could lead to a bug, though I agree that using spendheight would make more sense and might prevent future bugs.

@instagibbs
Copy link
Member Author

Lines up with my current thinking.

laanwj added a commit that referenced this issue May 29, 2019
fadbc5d mempool: remove unused magic number from consistency check (Gregory Sanders)

Pull request description:

  Unexplained magic numbers are no good. Since the exact number does not matter, opt for a constant that is less peculiar.

  Note that this could only possibly affect mempool consistency checks which is not active by default except on regtest.

  see discussion: #15080

ACKs for commit fadbc5:
  practicalswift:
    utACK fadbc5d

Tree-SHA512: 80f95ebc284c5bcc5d825fab0e9f962457a411539946d68ef4c8bdea4b1f2f7f0ead88928fac0eaaa02a1175f01f5ef381613ce53b0f27c3098e90d76ecfe9af
@maflcko maflcko closed this as completed May 29, 2019
sidhujag pushed a commit to syscoin/syscoin that referenced this issue May 30, 2019
…ency check

fadbc5d mempool: remove unused magic number from consistency check (Gregory Sanders)

Pull request description:

  Unexplained magic numbers are no good. Since the exact number does not matter, opt for a constant that is less peculiar.

  Note that this could only possibly affect mempool consistency checks which is not active by default except on regtest.

  see discussion: bitcoin#15080

ACKs for commit fadbc5:
  practicalswift:
    utACK fadbc5d

Tree-SHA512: 80f95ebc284c5bcc5d825fab0e9f962457a411539946d68ef4c8bdea4b1f2f7f0ead88928fac0eaaa02a1175f01f5ef381613ce53b0f27c3098e90d76ecfe9af
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jun 27, 2021
…ency check

fadbc5d mempool: remove unused magic number from consistency check (Gregory Sanders)

Pull request description:

  Unexplained magic numbers are no good. Since the exact number does not matter, opt for a constant that is less peculiar.

  Note that this could only possibly affect mempool consistency checks which is not active by default except on regtest.

  see discussion: bitcoin#15080

ACKs for commit fadbc5:
  practicalswift:
    utACK fadbc5d

Tree-SHA512: 80f95ebc284c5bcc5d825fab0e9f962457a411539946d68ef4c8bdea4b1f2f7f0ead88928fac0eaaa02a1175f01f5ef381613ce53b0f27c3098e90d76ecfe9af
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jun 28, 2021
…ency check

fadbc5d mempool: remove unused magic number from consistency check (Gregory Sanders)

Pull request description:

  Unexplained magic numbers are no good. Since the exact number does not matter, opt for a constant that is less peculiar.

  Note that this could only possibly affect mempool consistency checks which is not active by default except on regtest.

  see discussion: bitcoin#15080

ACKs for commit fadbc5:
  practicalswift:
    utACK fadbc5d

Tree-SHA512: 80f95ebc284c5bcc5d825fab0e9f962457a411539946d68ef4c8bdea4b1f2f7f0ead88928fac0eaaa02a1175f01f5ef381613ce53b0f27c3098e90d76ecfe9af
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jun 29, 2021
…ency check

fadbc5d mempool: remove unused magic number from consistency check (Gregory Sanders)

Pull request description:

  Unexplained magic numbers are no good. Since the exact number does not matter, opt for a constant that is less peculiar.

  Note that this could only possibly affect mempool consistency checks which is not active by default except on regtest.

  see discussion: bitcoin#15080

ACKs for commit fadbc5:
  practicalswift:
    utACK fadbc5d

Tree-SHA512: 80f95ebc284c5bcc5d825fab0e9f962457a411539946d68ef4c8bdea4b1f2f7f0ead88928fac0eaaa02a1175f01f5ef381613ce53b0f27c3098e90d76ecfe9af
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jul 1, 2021
…ency check

fadbc5d mempool: remove unused magic number from consistency check (Gregory Sanders)

Pull request description:

  Unexplained magic numbers are no good. Since the exact number does not matter, opt for a constant that is less peculiar.

  Note that this could only possibly affect mempool consistency checks which is not active by default except on regtest.

  see discussion: bitcoin#15080

ACKs for commit fadbc5:
  practicalswift:
    utACK fadbc5d

Tree-SHA512: 80f95ebc284c5bcc5d825fab0e9f962457a411539946d68ef4c8bdea4b1f2f7f0ead88928fac0eaaa02a1175f01f5ef381613ce53b0f27c3098e90d76ecfe9af
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jul 1, 2021
…ency check

fadbc5d mempool: remove unused magic number from consistency check (Gregory Sanders)

Pull request description:

  Unexplained magic numbers are no good. Since the exact number does not matter, opt for a constant that is less peculiar.

  Note that this could only possibly affect mempool consistency checks which is not active by default except on regtest.

  see discussion: bitcoin#15080

ACKs for commit fadbc5:
  practicalswift:
    utACK fadbc5d

Tree-SHA512: 80f95ebc284c5bcc5d825fab0e9f962457a411539946d68ef4c8bdea4b1f2f7f0ead88928fac0eaaa02a1175f01f5ef381613ce53b0f27c3098e90d76ecfe9af
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jul 12, 2021
…ency check

fadbc5d mempool: remove unused magic number from consistency check (Gregory Sanders)

Pull request description:

  Unexplained magic numbers are no good. Since the exact number does not matter, opt for a constant that is less peculiar.

  Note that this could only possibly affect mempool consistency checks which is not active by default except on regtest.

  see discussion: bitcoin#15080

ACKs for commit fadbc5:
  practicalswift:
    utACK fadbc5d

Tree-SHA512: 80f95ebc284c5bcc5d825fab0e9f962457a411539946d68ef4c8bdea4b1f2f7f0ead88928fac0eaaa02a1175f01f5ef381613ce53b0f27c3098e90d76ecfe9af
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants
@fanquake @promag @instagibbs @maflcko @mzumsande and others