diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 0c43dbe4b..463e577e8 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] - python: [3.7, 3.8, 3.9, '3.10'] + python: [3.8, 3.9, '3.10', 3.11] steps: - uses: actions/checkout@v3 @@ -55,7 +55,7 @@ jobs: - name: Build MacOs with maturin on Python ${{ matrix.python }} if: startsWith(matrix.os, 'macos') env: - MACOSX_DEPLOYMENT_TARGET: '10.14' + MACOSX_DEPLOYMENT_TARGET: '11.0' run: | python -m venv venv ln -s venv/bin/activate @@ -86,14 +86,14 @@ jobs: . ./activate && \ pip install --upgrade pip ' - docker run --rm -v $(pwd):/io ghcr.io/pyo3/maturin:v0.13.1 build --sdist --release --strip --manylinux 2010 + docker run --rm -v $(pwd):/io ghcr.io/pyo3/maturin:v1.1.0 build --release --strip --manylinux 2014 # Refresh in case any ownerships changed. mv target target.docker && cp -r target.docker target # Ensure an empty .cargo-lock file exists. touch target/release/.cargo-lock - name: Build alpine wheel via docker - if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.7') + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8') run: | cd resources/alpine && docker build -t clvm-tools-rs-alpine . docker run -v ${GITHUB_WORKSPACE}:/root/clvm_tools_rs -t clvm-tools-rs-alpine sh /root/build-alpine.sh @@ -161,7 +161,7 @@ jobs: python mandelbrot-cldb.py - name: Verify recompilation of old sources match - if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.7') + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8') run: | . ./activate # Build cmd line tools @@ -176,7 +176,7 @@ jobs: (cd chia-blockchain && python recompile_check.py) - name: Test Classic command line tools with pytest - if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.7') + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8') run: | python -m pip install pytest # This script installs the wheel built during this workflow. @@ -185,7 +185,7 @@ jobs: (cd resources/tests/cmdline/tests && py.test cmds_test.py ) - name: Verify recompilation of cl21 sources - if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.7') + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8') run: | . ./activate # We need chia-rs for the following. @@ -197,7 +197,7 @@ jobs: (cd resources/tests && python check-recompiles.py) - name: Verify recompilation follows date and modification rules - if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.7') + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8') run: | python support/wheelname.py python resources/tests/test-clvm-recompile-behavior.py @@ -220,11 +220,11 @@ jobs: pytest tests - name: Run tests - if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.7') - run: cargo test --features="${USE_FEATURES}" + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8') + run: cargo test --no-default-features - name: Check coverage - if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.7') + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8') run: | cargo install grcov rustup component add llvm-tools-preview diff --git a/Cargo.lock b/Cargo.lock index 64243fa3d..85cb87d7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,6 +28,18 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "binascii" version = "0.1.4" @@ -72,10 +84,11 @@ dependencies = [ [[package]] name = "bls12_381" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62250ece575fa9b22068b3a8d59586f01d426dd7785522efd97632959e71c986" +checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" dependencies = [ + "digest 0.9.0", "ff", "group", "pairing", @@ -139,7 +152,7 @@ dependencies = [ "regex", "serde", "serde_json", - "sha2 0.9.5", + "sha2 0.9.9", "tempfile", "unicode-segmentation", "wasm-bindgen", @@ -149,17 +162,21 @@ dependencies = [ [[package]] name = "clvmr" -version = "0.1.24" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5e907612d322d0d7def6b0ecb3ad681f6af2db106bcfabe4153746c60ef9e4" +checksum = "c2890f01537f1be43d2767ae71bbba0d0b3543dbb1ee892092d0ed4d913227fc" dependencies = [ "bls12_381", + "getrandom", + "group", "hex", + "k256", "lazy_static", "num-bigint", "num-integer", "num-traits", - "sha2 0.10.2", + "p256", + "sha2 0.9.9", ] [[package]] @@ -173,13 +190,10 @@ dependencies = [ ] [[package]] -name = "cpufeatures" -version = "0.1.5" +name = "const-oid" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" -dependencies = [ - "libc", -] +checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" [[package]] name = "cpufeatures" @@ -190,6 +204,18 @@ dependencies = [ "libc", ] +[[package]] +name = "crypto-bigint" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -200,6 +226,17 @@ dependencies = [ "typenum", ] +[[package]] +name = "der" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "derivative" version = "2.2.0" @@ -227,7 +264,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer 0.10.3", + "const-oid", "crypto-common", + "subtle", ] [[package]] @@ -236,6 +275,40 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e16a80c1dda2cf52fa07106427d3d798b6331dca8155fcb8c39f7fc78f6dd2" +[[package]] +name = "ecdsa" +version = "0.16.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" +dependencies = [ + "der", + "digest 0.10.6", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "elliptic-curve" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.6", + "ff", + "generic-array", + "group", + "pem-rfc7468", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "encoding8" version = "0.3.2" @@ -266,9 +339,9 @@ dependencies = [ [[package]] name = "ff" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "bitvec", "rand_core", @@ -283,19 +356,20 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "js-sys", @@ -306,9 +380,9 @@ dependencies = [ [[package]] name = "group" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core", @@ -330,6 +404,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + [[package]] name = "humantime" version = "2.1.0" @@ -389,6 +472,20 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "k256" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.2", + "signature", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -397,9 +494,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "linked-hash-map" @@ -511,9 +608,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.12.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "opaque-debug" @@ -521,11 +618,23 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.2", +] + [[package]] name = "pairing" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "135590d8bdba2b31346f9cd1fb2a912329f5135e832a4f422942eb6ead8b6b3b" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" dependencies = [ "group", ] @@ -574,12 +683,40 @@ dependencies = [ "proc-macro-hack", ] +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "ppv-lite86" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +[[package]] +name = "primeorder" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c2fcef82c0ec6eefcc179b978446c399b3cdf73c392c35604e399eee6df1ee3" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "proc-macro-hack" version = "0.5.19" @@ -690,9 +827,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] @@ -732,6 +869,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + [[package]] name = "ryu" version = "1.0.10" @@ -750,6 +897,20 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + [[package]] name = "serde" version = "1.0.137" @@ -783,13 +944,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.5" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if", - "cpufeatures 0.1.5", + "cpufeatures", "digest 0.9.0", "opaque-debug", ] @@ -801,8 +962,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" dependencies = [ "cfg-if", - "cpufeatures 0.2.5", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ "digest 0.10.6", + "rand_core", ] [[package]] @@ -811,6 +982,16 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +[[package]] +name = "spki" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "subtle" version = "2.4.1" @@ -1043,3 +1224,9 @@ checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ "linked-hash-map", ] + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" diff --git a/Cargo.toml b/Cargo.toml index 08dfe7a0d..0818ef94b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ python-source = "python" [dependencies] hex = "0.4.3" num-bigint = { version = "0.4.0", features = ["serde"] } -bls12_381 = "0.7.0" +bls12_381 = { version = "=0.8.0", features = ["experimental"] } bytestream = "0.4.1" num-traits = "0.2.14" lazy_static = "1.4.0" @@ -32,7 +32,7 @@ do-notation = "0.1.3" serde_json = "1.0" sha2 = "0.9.5" tempfile = "3.3.0" -clvmr = "0.1.24" +clvmr = { version = "0.2.6", features = ["pre-eval"] } env_logger = "0.9.0" log = "0.4.17" binascii = "0.1.4" @@ -61,7 +61,7 @@ js-sys = "0.3.58" getrandom = { version = "0.2", features = ["js"] } [target.'cfg(not(target_family="wasm"))'.dependencies] -pyo3 = { version = "0.14.2", features = ["abi3-py37", "extension-module"], optional = true } +pyo3 = { version = "0.14.2", features = ["abi3-py38", "extension-module"], optional = true } getrandom = { version = "0.2" } [build-dependencies] diff --git a/src/classic/clvm/serialize.rs b/src/classic/clvm/serialize.rs index 95ab47c63..05246789a 100644 --- a/src/classic/clvm/serialize.rs +++ b/src/classic/clvm/serialize.rs @@ -98,9 +98,11 @@ impl<'a> Iterator for SExpToBytesIterator<'a> { fn next(&mut self) -> Option { self.state.pop().and_then(|step| match step { SExpToByteOp::Object(x) => match self.allocator.sexp(x) { - SExp::Atom(b) => { - let buf = self.allocator.buf(&b).to_vec(); - let bytes = Bytes::new(Some(BytesFromType::Raw(buf.to_vec()))); + SExp::Atom() => { + // The only node we have in scope is x, so this atom + // capture is trivial. + let buf = self.allocator.atom(x).to_vec(); + let bytes = Bytes::new(Some(BytesFromType::Raw(buf.clone()))); match atom_size_blob(&bytes) { Ok((original, b)) => { if original { diff --git a/src/classic/clvm/sexp.rs b/src/classic/clvm/sexp.rs index 2cc433912..ef730eedd 100644 --- a/src/classic/clvm/sexp.rs +++ b/src/classic/clvm/sexp.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use std::rc::Rc; use std::string::String; -use clvm_rs::allocator::{Allocator, AtomBuf, NodePtr, SExp}; +use clvm_rs::allocator::{Allocator, NodePtr, SExp}; use clvm_rs::reduction::EvalErr; use bls12_381::G1Affine; @@ -150,7 +150,7 @@ pub fn to_sexp_type(allocator: &mut Allocator, value: CastableType) -> Result { + SExp::Atom() => { return Err(EvalErr( *target_value, "attempt to set_pair in atom".to_string(), @@ -335,7 +335,8 @@ pub fn bool_sexp(allocator: &mut Allocator, b: bool) -> NodePtr { pub fn non_nil(allocator: &mut Allocator, sexp: NodePtr) -> bool { match allocator.sexp(sexp) { SExp::Pair(_, _) => true, - SExp::Atom(b) => !b.is_empty(), + // sexp is the only node in scope, was !is_empty + SExp::Atom() => allocator.atom_len(sexp) != 0, } } @@ -353,9 +354,9 @@ pub fn rest(allocator: &mut Allocator, sexp: NodePtr) -> Result Result { +pub fn atom(allocator: &mut Allocator, sexp: NodePtr) -> Result, EvalErr> { match allocator.sexp(sexp) { - SExp::Atom(abuf) => Ok(abuf), + SExp::Atom() => Ok(allocator.atom(sexp).to_vec()), // only sexp in scope _ => Err(EvalErr(sexp, "not an atom".to_string())), } } @@ -365,7 +366,7 @@ pub fn proper_list(allocator: &mut Allocator, sexp: NodePtr, store: bool) -> Opt let mut args_sexp = sexp; loop { match allocator.sexp(args_sexp) { - SExp::Atom(_) => { + SExp::Atom() => { if !non_nil(allocator, args_sexp) { return Some(args); } else { @@ -453,10 +454,9 @@ pub fn equal_to(allocator: &mut Allocator, first_: NodePtr, second_: NodePtr) -> return true; } match (allocator.sexp(first), allocator.sexp(second)) { - (SExp::Atom(fbuf), SExp::Atom(sbuf)) => { - let fvec = allocator.buf(&fbuf); - let svec = allocator.buf(&sbuf); - return fvec == svec; + (SExp::Atom(), SExp::Atom()) => { + // two atoms in scope, both are used + return allocator.atom(first) == allocator.atom(second); } (SExp::Pair(ff, fr), SExp::Pair(rf, rr)) => { if !equal_to(allocator, ff, rf) { @@ -477,7 +477,7 @@ pub fn flatten(allocator: &mut Allocator, tree_: NodePtr, res: &mut Vec loop { match allocator.sexp(tree) { - SExp::Atom(_) => { + SExp::Atom() => { if non_nil(allocator, tree) { res.push(tree); } diff --git a/src/classic/clvm_tools/binutils.rs b/src/classic/clvm_tools/binutils.rs index 9e5e160ff..deac313cc 100644 --- a/src/classic/clvm_tools/binutils.rs +++ b/src/classic/clvm_tools/binutils.rs @@ -127,8 +127,9 @@ pub fn disassemble_to_ir_with_kw( IRRepr::Cons(Rc::new(v0), Rc::new(v1)) } - SExp::Atom(a) => { - let bytes = Bytes::new(Some(BytesFromType::Raw(allocator.buf(&a).to_vec()))); + SExp::Atom() => { + // sexp is the only node in scope. + let bytes = Bytes::new(Some(BytesFromType::Raw(allocator.atom(sexp).to_vec()))); ir_for_atom(&bytes, allow_keyword, keyword_from_atom) } } @@ -139,7 +140,7 @@ pub fn disassemble_with_kw( sexp: NodePtr, keyword_from_atom: &Record, String>, ) -> String { - let with_keywords = !matches!(allocator.sexp(sexp), SExp::Atom(_)); + let with_keywords = !matches!(allocator.sexp(sexp), SExp::Atom()); let symbols = disassemble_to_ir_with_kw(allocator, sexp, keyword_from_atom, with_keywords); write_ir(Rc::new(symbols)) } diff --git a/src/classic/clvm_tools/clvmc.rs b/src/classic/clvm_tools/clvmc.rs index 27bb88d0c..9c0a9d33f 100644 --- a/src/classic/clvm_tools/clvmc.rs +++ b/src/classic/clvm_tools/clvmc.rs @@ -118,7 +118,7 @@ pub fn compile_clvm_inner( ) -> Result<(), String> { let result = compile_clvm_text( allocator, - opts, + opts.clone(), symbol_table, text, filename, diff --git a/src/classic/clvm_tools/debug.rs b/src/classic/clvm_tools/debug.rs index 761a5640f..bbed5519b 100644 --- a/src/classic/clvm_tools/debug.rs +++ b/src/classic/clvm_tools/debug.rs @@ -180,7 +180,7 @@ fn table_trace( ) { let (sexp, args) = match allocator.sexp(form) { SExp::Pair(sexp, args) => (sexp, args), - SExp::Atom(_) => (form, allocator.null()), + SExp::Atom() => (form, allocator.null()), }; stdout.write_str(&format!("exp: {}\n", disassemble_f(allocator, sexp))); diff --git a/src/classic/clvm_tools/pattern_match.rs b/src/classic/clvm_tools/pattern_match.rs index df24d3c77..0df1345cd 100644 --- a/src/classic/clvm_tools/pattern_match.rs +++ b/src/classic/clvm_tools/pattern_match.rs @@ -51,40 +51,34 @@ pub fn match_sexp( */ match (allocator.sexp(pattern), allocator.sexp(sexp)) { - (SExp::Atom(pat_buf), SExp::Atom(sexp_buf)) => { - let sexp_bytes = allocator.buf(&sexp_buf).to_vec(); - if allocator.buf(&pat_buf).to_vec() == sexp_bytes { + (SExp::Atom(), SExp::Atom()) => { + // Two nodes in scope, both used. + if allocator.atom(pattern) == allocator.atom(sexp) { Some(known_bindings) } else { None } } (SExp::Pair(pleft, pright), _) => match (allocator.sexp(pleft), allocator.sexp(pright)) { - (SExp::Atom(pat_left), SExp::Atom(pat_right)) => { - let pat_right_bytes = allocator.buf(&pat_right).to_vec(); - let pat_left_bytes = allocator.buf(&pat_left).to_vec(); - + (SExp::Atom(), SExp::Atom()) => { + let pright_atom = allocator.atom(pright).to_vec(); match allocator.sexp(sexp) { - SExp::Atom(sexp_buf) => { - let sexp_bytes = allocator.buf(&sexp_buf).to_vec(); - if pat_left_bytes == ATOM_MATCH.to_vec() { - if pat_right_bytes == ATOM_MATCH.to_vec() { - if sexp_bytes == ATOM_MATCH.to_vec() { + SExp::Atom() => { + // Expression is ($ . $), sexp is '$', result: no capture. + // Avoid double borrow. + if allocator.atom(pleft) == ATOM_MATCH { + if allocator.atom(pright) == ATOM_MATCH { + if allocator.atom(sexp) == ATOM_MATCH { return Some(HashMap::new()); } return None; } - return unify_bindings( - allocator, - known_bindings, - &pat_right_bytes, - sexp, - ); + return unify_bindings(allocator, known_bindings, &pright_atom, sexp); } - if pat_left_bytes == SEXP_MATCH.to_vec() { - if pat_right_bytes == SEXP_MATCH.to_vec() - && sexp_bytes == SEXP_MATCH.to_vec() + if allocator.atom(pleft) == SEXP_MATCH { + if allocator.atom(pright) == SEXP_MATCH + && allocator.atom(sexp) == SEXP_MATCH { return Some(HashMap::new()); } @@ -92,7 +86,8 @@ pub fn match_sexp( return unify_bindings( allocator, known_bindings, - &pat_right_bytes, + // pat_right_bytes + &pright_atom, sexp, ); } @@ -100,13 +95,14 @@ pub fn match_sexp( None } SExp::Pair(sleft, sright) => { - if pat_left_bytes == SEXP_MATCH.to_vec() - && pat_right_bytes != SEXP_MATCH.to_vec() + if allocator.atom(pleft) == SEXP_MATCH + && allocator.atom(pright) != SEXP_MATCH { return unify_bindings( allocator, known_bindings, - &pat_right_bytes, + // pat_right_bytes + &pright_atom, sexp, ); } @@ -118,11 +114,11 @@ pub fn match_sexp( } } _ => match allocator.sexp(sexp) { - SExp::Atom(_) => None, + SExp::Atom() => None, SExp::Pair(sleft, sright) => match_sexp(allocator, pleft, sleft, known_bindings) .and_then(|new_bindings| match_sexp(allocator, pright, sright, new_bindings)), }, }, - (SExp::Atom(_), _) => None, + (SExp::Atom(), _) => None, } } diff --git a/src/classic/clvm_tools/sha256tree.rs b/src/classic/clvm_tools/sha256tree.rs index 3c9986cc3..0212d0c78 100644 --- a/src/classic/clvm_tools/sha256tree.rs +++ b/src/classic/clvm_tools/sha256tree.rs @@ -34,9 +34,10 @@ pub fn sha256tree(allocator: &mut Allocator, v: NodePtr) -> Bytes { .concat(&right), ) } - SExp::Atom(a) => sha256( + SExp::Atom() => sha256( Bytes::new(Some(BytesFromType::Raw(vec![1]))).concat(&Bytes::new(Some( - BytesFromType::Raw(allocator.buf(&a).to_vec()), + // only v in scope. + BytesFromType::Raw(allocator.atom(v).to_vec()), ))), ), } diff --git a/src/classic/clvm_tools/stages/stage_0.rs b/src/classic/clvm_tools/stages/stage_0.rs index a447b90bb..6292411b1 100644 --- a/src/classic/clvm_tools/stages/stage_0.rs +++ b/src/classic/clvm_tools/stages/stage_0.rs @@ -1,9 +1,9 @@ use clvm_rs::allocator::{Allocator, NodePtr}; -use clvm_rs::chia_dialect::{ChiaDialect, NO_NEG_DIV, NO_UNKNOWN_OPS}; +use clvm_rs::chia_dialect::{ChiaDialect, ENABLE_BLS_OPS, ENABLE_SECP_OPS, NO_UNKNOWN_OPS}; use clvm_rs::cost::Cost; use clvm_rs::reduction::Response; -use clvm_rs::run_program::{run_program, PreEval}; +use clvm_rs::run_program::{run_program_with_pre_eval, PreEval}; pub struct RunProgramOption { pub max_cost: Option, @@ -45,9 +45,9 @@ impl TRunProgram for DefaultProgramRunner { ) -> Response { let max_cost = option.as_ref().and_then(|o| o.max_cost).unwrap_or(0); - run_program( + run_program_with_pre_eval( allocator, - &ChiaDialect::new(NO_NEG_DIV | NO_UNKNOWN_OPS), + &ChiaDialect::new(NO_UNKNOWN_OPS | ENABLE_BLS_OPS | ENABLE_SECP_OPS), program, args, max_cost, diff --git a/src/classic/clvm_tools/stages/stage_2/compile.rs b/src/classic/clvm_tools/stages/stage_2/compile.rs index 4fe0a399f..24e25538a 100644 --- a/src/classic/clvm_tools/stages/stage_2/compile.rs +++ b/src/classic/clvm_tools/stages/stage_2/compile.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, HashSet}; use std::rc::Rc; -use clvm_rs::allocator::{Allocator, AtomBuf, NodePtr, SExp}; +use clvm_rs::allocator::{Allocator, NodePtr, SExp}; use clvm_rs::reduction::{EvalErr, Reduction, Response}; use crate::classic::clvm::__type_compatibility__::{Bytes, BytesFromType}; @@ -127,13 +127,14 @@ pub fn compile_qq( }; match allocator.sexp(sexp) { - SExp::Atom(_) => { + SExp::Atom() => { // (qq ATOM) => (q . ATOM) quote(allocator, sexp) } SExp::Pair(op, sexp_rest) => { - if let SExp::Atom(opbuf) = allocator.sexp(op) { - if allocator.buf(&opbuf).to_vec() == qq_atom() { + if let SExp::Atom() = allocator.sexp(op) { + // opbuf => op + if allocator.atom(op).to_vec() == qq_atom() { return m! { cons_atom <- allocator.new_atom(&[4]); subexp <- @@ -143,7 +144,8 @@ pub fn compile_qq( run_list <- enlist(allocator, &[cons_atom, op, consed]); com_qq(allocator, "qq sexp pair".to_string(), macro_lookup, symbol_table, runner, run_list) }; - } else if allocator.buf(&opbuf).to_vec() == unquote_atom() { + } else if allocator.atom(op).to_vec() == unquote_atom() { + // opbuf if level == 1 { // (qq (unquote X)) => X return m! { @@ -212,8 +214,10 @@ fn lower_quote_(allocator: &mut Allocator, prog: NodePtr) -> Result { - if allocator.buf(¯o_name).to_vec() == *operator { + SExp::Atom() => { + // was macro_name, but it's singular and probably + // not useful to rename. + if allocator.atom(mp_list[0]) == operator { return Ok(Some(value)); } } @@ -362,10 +368,10 @@ fn get_macro_program( fn transform_program_atom( allocator: &mut Allocator, prog: NodePtr, - a: &AtomBuf, + a: &[u8], symbol_table: NodePtr, ) -> Response { - if allocator.buf(a).to_vec() == "@".as_bytes().to_vec() { + if a == b"@" { return allocator .new_atom(NodePath::new(None).as_path().data()) .map(|x| Reduction(1, x)); @@ -384,8 +390,10 @@ fn transform_program_atom( let value = if v.len() > 1 { v[1] } else { allocator.null() }; match allocator.sexp(v[0]) { - SExp::Atom(s) => { - if allocator.buf(&s).to_vec() == allocator.buf(a).to_vec() { + SExp::Atom() => { + // v[0] is close by, and probably not useful to + // rename here. + if allocator.atom(v[0]) == a { return Ok(Reduction(1, value)); } } @@ -459,7 +467,7 @@ fn find_symbol_match( } match allocator.sexp(symdef[0]) { - SExp::Atom(symptr) => { + SExp::Atom() => { let symbol = symdef[0]; let value = if symdef.len() == 1 { allocator.null() @@ -467,10 +475,10 @@ fn find_symbol_match( symdef[1] }; - let symbuf = allocator.buf(&symptr).to_vec(); - if vec![b'*'] == symbuf { + let symbuf = allocator.atom(symdef[0]); + if b"*" == symbuf { return Ok(Some(SymbolResult::Direct(r))); - } else if *opname == symbuf { + } else if opname == symbuf { return Ok(Some(SymbolResult::Matched(symbol, value))); } } @@ -635,18 +643,21 @@ fn do_com_prog_( // quote atoms match allocator.sexp(prog) { - SExp::Atom(a) => { + SExp::Atom() => { + // Note: can't co-borrow with allocator below. + let prog_bytes = allocator.atom(prog).to_vec(); transform_program_atom( allocator, prog, - &a, + &prog_bytes, symbol_table ) }, SExp::Pair(operator,prog_rest) => { match allocator.sexp(operator) { - SExp::Atom(a) => { - let opbuf = allocator.buf(&a).to_vec(); + SExp::Atom() => { + // Note: can't co-borrow with allocator below. + let opbuf = allocator.atom(operator).to_vec(); get_macro_program(allocator, &opbuf, macro_lookup). and_then(|x| match x { Some(value) => { @@ -770,14 +781,16 @@ pub fn get_compile_filename( ) -> Result, EvalErr> { let cvt_prog = assemble(allocator, "(_get_compile_filename)")?; - let cvt_prog_result = runner.run_program(allocator, cvt_prog, allocator.null(), None)?; + let Reduction(_, cvt_prog_result) = + runner.run_program(allocator, cvt_prog, allocator.null(), None)?; - if cvt_prog_result.1 == allocator.null() { + if cvt_prog_result == allocator.null() { return Ok(None); } - if let SExp::Atom(buf) = allocator.sexp(cvt_prog_result.1) { - let abuf = allocator.buf(&buf).to_vec(); + if let SExp::Atom() = allocator.sexp(cvt_prog_result) { + // only cvt_prog_result in scope. + let abuf = allocator.atom(cvt_prog_result).to_vec(); return Ok(Some(Bytes::new(Some(BytesFromType::Raw(abuf))).decode())); } @@ -797,10 +810,12 @@ pub fn get_search_paths( let mut res = Vec::new(); if let Some(l) = proper_list(allocator, search_path_result.1, true) { - for elt in l.iter() { - if let SExp::Atom(buf) = allocator.sexp(*elt) { - let abuf = allocator.buf(&buf).to_vec(); - res.push(Bytes::new(Some(BytesFromType::Raw(abuf))).decode()); + for elt in l.iter().copied() { + if let SExp::Atom() = allocator.sexp(elt) { + // Only elt in scope. + res.push( + Bytes::new(Some(BytesFromType::Raw(allocator.atom(elt).to_vec()))).decode(), + ); } } } @@ -878,8 +893,9 @@ pub fn process_compile_file( let r_of_declaration = rest(allocator, declaration_sexp)?; let rr_of_declaration = rest(allocator, r_of_declaration)?; let frr_of_declaration = first(allocator, rr_of_declaration)?; - if let SExp::Atom(b) = allocator.sexp(frr_of_declaration) { - let b_name = allocator.buf(&b).to_vec(); + if let SExp::Atom() = allocator.sexp(frr_of_declaration) { + // frr_of_declaration, bound above. + let b_name = allocator.atom(frr_of_declaration).to_vec(); let compiled_output = compile_file( runner, allocator, diff --git a/src/classic/clvm_tools/stages/stage_2/inline.rs b/src/classic/clvm_tools/stages/stage_2/inline.rs index c989b6ad0..e47abbf73 100644 --- a/src/classic/clvm_tools/stages/stage_2/inline.rs +++ b/src/classic/clvm_tools/stages/stage_2/inline.rs @@ -15,11 +15,11 @@ pub fn is_at_capture( tree_first: NodePtr, tree_rest: NodePtr, ) -> Option<(NodePtr, NodePtr)> { - if let (SExp::Atom(a), Some(spec)) = ( + if let (SExp::Atom(), Some(spec)) = ( allocator.sexp(tree_first), proper_list(allocator, tree_rest, true), ) { - if allocator.buf(&a) == [b'@'] && spec.len() == 2 { + if allocator.atom(tree_first) == b"@" && spec.len() == 2 { return Some((spec[0], spec[1])); } } @@ -88,7 +88,7 @@ fn formulate_path_selections_for_destructuring_arg( SExp::Pair(a, b) => { let next_depth = arg_depth.clone() * 2_u32.to_bigint().unwrap(); if let Some((capture, substructure)) = is_at_capture(allocator, a, b) { - if let SExp::Atom(cbuf) = allocator.sexp(capture) { + if let SExp::Atom() = allocator.sexp(capture) { let (new_arg_path, new_arg_depth, tail) = if let Some(prev_ref) = referenced_from { (arg_path, arg_depth, prev_ref) @@ -99,7 +99,8 @@ fn formulate_path_selections_for_destructuring_arg( (bi_zero(), bi_one(), qtail) }; - selections.insert(allocator.buf(&cbuf).to_vec(), tail); + // Was cbuf from capture. + selections.insert(allocator.atom(capture).to_vec(), tail); return formulate_path_selections_for_destructuring_arg( allocator, @@ -146,8 +147,9 @@ fn formulate_path_selections_for_destructuring_arg( ) } } - SExp::Atom(b) => { - let buf = allocator.buf(&b).to_vec(); + SExp::Atom() => { + // Note: can't co-borrow with allocator below. + let buf = allocator.atom(arg_sexp).to_vec(); if !buf.is_empty() { if let Some(capture) = referenced_from { let tail = wrap_path_selection(allocator, arg_path + arg_depth, capture)?; @@ -223,10 +225,11 @@ pub fn formulate_path_selections_for_destructuring( ) -> Result { if let SExp::Pair(a, b) = allocator.sexp(args_sexp) { if let Some((capture, substructure)) = is_at_capture(allocator, a, b) { - if let SExp::Atom(cbuf) = allocator.sexp(capture) { + if let SExp::Atom() = allocator.sexp(capture) { let quoted_arg_list = wrap_in_unquote(allocator, capture)?; let tail = wrap_in_compile_time_list(allocator, quoted_arg_list)?; - let buf = allocator.buf(&cbuf); + // Was: cbuf from capture. + let buf = allocator.atom(capture); selections.insert(buf.to_vec(), tail); let newsub = formulate_path_selections_for_destructuring_arg( allocator, diff --git a/src/classic/clvm_tools/stages/stage_2/module.rs b/src/classic/clvm_tools/stages/stage_2/module.rs index e6df67597..99631223c 100644 --- a/src/classic/clvm_tools/stages/stage_2/module.rs +++ b/src/classic/clvm_tools/stages/stage_2/module.rs @@ -146,8 +146,9 @@ fn build_used_constants_names( .collect::>(); let matching_names = matching_names_1.iter().filter_map(|v| { - if let SExp::Atom(b) = allocator.sexp(*v) { - Some(allocator.buf(&b).to_vec()) + // Only v usefully in scope. + if let SExp::Atom() = allocator.sexp(*v) { + Some(allocator.atom(*v).to_vec()) } else { None } @@ -224,8 +225,9 @@ fn unquote_args( matches: &HashMap, NodePtr>, ) -> Result { match allocator.sexp(code) { - SExp::Atom(code_buf) => { - let code_atom = allocator.buf(&code_buf); + SExp::Atom() => { + // Only code in scope. + let code_atom = allocator.atom(code); let matching_args = args .iter() .filter(|arg| *arg == code_atom) @@ -285,8 +287,9 @@ fn defun_inline_to_macro( let arg_name_list = arg_atom_list .iter() .filter_map(|x| { - if let SExp::Atom(a) = allocator.sexp(*x) { - Some(allocator.buf(&a)) + if let SExp::Atom() = allocator.sexp(*x) { + // only x usefully in scope. + Some(allocator.atom(*x)) } else { None } @@ -323,11 +326,13 @@ fn parse_mod_sexp( .select_nodes(allocator, declaration_sexp)?; let op = match allocator.sexp(op_node) { - SExp::Atom(b) => allocator.buf(&b).to_vec(), + // op_node in use. + SExp::Atom() => allocator.atom(op_node).to_vec(), _ => Vec::new(), }; let name = match allocator.sexp(name_node) { - SExp::Atom(b) => allocator.buf(&b).to_vec(), + // name_node in use. + SExp::Atom() => allocator.atom(name_node).to_vec(), _ => Vec::new(), }; @@ -552,7 +557,7 @@ fn symbol_table_for_tree( } match allocator.sexp(tree) { - SExp::Atom(_) => Ok(vec![(tree, root_node.as_path().data().to_vec())]), + SExp::Atom() => Ok(vec![(tree, root_node.as_path().data().to_vec())]), SExp::Pair(_, _) => { let left_bytes = NodePath::new(None).first(); let right_bytes = NodePath::new(None).rest(); diff --git a/src/classic/clvm_tools/stages/stage_2/operators.rs b/src/classic/clvm_tools/stages/stage_2/operators.rs index 5aea4c2b6..c9913dd62 100644 --- a/src/classic/clvm_tools/stages/stage_2/operators.rs +++ b/src/classic/clvm_tools/stages/stage_2/operators.rs @@ -5,11 +5,11 @@ use std::path::PathBuf; use std::rc::Rc; use clvm_rs::allocator::{Allocator, NodePtr, SExp}; -use clvm_rs::chia_dialect::{ChiaDialect, NO_NEG_DIV, NO_UNKNOWN_OPS}; +use clvm_rs::chia_dialect::{ChiaDialect, ENABLE_BLS_OPS, ENABLE_SECP_OPS, NO_UNKNOWN_OPS}; use clvm_rs::cost::Cost; -use clvm_rs::dialect::Dialect; +use clvm_rs::dialect::{Dialect, OperatorSet}; use clvm_rs::reduction::{EvalErr, Reduction, Response}; -use clvm_rs::run_program::run_program; +use clvm_rs::run_program::run_program_with_pre_eval; use crate::classic::clvm::__type_compatibility__::{Bytes, BytesFromType, Stream}; @@ -119,7 +119,9 @@ impl Drop for CompilerOperators { impl CompilerOperatorsInternal { pub fn new(source_file: &str, search_paths: Vec, symbols_extra_info: bool) -> Self { - let base_dialect = Rc::new(ChiaDialect::new(NO_NEG_DIV | NO_UNKNOWN_OPS)); + let base_dialect = Rc::new(ChiaDialect::new( + NO_UNKNOWN_OPS | ENABLE_BLS_OPS | ENABLE_SECP_OPS, + )); let base_runner = Rc::new(DefaultProgramRunner::new()); CompilerOperatorsInternal { base_dialect, @@ -177,9 +179,9 @@ impl CompilerOperatorsInternal { match allocator.sexp(sexp) { SExp::Pair(f, _) => match allocator.sexp(f) { - SExp::Atom(b) => { + SExp::Atom() => { let filename = - Bytes::new(Some(BytesFromType::Raw(allocator.buf(&b).to_vec()))).decode(); + Bytes::new(Some(BytesFromType::Raw(allocator.atom(f).to_vec()))).decode(); // Use the read interface in CompilerOpts if we have one. if let Some(opts) = self.get_compiler_opts() { if let Ok((_, content)) = @@ -210,8 +212,8 @@ impl CompilerOperatorsInternal { fn write(&self, allocator: &mut Allocator, sexp: NodePtr) -> Response { if let SExp::Pair(filename_sexp, r) = allocator.sexp(sexp) { if let SExp::Pair(data, _) = allocator.sexp(r) { - if let SExp::Atom(filename_buf) = allocator.sexp(filename_sexp) { - let filename_buf = allocator.buf(&filename_buf); + if let SExp::Atom() = allocator.sexp(filename_sexp) { + let filename_buf = allocator.atom(filename_sexp); let filename_bytes = Bytes::new(Some(BytesFromType::Raw(filename_buf.to_vec()))); let ir = disassemble_to_ir_with_kw(allocator, data, keyword_from_atom(), true); @@ -252,9 +254,10 @@ impl CompilerOperatorsInternal { }; if let SExp::Pair(l, _r) = allocator.sexp(sexp) { - if let SExp::Atom(b) = allocator.sexp(l) { + if let SExp::Atom() = allocator.sexp(l) { + // l most relevant in scope. let filename = - Bytes::new(Some(BytesFromType::Raw(allocator.buf(&b).to_vec()))).decode(); + Bytes::new(Some(BytesFromType::Raw(allocator.atom(l).to_vec()))).decode(); // If we have a compiler opts injected, let that handle reading // files. The name will bubble up to the _read function. if self.get_compiler_opts().is_some() { @@ -285,14 +288,15 @@ impl CompilerOperatorsInternal { { for kv in symtable.iter() { if let SExp::Pair(hash, name) = allocator.sexp(*kv) { - if let (SExp::Atom(hash), SExp::Atom(name)) = + if let (SExp::Atom(), SExp::Atom()) = (allocator.sexp(hash), allocator.sexp(name)) { + // hash and name in scope. let hash_text = - Bytes::new(Some(BytesFromType::Raw(allocator.buf(&hash).to_vec()))) + Bytes::new(Some(BytesFromType::Raw(allocator.atom(hash).to_vec()))) .decode(); let name_text = - Bytes::new(Some(BytesFromType::Raw(allocator.buf(&name).to_vec()))) + Bytes::new(Some(BytesFromType::Raw(allocator.atom(name).to_vec()))) .decode(); self.compile_outcomes.replace_with(|co| { @@ -310,26 +314,39 @@ impl CompilerOperatorsInternal { } impl Dialect for CompilerOperatorsInternal { - fn val_stack_limit(&self) -> usize { - 10000000 - } fn quote_kw(&self) -> &[u8] { &[1] } + fn apply_kw(&self) -> &[u8] { &[2] } + fn softfork_kw(&self) -> &[u8] { + &[36] + } + + // The softfork operator comes with an extension argument. + fn softfork_extension(&self, ext: u32) -> OperatorSet { + match ext { + 0 => OperatorSet::BLS, + // new extensions go here + _ => OperatorSet::Default, + } + } + fn op( &self, allocator: &mut Allocator, op: NodePtr, sexp: NodePtr, max_cost: Cost, + extension: OperatorSet, ) -> Response { match allocator.sexp(op) { - SExp::Atom(opname) => { - let opbuf = allocator.buf(&opname); + SExp::Atom() => { + // use of op obvious. + let opbuf = allocator.atom(op); if opbuf == "_read".as_bytes() { self.read(allocator, sexp) } else if opbuf == "_write".as_bytes() { @@ -351,12 +368,19 @@ impl Dialect for CompilerOperatorsInternal { } else if opbuf == "_get_source_file".as_bytes() { self.get_source_file(allocator) } else { - self.base_dialect.op(allocator, op, sexp, max_cost) + self.base_dialect + .op(allocator, op, sexp, max_cost, extension) } } - _ => self.base_dialect.op(allocator, op, sexp, max_cost), + _ => self + .base_dialect + .op(allocator, op, sexp, max_cost, extension), } } + + fn allow_unknown_ops(&self) -> bool { + false + } } impl CompilerOperatorsInternal { @@ -384,7 +408,7 @@ impl TRunProgram for CompilerOperatorsInternal { option: Option, ) -> Response { let max_cost = option.as_ref().and_then(|o| o.max_cost).unwrap_or(0); - run_program( + run_program_with_pre_eval( allocator, self, program, diff --git a/src/classic/clvm_tools/stages/stage_2/optimize.rs b/src/classic/clvm_tools/stages/stage_2/optimize.rs index 7fde38552..5e1e2306d 100644 --- a/src/classic/clvm_tools/stages/stage_2/optimize.rs +++ b/src/classic/clvm_tools/stages/stage_2/optimize.rs @@ -41,7 +41,7 @@ pub fn seems_constant_tail(allocator: &mut Allocator, sexp_: NodePtr) -> bool { sexp = r; } - SExp::Atom(_) => { + SExp::Atom() => { return sexp == allocator.null(); } } @@ -50,13 +50,14 @@ pub fn seems_constant_tail(allocator: &mut Allocator, sexp_: NodePtr) -> bool { pub fn seems_constant(allocator: &mut Allocator, sexp: NodePtr) -> bool { match allocator.sexp(sexp) { - SExp::Atom(_b) => { + SExp::Atom() => { return sexp == allocator.null(); } SExp::Pair(operator, r) => { match allocator.sexp(operator) { - SExp::Atom(b) => { - let atom = allocator.buf(&b); + SExp::Atom() => { + // Was buf of operator. + let atom = allocator.atom(operator); if atom.len() == 1 && atom[0] == 1 { return true; } else if atom.len() == 1 && atom[0] == 8 { @@ -91,8 +92,9 @@ pub fn constant_optimizer( * return the quoted result. */ if let SExp::Pair(first, _) = allocator.sexp(r) { - if let SExp::Atom(b) = allocator.sexp(first) { - let buf = allocator.buf(&b); + // first relevant in scope. + if let SExp::Atom() = allocator.sexp(first) { + let buf = allocator.atom(first); if buf.len() == 1 && buf[0] == 1 { // Short circuit already quoted expression. return Ok(r); @@ -135,8 +137,9 @@ pub fn constant_optimizer( } pub fn is_args_call(allocator: &mut Allocator, r: NodePtr) -> bool { - if let SExp::Atom(b) = allocator.sexp(r) { - let buf = allocator.buf(&b); + if let SExp::Atom() = allocator.sexp(r) { + // Only r in scope. + let buf = allocator.atom(r); buf.len() == 1 && buf[0] == 1 } else { false @@ -217,8 +220,9 @@ fn path_from_args( new_args: NodePtr, ) -> Result { match allocator.sexp(sexp) { - SExp::Atom(v_buf) => { - let v = number_from_u8(allocator.buf(&v_buf)); + SExp::Atom() => { + // Only sexp in scope. + let v = number_from_u8(allocator.atom(sexp)); if v <= bi_one() { Ok(new_args) } else { @@ -242,7 +246,7 @@ pub fn sub_args( new_args: NodePtr, ) -> Result { match allocator.sexp(sexp) { - SExp::Atom(_) => path_from_args(allocator, sexp, new_args), + SExp::Atom() => path_from_args(allocator, sexp, new_args), SExp::Pair(first_pre, rest) => { let first; @@ -250,8 +254,9 @@ pub fn sub_args( SExp::Pair(_, _) => { first = sub_args(allocator, first_pre, new_args)?; } - SExp::Atom(b) => { - let atom = allocator.buf(&b); + SExp::Atom() => { + // Atom is a reflection of first_pre. + let atom = allocator.atom(first_pre); if atom.len() == 1 && atom[0] == 1 { return Ok(sexp); } else { @@ -369,8 +374,9 @@ pub fn var_change_optimizer_cons_eval( } let increment = match allocator.sexp(val) { SExp::Pair(val_first, _) => match allocator.sexp(val_first) { - SExp::Atom(b) => { - let vf_buf = allocator.buf(&b); + SExp::Atom() => { + // Atom reflects val_first. + let vf_buf = allocator.atom(val_first); (vf_buf.len() != 1 || vf_buf[0] != 1) as i32 } _ => 0, @@ -413,8 +419,8 @@ pub fn children_optimizer( if list.is_empty() { return Ok(r); } - if let SExp::Atom(op_buf) = allocator.sexp(list[0]) { - if allocator.buf(&op_buf).to_vec() == vec![1] { + if let SExp::Atom() = allocator.sexp(list[0]) { + if allocator.atom(list[0]).to_vec() == vec![1] { return Ok(r); } } @@ -518,7 +524,7 @@ fn path_optimizer( match first. get("atom"). and_then(|a| atom(allocator, *a).ok()). - map(|atom| number_from_u8(allocator.buf(&atom))) + map(|atom| number_from_u8(&atom)) { Some(atom) => { let node = @@ -533,7 +539,7 @@ fn path_optimizer( match rest. get("atom"). and_then(|a| atom(allocator, *a).ok()). - map(|atom| number_from_u8(allocator.buf(&atom))) + map(|atom| number_from_u8(&atom)) { Some(atom) => { let node = @@ -677,7 +683,7 @@ pub fn optimize_sexp_( let mut name = "".to_string(); match allocator.sexp(r) { - SExp::Atom(_) => { + SExp::Atom() => { return Ok(r); } SExp::Pair(_, _) => { diff --git a/src/classic/clvm_tools/stages/stage_2/reader.rs b/src/classic/clvm_tools/stages/stage_2/reader.rs index 0ff21e906..bc91c89b4 100644 --- a/src/classic/clvm_tools/stages/stage_2/reader.rs +++ b/src/classic/clvm_tools/stages/stage_2/reader.rs @@ -90,16 +90,16 @@ pub fn process_embed_file( )); } - if let (SExp::Atom(name), SExp::Atom(kind), SExp::Atom(filename)) = ( + if let (SExp::Atom(), SExp::Atom(), SExp::Atom()) = ( allocator.sexp(l[0]), allocator.sexp(l[1]), allocator.sexp(l[2]), ) { // Note: we don't want to keep borrowing here because we // need the mutable borrow below. - let name_buf = allocator.buf(&name).to_vec(); - let kind_buf = allocator.buf(&kind).to_vec(); - let filename_buf = allocator.buf(&filename).to_vec(); + let name_buf = allocator.atom(l[0]).to_vec(); + let kind_buf = allocator.atom(l[1]); + let filename_buf = allocator.atom(l[2]).to_vec(); let file_data = if kind_buf == b"bin" { let file = read_file( runner, @@ -128,7 +128,7 @@ pub fn process_embed_file( return Err(EvalErr(declaration_sexp, "no such embed kind".to_string())); }; - Ok((name_buf, quote(allocator, file_data)?)) + Ok((name_buf.to_vec(), quote(allocator, file_data)?)) } else { Err(EvalErr( declaration_sexp, diff --git a/src/compiler/clvm.rs b/src/compiler/clvm.rs index 13fca0eb5..db7dabada 100644 --- a/src/compiler/clvm.rs +++ b/src/compiler/clvm.rs @@ -264,11 +264,11 @@ pub fn convert_from_clvm_rs( head: NodePtr, ) -> Result, RunFailure> { match allocator.sexp(head) { - allocator::SExp::Atom(h) => { - if h.is_empty() { + allocator::SExp::Atom() => { + let atom_data = allocator.atom(head); + if atom_data.is_empty() { Ok(Rc::new(SExp::Nil(loc))) } else { - let atom_data = allocator.buf(&h); let integer = number_from_u8(atom_data); // Ensure that atom values that don't evaluate equal to integers // are represented faithfully as atoms. diff --git a/src/compiler/dialect.rs b/src/compiler/dialect.rs index 062cb47c2..9c8ef7d03 100644 --- a/src/compiler/dialect.rs +++ b/src/compiler/dialect.rs @@ -86,9 +86,14 @@ lazy_static! { } fn include_dialect(allocator: &mut Allocator, e: &[NodePtr]) -> Option { - if let (SExp::Atom(inc), SExp::Atom(name)) = (allocator.sexp(e[0]), allocator.sexp(e[1])) { - if allocator.buf(&inc) == "include".as_bytes().to_vec() { - if let Some(dialect) = KNOWN_DIALECTS.get(&decode_string(allocator.buf(&name))) { + let include_keyword_sexp = e[0]; + let name_sexp = e[1]; + if let (SExp::Atom(), SExp::Atom()) = ( + allocator.sexp(include_keyword_sexp), + allocator.sexp(name_sexp), + ) { + if allocator.atom(include_keyword_sexp) == "include".as_bytes().to_vec() { + if let Some(dialect) = KNOWN_DIALECTS.get(&decode_string(allocator.atom(name_sexp))) { return Some(dialect.accepted.clone()); } } diff --git a/src/tests/classic/smoke.rs b/src/tests/classic/smoke.rs index e7a7d6639..bb4b2e680 100644 --- a/src/tests/classic/smoke.rs +++ b/src/tests/classic/smoke.rs @@ -1,5 +1,6 @@ use num_bigint::ToBigInt; +use std::collections::HashMap; use std::fs; use std::io; use std::path::PathBuf; @@ -20,9 +21,11 @@ use crate::classic::clvm_tools::binutils::{assemble, assemble_from_ir, disassemb use crate::classic::clvm_tools::ir::r#type::IRRepr; use crate::classic::clvm_tools::ir::reader::read_ir; use crate::classic::clvm_tools::node_path::NodePath; +use crate::classic::clvm_tools::pattern_match::match_sexp; use crate::classic::clvm_tools::stages; use crate::classic::clvm_tools::stages::stage_0::{DefaultProgramRunner, TRunProgram}; use crate::classic::clvm_tools::stages::stage_2::operators::run_program_for_search_paths; +use crate::classic::clvm_tools::stages::stage_2::optimize::sub_args; use crate::classic::platform::argparse::{ Argument, ArgumentParser, NArgsSpec, TArgumentParserProps, }; @@ -139,8 +142,8 @@ fn mid_negative_value_bin() { Box::new(SimpleCreateCLVMObject {}), ) .expect("should be able to make nodeptr"); - if let SExp::Atom(abuf) = allocator.sexp(atom.1) { - let res_bytes = allocator.buf(&abuf); + if let SExp::Atom() = allocator.sexp(atom.1) { + let res_bytes = allocator.atom(atom.1); assert_eq!(res_bytes, &[0xff, 0xff]); } else { assert!(false); @@ -267,8 +270,8 @@ fn can_run_from_source_nil() { let mut allocator = Allocator::new(); let res = run_from_source(&mut allocator, "()".to_string()); match allocator.sexp(res) { - SExp::Atom(b) => { - let res_bytes = allocator.buf(&b).to_vec(); + SExp::Atom() => { + let res_bytes = allocator.atom(res); assert_eq!(res_bytes.len(), 0); } _ => { @@ -282,8 +285,8 @@ fn can_echo_quoted_nil() { let mut allocator = Allocator::new(); let res = run_from_source(&mut allocator, "(1)".to_string()); match allocator.sexp(res) { - SExp::Atom(b) => { - let res_bytes = allocator.buf(&b).to_vec(); + SExp::Atom() => { + let res_bytes = allocator.atom(res); assert_eq!(res_bytes.len(), 0); } _ => { @@ -313,8 +316,8 @@ fn can_echo_quoted_atom() { let mut allocator = Allocator::new(); let res = run_from_source(&mut allocator, "(1 . 3)".to_string()); match allocator.sexp(res) { - SExp::Atom(b) => { - let res_bytes = allocator.buf(&b).to_vec(); + SExp::Atom() => { + let res_bytes = allocator.atom(res); assert_eq!(res_bytes.len(), 1); assert_eq!(res_bytes[0], 3); } @@ -329,8 +332,8 @@ fn can_do_operations() { let mut allocator = Allocator::new(); let res = run_from_source(&mut allocator, "(16 (1 . 3) (1 . 5))".to_string()); match allocator.sexp(res) { - SExp::Atom(b) => { - let res_bytes = allocator.buf(&b).to_vec(); + SExp::Atom() => { + let res_bytes = allocator.atom(res); assert_eq!(res_bytes.len(), 1); assert_eq!(res_bytes[0], 8); } @@ -345,8 +348,8 @@ fn can_do_operations_kw() { let mut allocator = Allocator::new(); let res = run_from_source(&mut allocator, "(+ (q . 3) (q . 5))".to_string()); match allocator.sexp(res) { - SExp::Atom(b) => { - let res_bytes = allocator.buf(&b).to_vec(); + SExp::Atom() => { + let res_bytes = allocator.atom(res); assert_eq!(res_bytes.len(), 1); assert_eq!(res_bytes[0], 8); } @@ -770,3 +773,37 @@ fn test_bytes_to_pybytes_repr_0() { "b'\\x11\\x01abc\\r\\ntest\\ttest\\r\\n'" ); } + +#[test] +fn test_pattern_match_dollar_for_dollar() { + let mut allocator = Allocator::new(); + let pattern = assemble(&mut allocator, "($ . $)").expect("should assemble"); + let target_expr = assemble(&mut allocator, "$").expect("should assemble"); + let empty_map = HashMap::new(); + let matched = match_sexp(&mut allocator, pattern, target_expr, empty_map.clone()); + // Returns empty map. + assert_eq!(Some(empty_map), matched); +} + +#[test] +fn test_pattern_match_colon_for_colon() { + let mut allocator = Allocator::new(); + let pattern = assemble(&mut allocator, "(: . :)").expect("should assemble"); + let target_expr = assemble(&mut allocator, ":").expect("should assemble"); + let empty_map = HashMap::new(); + let matched = match_sexp(&mut allocator, pattern, target_expr, empty_map.clone()); + // Returns empty map. + assert_eq!(Some(empty_map), matched); +} + +#[test] +fn test_sub_args() { + let mut allocator = Allocator::new(); + let expr_sexp = assemble(&mut allocator, "(body 2 5)").expect("should assemble"); + let new_args = assemble(&mut allocator, "(test1 test2)").expect("should assemble"); + let result = sub_args(&mut allocator, expr_sexp, new_args).expect("should run"); + assert_eq!( + disassemble(&mut allocator, result), + "(\"body\" (f (\"test1\" \"test2\")) (f (r (\"test1\" \"test2\"))))" + ); +} diff --git a/support/recompile_check.py b/support/recompile_check.py index 81c1244d3..c991198e4 100644 --- a/support/recompile_check.py +++ b/support/recompile_check.py @@ -1,24 +1,55 @@ import os +from pathlib import Path import subprocess import traceback +FULL_NODE='chia/full_node/puzzles' +CAT_WALLET='chia/wallet/cat_wallet/puzzles' +DID_WALLET='chia/wallet/did_wallet/puzzles' +NFT_WALLET='chia/wallet/nft_wallet/puzzles' +POOLS='chia/pools/puzzles' +CONSENSUS='chia/consensus/puzzles' +GENTEST='tests/generator/puzzles' + +def full_node(x): + return {'fname': x, 'dirname': FULL_NODE} + +def cat_wallet(x): + return {'fname': x, 'dirname': CAT_WALLET} + +def did_wallet(x): + return {'fname': x, 'dirname': DID_WALLET} + +def nft_wallet(x): + return {'fname': x, 'dirname': NFT_WALLET} + +def pools(x): + return {'fname': x, 'dirname': POOLS} + +def consensus(x): + return {'fname': x, 'dirname': CONSENSUS} + +def gentest(x): + return {'fname': x, 'dirname': GENTEST} + recompile_list = [ - 'block_program_zero.clsp', - 'calculate_synthetic_public_key.clsp', - 'chialisp_deserialisation.clsp', - 'decompress_coin_spend_entry.clsp', - 'decompress_coin_spend_entry_with_prefix.clsp', - 'decompress_puzzle.clsp', - 'delegated_tail.clsp', - 'did_innerpuz.clsp', - 'everything_with_signature.clsp', - 'genesis_by_coin_id.clsp', - 'genesis_by_puzzle_hash.clsp', - 'nft_metadata_updater_default.clsp', - 'nft_metadata_updater_updateable.clsp', - 'nft_ownership_layer.clsp', - 'nft_ownership_transfer_program_one_way_claim_with_royalties.clsp', - 'nft_state_layer.clsp', + full_node('block_program_zero.clsp'), + full_node('decompress_coin_spend_entry.clsp'), + full_node('decompress_coin_spend_entry_with_prefix.clsp'), + full_node('decompress_puzzle.clsp'), + cat_wallet('delegated_tail.clsp'), + cat_wallet('everything_with_signature.clsp'), + cat_wallet('genesis_by_coin_id.clsp'), + cat_wallet('genesis_by_puzzle_hash.clsp'), + did_wallet('did_innerpuz.clsp'), + nft_wallet('nft_metadata_updater_default.clsp'), + nft_wallet('nft_metadata_updater_updateable.clsp'), + nft_wallet('nft_ownership_layer.clsp'), + nft_wallet('nft_ownership_transfer_program_one_way_claim_with_royalties.clsp'), + nft_wallet('nft_state_layer.clsp'), + pools('pool_member_innerpuz.clsp'), + pools('pool_waitingroom_innerpuz.clsp'), + consensus('rom_bootstrap_generator.clsp'), 'p2_conditions.clsp', 'p2_delegated_conditions.clsp', 'p2_delegated_puzzle.clsp', @@ -27,24 +58,28 @@ 'p2_puzzle_hash.clsp', 'p2_singleton.clsp', 'p2_singleton_or_delayed_puzhash.clsp', - 'pool_member_innerpuz.clsp', - 'pool_waitingroom_innerpuz.clsp', - 'rom_bootstrap_generator.clsp', 'settlement_payments.clsp', - 'sha256tree_module.clsp', 'singleton_launcher.clsp', 'singleton_top_layer.clsp', 'singleton_top_layer_v1_1.clsp', - 'test_generator_deserialize.clsp', - 'test_multiple_generator_input_arguments.clsp' + gentest('test_generator_deserialize.clsp'), + gentest('test_multiple_generator_input_arguments.clsp') ] -for fname in recompile_list: - hexfile = f'./chia/wallet/puzzles/{fname}.hex' +for recompile_entry in recompile_list: + if 'dirname' in recompile_entry and 'fname' in recompile_entry: + dirname = recompile_entry['dirname'] + filename = recompile_entry['fname'] + else: + filename = recompile_entry + dirname = 'chia/wallet/puzzles' + + srcfile = str(Path(dirname) / Path(filename)) + hexfile = f'{str(srcfile)}.hex' hexdata = open(hexfile).read().strip() os.unlink(hexfile) try: - compiled = subprocess.check_output(['../target/release/run', '-i', 'chia/wallet/puzzles/', f'chia/wallet/puzzles/{fname}']).strip() + compiled = subprocess.check_output(['../target/release/run', '-i', dirname, '-i', 'chia/wallet/puzzles', srcfile]).strip() recompile = subprocess.check_output(['../target/release/opc', compiled]).decode('utf8').strip() except: print(f'compiling {fname}') diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 94e5f3e7f..6a088b074 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -62,23 +62,28 @@ dependencies = [ ] [[package]] -name = "block-buffer" -version = "0.10.3" +name = "bls12_381" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "62250ece575fa9b22068b3a8d59586f01d426dd7785522efd97632959e71c986" dependencies = [ - "generic-array", + "ff 0.12.1", + "group 0.12.1", + "pairing 0.22.0", + "rand_core", + "subtle", ] [[package]] name = "bls12_381" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62250ece575fa9b22068b3a8d59586f01d426dd7785522efd97632959e71c986" +checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" dependencies = [ - "ff", - "group", - "pairing", + "digest", + "ff 0.13.0", + "group 0.13.0", + "pairing 0.23.0", "rand_core", "subtle", ] @@ -115,7 +120,7 @@ name = "clvm_tools_rs" version = "0.1.51" dependencies = [ "binascii", - "bls12_381", + "bls12_381 0.7.0", "bytestream", "clvmr", "derivative", @@ -137,7 +142,7 @@ dependencies = [ "regex", "serde", "serde_json", - "sha2 0.9.9", + "sha2", "tempfile", "unicode-segmentation", "wasm-bindgen", @@ -158,17 +163,18 @@ dependencies = [ [[package]] name = "clvmr" -version = "0.1.24" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5e907612d322d0d7def6b0ecb3ad681f6af2db106bcfabe4153746c60ef9e4" +checksum = "d234802ce73011e01f7019ef5701df1f9bffad9326d7d0a6dbca8d4b7591f083" dependencies = [ - "bls12_381", + "bls12_381 0.8.0", + "group 0.13.0", "hex", "lazy_static", "num-bigint", "num-integer", "num-traits", - "sha2 0.10.2", + "sha2", ] [[package]] @@ -190,16 +196,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - [[package]] name = "derivative" version = "2.2.0" @@ -220,16 +216,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "digest" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" -dependencies = [ - "block-buffer 0.10.3", - "crypto-common", -] - [[package]] name = "do-notation" version = "0.1.3" @@ -275,6 +261,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "bitvec", + "rand_core", + "subtle", +] + [[package]] name = "funty" version = "2.0.0" @@ -310,7 +307,18 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ - "ff", + "ff 0.12.1", + "rand_core", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", "rand_core", "subtle", ] @@ -527,7 +535,16 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "135590d8bdba2b31346f9cd1fb2a912329f5135e832a4f422942eb6ead8b6b3b" dependencies = [ - "group", + "group 0.12.1", +] + +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group 0.13.0", ] [[package]] @@ -757,24 +774,13 @@ version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ - "block-buffer 0.9.0", + "block-buffer", "cfg-if", "cpufeatures", - "digest 0.9.0", + "digest", "opaque-debug", ] -[[package]] -name = "sha2" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.5", -] - [[package]] name = "smallvec" version = "1.10.0" diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index 83cd4398c..e6c6119bb 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -18,7 +18,7 @@ path = "src/mod.rs" [dependencies] clvm_tools_rs = { path= "..", features = [] } -clvmr = "0.1.24" +clvmr = { version = "0.2.5", features = ["pre-eval"] } wasm-bindgen = "=0.2.83" wasm-bindgen-test = "=0.3.25" js-sys = "0.3.60"