module arch.system.state.resource_machine.data_structures.transaction.transaction;
Transaction¶
A transaction is a necessary and sufficient collection of fields required to validate and apply a state update to the state. It is a composite structure that contains the following components:
| Component | Type | Description | 
|---|---|---|
| CMTreeRoots | Set CMtree.Value | A set of valid commitment tree roots used to prove the existence of the resources being consumed in the transaction. This set is not a part of actions to avoid duplication of data | 
| actions | Set Action | A set of actions that comprise the transaction | 
| deltaProof | DeltaProvingSystem.Proof | Balance proof. It makes sure that transactionDeltais correctly derived from the actions' deltas and commits to the expected publicly known value, called a balancing value. There is just one delta proof per transaction | 
Interface¶
- create(Set CMtree.Value, Set Actions) -> Transaction
- compose(Transaction, Transaction) -> Transaction
- verify(Transaction) -> Bool
- delta(Transaction) -> DeltaHash
create¶
Given a set of roots and a set of actions, a transaction is formed as follows:
- tx.CMTreeRoots = CMTreeRoots
- tx.actions = actions
- tx.transactionDelta = sum(action.Delta() for action in actions)
- tx.deltaProof = DeltaProvingSystem(deltaProvingKey, deltaInstance, deltaWitness)
compose¶
Having two transactions tx1 and tx2, their composition compose(tx1, tx2) is defined as a transaction tx, where:
- tx.CMTreeRoots = Set.union(tx1.CMTreeRoots, tx2.CMTreeRoots)
- tx.actions = Set.union(tx1.actions, tx2.actions)
- tx.deltaProof = DeltaProvingSystem.aggregate(tx1.deltaProof, tx2.deltaProof)
- tx.transactionDelta = tx1.transactionDelta + tx2.transactionDelta
Note
When composing transactions, action sets are simply united without composing the actions themselves. For example, composing a transaction with two actions and another transaction with three actions will result in a transaction with five actions.
verify¶
A transaction is considered valid if the following statements hold:
Checks that do not require access to global structures:
- all actions in the transaction are valid, as defined per action validity rules
- actions partition the state change induced by the transaction:- there is no resource created more than once across actions
- there is no resource consumed more than once across actions
 
- deltaProofis valid
Checks that require access to global CMTree and NullifierSet:
- each created resource wasn't created in prior transactions
- each consumed resource wasn't consumed in prior transactions
A transaction is executable if it is valid and transactionDelta commits to the expected balancing value.
delta¶
Transaction delta is a hash of transaction balance - the total quantity change per resource kind induced by the transaction. It isn't computed from the transaction balance directly by applying a hash function to it, but rather by using the homomoprhic properties of deltaHash: adding action deltas together results in transaction delta.