Skip to content

Conversation

@mbenke
Copy link
Collaborator

@mbenke mbenke commented Jan 2, 2026

Claude-coded reimplementation of runsol.sh as a Haskell executable

mbenke and others added 8 commits December 31, 2025 15:31
Implement a new RunSol Haskell program (app/RunSol.hs) that replicates
the functionality of runsol.sh while integrating sol-core and yule
compilation directly as library functions instead of external processes.

Key changes:
- Move yule modules from yule/ to src/Yule/ with proper namespacing
  - Yule/Translate.hs, Yule/TM.hs, Yule/Compress.hs, Yule/Builtins.hs,
    Yule/Locus.hs, Yule/Options.hs
- Expose Yule.* modules in library for use by RunSol
- Create new runsol executable that:
  - Calls compile() directly for sol-core compilation
  - Calls translateObject() directly for yule translation
  - Uses aeson for JSON processing (instead of jq)
  - Calls external processes for solc, evm, cast
  - Supports all runsol.sh command-line options
- Update yule/Main.hs to use new Yule.* module imports
- Update sol-core.cabal with Yule.* exports and runsol executable

Benefits:
- Faster execution (no process spawning for sol-core and yule)
- Better error handling through Haskell types
- Single executable instead of shell script
- Type safety through direct function calls
- Better module organization with Yule namespace

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
Extend RunSol executable to recognize and process all sol-core options:
- -i, --include DIRS: Colon-separated import directories
- -n, --no-specialise: Skip specialisation phase
- -s, --no-desugar-calls: Skip indirect call desugaring
- -m, --no-match-compiler: Skip match compilation
- -d, --no-if-desugar: Skip if/bool desugaring
- -g, --no-gen-dispatch: Skip contract dispatch generation
- -v, --verbose: Verbose output
- --dump-ast, --dump-env, --dump-dispatch, --dump-ds, --dump-df,
  --dump-spec, --dump-core: Dump intermediate representations
- --debug-spec, --debug-core: Debug output for specialisation and core
- --timing: Measure compilation time

All options are now passed directly to the compile function, making
RunSol a fully-featured replacement for runsol.sh with the ability to
control every aspect of the compilation pipeline.

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
Add addRetCode wrapper to Yul objects to ensure contract function results
are stored in memory and returned to the EVM caller. This adds code to
mstore the result and return 32 bytes from memory location 0.

Also add JSONL parsing to extract return data from evm trace output,
fixing the issue where runsol would show "Execution successful" without
displaying the actual return value (e.g., returndata: 0x...2a for value 42).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
Add pattern match for SComment in genStmt to properly handle comments
in Core code. Comments are translated to YComment statements, which
is consistent with the existing genStmtWithComment function.

This fixes the error 'genStmt unimplemented for: /* ... */' that
occurred when compiling Core code containing type annotations or
other comments.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
Update error extraction logic to properly parse JSON error fields:
- Extract error values as strings instead of showing JSON representation
- Handle null error fields (means no error) vs actual error strings
- Use extracted evmError from JSON when available, fall back to exit code

This fixes the issue where "execution reverted" was being displayed as
"String \"execution reverted\"" (JSON show representation).

Matches the behavior of runsol.sh which checks if error field is null
and reports accordingly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
Generate two versions of the compiled contract:
1. Deployment bytecode: Wraps contract with deployment initialization code
2. Runtime bytecode: Plain contract code for function execution

This fixes the issue where runtime execution would return the deployment
bytecode itself (when called without --create) instead of executing the
actual contract functions.

Now correctly:
- Creation phase returns the deployment bytecode
- Runtime phase executes the runtime bytecode and properly returns
  execution results or reverts when no valid selector is provided

Verified with test cases:
- No selector: "Execution failed: execution reverted"
- something()(): returns 1 (decoded)
- add2(2, 3): returns 5 (decoded, 2+3)

Matches the expected behavior of runsol.sh.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
@mbenke mbenke requested a review from d-xo January 2, 2026 09:59
@mbenke mbenke marked this pull request as draft January 8, 2026 16:42
@mbenke
Copy link
Collaborator Author

mbenke commented Jan 8, 2026

Still needs some work - constructors are not emitted properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants