Skip to content

Commit 37c3ffb

Browse files
Merge pull request #27 from runtimeverification/chore/remove-demo-leftover
Remove leftover contract-lifecycle walkthrough and demo module
2 parents 7f95807 + 98bf765 commit 37c3ffb

6 files changed

Lines changed: 2 additions & 159 deletions

File tree

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,6 @@ curl -s http://localhost:8000 -H 'Content-Type: application/json' \
141141

142142
Each trace record captures the VM state at instruction entry: `pos` is the instruction's byte offset in the binary (`null` for synthetic instructions), `instr` is the instruction and its operands, and `stack`/`locals` are the value stack and locals as `[type, value]` pairs. See [docs/interpreter.md](docs/interpreter.md) for the full trace format.
143143

144-
#### Walk through a contract lifecycle
145-
146-
The bundled demo deploys and invokes a Soroban contract end-to-end (create account → upload wasm → deploy → invoke):
147-
148-
```bash
149-
uv run python -m komet_node.demo src/tests/integration/data/wasm/empty.wat
150-
```
151-
152-
This produces `state.kore` plus `state_<n>_<step>.pretty` files under `./out`, letting you inspect exactly how the ledger state evolves at each step. (Requires `wat2wasm` from [`wabt`](https://github.com/WebAssembly/wabt) on your `PATH`.)
153-
154144
---
155145

156146
## For Developers

docs/interpreter.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ return _set_cell(pattern, "<program> cell symbol", steps_kore) # KORE-level sp
5959

6060
Because Soroban allows only a single host-function operation per transaction, a wasm-upload transaction is exactly one `uploadWasm` op — this path never carries anything else.
6161

62-
### `pretty_print(kore_str)`
63-
64-
`pretty_print` is a debugging helper that pretty-prints a KORE configuration string using `krun --output pretty --depth 0`. `demo.py` uses it to render each step of a contract lifecycle.
65-
6662
---
6763

6864
## Supported operations
@@ -80,4 +76,4 @@ The mapping from Stellar operations to kasmer steps is performed by [`Transactio
8076

8177
## Error handling
8278

83-
`NodeInterpreterError` is raised for interpreter-level failures (e.g. `pretty_print`). A *transaction* failure is not an exception: the semantics get stuck without writing `response.json`, so `run` returns `None` and the server records a `FAILED` receipt while leaving `state.kore` unchanged (the state effectively rolls back).
79+
`NodeInterpreterError` is raised for interpreter-level failures (e.g. the interpreter crashing or producing no output). A *transaction* failure is not an exception: the semantics get stuck without writing `response.json`, so `run` returns `None` and the server records a `FAILED` receipt while leaving `state.kore` unchanged (the state effectively rolls back).

docs/notes.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
`komet-node` is a local Stellar testnet backed by the K semantics of Soroban. The compiled semantics are a one-shot interpreter (one process per request, no networking, no state between runs), so Python wraps them into a long-running server: it holds the HTTP socket, keeps state on disk between runs, and decodes Stellar XDR, which K cannot. The RPC layer itself — method dispatch, receipt bookkeeping, ledger accounting, status, and response formatting — runs inside the K semantics ([`node.md`](node-semantics.md)).
66

7-
See `src/komet_node/demo.py` for an end-to-end example: empty state → create account → upload wasm → deploy contract → call `foo()`, with each step's K configuration pretty-printed.
8-
97
---
108

119
## Module map

src/komet_node/demo.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

src/komet_node/interpreter.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
from pyk.kore.parser import KoreParser
1212
from pyk.kore.prelude import SORT_K_ITEM, inj, int_dv, str_dv, top_cell_initializer
1313
from pyk.kore.syntax import App, SortApp
14-
from pyk.ktool.krun import KRunOutput, _krun
1514
from pyk.utils import check_file_path, run_process_2
1615

17-
from .utils import simbolik_definition, temp_working_directory
16+
from .utils import simbolik_definition
1817

1918
if TYPE_CHECKING:
2019
from pathlib import Path
@@ -175,24 +174,6 @@ def _inject_program(self, pattern: Pattern, steps: list[KInner]) -> Pattern:
175174
steps_kore = kast_to_kore(self.definition.kdefinition, steps_of(steps), KSort('Steps'))
176175
return _set_cell(pattern, _PROGRAM_CELL, steps_kore)
177176

178-
def pretty_print(self, kore_str: str) -> str:
179-
"""Pretty-print a KORE configuration string using the K definition."""
180-
with temp_working_directory() as root:
181-
kore_file = root / 'input.kore'
182-
kore_file.write_text(kore_str)
183-
res = _krun(
184-
input_file=kore_file,
185-
definition_dir=self.definition.path,
186-
parser='cat',
187-
term=True,
188-
output=KRunOutput.PRETTY,
189-
check=False,
190-
depth=0,
191-
)
192-
if res.returncode:
193-
raise NodeInterpreterError('Failed to pretty-print kore', res)
194-
return res.stdout
195-
196177

197178
class NodeInterpreterError(RuntimeError):
198179
pass

src/komet_node/utils.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,8 @@
11
from __future__ import annotations
22

3-
import os
4-
import tempfile
5-
from contextlib import contextmanager
6-
from pathlib import Path
7-
from typing import TYPE_CHECKING
8-
93
from komet.utils import SorobanDefinition
104
from pyk.kdist import kdist
115

12-
if TYPE_CHECKING:
13-
from collections.abc import Generator
14-
15-
16-
@contextmanager
17-
def temp_working_directory() -> Generator[Path, None, None]:
18-
original = os.getcwd()
19-
with tempfile.TemporaryDirectory() as tmp_dir:
20-
try:
21-
os.chdir(tmp_dir)
22-
yield Path(tmp_dir)
23-
finally:
24-
os.chdir(original)
25-
266

277
class SimbolikDefinition(SorobanDefinition): ...
288

0 commit comments

Comments
 (0)