Skip to content

Mempool transaction handling properties #223

Open

Description

@josef-widder

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

  1. added
    spec
    on Jan 27, 2023
  2. changed the title [-]Mempool transaction handling specification[/-] [+]Mempool transaction handling properties[/+] on Jan 27, 2023
  3. josef-widder commented on Jan 30, 2023

    @josef-widder
    ContributorAuthor

    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.

  4. peterbourgon commented on Apr 3, 2023

    @peterbourgon

    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.

    --

    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).

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    mempoolspec

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions