part of cluster mempool: #30289
It became clear while working on cluster mempool that it would be helpful for transaction validation if we could consider a full set of proposed changes to the mempool – consisting of a set of transactions to add, and a set of transactions (ie conflicts) to simultaneously remove – and perform calculations on what the mempool would look like if the proposed changes were to be applied. Two specific examples of where we’d like to do this:
- Determining if ancestor/descendant/TRUC limits would be violated (in the future, cluster limits) if either a single transaction or a package of transactions were to be accepted
- Determining if an RBF would make the mempool “better”, however that idea is defined, both in the single transaction and package of transaction cases
In preparation for cluster mempool, I have pulled this reworking of the mempool interface out of #28676 so it can be reviewed on its own. I have not re-implemented ancestor/descendant limits to be run through the changeset, since with cluster mempool those limits will be going away, so this seems like wasted effort. However, I have rebased #28676 on top of this branch so reviewers can see what the new mempool interface could look like in the cluster mempool setting.
There are some minor behavior changes here, which I believe are inconsequential:
- In the package validation setting, transactions would be added to the mempool before the
ConsensusScriptChecks()
are run. In theory,ConsensusScriptChecks()
should always pass if thePolicyScriptChecks()
have passed and it’s just a belt-and-suspenders for us, but if somehow they were to diverge then there could be some small behavior change from adding transactions and then removing them, versus never adding them at all. - The error reporting on
CheckConflictTopology()
has slightly changed due to no longer distinguishing between direct conflicts and indirect conflicts. I believe this should be entirely inconsequential because there shouldn’t be a logical difference between those two ideas from the perspective of this function, but I did have to update some error strings in some tests. - Because, in a package setting, RBFs now happen as part of the entire package being accepted, the logging has changed slightly because we do not know which transaction specifically evicted a given removed transaction.
- Specifically, the “package hash” is now used to reference the set of transactions that are being accepted, rather than any single txid. The log message relating to package RBF that happen in the
TXPACKAGES
category has been updated as well to include the package hash, so that it’s possible to see which specific set of transactions are being referenced by that package hash. - Relatedly, the tracepoint logging in the package rbf case has been updated as well to reference the package hash, rather than a transaction hash.
- Specifically, the “package hash” is now used to reference the set of transactions that are being accepted, rather than any single txid. The log message relating to package RBF that happen in the