Skip to main content

tools for working with chialisp language; compiler, repl, python and wasm bindings

Project description

chialisp

GitHub Coverage Status Build Crate Build Wheels

PyPI Crates.io

Theory of operation of the modern compiler: ./HOW_CHIALISP_IS_COMPILED.md

This repo can be installed via cargo

cargo install chialisp

or via pip

pip install chialisp@git+https://github.com/Chia-Network/clvm_tools_rs.git@e17412032aa7d3b8b1d1f931893fb5802eee626a

Note: pip installs a subset of the tools installed by cargo, including brun, run, opc and opd.

The most current version of the language is in the nightly branch:

[nightly](https://github.com/Chia-Network/chialisp/tree/nightly)

To install from a specific branch:

cargo install --no-default-features --git 'https://github.com/Chia-Network/chialisp' --branch nightly

To install a git checkout into your current python environment (must be in some kind of venv or conda environment):

git clone https://github.com/Chia-Network/chialisp
cd chialisp
maturin develop

Install from PYPI:

pip install -i https://pypi.chia.net/nightlies/ chialisp

Most people still compile chialisp via python. One way to set up compilation in that way is like this:

import json
from chialisp import compile_clvm

def compile_module_with_symbols(include_paths,source):
    path_obj = Path(source)
    file_path = path_obj.parent
    file_stem = path_obj.stem
    target_file = file_path / (file_stem + ".clvm.hex")
    sym_file = file_path / (file_stem + ".sym")
    compile_result = compile_clvm(source, str(target_file.absolute()), include_paths, True)
    symbols = compile_result['symbols']
    if len(symbols) != 0:
        with open(str(sym_file.absolute()),'w') as symfile:
            symfile.write(json.dumps(symbols))

The command line tools provided:

- run -- Compiles CLVM code from chialisp

Most commonly, you'll compile chialisp like this:

  ./target/debug/run -O -i include_dir chialisp.clsp

'run' outputs the code resulting from compiling the program, or an error.

- repl -- Accepts chialisp forms and expressions and produces results
          interactively.
          
Run like:

  ./target/debug/repl
  
Example session:

>>> (defmacro assert items
   (if (r items)
       (list if (f items) (c assert (r items)) (q . (x)))
     (f items)
     )
   )
(q)
>>> (assert 1 1 "hello")
(q . hello)
>>> (assert 1 0 "bye")
failed: CompileErr(Srcloc { file: "*macros*", line: 2, col: 26, until: Some(Until { line: 2, col: 82 }) }, "clvm raise in (8) (())")
>>> 

- cldb -- Stepwise run chialisp programs with program readable yaml output.

  ./target/debug/cldb '(mod (X) (x X))' '(4)'
  ---
  - Arguments: (() (4))
    Operator: "4"
    Operator-Location: "*command*(1):11"
    Result-Location: "*command*(1):11"
    Row: "0"
    Value: (() 4)
  - Env: "4"
    Env-Args: ()
    Operator: "2"
    Operator-Location: "*command*(1):11"
    Result-Location: "*command*(1):13"
    Row: "1"
    Value: "4"
  - Arguments: (4)
    Failure: clvm raise in (8 5) (() 4)
    Failure-Location: "*command*(1):11"
    Operator: "8"
    Operator-Location: "*command*(1):13"

- brun -- Runs a "binary" program.  Instead of serving as a chialisp
  compiler, instead runs clvm programs.

As 'brun' from the python code:

$ ./target/debug/run '(mod (X) (defun fact (N X) (if (> 2 X) N (fact (* X N) (- X 1)))) (fact 1 X))'
(a (q 2 2 (c 2 (c (q . 1) (c 5 ())))) (c (q 2 (i (> (q . 2) 11) (q . 5) (q 2 2 (c 2 (c (* 11 5) (c (- 11 (q . 1)) ()))))) 1) 1))
$ ./target/debug/brun '(a (q 2 2 (c 2 (c (q . 1) (c 5 ())))) (c (q 2 (i (> (q . 2) 11) (q . 5) (q 2 2 (c 2 (c (* 11 5) (c (- 11 (q . 1)) ()))))) 1) 1))' '(5)'
120

- opc -- crush clvm s-expression form to hex.

As 'opc' from the python code.

opc '(a (q 2 2 (c 2 (c (q . 1) (c 5 ())))) (c (q 2 (i (> (q . 2) 11) (q . 5) (q 2 2 (c 2 (c (* 11 5) (c (- 11 (q . 1)) ()))))) 1) 1))'
ff02ffff01ff02ff02ffff04ff02ffff04ffff0101ffff04ff05ff8080808080ffff04ffff01ff02ffff03ffff15ffff0102ff0b80ffff0105ffff01ff02ff02ffff04ff02ffff04ffff12ff0bff0580ffff04ffff11ff0bffff010180ff808080808080ff0180ff018080

- opd -- disassemble hex to s-expression form.

As 'opd' from the python code.

opd 'ff02ffff01ff02ff02ffff04ff02ffff04ffff0101ffff04ff05ff8080808080ffff04ffff01ff02ffff03ffff15ffff0102ff0b80ffff0105ffff01ff02ff02ffff04ff02ffff04ffff12ff0bff0580ffff04ffff11ff0bffff010180ff808080808080ff0180ff018080'
(a (q 2 2 (c 2 (c (q . 1) (c 5 ())))) (c (q 2 (i (> (q . 2) 11) (q . 5) (q 2 2 (c 2 (c (* 11 5) (c (- 11 (q . 1)) ()))))) 1) 1))

History

This is a second-hand port of chia's clvm tools to rust via the work of ChiaMineJP porting to typescript. This would have been a lot harder to get to where it is without prior work mapping out the types of various semi-dynamic things (thanks, ChiaMineJP).

Some reasons for doing this are:

  • Chia switched the clvm implementation to rust: clvm_rs, and this code may both pick up speed and track clvm better being in the same language.

  • I wrote a new compiler with a simpler, less intricate structure that should be easier to improve and verify in the future in ocaml: ochialisp.

  • Also it's faster even in this unoptimized form.

All acceptance tests i've brought over so far work, and more are being added. As of now, I'm not aware of anything that shouldn't be authentic when running these command line tools from clvm_tools in their equivalents in this repository

  • opc

  • opd

  • run

  • brun

  • repl

argparse was ported to javascript and I believe I have faithfully reproduced it as it is used in cmds, so command line parsing should work similarly in all three versions.

The directory structure is expected to be:

src/classic  <-- any ported code with heritage pointing back to
                 the original chia repo.
                
src/compiler <-- a newer compiler (ochialisp) with a simpler
                 structure.  Select new style compilation by
                 including a `(include *standard-cl-21*)`
                 form in your toplevel `mod` form.

Mac M1

Use cargo build --no-default-features due to differences in how mac m1 and other platforms handle python extensions.

Use with chia-blockchain

# Activate your venv, then
$ maturin develop --release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chialisp-0.4.1.tar.gz (553.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

chialisp-0.4.1-cp310-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.10+Windows x86-64

chialisp-0.4.1-cp310-abi3-musllinux_1_1_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.1+ x86-64

chialisp-0.4.1-cp310-abi3-manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

chialisp-0.4.1-cp310-abi3-manylinux_2_28_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

chialisp-0.4.1-cp310-abi3-macosx_15_0_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10+macOS 15.0+ x86-64

chialisp-0.4.1-cp310-abi3-macosx_15_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.10+macOS 15.0+ ARM64

chialisp-0.4.1-cp39-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

chialisp-0.4.1-cp39-abi3-musllinux_1_1_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.1+ x86-64

chialisp-0.4.1-cp39-abi3-manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ x86-64

chialisp-0.4.1-cp39-abi3-manylinux_2_28_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

chialisp-0.4.1-cp39-abi3-macosx_13_0_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9+macOS 13.0+ x86-64

chialisp-0.4.1-cp39-abi3-macosx_13_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.9+macOS 13.0+ ARM64

File details

Details for the file chialisp-0.4.1.tar.gz.

File metadata

  • Download URL: chialisp-0.4.1.tar.gz
  • Upload date:
  • Size: 553.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chialisp-0.4.1.tar.gz
Algorithm Hash digest
SHA256 aeeea3ceea0c909424aed8fa34d091a1d04e14ecd49449d1bbf4dad38695e36d
MD5 996d375efdbaf0ac8bdf4a21e46b0449
BLAKE2b-256 3c6e9a82a159e8a849ccd515db961944283a1aab3a79b7b41019d7bb8390fb3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1.tar.gz:

Publisher: build-test.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: chialisp-0.4.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chialisp-0.4.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f7e2d264c5dd272890f477316b081431c72ca4b1b49dd6d2555f0fc6edddff09
MD5 05702593ff84f13f49b2132d8b5aca54
BLAKE2b-256 0a7fc781575cac1e93f7460ad751bb97b0824d9927b259a226ca8e288758f28f

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp310-abi3-win_amd64.whl:

Publisher: build-test.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp310-abi3-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for chialisp-0.4.1-cp310-abi3-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 0af3af4635cf1f14967a133180578361c236484010762741f0ee82360241e693
MD5 ba4f2a686762f46bad560bac4aff9205
BLAKE2b-256 2d00e97304ed46ab7792adffb46d98f9c72737f8c1c73f49d05257d12c9722e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp310-abi3-musllinux_1_1_x86_64.whl:

Publisher: build-test.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chialisp-0.4.1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0903d73f21e9a56243f6d1180a34c9385edc5369fe4909282beb567a8ae190bd
MD5 3d5225cfa17b3b6f57d9348236425a4c
BLAKE2b-256 db5574645b578d85266f904b4a5cb9d8c9b4d8b238676800c97655682d451beb

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: build-test.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chialisp-0.4.1-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cd3a8ed6cab8e8cad76715c7b880b009a0895757d10b751549c3fbb8ce5b4cfe
MD5 bb254cb2c4b4e7ba2a56e94fc2a71ef8
BLAKE2b-256 5fce6af47c1c854758abfa138fcf2d0ad8fce1073c5c865575615b52cb869080

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: build-arm64-wheels.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp310-abi3-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for chialisp-0.4.1-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 b59dcca36571a4a06312f6b6955ff172794b27c7936d052dddc56a8a7f657059
MD5 339c9230464e261595ab766a2851a65c
BLAKE2b-256 d0718e38414224c7ef12a2847896e609b6e05c1155dff57a6ae161a00a70e77e

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp310-abi3-macosx_15_0_x86_64.whl:

Publisher: build-test.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp310-abi3-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for chialisp-0.4.1-cp310-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 acfb22291189af9e8cdcf59c2618327e35f6cbb643f7d96d21b9f6488ae317c4
MD5 a7d20c1f6e5327a99beb63fab7e29fe3
BLAKE2b-256 f62ba4aa5bc572554039cf15760a55435193763d39f0f3672fa4b78faeb0ad8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp310-abi3-macosx_15_0_arm64.whl:

Publisher: build-m1-wheel.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: chialisp-0.4.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chialisp-0.4.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c3acc38e52edb0e36193194fd47b3f3c6cde9b84e2575cb20cc130f21f42c4fe
MD5 d512d24df04e5ce4b497a9cf43eeea43
BLAKE2b-256 32bd0608d6a96187961bdaba1b15b2f81cb6bab3b2b191a98017feb05b105eb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp39-abi3-win_amd64.whl:

Publisher: build-test.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp39-abi3-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for chialisp-0.4.1-cp39-abi3-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 c750be324fbdc6fa8fb2aee575114bba5f7cea4dbcc856ce14e63c681e0bfaa7
MD5 918d90f95973c5b16fb627a7e71e8b38
BLAKE2b-256 16b3d064e1f4d178d5dcd703d8cc2c59c54950ac3bd45e6ed9b340e3a900d3c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp39-abi3-musllinux_1_1_x86_64.whl:

Publisher: build-test.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp39-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chialisp-0.4.1-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eae1724a6dde700b0e9e604d89712ebe62cbc1561099cc73b862037f99a3bc1d
MD5 36e06849a9ab8fd2066e239be14fd3b7
BLAKE2b-256 474f2a7726effa6c28c5508a6f8bfae7e6a3aecb3604ff0a1570445fe461f284

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp39-abi3-manylinux_2_28_x86_64.whl:

Publisher: build-test.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chialisp-0.4.1-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ffb0e4627d64d160b6a49bdce356d2af16dae5c6eec818eba551aeb39525c830
MD5 1193ec460bde8f3d369a9da9e39a6ec9
BLAKE2b-256 28a205c27244c4588fdd958e3ad7503348f705a3f682bbbc02dd355096019a4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp39-abi3-manylinux_2_28_aarch64.whl:

Publisher: build-arm64-wheels.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp39-abi3-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for chialisp-0.4.1-cp39-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 c5a94ab4124d2d03416d9692d8e0542f547f8d27c3171811a90de6815db1f2f3
MD5 10c4e15c8f406e34b642b6457ceea478
BLAKE2b-256 61f1e9ae98882692c89d570d7f33e218a72d49f0d24794afffd1caaa58b37820

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp39-abi3-macosx_13_0_x86_64.whl:

Publisher: build-test.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chialisp-0.4.1-cp39-abi3-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for chialisp-0.4.1-cp39-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 8f5847359869218053cdc2a326acd43b122e657bfa50de15af3a6b690f791444
MD5 d8f69390758ee793bbc1595023f59d2a
BLAKE2b-256 68ad7a7bb45d9fa3827d55648d553ec4d6397fb6d68807e8ddb680f1f5a8bc1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for chialisp-0.4.1-cp39-abi3-macosx_13_0_arm64.whl:

Publisher: build-m1-wheel.yml on Chia-Network/chialisp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page