Skip to content

Add csol#352

Open
d-xo wants to merge 9 commits intomainfrom
cli
Open

Add csol#352
d-xo wants to merge 9 commits intomainfrom
cli

Conversation

@d-xo
Copy link
Copy Markdown
Contributor

@d-xo d-xo commented Apr 9, 2026

This branch adds csol, a unified CLI that drives the full compilation and execution pipeline (sol-core → yule → solc → EVM) from a single command, replacing the need to manually chain separate binaries or use shell scripts like runsol.sh.

I kept the old binaries and scripts around for now in case peoples workflows still depend on them, but would suggest that we can drop them in a future PR unless there are objections?

As part of the changes here I also bumped our ghc from 9.8 to 9.10 and updated to the latest nixpkgs (needed for hevm to build) and fixed a small bug in yul generation to support emiting code containing comments (these were always stripped in the previous pipeline when converting the in memory hull objects to their text form).

> nix run .#csol -- --help
csol - solcore compiler toolkit

Usage: csol COMMAND

Available options:
  -h,--help                Show this help text

Available commands:
  build                    Compile a .solc file to Hull, Yul, or hex
  run                      Build and execute a .solc file

d-xo and others added 9 commits April 9, 2026 12:25
genStmt had no case for SComment, causing a crash when translating Hull
IR that contains comments. The runsol pipeline was unaffected because
the Hull parser strips comments during the serialize/parse roundtrip.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
move the hull→yul pipeline logic from yule/Main.hs into a reusable
yule/Pipeline.hs module. add --output-dir flag to sol-core so output
files can be written to a specified directory instead of cwd.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
new `csol` binary with a `build` subcommand that compiles .solc files
through the full sol-core→yule→solc pipeline. supports --contract to
select a specific hull object and --output-dir for output placement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
`csol run` compiles and executes a contract in a single step using hevm
as a library. supports calldata specification (--sig/--arg or --calldata),
--value, --no-create (skip deployment), --solc-optimize, and -d for
dumping intermediate artifacts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- remove unused foldl' import in FieldAccess.hs
- remove redundant catch-all in genStmt (all cases now covered)
- gate EmitHull debug output behind --debug-hull flag

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@mbenke mbenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ cabal run -- csol run test/examples/dispatch/basic.solc --runtime-sig 'something()(uint)'
Compiling to Hull...
Lowering to Yul and compiling to EVM bytecode...

Create: success
  Gas used: 278171
  Address:  0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
  State changes:
    0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84:
      code:    0 -> 1389 bytes
      nonce:   0 -> 0x1

csol: Internal Error: while trying to parse function signature `something()(uint)`, unable to parse solc output:
{"errors":[{"component":"general","errorCode":"2314","formattedMessage":"ParserError: Expected '{' but got '('\n --> hevm.sol:1:36:\n  |\n1 | contract ABI { function something()(uint) public {}}\n  |                                    ^\n\n","message":"Expected '{' but got '('","severity":"error","sourceLocation":{"end":36,"file":"hevm.sol","start":35},"type":"ParserError"}],"sources":{}}
 -- CallStack (from HasCallStack):
  internalError, called at src/EVM/Solidity.hs:424:10 in hevm-0.57.0-KXDqVf1FXowDQ8m2JSt4uT:EVM.Solidity
CallStack (from HasCallStack):
  error, called at src/EVM/Types.hs:1539:19 in hevm-0.57.0-KXDqVf1FXowDQ8m2JSt4uT:EVM.Types
  internalError, called at src/EVM/Solidity.hs:424:10 in hevm-0.57.0-KXDqVf1FXowDQ8m2JSt4uT:EVM.Solidity
HasCallStack backtrace:
  collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
  toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:204:5 in ghc-internal:GHC.Internal.Exception
  error, called at src/EVM/Types.hs:1539:19 in hevm-0.57.0-KXDqVf1FXowDQ8m2JSt4uT:EVM.Types
  internalError, called at src/EVM/Solidity.hs:424:10 in hevm-0.57.0-KXDqVf1FXowDQ8m2JSt4uT:EVM.Solidity

@mbenke
Copy link
Copy Markdown
Collaborator

mbenke commented Apr 14, 2026

How is csol included in end-to-end contract tests?
Perhaps it should be included in tests run via scripts/cabal-contract-tests.sh

@d-xo
Copy link
Copy Markdown
Contributor Author

d-xo commented Apr 15, 2026

$ cabal run -- csol run test/examples/dispatch/basic.solc --runtime-sig 'something()(uint)'
Compiling to Hull...
Lowering to Yul and compiling to EVM bytecode...

Create: success
  Gas used: 278171
  Address:  0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
  State changes:
    0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84:
      code:    0 -> 1389 bytes
      nonce:   0 -> 0x1

csol: Internal Error: while trying to parse function signature `something()(uint)`, unable to parse solc output:
{"errors":[{"component":"general","errorCode":"2314","formattedMessage":"ParserError: Expected '{' but got '('\n --> hevm.sol:1:36:\n  |\n1 | contract ABI { function something()(uint) public {}}\n  |                                    ^\n\n","message":"Expected '{' but got '('","severity":"error","sourceLocation":{"end":36,"file":"hevm.sol","start":35},"type":"ParserError"}],"sources":{}}
 -- CallStack (from HasCallStack):
  internalError, called at src/EVM/Solidity.hs:424:10 in hevm-0.57.0-KXDqVf1FXowDQ8m2JSt4uT:EVM.Solidity
CallStack (from HasCallStack):
  error, called at src/EVM/Types.hs:1539:19 in hevm-0.57.0-KXDqVf1FXowDQ8m2JSt4uT:EVM.Types
  internalError, called at src/EVM/Solidity.hs:424:10 in hevm-0.57.0-KXDqVf1FXowDQ8m2JSt4uT:EVM.Solidity
HasCallStack backtrace:
  collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
  toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:204:5 in ghc-internal:GHC.Internal.Exception
  error, called at src/EVM/Types.hs:1539:19 in hevm-0.57.0-KXDqVf1FXowDQ8m2JSt4uT:EVM.Types
  internalError, called at src/EVM/Solidity.hs:424:10 in hevm-0.57.0-KXDqVf1FXowDQ8m2JSt4uT:EVM.Solidity

Ah yea, I think hevm doesn't support parsing the return type in abi signatures as cast does, can add a nicer error at least here though...

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