Where is this magic number from?
Unexplained 1 million block height in mempool code #15080
issue instagibbs opened this issue on January 2, 2019-
instagibbs commented at 5:00 PM on January 2, 2019: member
- fanquake added the label Mempool on Jan 2, 2019
-
fanquake commented at 12:06 AM on January 3, 2019: member
Looks like it was introduced by @TheBlueMatt in #5267.
-
promag commented at 7:34 PM on January 28, 2019: member
A block far far away?
-
instagibbs commented at 7:40 PM on January 28, 2019: member
It's not for testnet.
On Mon, Jan 28, 2019, 7:35 PM João Barbosa <notifications@github.com wrote:
A block far far away?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/issues/15080#issuecomment-458270164, or mute the thread https://github.com/notifications/unsubscribe-auth/AFgC04pUw8iuSBR1Ae1XhOlVJ5P6azI-ks5vH1EOgaJpZM4Zm8HF .
- MarcoFalke added the label Brainstorming on Jan 28, 2019
-
instagibbs commented at 2:56 PM on April 6, 2019: member
I'm having a really difficult time convincing myself this behavior could not lead to incorrect results. But this can only be hit when
-checkmempoolis non-0, aka-regtestby default so it's not used in production.I think here the
spendheightis 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 closed this on Apr 6, 2019
- instagibbs reopened this on Apr 6, 2019
-
mzumsande commented at 3:59 PM on May 20, 2019: member
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 theUpdateCoins()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 theirCOutPoint.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
spendheightwould make more sense and might prevent future bugs. -
instagibbs commented at 4:03 PM on May 20, 2019: member
Lines up with my current thinking.
- laanwj referenced this in commit de458da0c1 on May 29, 2019
- MarcoFalke closed this on May 29, 2019
- sidhujag referenced this in commit 362d0777c7 on May 30, 2019
- PastaPastaPasta referenced this in commit 758a470cb7 on Jun 27, 2021
- PastaPastaPasta referenced this in commit 119c1f82b9 on Jun 28, 2021
- PastaPastaPasta referenced this in commit 3cf5c685f5 on Jun 29, 2021
- PastaPastaPasta referenced this in commit 79af4eaa30 on Jul 1, 2021
- PastaPastaPasta referenced this in commit e9b5a6b4d6 on Jul 1, 2021
- PastaPastaPasta referenced this in commit 7243a59952 on Jul 12, 2021
- MarcoFalke locked this on Dec 16, 2021