Repository navigation
Open
Description
Protocol Change Proposal
Summary
In #80 we started to discuss details about properties of transactions (pending, valid), and what influence they have on the mempool: The mempool is a distributed pool of "pending" transactions.
A pending transaction is a "valid" transaction that has been submitted by a
client of the blockchain but has not yet been committed to the blockchain. The purpose of this issue is to get a precise understanding what we mean by "pending" and "valid".
Problem Definition
In an upcoming specification of the mempool, we will need to capture
- definition of pending
- definition of valid; in particular
- relation to the application,
- checktx,
- properties of checktx (what does the return value of checktx depend on. Currently, it depends on
min_gas, which is not a consensus parameter but a configuration variable, so it can be different at different validators, so at the same application state, validators may disagree on the validity of a transaction, which seems to result in unforeseeable behavior) - monotonicity of validity (checktx): mostly we assume the case that a transaction can transition from being valid to being invalid at most once (and never back). This is, in fact, an implicit assumption on the application (whatever we decide to do about it, we need to make it explicit and capture it in the spec). If we assume that transactions can go from invalid to valid, this has to be explicitly treated somehow
- currently it seems that the mempool does not ensure anything for such transactions; they may or may not be dropped and consequently eventually be put into a block or not. We can maintain this but should make this explicit in the properties (e.g., we can give guarantees only for transaction that can go from being invalid to being valid)
- We might decide that applications need stronger guarantees. Then we would need to change the implementation as invalid transaction should not be dropped automatically
Proposal
We need to properly define the above notions and the behavior we expect from the application (checktx), and from the mempool. This result of this work should go into an upcoming mempool specification.
Activity
[-]Mempool transaction handling specification[/-][+]Mempool transaction handling properties[/+]josef-widder commentedon Jan 30, 2023
As @lasarojc mentioned in #80 (comment), we might also think about timeliness for transactions. I guess this would mean adding a deadline field into the transaction? I leave this comment here for future discussion.
spec: migrate v0.7.1. into v0.34 (#9262)
peterbourgon commentedon Apr 3, 2023
Whether or not a transaction is valid, is a function of not just the transaction itself, but also application state when the transaction is executed.
CheckTx executes all transactions against the same (previous height) state, which provides some basic (weak) form of validation, but doesn't mean the transaction will execute successfully in a given block, where previously-executed transactions can modify that state.
And, because the mempool is (of course) different for each node, it's not possible to "pre-compute" the validity of a mempool transaction in one node, in a way that's comparable to any other node, or to the ultimately proposed block.
--
Transaction validity is not monotonic, and applications should definitely not assume otherwise.
Transactions are valid if all messages in the transaction are valid; a message is valid if its message handler returns a non-nil error; there is no guarantee that message handlers provide monotonic validity. That is, nothing prevents a message from evaluating successfully against some application state [A], unsuccessfully against some application state [A B], and successfully again against some application state [A B C].
--
tl;dr: transaction "validity" is at best a guess until that transaction exists in a specific block