-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Performance fix for #6312 #7190
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
Conversation
Instead of checking if the transaction is in a category of cases to return true and failing otherwise, we return false if the tx is a failure case and otherwise return true. This removes an early-exit opportunity which will no longer be possible once sequence numbers are re-enabled, but has no change in behaviour.
…hose semantics will not survive revival of sequence numbers, and introduce CTxIn::SEQUENCE_FINAL constant instead.
…Time() Breaks up the modifications to IsFinalTx() / LockTime() for easier review. This commit does not change the logic of IsFinalTx().
…ve lock time In summary, the sequence number of each input in a transaction can be used to store a relative locktime: a delta value which is added to the height or time of the block which included the output being spent to generate a per-input lock time from the sequence number. If enforced, this would make consensus-enforced transaction replacement possible as replacing an input with a lower sequence number / relative lock time would allow the new transaction to make it on the chain before previous versions of the transaction become valid. This commit does not implement the transaction replacement logic. Nor does this commit make the relative lock time rules as consensus or policy rules. It merely adds new, but disabled functionality and unit tests of that functionality.
…he mempool and transaction selection code, for the purpose of later supporting consensus-enforced transaction replacement Transactions that fail relative lock time checks will be rejected from the mempool and not included in generated blocks, making it easy to test the feature. However blocks including transactions containing "invalid" relative lock times will still be accepted; this is *not* the soft-fork required to actually enable relative lock times for production use.
… making it responsible to calculate the right blockTime from flags LockTime() : the nCoinTime of a confirmed coin does not depend on MTP flag, so the nCoinTime of an unconfirmed also should not be. Addressing sipa's nits
_SECONDS_FLAG to _TYPE_FLAG _DISABLED_FLAG to _DISABLE_FLAG
There was an extraneous tx being added to the mempool which spent the same inputs. This only didn't cause a problem because locktimes stopped it from being selected for the template. In addition, since the merger of MedianTimePast, locked txs that were time based were not being correctly tested in the unit test.
|
Any tx that has been in your mempool for longer than 10 blocks will have to be recalculated from scratch during a reorg. In addition any transaction which entered your mempool more recently than the reorg depth will have to recalculated, so you will always have to recalculate at least the txs that came in since the last blcok. I think if we are going to try to make reorgs fast, we should do it properly. |
…the tip at the time of calculation is still in the main chain
0559bb2 to
2615613
Compare
|
We could potentially scan the whole header chain instead of only 10, but I don't think this is a good idea performance wise. I think this is better to only scan 10 and just recalculate locktime if it is more, rather than wasting time scanning to the genesis. I can change that though if you think it is indeed faster to scan to genesis. MempoolEntry older than 10 blocks are rather rare I would expect.
I don't understand your point. If I understand your point : yes, during a reorg, all transaction which came since the last block will be invalidated, and they should be. |
|
Yes that is my point. |
The blockTime will have changed. The old tip (BlockA) was part of the median.
I need to. After a reorg, the "birthdate" of the inputs may have changed, and so, the minimum time/height (what you call LockPoint) to satisfy as well. Am I missing something ? |
Yes sorry, you are right about that, anyway we both agreed it should be checked.
Yes you need to in your code. I'm saying my approach saves that. |
|
I agree, with jtimon. What is wrong with this code is the I recheck more than I need to. I myself prefer not touching the code that was heavily reviewed though. |
|
@NicolasDorier this should be closed as the related ticket was also closed and superseded. |
Build on #6312 commit added is 0559bb24e6e92a2d790c77707e464aa1e17919ca :