Commit bf1695a
committed
refactor(architecture): ChainStore, RpcError, typed envelopes, errors module
A bigger-picture pass following the earlier contained cleanups. Four related
changes, no behaviour change (90 tests pass, make check clean):
1. errors.py: one home for the internal exceptions. transaction.py raised the
interpreter's NodeInterpreterError for encoding failures, forcing a
transaction -> interpreter dependency that existed only for that type. It now
raises TransactionEncodingError and no longer imports interpreter, removing
the one semantically-wrong edge in the module graph.
2. RpcError replaces the union-encoded control flow. The envelope builders
returned dict | str | None, where str secretly meant "pre-formatted error"
and None "unknown method", forced open with isinstance(x, str). They now
return dict and raise RpcError; handle_rpc delegates to _dispatch and catches
once. request_id drops out of the builders' signatures.
3. ChainStore (store.py) owns the io-dir layout. StellarRpcServer conflated HTTP
transport, disk layout, and RPC orchestration, with ~5 scattered inline
metadata reads and path-joins. The store is now the sole reader/writer of
state.kore, metadata.json, and the receipts/ ledgers/ events/ requests/ wasms/
files; the server asks it for records. server.io_dir/state_file are kept for
callers and tests.
4. TypedDicts at the boundaries: TxRequest/SimulateRequest (encoder outputs),
SimulateResult (K result), and LedgerRecord/EventRecord (disk records).
interpreter.run widened to Mapping[str, Any] to accept them. Read-only
envelopes stay dict[str, Any] on purpose — they are built by {**base} spread
and pattern-matched dynamically by node.md, where TypedDicts fight the idiom.
test_unit.py updated to expect TransactionEncodingError.1 parent fcc3d2b commit bf1695a
7 files changed
Lines changed: 405 additions & 198 deletions
File tree
- docs
- src
- komet_node
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
125 | | - | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
0 commit comments