Skip to content

Commit afccf47

Browse files
docs: network transaction builder (#1074)
1 parent 5163e83 commit afccf47

File tree

6 files changed

+68
-9
lines changed

6 files changed

+68
-9
lines changed

crates/store/src/genesis/config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl GenesisConfig {
178178
// yet to be deployed. An account is deployed onchain along with its first
179179
// transaction which results in a non-zero nonce onchain.
180180
//
181-
// The genesis block is special in that accounts are "deplyed" without transactions and
181+
// The genesis block is special in that accounts are "deployed" without transactions and
182182
// therefore we need bump the nonce manually to uphold this invariant.
183183
let wallet_delta = AccountDelta::new(
184184
wallet_account.id(),

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- [RPC](./developer/rpc.md)
2828
- [Store](./developer/store.md)
2929
- [Block producer](./developer/block-producer.md)
30+
- [Network transaction builder](./developer/ntx-builder.md)
3031
- [Common issues other oddities](./developer/oddities.md)
3132

3233
---

docs/src/developer/codebase.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ instead simply serve to enforce code organisation and decoupling.
1010
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
1111
| `node` | The node executable. Configure and run the node and its components. |
1212
| `faucet` | A reference faucet app implementation used by the official Miden faucet. |
13-
| `remote-prover` | Remote prover executables. Includes workers and proxies. |
14-
| `remote-prover-client` | Remote prover client implementation. |
13+
| `remote-prover` | Remote prover executables. Includes workers and proxies. |
14+
| `remote-prover-client` | Remote prover client implementation. |
1515
| `block-producer` | Block-producer component implementation. |
1616
| `store` | Store component implementation. |
17+
| `ntx-builder` | Network transaction builder component implementation. |
1718
| `rpc` | RPC component implementation. |
1819
| `proto` | Contains and exports all protobuf definitions. |
1920
| `rpc-proto` | Contains the RPC protobuf definitions. Currently this is an awkward clone of `proto` because we re-use the definitions from the internal protobuf types. |

docs/src/developer/ntx-builder.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.

docs/src/operator/architecture.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Node architecture
22

3-
The node itself consists of three distributed components: store, block-producer and RPC. We also provide a reference
4-
faucet implementation which we use to distribute testnet and devnet tokens.
3+
The node itself consists of four distributed components: store, block-producer, network transaction builder, and RPC.
4+
We also provide a reference faucet implementation which we use to distribute testnet and devnet tokens.
55

66
The components can be run on separate instances when optimised for performance, but can also be run as a single process
7-
for convenience. At the moment both of Miden's public networks (testnet and devnet) are operating in single process
7+
for convenience. The exception to this is the network transaction builder which can currently only be run as part of
8+
the single process. At the moment both of Miden's public networks (testnet and devnet) are operating in single process
89
mode.
910

10-
The inter-component communication is done using a gRPC API wnich is assumed trusted. In other words this _must not_ be
11+
The inter-component communication is done using a gRPC API which is assumed trusted. In other words this _must not_ be
1112
public. External communication is handled by the RPC component with a separate external-only gRPC API.
1213

1314
![node architecture](../resources/operator_architecture.svg)
@@ -40,6 +41,15 @@ proved, and then periodically aggregated into a block. This block is then proved
4041
Proof generation in production is typically outsourced to a remote machine with appropriate resources. For convenience,
4142
it is also possible to perform proving in-process. This is useful when running a local node for test purposes.
4243

44+
## Network transaction builder
45+
46+
The network transaction builder monitors the mempool for network notes, and creates transactions consuming these.
47+
We call these network transactions and at present this is the only entity that is allowed to create such transactions.
48+
This restriction is will be lifted in the future, but for now this component _must_ be enabled to have support for
49+
network transactions.
50+
51+
The mempool is monitored via a gRPC event stream served by the block-producer.
52+
4353
## Faucet
4454

4555
A stand-alone binary which serves a webpage where users can request tokens from a customizable faucet account. The

0 commit comments

Comments
 (0)