You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: convert architecture ASCII diagrams to mermaid
Replace the three ASCII diagrams in architecture.md with mermaid, each
in the form that fits: a flowchart for the component/data-flow overview,
a lifecycle flowchart for state management, and a sequence diagram for
the end-to-end request flow. All three validated against mermaid 11.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/architecture.md
+81-56Lines changed: 81 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,23 +6,37 @@ komet-node is a local Stellar testnet whose execution engine is the [K formal se
6
6
7
7
The split between Python and K follows one rule: K does everything that is part of the Soroban/Stellar protocol, and Python does only what K structurally cannot. The compiled K semantics are a *one-shot interpreter* — one invocation runs one request to completion and exits, with no network, no memory between invocations, and no decoder for Stellar's binary XDR format. Python supplies exactly those three missing pieces: it is the long-running process that holds the HTTP socket, it keeps the world state on disk between invocations, and it decodes the XDR envelope (and parses uploaded wasm). Everything else — RPC method dispatch, the transaction store, ledger-sequence accounting, status determination, and JSON-RPC response formatting — runs inside the K semantics (`node.md`).
8
8
9
-
```
10
-
Stellar client
11
-
│ JSON-RPC request (base64 XDR transaction)
12
-
▼
13
-
StellarRpcServer ← server.py (long-running http.server; holds the socket + state files)
node["dispatch RPC method · run steps via KASMER<br/>update bookkeeping · format response"]
24
+
end
25
+
26
+
subgraph iodir["io dir (on disk)"]
27
+
direction LR
28
+
state[("state.kore")]
29
+
meta[("metadata.json")]
30
+
txs[("transactions.json")]
31
+
end
32
+
33
+
client -->|"JSON-RPC (base64 XDR)"| server
34
+
interp -->|"request.json + state.kore"| node
35
+
node -->|"response.json"| interp
36
+
node <-->|"read / write"| meta
37
+
node <-->|"read / write"| txs
38
+
interp <-->|"round-trip"| state
39
+
server -->|"JSON-RPC response"| client
26
40
```
27
41
28
42
---
@@ -79,21 +93,21 @@ Server state is split across the *io dir* (the directory containing the state fi
79
93
80
94
The world state stays in KORE (rather than a JSON snapshot) because an uploaded wasm module is a `ModuleDecl` that the semantics cannot reconstruct from bytes — only `wasm2kast` (Python) can produce it. The RPC bookkeeping, by contrast, is plain data and lives in the two JSON sidecar files, which the semantics read and write directly via the file-system hooks.
81
95
82
-
```
83
-
startup (state.kore absent):
84
-
→ NodeInterpreter.empty_config() builds the idle K configuration in KORE
85
-
and runs it through llvm_interpret (no krun, no kast conversion)
86
-
→ server writes state.kore, and seeds metadata.json ({latest_ledger: 0})
87
-
and transactions.json ({})
88
-
89
-
per successful transaction:
90
-
→ the semantics execute the steps, append a SUCCESS receipt to
91
-
transactions.json, bump latest_ledger in metadata.json, and write
92
-
response.json; NodeInterpreter persists the new state.kore
93
-
94
-
per failed (stuck) transaction:
95
-
→ no response.json is produced; state.kore is left unchanged and the
96
-
ledger is not bumped. The server synthesises a FAILED receipt.
stuck -->|"no — FAILED"| fail["no response.json<br/>state.kore and ledger left unchanged<br/>server synthesises a FAILED receipt"]
109
+
ok --> ready
110
+
fail --> ready
97
111
```
98
112
99
113
Because all three files live on disk, the server can be stopped and restarted without losing the world state, the ledger counter, or the transaction store. To resume a session, point `--state-file` at a saved `state.kore` (its sidecar files are read if present). To start fresh, delete the files.
@@ -102,30 +116,41 @@ Because all three files live on disk, the server can be stopped and restarted wi
102
116
103
117
## Request flow (end to end)
104
118
105
-
```
106
-
1. Client: POST {"method": "sendTransaction", "params": {"transaction": "<base64 XDR>"}}
0 commit comments