Skip to content

feat: bin/dio generates -w config from on-chain state#113

Open
wjmelements wants to merge 23 commits intomasterfrom
dio-trace
Open

feat: bin/dio generates -w config from on-chain state#113
wjmelements wants to merge 23 commits intomasterfrom
dio-trace

Conversation

@wjmelements
Copy link
Owner

Implements #96.

Changes

  • bin/dio: new tool to generate -w config files from on-chain state
  • dio.py: uses debug_traceCall to build access list and fetch all touched account/storage state; falls back to spawning evm -nx as a JSON-RPC proxy when debug_traceCall is unavailable
  • dio.py: generated test entries include output from execution result; storage keys trimmed of leading zeros
  • evm -nx: new interactive mode where missing account/storage state is fetched on demand via JSON-RPC over stdin/stdout
  • evm -x now accepts a JSON call object input (detected by {) with to, from, data — routes to txCall instead of txCreate
  • src/network.c + include/network.h: network fetch callbacks via JSON-RPC over stdio
  • include/evm.h: evmSetFetch, evmBlockNumberIsSet, evmGetBlockNumber API
  • Makefile: generalized .py → bin/ build rule

wjmelements and others added 5 commits March 6, 2026 22:31
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ug_traceCall unavailable

- evm -nx: when executing with -n flag, emit JSON-RPC requests on stdout
  and read responses from stdin for on-demand account/storage fetching
- evm -x now accepts JSON call object input (detected by leading '{') with
  to/from/data fields, enabling txCall instead of txCreate
- src/network.c: network fetch callbacks using JSON-RPC over stdio
- include/network.h: evmSetNetworkFetch() declaration
- include/evm.h: evmSetFetch, evmBlockNumberIsSet, evmGetBlockNumber
- dio: falls back to evm -nx proxy when debug_traceCall is unavailable

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wjmelements wjmelements added the enhancement New feature or request label Mar 7, 2026
wjmelements and others added 5 commits March 7, 2026 00:22
…parse flow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ss:// URLs

WebSocket connections are kept open for the duration of each run via
async with websockets.connect(). The post function is passed through
run, run_via_evm, rpc_call, and batch_rpc. HTTP path wraps http_post
in an async function for uniform interface.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removes buildAccessList and all associated dead code (storage_key_t,
batch_meta_t, jArrayTailN, jStrHex, addAccessKey, stackToAddress,
sbFmt) since no public RPC supports the structLog tracer for free.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wjmelements
Copy link
Owner Author

I also considered having evm track the state and just dump at the end but then I would need to keep original values while executing all of the calls in the tests. Calls can modify state so maybe --extend doesn't make sense. In the past I've done that manually.

wjmelements and others added 13 commits March 8, 2026 01:41
- extract JSON helpers to src/json.c / include/json.h
- add call_result_t; accumulate all calls into one writeConfig output
- pass len to postFn instead of re-running strlen
- compute evmPath once in main; drop self param from run/runViaEvm
- skip curl cleanup on exit (OS reclaims resources)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- dio: capture gasUsed, logs, status from evm output into generated configs
- dio: add jValDup for copying raw JSON values
- evm -w: parse logIndex from test JSON logs
- evm -w: compare logIndex in LogsEqual (optional: zero means unspecified)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- add fprintCompact256 (trims leading zeros) to uint256
- use fprintCompact256 for log topics and evm -xs status output
- use fprint256 for eth_getStorageAt key in network.c
- replace no-param printf/fprintf with fputs/fputc/putchar/puts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add jArrayNext for sequential array iteration, then use it in three
new helpers — rpcFailed (network failure), rpcError (RPC-level error),
checkBatchErrors (per-element batch errors matched by id to method).

All RPC call sites now report the method name and error object on
failure instead of a generic message, and eth_blockNumber is checked
for errors before its result is used, preventing "latest" from
leaking into the evm subprocess.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace sequential jArrayGet(line, N) calls in runViaEvm with
jArrayNext to avoid restarting the scan from the beginning each time.

Add tst/json.c covering jFind, jStr, jUint, jArrayGet, jArrayNext,
jStrDup, jValDup, and resultById.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Calls with no `to` field become create entries with `initcode` and
  `constructTest` instead of a `tests` entry
- Split results into separate `creates` and `calls` lists at creation time
- Skip the `tests` entry entirely when there are no calls

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Extract writeConfig, account_t, call_result_t, storage_kv_t and
  related macros from dio.c into include/config.h + src/config.c
- Skip "status" in constructTest output when success (non-"0x0")
- Skip "status" in tests output when "0x1" (default success)
- Add tst/config.c with 13 unit tests covering accounts, creates, calls
- Add tst/tst.h to share assertStderr macro; remove duplicate from tst/evm.c

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant