diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index a147046d..fe5239de 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -51,8 +51,6 @@ jobs: python -m venv venv . .\venv\Scripts\Activate.ps1 ln -s venv\Scripts\Activate.ps1 activate - git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch - python -m pip install ./clvm_tools python -m pip install colorama maturin develop -m wheel/Cargo.toml --release @@ -70,8 +68,6 @@ jobs: python -m venv venv ln -s venv/bin/activate . ./activate - git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch - python -m pip install ./clvm_tools python -m pip install colorama maturin develop -m wheel/Cargo.toml --release --features=openssl @@ -116,8 +112,6 @@ jobs: python -m venv venv ln -s venv/bin/activate . ./activate - git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch - python -m pip install ./clvm_tools python -m pip install colorama maturin develop -m wheel/Cargo.toml --release --features=openssl diff --git a/.github/workflows/build-m1-wheel.yml b/.github/workflows/build-m1-wheel.yml index 0f731f21..234e1511 100644 --- a/.github/workflows/build-m1-wheel.yml +++ b/.github/workflows/build-m1-wheel.yml @@ -55,35 +55,6 @@ jobs: arch -arm64 python -m pip install pytest arch -arm64 python -m pip install blspy - - name: install clvm & clvm_tools - run: | - . ./venv/bin/activate - arch -arm64 git clone https://github.com/Chia-Network/clvm.git --branch=main --single-branch - arch -arm64 python -m pip install ./clvm - - arch -arm64 git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch - arch -arm64 python -m pip install ./clvm_tools - - - name: Ensure clvm, clvm_rs, clvm_tools are installed - run: | - . ./venv/bin/activate - arch -arm64 python -c 'import clvm' - arch -arm64 python -c 'import clvm; print(clvm.__file__)' - arch -arm64 python -c 'import clvm_rs; print(clvm_rs.__file__)' - arch -arm64 python -c 'import clvm_tools; print(clvm_tools.__file__)' - - - name: Run tests from clvm - run: | - . ./venv/bin/activate - cd clvm - arch -arm64 pytest tests - - - name: Run tests from clvm_tools - run: | - . ./venv/bin/activate - cd clvm_tools - arch -arm64 pytest tests - - name: Run tests from wheel run: | . ./venv/bin/activate diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 9a6dd9ee..09eeef62 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -114,6 +114,11 @@ jobs: python -m pip install pytest python -m pip install blspy + # we need this for brun and opc + - name: install clvm_tools + run: | + cargo install clvm_tools_rs + - name: Run tests from wheel run: | . ./activate @@ -272,8 +277,6 @@ jobs: cargo test --release --workspace python -m venv venv source venv/bin/activate - git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch - pip install ./clvm_tools pip install colorama maturin pytest pytest-cov maturin develop --release -m wheel/Cargo.toml --features=openssl (cd tests && python generate-programs.py && python run-programs.py) || true diff --git a/benchmark/run-benchmark.py b/benchmark/run-benchmark.py index 03a7717f..1addf899 100755 --- a/benchmark/run-benchmark.py +++ b/benchmark/run-benchmark.py @@ -6,7 +6,7 @@ import os import time import random -from clvm_rs import Program +from clvm_rs import run_serialized_chia_program from colorama import init, Fore, Style init() @@ -201,11 +201,11 @@ def need_update(file_path, mtime): else: if "-v" in sys.argv: print(fn) - program = Program.fromhex(open(fn, 'r').read()) - env = Program.fromhex(open(env_fn, 'r').read()) + program = bytes.fromhex(open(fn, 'r').read()) + env = bytes.fromhex(open(env_fn, 'r').read()) time_start = time.perf_counter() - cost, result = program.run_with_cost( + cost, result = run_serialized_chia_program( env, max_cost, flags, diff --git a/fuzz/decode.py b/fuzz/decode.py deleted file mode 100644 index 414c46fa..00000000 --- a/fuzz/decode.py +++ /dev/null @@ -1,14 +0,0 @@ -# tool to decompile a fuzz_run_program test case to human readable form - -import sys -import io -from ir import reader -from clvm_tools import binutils -from clvm.serialize import sexp_from_stream -from clvm import to_sexp_f - -with open(sys.argv[1], 'rb') as f: - blob = f.read() - sexp = sexp_from_stream(io.BytesIO(blob), to_sexp_f) - print(binutils.disassemble(sexp)) - diff --git a/fuzz/gen_corpus.py b/fuzz/gen_corpus.py deleted file mode 100644 index 39bbb241..00000000 --- a/fuzz/gen_corpus.py +++ /dev/null @@ -1,90 +0,0 @@ -import hashlib -from ir import reader -from clvm_tools import binutils - -OPERATORS = [ - ("q", 1), - ("a", 3), - ("i", 3), - ("c", 2), - ("f", 1), - ("r", 2), - ("l", 2), - ("x", 1), - ("=", 2), - ("sha256", 2), - ("+", 2), - ("-", 2), - ("*", 2), - ("divmod", 2), - ("div", 2), - ("substr", 3), - ("strlen", 1), - ("point_add", 2), - ("pubkey_for_exp", 2), - ("concat", 2), - (">", 2), - (">s", 2), - ("logand", 2), - ("logior", 2), - ("logxor", 2), - ("lognot", 2), - ("ash", 2), - ("lsh", 2), - ("not", 1), - ("any", 2), - ("all", 2), - ("softfork", 3), -] - -def arguments(): - for v in [0, 1, -1]: - yield v - yield '"FOOBAR"' - yield "(q 1 2 3)" - yield "(q . ())" - for sign in [1, -1]: - for l in [0, 8, 16, 32, 64]: - for v in [0x80, 0x100]: - yield (v << l) * sign - yield ((v << l) - 1) * sign - -def gen_args(max_args): - # 0 args - yield "" - - if max_args == 0: - return - - # 1 argument - for a in arguments(): - yield f" {a}" - - if max_args == 1: - return - - # 2 arguments - for a0 in arguments(): - for a1 in arguments(): - yield f" {a0} {a1}" - - if max_args == 2: - return - - # 3 arguments - for a0 in arguments(): - for a1 in arguments(): - for a2 in arguments(): - yield f" {a0} {a1} {a2}" - -for op, max_args in OPERATORS: - for args in gen_args(max_args): - prg = f"({op}{args})" - ir_sexp = reader.read_ir(prg) - prg = binutils.assemble_from_ir(ir_sexp).as_bin() - h = hashlib.sha1() - h.update(prg) - name = h.digest().hex() - with open(f"corpus/fuzz_run_program/{name}", "wb+") as f: - f.write(prg) -