Anoma.Node.Transaction.Mempool (Anoma v0.29.0)

I am the Mempool Engine.

I posess the core functionality to submit new transactions, execute incoming consensus, and dump current transactions. Alongside that, I store all currently running transactions as well as their intermediate VM results.

As the main point of user-input, I also send the events needed for replays.

All transactions are assumed to come in the form of {backend, noun}.

All consensus is assumed to come in a form of an orered list of binaries.

Public API

I provide the following public functionality:

Summary

Types

t()

I am the type of the Mempool Engine.

I am the type of the transaction result.

I am the type of the Nock VM result.

Functions

Returns a specification to start this module under a supervisor.

I am the execution function.

I am a filter spec which filters for Mempool-related messages.

I am the initialization function for the Mempool Engine.

I am the start_link function for the Mempool Engine.

I am a launch function for a new transaction.

I am a launch function for a new transaction with a given ID.

I am a function to dump transactions.

I am a filter spec which filters for messages from the Backends module.

Types

@type t() :: %Anoma.Node.Transaction.Mempool{
  node_id: String.t() | nil,
  round: non_neg_integer(),
  transactions: %{required(binary()) => Anoma.Node.Transaction.Mempool.Tx.t()}
}

I am the type of the Mempool Engine.

I contain the core information for the mempool functionality, storing the node ID for which the Mempool is launched, a map of transactions with their IDs, as well as the most recent block round.

Fields

  • :node_id - The ID of the Node to which a Mempool instantiation is
             is bound.
  • :transactions - A map with keys being the binary IDs of launched
                  transactions and values the corresponding
                  transaction data. See `Tx.t()`
                  Default: %{}
  • :round - The round of the next block to be created.
           Default: 0
@type tx_result() :: {:ok, any()} | :error | :in_progress

I am the type of the transaction result.

@type vm_result() :: {:ok, Noun.t()} | :error | :in_progress

I am the type of the Nock VM result.

Functions

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

execute(node_id, ordered_list_of_txs)

@spec execute(String.t(), [binary()]) :: :ok

I am the execution function.

I receive a list of binaries, which I recognize as a partial order for block execution, sending an appropriate consensus submission event.

Once launched, I send the list to the Executor.

I am asynchronous, meaning that I do not block and blocks can be submitted before the last one got executed.

If execution is susccesful, the Mempool will handle an appropriate message from the Executor, which will trigger block-creation.

Link to this function

filter_for_mempool()

@spec filter_for_mempool() :: Anoma.Node.Transaction.Backends.ForMempoolFilter.t()

I am a filter spec which filters for Mempool-related messages.

@spec init([startup_options()]) :: {:ok, t()}

I am the initialization function for the Mempool Engine.

I assume that my arguments come with keywords specifying the node id, alongside transactions, pending orders, and a block round.

If any transactions are provided upon startup, I ask the Mempool to execute them with a particular ID.

If any orders are provided, I also launch them afterwards in the order specified.

Afterwards, I initialize the Mempool with round and node ID specified.

Link to this function

start_link(args \\ [])

@spec start_link([startup_options()]) :: GenServer.on_start()

I am the start_link function for the Mempool Engine.

I register the mempool with supplied node ID provided by the arguments.

Link to this function

tx(node_id, tx_w_backend)

I am a launch function for a new transaction.

Given a node ID with a {backend, tx} tuple, I launch a new transaction with a random ID, sending an appropriate event.

Afterwards, the transaction code is sent to the Executor Engine to be assigned to a Worder, while the code wrapped in Tx.t() will be stored in Mempool's state.

See tx/3 for launching a transaction with a given ID.

Link to this function

tx(node_id, tx_w_backend, id)

I am a launch function for a new transaction with a given ID.

See tx/2 for logic documentation. In constrast to it, I launch an new transaction with a particular given ID. This functionality is to be used only for replays and testing.

Link to this function

tx_dump(node_id)

I am a function to dump transactions.

Given a node ID, I give all the transactions as currently stored in the corresponding Mempool state.

Link to this function

worker_module_filter()

@spec worker_module_filter() :: EventBroker.Filters.SourceModule.t()

I am a filter spec which filters for messages from the Backends module.