|
| 1 | +# Network Transaction Builder Component |
| 2 | + |
| 3 | +The network transaction builder (NTB) is responsible for driving the state of network accounts. |
| 4 | + |
| 5 | +## What is a network account |
| 6 | + |
| 7 | +Network accounts are a special type of fully public account which contains no authentication and |
| 8 | +whose state can therefore be updated by anyone (in theory). Such accounts are required when publicly |
| 9 | +mutable state is needed. |
| 10 | + |
| 11 | +The issue with publicly mutable state is that transactions against an account must be sequential |
| 12 | +and require the previous account commitment in order to create the transaction proof. This conflicts |
| 13 | +with Miden's client side proving and concurrency model since users would race each other to submit |
| 14 | +transactions against such an account. |
| 15 | + |
| 16 | +Instead the solution is to have the network be responsible for driving the account state forward, |
| 17 | +and users can interact with the account using notes. Notes don't require a specific ordering and |
| 18 | +can be created concurrently without worrying about conflicts. We call these network notes and they |
| 19 | +always target a specific network account. |
| 20 | + |
| 21 | +A network transaction is a transaction which consumes and applies a set of network notes to a |
| 22 | +network account. There is nothing special about the transaction itself - it can only be identified |
| 23 | +by the fact that it updates the state of a network account. |
| 24 | + |
| 25 | +## Limitations |
| 26 | + |
| 27 | +At present, we artificially limit this such that only this component may create transactions against |
| 28 | +network accounts. This is enforced at the RPC layer by disallowing network transactions entirely in |
| 29 | +that component. The NTB skirts around this by submitting its transactions directly to the |
| 30 | +block-producer. |
| 31 | + |
| 32 | +This limitation is there to prevent complicating the NTBs implementation while the protocol and |
| 33 | +definitions of network accounts, notes and transactions mature. |
| 34 | + |
| 35 | +## Implementation |
| 36 | + |
| 37 | +On startup the mempool loads all unconsumed network notes from the store. From there it monitors |
| 38 | +the mempool for events which would impact network account state. This communication takes the form |
| 39 | +of an event stream via gRPC. |
| 40 | + |
| 41 | +The NTB periodically selects an arbitrary network account with available network notes and creates |
| 42 | +a network transaction for it. |
| 43 | + |
| 44 | +The block-producer remains blissfully unaware of network transactions. From its perspective a |
| 45 | +network transaction is simply the same as any other. |
0 commit comments