This is a list of my contributions to the Bitcoin Core project. Additionally, I’ll detail the background and context of my contributions.
test: Transaction expiry from mempool #18172 (18th February 2020)
There are multiple reasons a transaction can be removed from the mempool.
The two most common removal reasons are transaction confirmation and transaction replacement.
Transactions that remain in the mempool for a long time are probably not attractive to miners.
By default, these are removed after 336 hours (two weeks).
This default timeout can be overwritten with the
-mempoolexpiry=<n> command-line argument where
<n> specifies the timeout in hours.
This functionality is important as we don’t want our mempool to fill up with transactions that are unattractive to miners (either because they pay a low fee or through other quirks).
Having a test for this behavior is important to make sure that the functionally does not break.
In PR #18172 I’ve added a test for the mempool expiry behavior.
This test tests both the default and the user-definable timeout.
A first transaction called parent is added to our test nodes mempool and its entry time is recorded.
Then the time is forwarded using
This simulates the test nodes time and conveniently allows for testing time-dependent functionality without having to wait until that time passes.
A second transaction called child which spends an output from the first transaction is broadcasted to the test node after the first half of the expiry timeout.
Then the time is forwarded to five seconds before the expiry of the parent transaction.
The parent transaction should still be in our test nodes mempool.
Five seconds after the expiry timeout the parent transaction should not be in our mempool anymore.
As the child transaction depends on the removed parent transaction it becomes invalid and should be removed as well.