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

I am the Transaction Backend module.

I define a set of backends for the execution of the given transaction candidate. Currently, I support transparent resource machine (RM) execution as well as the following debug executions: read-only, key-value store, and blob store executions.

Public API

I have the following public functionality:

Summary

Functions

I am the commitment accumulator add function for the transparent resource machine.

I execute the specified transaction candidate using the designated backend. If the transaction is provided as a jammed noun atom, I first attempt to apply cue/1 in order to unpack the transaction code.

I am the commitment accumulator value function for the transparent resource machine.

I am the commitment accumulator verify function for the transparent resource machine.

I am the commitment accumulator witness function for the transparent resource machine.

Types

@type backend() ::
  :debug_term_storage
  | {:debug_read_term, pid()}
  | :debug_bloblike
  | :transparent_resource
Link to this type

transaction()

@type transaction() :: {backend(), Noun.t() | binary()}

Functions

@spec add(MapSet.t(), binary()) :: MapSet.t()

I am the commitment accumulator add function for the transparent resource machine.

Given the commitment set, I add a commitment to it.

Link to this function

blob_store(node_id, id, result)

@spec blob_store(String.t(), binary(), Noun.t()) :: {:ok, any()} | :error
Link to this function

execute(node_id, arg, id)

@spec execute(node_id, {back, Noun.t()}, id) :: :ok
when id: binary(), node_id: String.t(), back: backend()

I execute the specified transaction candidate using the designated backend. If the transaction is provided as a jammed noun atom, I first attempt to apply cue/1 in order to unpack the transaction code.

First, I execute the transaction code on the Anoma VM. Next, I apply processing logic to the resulting value, dependent on the selected backend.

  • For read-only backend, the value is transmitted as a Result Event.
  • For the key-value and blob store executions, the obtained value is stored and a Complete Event is issued.
  • For the transparent Resource Machine (RM) execution, I verify the transaction's validity and compute the corresponding set of nullifiers, which is transmitted as a Nullifier Event.
Link to this function

store_value(node_id, id, result)

@spec store_value(String.t(), binary(), Noun.t()) :: {:ok, any()} | :error
@spec value(MapSet.t()) :: binary()

I am the commitment accumulator value function for the transparent resource machine.

Given the commitment set, I turn it to binary and then hash it using sha-256.

Link to this function

verify(cm, w, val)

@spec verify(binary(), MapSet.t(), binary()) :: bool()

I am the commitment accumulator verify function for the transparent resource machine.

Given the commitment, a witness (i.e. a set) and a commitment value, I output true iff the witness's value is the same as the provided value and the commitment is indeed in the set.

Link to this function

witness(acc, cm)

@spec witness(MapSet.t(), binary()) :: MapSet.t() | nil

I am the commitment accumulator witness function for the transparent resource machine.

Given the commitment set and a commitment, I return the original set if the commitment is a member of the former. Otherwise, I return nil