diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml new file mode 100644 index 000000000..9fdf41d48 --- /dev/null +++ b/.github/workflows/doc.yml @@ -0,0 +1,54 @@ +name: Generate cargo docs + +# Only generate docs on main +on: + push: + branches: [ "main" ] + +jobs: + docs: + name: Docs + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Configure cache + uses: Swatinem/rust-cache@v2 + + - name: Setup pages + id: pages + uses: actions/configure-pages@v4 + + - name: Clean docs folder + run: cargo clean --doc + + - name: Build docs + run: cargo doc --no-deps + + - name: Remove lock file + run: rm target/doc/.lock + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: target/doc + + deploy: + name: Deploy + runs-on: ubuntu-latest + needs: docs + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index eadd38375..331adb69a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -8,42 +8,47 @@ on: name: Check, Test, and Format jobs: - fmt: - runs-on: ['memory:8GB'] + base: + name: build base + runs-on: ['hostname:hetzner-dedicated-6'] + outputs: + RUNNER: ${{ steps.get-label.outputs.runner_name }} steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Install devenv + - name: Get Runner Label + id: get-label run: | - if [ -e /nix/var/nix/profiles/default/bin/nix-env ] - then - /nix/var/nix/profiles/default/bin/nix-env -if https://github.com/cachix/devenv/tarball/latest + if [[ "${{ runner.name }}" == *"@hetzner-dedicated-6" ]]; then + echo "runner_name=hostname:hetzner-dedicated-6" >> $GITHUB_OUTPUT else - nix-env -if https://github.com/cachix/devenv/tarball/latest + echo "runner_name=nix-128g" >> $GITHUB_OUTPUT fi - echo "$HOME/.nix-profile/bin" >> $GITHUB_PATH - - name: Run cargo test - shell: devenv shell bash -- -e {0} - run: cargo fmt --all -- --check # + - name: Cleanup docker build cache + run: | + docker system prune --force + docker builder prune --all --force + - name: Checkout code + uses: actions/checkout@v4 - check: - name: Check - runs-on: ['memory:8GB'] + - name: Build base + env: + DOCKER_BUILDKIT: 1 + run: | + docker build --tag base --file docker/base/Dockerfile . --platform linux/amd64 --build-arg INSTRUCTION_SET="x86-64-v3" + clippy-fmt-check: + needs: base + runs-on: ${{needs.base.outputs.RUNNER}} steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Install devenv + + - name: clippy run: | - if [ -e /nix/var/nix/profiles/default/bin/nix-env ] - then - /nix/var/nix/profiles/default/bin/nix-env -if https://github.com/cachix/devenv/tarball/latest - else - nix-env -if https://github.com/cachix/devenv/tarball/latest - fi - echo "$HOME/.nix-profile/bin" >> $GITHUB_PATH - - name: Run cargo check - shell: devenv shell bash -- -e {0} - run: cargo check --tests + docker run --rm base cargo clippy --all-targets --all -- -D warnings -A incomplete-features -A clippy::needless_return -A clippy::too_long_first_doc_paragraph -A clippy::await_holding_lock + - name: fmt + run: | + docker run --rm base cargo fmt --all -- --check + - name: check + run: | + docker run --rm base cargo check --tests + test: name: Test Suite diff --git a/Cargo.lock b/Cargo.lock index ade5da76e..743ac467c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" @@ -25,19 +25,13 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -106,10 +100,11 @@ dependencies = [ [[package]] name = "alloy-chains" -version = "0.1.27" +version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b515e82c8468ddb6ff8db21c78a5997442f113fd8471fd5b2261b2602dd0c67" +checksum = "156bfc5dcd52ef9a5f33381701fa03310317e14c65093a9430d3e3557b08dcd3" dependencies = [ + "alloy-primitives 0.8.8", "num_enum", "strum", ] @@ -121,7 +116,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "705687d5bfd019fee57cf9e206b27b30a9a9617535d5590a02b171e813208f8e" dependencies = [ "alloy-eips", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-rlp", "alloy-serde", "auto_impl", @@ -140,7 +135,7 @@ dependencies = [ "alloy-json-abi", "alloy-network", "alloy-network-primitives", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-provider", "alloy-rpc-types-eth", "alloy-sol-types", @@ -158,7 +153,7 @@ checksum = "3cf9b7166dd6aee2236646457b81fa032af8a67c25f3965d56e48881658bc85f" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-rlp", "alloy-sol-types", ] @@ -170,14 +165,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1109c57718022ac84c194f775977a534e1b3969b405e55693a61c42187cc0612" dependencies = [ "alloy-json-abi", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-sol-type-parser", "alloy-sol-types", "const-hex", "itoa", "serde", "serde_json", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -186,7 +181,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" dependencies = [ - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-rlp", "serde", ] @@ -197,7 +192,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea59dc42102bc9a1905dc57901edc6dd48b9f38115df86c7d252acba70d71d04" dependencies = [ - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-rlp", "serde", ] @@ -210,7 +205,7 @@ checksum = "6ffb906284a1e1f63c4607da2068c8197458a352d0b3e9796e67353d72a9be85" dependencies = [ "alloy-eip2930", "alloy-eip7702", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-rlp", "alloy-serde", "c-kzg", @@ -226,7 +221,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8429cf4554eed9b40feec7f4451113e76596086447550275e3def933faf47ce3" dependencies = [ - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-serde", "serde", ] @@ -237,7 +232,7 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4cc0e59c803dd44d14fc0cfa9fea1f74cfa8fd9fb60ca303ced390c58c28d4e" dependencies = [ - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-sol-type-parser", "serde", "serde_json", @@ -249,7 +244,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8fa8a1a3c4cbd221f2b8e3693aeb328fca79a757fe556ed08e47bbbc2a70db7" dependencies = [ - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-sol-types", "serde", "serde_json", @@ -267,7 +262,7 @@ dependencies = [ "alloy-eips", "alloy-json-rpc", "alloy-network-primitives", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-rpc-types-eth", "alloy-serde", "alloy-signer", @@ -286,7 +281,7 @@ checksum = "801492711d4392b2ccf5fc0bc69e299fa1aab15167d74dcaa9aab96a54f684bd" dependencies = [ "alloy-consensus", "alloy-eips", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-serde", "serde", ] @@ -298,7 +293,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f1334a738aa1710cb8227441b3fcc319202ce78e967ef37406940242df4a454" dependencies = [ "alloy-genesis", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "k256", "rand", "serde_json", @@ -327,9 +322,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a289ffd7448036f2f436b377f981c79ce0b2090877bad938d43387dc09931877" +checksum = "38f35429a652765189c1c5092870d8360ee7b7769b09b06d89ebaefd34676446" dependencies = [ "alloy-rlp", "bytes", @@ -368,7 +363,7 @@ dependencies = [ "alloy-network", "alloy-network-primitives", "alloy-node-bindings", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-rpc-client", "alloy-rpc-types-anvil", "alloy-rpc-types-eth", @@ -383,7 +378,7 @@ dependencies = [ "futures-utils-wasm", "lru", "pin-project", - "reqwest 0.12.7", + "reqwest 0.12.8", "serde", "serde_json", "thiserror", @@ -411,7 +406,7 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -421,17 +416,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "370143ed581aace6e663342d21d209c6b2e34ee6142f7d6675adb518deeaf0dc" dependencies = [ "alloy-json-rpc", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-transport", "alloy-transport-http", "futures", "pin-project", - "reqwest 0.12.7", + "reqwest 0.12.8", "serde", "serde_json", "tokio", "tokio-stream", - "tower 0.5.1", + "tower", "tracing", "url", ] @@ -442,7 +437,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ffc534b7919e18f35e3aa1f507b6f3d9d92ec298463a9f6beaac112809d8d06" dependencies = [ - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-rpc-types-eth", "alloy-serde", "serde", @@ -454,7 +449,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d780adaa5d95b07ad92006b2feb68ecfa7e2015f7d5976ceaac4c906c73ebd07" dependencies = [ - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-serde", "serde", ] @@ -468,7 +463,7 @@ dependencies = [ "alloy-consensus", "alloy-eips", "alloy-network-primitives", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-rlp", "alloy-serde", "alloy-sol-types", @@ -484,7 +479,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dff0ab1cdd43ca001e324dc27ee0e8606bd2161d6623c63e0e0b8c4dfc13600" dependencies = [ - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "serde", "serde_json", ] @@ -495,7 +490,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd4e0ad79c81a27ca659be5d176ca12399141659fef2bcbfdc848da478f4504" dependencies = [ - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "async-trait", "auto_impl", "elliptic-curve", @@ -511,7 +506,7 @@ checksum = "494e0a256f3e99f2426f994bcd1be312c02cb8f88260088dacb33a8b8936475f" dependencies = [ "alloy-consensus", "alloy-network", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-signer", "async-trait", "k256", @@ -530,7 +525,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -547,7 +542,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", "syn-solidity", "tiny-keccak", ] @@ -565,7 +560,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.75", + "syn 2.0.79", "syn-solidity", ] @@ -576,7 +571,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbd3548d5262867c2c4be6223fe4f2583e21ade0ca1c307fd23bc7f28fca479e" dependencies = [ "serde", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -586,7 +581,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4aa666f1036341b46625e72bd36878bf45ad0185f1b88601223e1ec6ed4b72b1" dependencies = [ "alloy-json-abi", - "alloy-primitives 0.8.6", + "alloy-primitives 0.8.8", "alloy-sol-macro", "const-hex", "serde", @@ -606,7 +601,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tower 0.5.1", + "tower", "tracing", "url", ] @@ -619,9 +614,9 @@ checksum = "b367dcccada5b28987c2296717ee04b9a5637aacd78eacb1726ef211678b5212" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.7", + "reqwest 0.12.8", "serde_json", - "tower 0.5.1", + "tower", "tracing", "url", ] @@ -711,9 +706,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "ark-ff" @@ -749,7 +744,7 @@ dependencies = [ "num-bigint 0.4.6", "num-traits", "paste", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "zeroize", ] @@ -868,9 +863,9 @@ dependencies = [ [[package]] name = "async-stream" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" dependencies = [ "async-stream-impl", "futures-core", @@ -879,24 +874,24 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -907,7 +902,7 @@ checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" dependencies = [ "futures", "pharos", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -929,28 +924,28 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", - "miniz_oxide 0.7.4", + "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -1118,9 +1113,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -1148,15 +1143,16 @@ dependencies = [ [[package]] name = "c-kzg" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf100c4cea8f207e883ff91ca886d621d8a166cb04971dfaa9bb8fd99ed95df" +checksum = "f0307f72feab3300336fb803a57134159f6e20139af1357f36c54cb90d8e8928" dependencies = [ "blst", "cc", "glob", "hex", "libc", + "once_cell", "serde", ] @@ -1200,9 +1196,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.13" +version = "1.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" dependencies = [ "jobserver", "libc", @@ -1240,9 +1236,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", "clap_derive", @@ -1250,9 +1246,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -1262,14 +1258,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -1361,9 +1357,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.12.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8a24a26d37e1ffd45343323dc9fe6654ceea44c12f2fcb3d7ac29e610bc6" +checksum = "0121754e84117e65f9d90648ee6aa4882a6e63110307ab73967a4c5e7e69e586" dependencies = [ "cfg-if", "cpufeatures", @@ -1428,9 +1424,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1551,7 +1547,7 @@ dependencies = [ "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "subtle", "zeroize", ] @@ -1564,7 +1560,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -1588,7 +1584,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -1599,7 +1595,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -1643,7 +1639,7 @@ checksum = "4e018fccbeeb50ff26562ece792ed06659b9c2dae79ece77c4456bb10d9bf79b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -1686,8 +1682,8 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", - "syn 2.0.75", + "rustc_version 0.4.1", + "syn 2.0.79", ] [[package]] @@ -1707,7 +1703,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", "unicode-xid", ] @@ -1914,7 +1910,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -2194,7 +2190,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "syn 2.0.75", + "syn 2.0.79", "toml", "walkdir", ] @@ -2218,7 +2214,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "syn 2.0.75", + "syn 2.0.79", "toml", "walkdir", ] @@ -2235,7 +2231,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -2251,7 +2247,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -2276,7 +2272,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.75", + "syn 2.0.79", "tempfile", "thiserror", "tiny-keccak", @@ -2306,7 +2302,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.75", + "syn 2.0.79", "tempfile", "thiserror", "tiny-keccak", @@ -2587,9 +2583,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fastrlp" @@ -2666,12 +2662,12 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.32" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c0596c1eac1f9e04ed902702e9878208b336edc9d6fddc8a48387349bab3666" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide", ] [[package]] @@ -2738,9 +2734,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -2753,9 +2749,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -2763,15 +2759,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -2780,9 +2776,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-locks" @@ -2796,26 +2792,26 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-timer" @@ -2829,9 +2825,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -2906,9 +2902,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" @@ -2959,14 +2955,11 @@ dependencies = [ "itertools 0.12.1", "log", "mp2_common", - "mp2_test", "plonky2", - "plonky2_ecgfp5", "plonky2x", "rand", "recursion_framework", "revm", - "rlp", "serde", "serde_json", "serial_test 3.1.1", @@ -3028,6 +3021,8 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" dependencies = [ + "allocator-api2", + "equivalent", "foldhash", "serde", ] @@ -3165,9 +3160,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -3269,9 +3264,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -3282,16 +3277,15 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower 0.4.13", "tower-service", "tracing", ] [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3406,21 +3400,16 @@ name = "inspect" version = "0.1.0" dependencies = [ "anyhow", - "bb8", - "bb8-postgres", "clap", "colored", "dialoguer", "hex", "itertools 0.12.1", "mp2_v1", - "postgres-types", "ryhope", "serde", - "serde_json", "tabled", "tokio", - "tokio-postgres", ] [[package]] @@ -3434,9 +3423,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is-terminal" @@ -3524,9 +3513,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -3547,9 +3536,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa", @@ -3570,9 +3559,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422fbc7ff2f2f5bdffeb07718e5a5324dca72b0c9293d50df4026652385e3314" +checksum = "505d1856a39b200489082f90d897c3f07c455563880bc5952e38eabf731c83b6" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -3611,7 +3600,7 @@ dependencies = [ "lalrpop-util", "petgraph", "regex", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "string_cache", "term", "tiny-keccak", @@ -3625,7 +3614,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata 0.4.7", + "regex-automata 0.4.8", ] [[package]] @@ -3639,9 +3628,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libm" @@ -3683,11 +3672,11 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.14.5", + "hashbrown 0.15.0", ] [[package]] @@ -3717,9 +3706,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" +checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" dependencies = [ "libc", ] @@ -3736,15 +3725,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -3773,7 +3753,6 @@ dependencies = [ "alloy", "anyhow", "bincode", - "csv", "derive_more 0.99.18", "eth_trie", "ethereum-types", @@ -3791,11 +3770,8 @@ dependencies = [ "poseidon2_plonky2", "rand", "rlp", - "rmp-serde", "rstest 0.18.2", "serde", - "serde_json", - "serial_test 3.1.1", "sha3", "tokio", ] @@ -3808,8 +3784,6 @@ dependencies = [ "anyhow", "env_logger 0.11.5", "eth_trie", - "ethers 2.0.13", - "hashbrown 0.14.5", "log", "mp2_common", "plonky2", @@ -3853,13 +3827,10 @@ dependencies = [ "rand_chacha", "recursion_framework", "rlp", - "rmp-serde", "ryhope", "serde", - "serde_arrays", "serde_json", "serial_test 3.1.1", - "sha3", "sqlparser", "test-log", "testfile", @@ -4032,23 +4003,23 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] name = "object" -version = "0.36.3" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "open-fastrlp" @@ -4098,7 +4069,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -4198,7 +4169,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.3", + "redox_syscall", "smallvec", "windows-targets 0.52.6", ] @@ -4212,9 +4183,6 @@ dependencies = [ "camelpaste", "clap", "log", - "mp2_common", - "plonky2", - "postgres", "ryhope", "serde", "serde_json", @@ -4286,9 +4254,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", "thiserror", @@ -4312,7 +4280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" dependencies = [ "futures", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -4345,7 +4313,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -4368,22 +4336,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -4410,14 +4378,14 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plonky2" version = "0.2.2" -source = "git+https://github.com/Lagrange-Labs/plonky2?branch=upstream#3c4cc3749683a82477dcfcea19d423fe844c3ed6" +source = "git+https://github.com/Lagrange-Labs/plonky2?branch=upstream#22c42f64367e8f087e565bdb664525910a62fc76" dependencies = [ "ahash", "anyhow", @@ -4459,7 +4427,7 @@ dependencies = [ [[package]] name = "plonky2_ecdsa" version = "0.1.0" -source = "git+https://github.com/Lagrange-Labs/plonky2-ecdsa#287b88514478bd88ca3457192b763c1fe3cfdb91" +source = "git+https://github.com/Lagrange-Labs/plonky2-ecdsa#ea7220beaf3513ced7e72b1227782084914e1fd0" dependencies = [ "anyhow", "itertools 0.10.5", @@ -4488,7 +4456,7 @@ dependencies = [ [[package]] name = "plonky2_field" version = "0.2.2" -source = "git+https://github.com/Lagrange-Labs/plonky2?branch=upstream#3c4cc3749683a82477dcfcea19d423fe844c3ed6" +source = "git+https://github.com/Lagrange-Labs/plonky2?branch=upstream#22c42f64367e8f087e565bdb664525910a62fc76" dependencies = [ "anyhow", "itertools 0.11.0", @@ -4518,7 +4486,7 @@ dependencies = [ [[package]] name = "plonky2_maybe_rayon" version = "0.2.0" -source = "git+https://github.com/Lagrange-Labs/plonky2?branch=upstream#3c4cc3749683a82477dcfcea19d423fe844c3ed6" +source = "git+https://github.com/Lagrange-Labs/plonky2?branch=upstream#22c42f64367e8f087e565bdb664525910a62fc76" dependencies = [ "rayon", ] @@ -4539,7 +4507,7 @@ dependencies = [ [[package]] name = "plonky2_util" version = "0.2.0" -source = "git+https://github.com/Lagrange-Labs/plonky2?branch=upstream#3c4cc3749683a82477dcfcea19d423fe844c3ed6" +source = "git+https://github.com/Lagrange-Labs/plonky2?branch=upstream#22c42f64367e8f087e565bdb664525910a62fc76" [[package]] name = "plonky2x" @@ -4590,13 +4558,13 @@ source = "git+https://github.com/Lagrange-Labs/succinctx?branch=fix-build#8580a6 dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] name = "poseidon2_plonky2" version = "0.1.0" -source = "git+https://github.com/Lagrange-Labs/plonky2?branch=upstream#3c4cc3749683a82477dcfcea19d423fe844c3ed6" +source = "git+https://github.com/Lagrange-Labs/plonky2?branch=upstream#22c42f64367e8f087e565bdb664525910a62fc76" dependencies = [ "anyhow", "plonky2", @@ -4605,20 +4573,6 @@ dependencies = [ "unroll", ] -[[package]] -name = "postgres" -version = "0.19.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c9ec84ab55b0f9e418675de50052d494ba893fd28c65769a6e68fcdacbee2b8" -dependencies = [ - "bytes", - "fallible-iterator", - "futures-util", - "log", - "tokio", - "tokio-postgres", -] - [[package]] name = "postgres-protocol" version = "0.6.7" @@ -4639,9 +4593,9 @@ dependencies = [ [[package]] name = "postgres-types" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02048d9e032fb3cc3413bbf7b83a15d84a5d419778e2628751896d856498eee9" +checksum = "f66ea23a2d0e5734297357705193335e0a957696f34bed2f2faefacb2fec336f" dependencies = [ "bytes", "chrono", @@ -4674,12 +4628,12 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "prettyplease" -version = "0.2.20" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -4708,11 +4662,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.21.1", + "toml_edit", ] [[package]] @@ -4758,14 +4712,14 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -4784,7 +4738,7 @@ dependencies = [ "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "rusty-fork", "tempfile", "unarray", @@ -4798,9 +4752,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -4890,8 +4844,6 @@ dependencies = [ "log", "mp2_common", "plonky2", - "plonky2_crypto", - "plonky2_ecgfp5", "plonky2_monolith", "rstest 0.18.2", "serde", @@ -4900,18 +4852,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.5.3" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -4929,14 +4872,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -4950,13 +4893,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -4967,9 +4910,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "relative-path" @@ -5023,9 +4966,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64 0.22.1", "bytes", @@ -5045,7 +4988,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile 2.1.3", + "rustls-pemfile 2.2.0", "serde", "serde_json", "serde_urlencoded", @@ -5182,28 +5125,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "rmp" -version = "0.8.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" -dependencies = [ - "byteorder", - "num-traits", - "paste", -] - -[[package]] -name = "rmp-serde" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" -dependencies = [ - "byteorder", - "rmp", - "serde", -] - [[package]] name = "rstest" version = "0.17.0" @@ -5213,7 +5134,7 @@ dependencies = [ "futures", "futures-timer", "rstest_macros 0.17.0", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -5225,7 +5146,7 @@ dependencies = [ "futures", "futures-timer", "rstest_macros 0.18.2", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -5237,7 +5158,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "syn 1.0.109", "unicode-ident", ] @@ -5254,8 +5175,8 @@ dependencies = [ "quote", "regex", "relative-path", - "rustc_version 0.4.0", - "syn 2.0.75", + "rustc_version 0.4.1", + "syn 2.0.79", "unicode-ident", ] @@ -5320,18 +5241,18 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver 1.0.23", ] [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -5363,19 +5284,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "rustls-webpki" @@ -5389,9 +5309,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "rusty-fork" @@ -5478,20 +5398,20 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.16" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb7ac86243095b70a7920639507b71d51a63390d1ba26c4f60a552fbb914a37" +checksum = "f2c1f7fc6deb21665a9060dfc7d271be784669295a31babdcd4dd2c79ae8cbfb" dependencies = [ "sdd", ] [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5524,9 +5444,9 @@ dependencies = [ [[package]] name = "sdd" -version = "3.0.2" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0495e4577c672de8254beb68d01a9b62d0e8a13c099edecdbedccce3223cd29f" +checksum = "49c1eeaf4b6a87c7479688c6d52b9f1153cedd3c489300564f932b065c6eab95" [[package]] name = "sec1" @@ -5557,9 +5477,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -5606,38 +5526,29 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.208" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] -[[package]] -name = "serde_arrays" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" -dependencies = [ - "serde", -] - [[package]] name = "serde_derive" -version = "1.0.208" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -5656,9 +5567,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -5718,7 +5629,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -5730,7 +5641,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -5780,7 +5691,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -5830,9 +5741,9 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d79b758b7cb2085612b11a235055e485605a5103faccdd633f35bd7aee69dd" +checksum = "c28efc5e327c837aa837c59eae585fc250715ef939ac32881bcc11677cd02d46" dependencies = [ "cc", "cfg-if", @@ -6064,7 +5975,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -6128,9 +6039,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.75" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -6146,7 +6057,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -6218,9 +6129,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -6268,7 +6179,7 @@ checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -6282,22 +6193,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -6376,9 +6287,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -6400,7 +6311,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -6415,9 +6326,9 @@ dependencies = [ [[package]] name = "tokio-postgres" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03adcf0147e203b6032c0b2d30be1415ba03bc348901f3ff1cc0df6a733e60c3" +checksum = "3b5d3742945bc7d7f210693b0c58ae542c6fd47b17adbbda0885f3dcb34a6bdb" dependencies = [ "async-trait", "byteorder", @@ -6451,9 +6362,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -6478,9 +6389,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -6498,7 +6409,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.20", + "toml_edit", ] [[package]] @@ -6512,41 +6423,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.6.0", - "toml_datetime", - "winnow 0.5.40", -] - -[[package]] -name = "toml_edit" -version = "0.22.20" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.18", -] - -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", + "winnow", ] [[package]] @@ -6594,7 +6479,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -6679,9 +6564,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "uint" @@ -6703,30 +6588,30 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-properties" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" [[package]] name = "unicode-width" @@ -6736,9 +6621,9 @@ checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "unroll" @@ -6824,7 +6709,6 @@ dependencies = [ "anyhow", "bincode", "derive_more 0.99.18", - "env_logger 0.11.5", "futures", "itertools 0.12.1", "log", @@ -6918,9 +6802,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -6929,24 +6813,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -6956,9 +6840,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6966,28 +6850,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -7011,11 +6895,11 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "whoami" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" +checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" dependencies = [ - "redox_syscall 0.4.1", + "redox_syscall", "wasite", "web-sys", ] @@ -7240,18 +7124,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -7277,7 +7152,7 @@ dependencies = [ "js-sys", "log", "pharos", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "send_wrapper 0.6.0", "thiserror", "wasm-bindgen", @@ -7318,7 +7193,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] @@ -7338,7 +7213,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.79", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 11b392be3..cc58bb804 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ alloy = { version = "0.4", default-features = false, features = [ "getrandom", "network", "node-bindings", - "postgres", "providers", "reqwest", "rlp", @@ -56,14 +55,11 @@ plonky2_ecgfp5 = { git = "https://github.com/Lagrange-Labs/plonky2-ecgfp5" } plonky2_monolith = "0.1.0" plonky2x = { git = "https://github.com/Lagrange-Labs/succinctx", branch = "fix-build" } poseidon2_plonky2 = { git = "https://github.com/Lagrange-Labs/plonky2", branch = "upstream" } -postgres = { version = "0.19.7", features = ["with-serde_json-1"] } rand = "0.8" revm = { version = "3.5", default-features = false } rlp = "0.5" -rmp-serde = "1.1" rstest = "0.18" serde = { version = "1.0", features = ["derive"] } -serde_arrays = "0.1" serde_json = "1.0" serial_test = "3.0" sha2 = "0.10" diff --git a/devenv.lock b/devenv.lock index 01203ebb9..e8c3e821c 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,11 +3,10 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1724144412, + "lastModified": 1728993896, "owner": "cachix", "repo": "devenv", - "rev": "bd79132088803517ac158fcfe2c103fe71e1206a", - "treeHash": "95a0cd92da337cf1735d7b2feea95b0570d8b3ff", + "rev": "dc7ebaf872306526ea6dcbb2122acca792680701", "type": "github" }, "original": { @@ -25,11 +24,10 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1724221791, + "lastModified": 1728973961, "owner": "nix-community", "repo": "fenix", - "rev": "e88b38a5a3834e039d413a88f8150a75ef6453ef", - "treeHash": "4cda0e2d7fbb5e9391207dd5d2e0e4147b28069b", + "rev": "d6a9ff4d1e60c347a23bc96ccdb058d37a810541", "type": "github" }, "original": { @@ -45,7 +43,6 @@ "owner": "edolstra", "repo": "flake-compat", "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "treeHash": "2addb7b71a20a25ea74feeaf5c2f6a6b30898ecb", "type": "github" }, "original": { @@ -66,7 +63,6 @@ "owner": "hercules-ci", "repo": "gitignore.nix", "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "treeHash": "ca14199cabdfe1a06a7b1654c76ed49100a689f9", "type": "github" }, "original": { @@ -81,7 +77,6 @@ "owner": "cachix", "repo": "devenv-nixpkgs", "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6", - "treeHash": "6d9f1f7ca0faf1bc2eeb397c78a49623260d3412", "type": "github" }, "original": { @@ -93,11 +88,10 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1724098845, + "lastModified": 1728740863, "owner": "NixOS", "repo": "nixpkgs", - "rev": "f1bad50880bae73ff2d82fafc22010b4fc097a9c", - "treeHash": "c217afffc0b4aa4caf4533a68d4b8a2f9eff6e07", + "rev": "a3f9ad65a0bf298ed5847629a57808b97e6e8077", "type": "github" }, "original": { @@ -117,11 +111,10 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1724227338, + "lastModified": 1728778939, "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "6cedaa7c1b4f82a266e5d30f212273e60d62cb0d", - "treeHash": "698918d3a04360f1dfd19164903511a167368ec1", + "rev": "ff68f91754be6f3427e4986d7949e6273659be1d", "type": "github" }, "original": { @@ -141,11 +134,10 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1724153119, + "lastModified": 1728921748, "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "3723e5910c14f0ffbd13de474b8a8fcc74db04ce", - "treeHash": "518b23d63d6577dbed2c2e683a4380fdb91bf2aa", + "rev": "0319586ef2a2636f6d6b891690b7ebebf4337c85", "type": "github" }, "original": { diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 000000000..4c3ccbb23 --- /dev/null +++ b/docker/base/Dockerfile @@ -0,0 +1,26 @@ +FROM rustlang/rust:nightly-slim as base + +ARG GO_VERSION=1.22.2 + +# Install necessary packages and Go +RUN apt-get update && apt-get install -y \ + wget \ + libssl-dev \ + git \ + pkg-config \ + libssl3 + +RUN rustup component add clippy rustfmt + +# Install Go +RUN wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz && \ + tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \ + rm go${GO_VERSION}.linux-amd64.tar.gz + +ENV PATH="/usr/local/go/bin:${PATH}" + +# Set work directory +WORKDIR /lgn-coprocessor + +# Copy the source code +COPY . . diff --git a/groth16-framework/Cargo.toml b/groth16-framework/Cargo.toml index f9a68886c..a8ce89abe 100644 --- a/groth16-framework/Cargo.toml +++ b/groth16-framework/Cargo.toml @@ -11,21 +11,18 @@ log.workspace = true plonky2.workspace = true plonky2x.workspace = true revm.workspace = true -rlp.workspace = true serde.workspace = true serde_json.workspace = true gnark-utils = { path = "../gnark-utils" } mp2_common = { path = "../mp2-common" } -recursion_framework = { path = "../recursion-framework" } [dev-dependencies] env_logger.workspace = true itertools.workspace = true -plonky2_ecgfp5.workspace = true rand.workspace = true serial_test.workspace = true sha2.workspace = true -mp2_test = { path = "../mp2-test" } +recursion_framework = { path = "../recursion-framework" } verifiable-db = { path = "../verifiable-db" } diff --git a/groth16-framework/tests/common/query.rs b/groth16-framework/tests/common/query.rs index 7843d902c..5f5f80723 100644 --- a/groth16-framework/tests/common/query.rs +++ b/groth16-framework/tests/common/query.rs @@ -11,7 +11,6 @@ use mp2_common::{ F, }; use plonky2::field::types::PrimeField64; -use rand::thread_rng; use verifiable_db::{ query::api::CircuitInput as QueryInput, revelation::{api::CircuitInput, PublicInputs as RevelationPI}, @@ -48,7 +47,7 @@ impl TestContext { let preprocessing_proof = serialize_proof(&preprocessing_proof).unwrap(); // Generate the revelation proof. - let input = CircuitInput::new_revelation_no_results_tree( + let input = CircuitInput::new_revelation_aggregated( query_proof, preprocessing_proof, test_data.query_bounds(), diff --git a/inspect/Cargo.toml b/inspect/Cargo.toml index 53cb8e667..ae503c2cd 100644 --- a/inspect/Cargo.toml +++ b/inspect/Cargo.toml @@ -8,18 +8,12 @@ anyhow.workspace = true hex.workspace = true itertools.workspace = true serde.workspace = true -serde_json.workspace = true - -bb8 = "0.8.5" -bb8-postgres = "0.8.1" clap = { version = "4.5.17", features = ["derive"] } colored = "2.1.0" dialoguer = { version = "0.11.0", features = ["fuzzy-select"] } -postgres-types = {version = "0.2.6", features = ["with-serde_json-1"] } tabled = { version = "0.16.0", features = ["ansi"] } tokio = { version = "1.34", features = ["sync", "macros"], default-features = false } -tokio-postgres = { version = "0.7.10", features = ["with-chrono-0_4"] } ryhope = { path = "../ryhope" } mp2_v1 = { path = "../mp2-v1" } diff --git a/inspect/src/repl.rs b/inspect/src/repl.rs index fcfc1021d..ca3196b92 100644 --- a/inspect/src/repl.rs +++ b/inspect/src/repl.rs @@ -123,7 +123,7 @@ impl< } self.current_epoch = epoch; - return Ok(()); + Ok(()) } async fn select_key(&self) -> Option { diff --git a/mp2-common/Cargo.toml b/mp2-common/Cargo.toml index 4feeb114f..a0de99ec8 100644 --- a/mp2-common/Cargo.toml +++ b/mp2-common/Cargo.toml @@ -26,12 +26,8 @@ sha3.workspace = true ethereum-types = "0.14.1" [dev-dependencies] -csv.workspace = true hex.workspace = true rand.workspace = true -rmp-serde.workspace = true -serde_json.workspace = true -serial_test.workspace = true tokio.workspace = true ethers.workspace = true diff --git a/mp2-common/src/array.rs b/mp2-common/src/array.rs index f6816a321..a8a9792d7 100644 --- a/mp2-common/src/array.rs +++ b/mp2-common/src/array.rs @@ -573,12 +573,12 @@ where ) -> T { // Only use random_access when SIZE is a power of 2 and smaller than 64 // see https://stackoverflow.com/a/600306/1202623 for the trick - if SIZE < RANDOM_ACCESS_SIZE && (SIZE & (SIZE - 1) == 0) { + if SIZE < RANDOM_ACCESS_SIZE && SIZE.is_power_of_two() { // Escape hatch when we can use random_access from plonky2 base - return T::from_target(b.random_access( + T::from_target(b.random_access( at, self.arr.iter().map(|v| v.to_target()).collect::>(), - )); + )) } else { self.value_at_failover(b, at) } diff --git a/mp2-common/src/digest.rs b/mp2-common/src/digest.rs index 1af72eab7..9265af657 100644 --- a/mp2-common/src/digest.rs +++ b/mp2-common/src/digest.rs @@ -30,11 +30,12 @@ pub enum TableDimension { /// uint256 or a bytes32 will only generate a single row per block. Single, /// Set to Compound for types that - /// * have multiple entries (like an mapping, unlike a single uin256 for example) - /// * don't need or have an associated length slot to combine with - /// It happens contracts don't have a length slot associated with the mapping - /// like ERC20 and thus there is no proof circuits have looked at _all_ the entries - /// due to limitations on EVM (there is no mapping.len()). + /// 1. have multiple entries (like an mapping, unlike a single uin256 for example) + /// 2. don't need or have an associated length slot to combine with + /// + /// It happens contracts don't have a length slot associated with the mapping like ERC20 and + /// thus there is no proof circuits have looked at _all_ the entries due to limitations on EVM + /// (there is no mapping.len()). Compound, } @@ -183,18 +184,12 @@ mod test { use crate::{types::CBuilder, utils::FromFields, C, D, F}; use super::{ - Digest, DigestTarget, SplitDigest, SplitDigestPoint, SplitDigestTarget, TableDimension, + Digest, DigestTarget, SplitDigestPoint, SplitDigestTarget, TableDimension, TableDimensionWire, }; use crate::utils::TryIntoBool; use mp2_test::circuit::{run_circuit, UserCircuit}; - use plonky2::{ - field::types::Sample, - iop::{ - target::BoolTarget, - witness::{PartialWitness, WitnessWrite}, - }, - }; + use plonky2::{field::types::Sample, iop::witness::PartialWitness}; use plonky2_ecgfp5::{ curve::curve::Point, gadgets::curve::{CircuitBuilderEcGFp5, PartialWitnessCurve}, diff --git a/mp2-common/src/eth.rs b/mp2-common/src/eth.rs index 1cc43e882..a0dc8364f 100644 --- a/mp2-common/src/eth.rs +++ b/mp2-common/src/eth.rs @@ -698,7 +698,7 @@ mod test { rlp::encode(&rlp).to_vec() } } - impl<'a, X> rlp::Encodable for RLPBlock<'a, X> { + impl rlp::Encodable for RLPBlock<'_, X> { fn rlp_append(&self, s: &mut rlp::RlpStream) { s.begin_unbounded_list(); s.append(&self.0.parent_hash); diff --git a/mp2-common/src/group_hashing/mod.rs b/mp2-common/src/group_hashing/mod.rs index c79fcb2f7..819eb7c2b 100644 --- a/mp2-common/src/group_hashing/mod.rs +++ b/mp2-common/src/group_hashing/mod.rs @@ -234,28 +234,21 @@ pub fn cond_field_hashed_scalar_mul(cond: bool, mul: Point, base: Point) -> Poin #[cfg(test)] mod test { - use plonky2::{ - field::types::Sample, - iop::{target::Target, witness::PartialWitness}, - }; - use plonky2_ecdsa::curve::curve_types::base_to_scalar; + use plonky2::{field::types::Sample, iop::witness::PartialWitness}; + use plonky2_ecgfp5::{ curve::curve::{Point, WeierstrassPoint}, gadgets::curve::{CircuitBuilderEcGFp5, CurveTarget, PartialWitnessCurve}, }; use crate::{ - digest::DigestTarget, types::CBuilder, - utils::{FromFields, FromTargets, ToFields, ToTargets}, + utils::{FromFields, ToFields}, C, D, F, }; use mp2_test::circuit::{run_circuit, UserCircuit}; - use super::{ - circuit_hashed_scalar_mul, field_hashed_scalar_mul, weierstrass_to_point, - CircuitBuilderGroupHashing, - }; + use super::{circuit_hashed_scalar_mul, field_hashed_scalar_mul, weierstrass_to_point}; #[derive(Clone, Debug)] struct TestScalarMul { diff --git a/mp2-common/src/keccak.rs b/mp2-common/src/keccak.rs index 7addd3b55..dedbafaf5 100644 --- a/mp2-common/src/keccak.rs +++ b/mp2-common/src/keccak.rs @@ -74,6 +74,7 @@ impl ToTargets for OutputHash { /// padded version length is less than N. In other words, N is the maximal size /// of the array + padding to hash. #[derive(Clone, Debug)] +#[allow(dead_code)] pub struct KeccakCircuit { data: Vec, } @@ -284,7 +285,7 @@ pub enum InputData<'a, F, const N: usize> { NonAssigned(&'a Vector), } -impl<'a, F, const N: usize> InputData<'a, F, N> { +impl InputData<'_, F, N> { pub fn real_len(&self) -> usize { match self { InputData::Assigned(v) => v.real_len, diff --git a/mp2-common/src/merkle_tree/state_tree.rs b/mp2-common/src/merkle_tree/state_tree.rs index a24f65032..537f2f017 100644 --- a/mp2-common/src/merkle_tree/state_tree.rs +++ b/mp2-common/src/merkle_tree/state_tree.rs @@ -44,7 +44,7 @@ impl StateTreeWires { /// /// - `leaf_data` will be the preimage of the node of the branch at depth `0`. /// - `siblings` will be the full Merkle path up to [MAX_DEPTH]; the remainder nodes will be - /// ignored. + /// ignored. /// - `positions` will be bits path up to [MAX_DEPTH]; the remainder items will be ignored. /// - `depth` will be the variable depth to be proven. pub fn build( @@ -83,10 +83,10 @@ impl StateTreeWires { // d == Σ(v₍ᵢ₋₁₎ · vᵢ) let mut val = cb.one(); let mut acc = cb.zero(); - for i in 0..MAX_DEPTH { - val = cb.mul(val, is_value[i].target); - acc = cb.add(acc, val); - } + acc = is_value.iter().take(MAX_DEPTH).fold(acc, |acc, iv| { + val = cb.mul(val, iv.target); + cb.add(acc, val) + }); cb.connect(acc, depth); let mut root = cb.hash_n_to_hash_no_pad::(leaf_data.to_vec()); diff --git a/mp2-common/src/mpt_sequential/mod.rs b/mp2-common/src/mpt_sequential/mod.rs index a887c9d06..3ded0e97c 100644 --- a/mp2-common/src/mpt_sequential/mod.rs +++ b/mp2-common/src/mpt_sequential/mod.rs @@ -332,7 +332,7 @@ where /// * The key where to lookup the next nibble and thus the hash stored at /// nibble position in the branch node. /// * RLP headers of the current node. - /// And it returns: + /// And it returns: /// * New key with the pointer moved. /// * The child hash / value of the node. /// * A boolean that must be true if the given node is a leaf or an extension. diff --git a/mp2-common/src/proof.rs b/mp2-common/src/proof.rs index 007c43459..4f9154f05 100644 --- a/mp2-common/src/proof.rs +++ b/mp2-common/src/proof.rs @@ -15,8 +15,10 @@ use plonky2::plonk::{ }; use serde::{Deserialize, Serialize}; -/// This data structure allows to specify the inputs for a circuit that needs to -/// recursively verify proofs; the generic type `T` allows to specify the +/// This data structure allows to specify the inputs for a circuit +/// that needs to recursively verify proofs. +/// +/// The generic type `T` allows to specify the /// specific inputs of each circuits besides the proofs that need to be /// recursively verified, while the proofs are serialized in byte format. #[derive(Serialize, Deserialize)] diff --git a/mp2-common/src/rlp.rs b/mp2-common/src/rlp.rs index 7a3e0d225..5784eb2a1 100644 --- a/mp2-common/src/rlp.rs +++ b/mp2-common/src/rlp.rs @@ -251,6 +251,7 @@ pub fn decode_header, const D: usize>( } /// Decodes the header of the list, and then decodes the first N items of the list. +/// /// The offsets decoded in the returned list are starting from the 0-index of `data` /// not from the `offset` index. /// If N is less than the actual number of items, then the number of fields will be N. diff --git a/mp2-common/src/serialization/mod.rs b/mp2-common/src/serialization/mod.rs index 12f5c63bc..9f428e832 100644 --- a/mp2-common/src/serialization/mod.rs +++ b/mp2-common/src/serialization/mod.rs @@ -1,6 +1,6 @@ use std::fmt::Display; -use plonky2::util::serialization::{Buffer, IoError, Read}; +use plonky2::util::serialization::IoError; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; /// Implement serialization for Plonky2 circuits-related data structures diff --git a/mp2-common/src/storage_key.rs b/mp2-common/src/storage_key.rs index 34cb5c986..b12ca87fd 100644 --- a/mp2-common/src/storage_key.rs +++ b/mp2-common/src/storage_key.rs @@ -1,4 +1,6 @@ -//! Module handling the recursive proving of the correct derivation of the MPT path +//! Module handling the recursive proving of the correct derivation +//! of the MPT path +//! //! depending on the type of variables the slot is holding (simple unit variable like uint256 //! variable length & composite type like a mapping). @@ -201,8 +203,8 @@ impl KeccakStructMPT { /// Deriving a MPT key from simple slot is done like: /// 1. location = left_pad32(slot) /// 2. mpt_key = keccak(location) -/// WARNING: Currently takes the assumption that the storage slot number fits -/// inside a single byte. +/// WARNING: Currently takes the assumption that the storage slot number fits +/// inside a single byte. #[derive(Clone, Debug, Serialize, Deserialize)] pub struct SimpleSlot(pub StorageSlot); @@ -256,6 +258,7 @@ impl SimpleSlot { /// mpt_key = keccak256(location) /// Note the simple slot wire and the contract address wires are NOT range /// checked, because they are expected to be given by the verifier. + /// /// If that assumption is not true, then the caller should call /// `b.range_check(slot, 8)` to ensure its byteness. pub fn build_single, const D: usize>( @@ -401,7 +404,7 @@ impl SimpleSlot { /// Deriving a MPT key from mapping slot is done like: /// 1. location = keccak(left_pad32(key), left_pad32(slot)) /// 2. mpt_key = keccak(location) -/// WARNING: Currently takes the assumption that the storage slot number fits inside a single byte. +/// WARNING: Currently takes the assumption that the storage slot number fits inside a single byte. #[derive(Clone, Debug, Serialize, Deserialize)] pub struct MappingSlot { mapping_slot: u8, diff --git a/mp2-common/src/utils.rs b/mp2-common/src/utils.rs index 4d9ca1ad9..d7942d4f6 100644 --- a/mp2-common/src/utils.rs +++ b/mp2-common/src/utils.rs @@ -30,6 +30,7 @@ const TWO_POWER_8: usize = 256; const TWO_POWER_16: usize = 65536; const TWO_POWER_24: usize = 16777216; +#[allow(dead_code)] trait ConnectSlice { fn connect_slice(&mut self, a: &[Target], b: &[Target]); } @@ -142,6 +143,7 @@ pub fn less_than, const D: usize>( } /// Returns true if a < b in the first n bits, False otherwise. +/// /// Will panic if `n >= F::BITS-1`. /// This variant is unsafe since it assumes that `a < 2^n` and `b < 2^n`; /// undefined behavior may occur if this assumption is not ensured by the @@ -177,6 +179,7 @@ pub fn greater_than, const D: usize>( } /// Returns true if a > b in the first n bits, False otherwise. +/// /// Will panic if `n >= F::BITS-1`. /// This variant is unsafe since it assumes that `a < 2^n` and `b < 2^n`; /// undefined behavior may occur if this assumption is not ensured by the @@ -207,6 +210,7 @@ pub fn less_than_or_equal_to, const D: usize>( } /// Returns true if a <= b in the first n bits, False otherwise. +/// /// Will panic if `n >= F::BITS-1`. /// This variant is unsafe since it assumes that `a < 2^n` and `b < 2^n`; /// undefined behavior may occur if this assumption is not ensured by the @@ -238,6 +242,7 @@ pub fn greater_than_or_equal_to, const D: usize>( } /// Returns true if a >= b in the first n bits, False otherwise. +/// /// Will panic if `n >= F::BITS-1`. /// This variant is unsafe since it assumes that `a < 2^n` and `b < 2^n`; /// undefined behavior may occur if this assumption is not ensured by the @@ -480,7 +485,7 @@ impl ToTargets for HashOutTarget { } } -impl<'a> ToTargets for &'a HashOutTarget { +impl ToTargets for &HashOutTarget { fn to_targets(&self) -> Vec { self.elements.to_vec() } @@ -519,7 +524,8 @@ impl TryIntoBool for U256 { } } -/// Trait alias defined to implement `Packer` and `ToBool` traits for `RichField` +/// Implement `Packer` and `ToBool` for `RichField`. +/// /// Fields that want to be packed with `Packer` have to implement /// this trait (trivial implementation). Currently implemented only /// for Goldilocks diff --git a/mp2-test/Cargo.toml b/mp2-test/Cargo.toml index 1c824abda..e4fd7ddbb 100644 --- a/mp2-test/Cargo.toml +++ b/mp2-test/Cargo.toml @@ -8,8 +8,6 @@ alloy.workspace = true anyhow.workspace = true env_logger.workspace = true eth_trie.workspace = true -ethers.workspace = true -hashbrown.workspace = true log.workspace = true plonky2.workspace = true plonky2_ecgfp5.workspace = true diff --git a/mp2-test/src/circuit.rs b/mp2-test/src/circuit.rs index 968655cd6..262d4384e 100644 --- a/mp2-test/src/circuit.rs +++ b/mp2-test/src/circuit.rs @@ -1,17 +1,14 @@ use anyhow::Result; use mp2_common::{C, D, F}; -use plonky2::iop::target::BoolTarget; use plonky2::plonk::circuit_data::CircuitConfig; -use plonky2::plonk::proof::{ProofWithPublicInputs, ProofWithPublicInputsTarget}; +use plonky2::plonk::proof::ProofWithPublicInputs; use plonky2::{ field::extension::Extendable, hash::hash_types::RichField, iop::witness::PartialWitness, plonk::{ circuit_builder::CircuitBuilder, - circuit_data::{ - CircuitData, CommonCircuitData, VerifierCircuitData, VerifierOnlyCircuitData, - }, + circuit_data::{CircuitData, VerifierCircuitData}, config::GenericConfig, }, }; diff --git a/mp2-v1/Cargo.toml b/mp2-v1/Cargo.toml index 7ff9b4590..8b66b1c13 100644 --- a/mp2-v1/Cargo.toml +++ b/mp2-v1/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] anyhow.workspace = true bincode.workspace = true -env_logger.workspace = true eth_trie.workspace = true hashbrown.workspace = true alloy.workspace = true @@ -20,8 +19,6 @@ plonky2_ecgfp5.workspace = true rand.workspace = true rlp.workspace = true serde.workspace = true -serde_arrays.workspace = true -sha3.workspace = true mp2_common = { path = "../mp2-common" } recursion_framework = { path = "../recursion-framework" } @@ -29,19 +26,19 @@ ryhope = { path = "../ryhope" } verifiable-db = { path = "../verifiable-db" } derive_more = "0.99.18" hex.workspace = true -parsil = { path = "../parsil" } serde_json.workspace = true [dev-dependencies] alloy.workspace = true csv.workspace = true hex.workspace = true -rmp-serde.workspace = true serde_json.workspace = true tokio.workspace = true serial_test.workspace = true mp2_test = { path = "../mp2-test" } +parsil = { path = "../parsil" } +env_logger.workspace = true envconfig = "0.10.0" test-log = "0.2.16" jammdb = "0.11.0" diff --git a/mp2-v1/src/block_extraction/public_inputs.rs b/mp2-v1/src/block_extraction/public_inputs.rs index 4f8fd60d6..143eeac93 100644 --- a/mp2-v1/src/block_extraction/public_inputs.rs +++ b/mp2-v1/src/block_extraction/public_inputs.rs @@ -30,7 +30,7 @@ pub struct PublicInputs<'a, T> { pub(crate) sh: &'a [T], } -impl<'a> PublicInputCommon for PublicInputs<'a, Target> { +impl PublicInputCommon for PublicInputs<'_, Target> { const RANGES: &'static [PublicInputRange] = &[BH_RANGE, PREV_BH_RANGE, BN_RANGE, SH_RANGE]; fn register_args(&self, cb: &mut CBuilder) { @@ -74,7 +74,7 @@ impl<'a> PublicInputs<'a, Target> { } } -impl<'a, T: Clone> PublicInputs<'a, T> { +impl PublicInputs<'_, T> { /// Creates a vector from the parts of the public inputs pub fn to_vec(&self) -> Vec { self.bh diff --git a/mp2-v1/src/contract_extraction/api.rs b/mp2-v1/src/contract_extraction/api.rs index 885270e0b..8d0d8a53a 100644 --- a/mp2-v1/src/contract_extraction/api.rs +++ b/mp2-v1/src/contract_extraction/api.rs @@ -278,7 +278,7 @@ mod tests { let child_pi = PublicInputs::from_slice(&child_pi); // Check packed block hash { - let hash = keccak256(&node).pack(Endianness::Little).to_fields(); + let hash = keccak256(node).pack(Endianness::Little).to_fields(); assert_eq!(pi.h, hash); } // Check metadata digest @@ -288,7 +288,7 @@ mod tests { assert_eq!(pi.k, child_pi.k); // child pointer - partial key length - let keys: Vec> = rlp::decode_list(&node); + let keys: Vec> = rlp::decode_list(node); let nibbles = Nibbles::from_compact(&keys[0]); let exp_ptr = *child_pi.t - F::from_canonical_usize(nibbles.nibbles().len()); @@ -311,7 +311,7 @@ mod tests { let child_pi = PublicInputs::from_slice(&child_pi); // Check packed block hash { - let hash = keccak256(&node).pack(Endianness::Little).to_fields(); + let hash = keccak256(node).pack(Endianness::Little).to_fields(); assert_eq!(pi.h, hash); } // Check metadata digest diff --git a/mp2-v1/src/contract_extraction/branch.rs b/mp2-v1/src/contract_extraction/branch.rs index 88b3ed0b4..ff27d2147 100644 --- a/mp2-v1/src/contract_extraction/branch.rs +++ b/mp2-v1/src/contract_extraction/branch.rs @@ -147,7 +147,7 @@ mod tests { child_pi: &'a [F], } - impl<'a, const NODE_LEN: usize> UserCircuit for TestBranchCircuit<'a, NODE_LEN> + impl UserCircuit for TestBranchCircuit<'_, NODE_LEN> where [(); PAD_LEN(NODE_LEN)]:, { diff --git a/mp2-v1/src/contract_extraction/extension.rs b/mp2-v1/src/contract_extraction/extension.rs index 487bfd9dd..afca4bae9 100644 --- a/mp2-v1/src/contract_extraction/extension.rs +++ b/mp2-v1/src/contract_extraction/extension.rs @@ -118,7 +118,7 @@ mod tests { child_pi: &'a [F], } - impl<'a> UserCircuit for TestExtensionCircuit<'a> { + impl UserCircuit for TestExtensionCircuit<'_> { // Extension node wires + child public inputs type Wires = (ExtensionWires, Vec); diff --git a/mp2-v1/src/contract_extraction/public_inputs.rs b/mp2-v1/src/contract_extraction/public_inputs.rs index 9b78908ea..3f8f4275e 100644 --- a/mp2-v1/src/contract_extraction/public_inputs.rs +++ b/mp2-v1/src/contract_extraction/public_inputs.rs @@ -35,7 +35,7 @@ pub struct PublicInputs<'a, T> { pub(crate) s: &'a [T], } -impl<'a> PublicInputCommon for PublicInputs<'a, Target> { +impl PublicInputCommon for PublicInputs<'_, Target> { const RANGES: &'static [PublicInputRange] = &[H_RANGE, DM_RANGE, K_RANGE, T_RANGE, S_RANGE]; fn register_args(&self, cb: &mut CBuilder) { @@ -47,7 +47,7 @@ impl<'a> PublicInputCommon for PublicInputs<'a, Target> { } } -impl<'a> PublicInputs<'a, GFp> { +impl PublicInputs<'_, GFp> { /// Get the metadata point. pub fn metadata_point(&self) -> WeierstrassPoint { WeierstrassPoint::from_fields(self.dm) @@ -172,7 +172,7 @@ mod tests { exp_pi: &'a [F], } - impl<'a> UserCircuit for TestPICircuit<'a> { + impl UserCircuit for TestPICircuit<'_> { type Wires = Vec; fn build(b: &mut CBuilder) -> Self::Wires { @@ -183,7 +183,7 @@ mod tests { } fn prove(&self, pw: &mut PartialWitness, wires: &Self::Wires) { - pw.set_target_arr(&wires, self.exp_pi); + pw.set_target_arr(wires, self.exp_pi); } } diff --git a/mp2-v1/src/final_extraction/base_circuit.rs b/mp2-v1/src/final_extraction/base_circuit.rs index 52cdf52c1..92f1457e4 100644 --- a/mp2-v1/src/final_extraction/base_circuit.rs +++ b/mp2-v1/src/final_extraction/base_circuit.rs @@ -4,7 +4,7 @@ use mp2_common::{ group_hashing::CircuitBuilderGroupHashing, keccak::PACKED_HASH_LEN, proof::{deserialize_proof, verify_proof_fixed_circuit, ProofWithVK}, - serialization::{deserialize, deserialize_vec, serialize, serialize_vec}, + serialization::{deserialize, serialize}, u256::UInt256Target, C, D, F, }; @@ -16,7 +16,6 @@ use plonky2::{ }, plonk::{ circuit_builder::CircuitBuilder, - config::AlgebraicHasher, proof::{ProofWithPublicInputs, ProofWithPublicInputsTarget}, }, }; @@ -25,7 +24,6 @@ use recursion_framework::framework::{ RecursiveCircuits, RecursiveCircuitsVerifierGagdet, RecursiveCircuitsVerifierTarget, }; use serde::{Deserialize, Serialize}; -use std::array::from_fn as create_array; use crate::{block_extraction, contract_extraction, values_extraction}; @@ -116,6 +114,7 @@ pub(crate) struct BaseCircuitProofWires { pub(crate) const CONTRACT_SET_NUM_IO: usize = contract_extraction::PublicInputs::::TOTAL_LEN; pub(crate) const VALUE_SET_NUM_IO: usize = values_extraction::PublicInputs::::TOTAL_LEN; +// WARN: clippy is wrong on this one, it is used somewhere else. pub(crate) const BLOCK_SET_NUM_IO: usize = block_extraction::public_inputs::PublicInputs::::TOTAL_LEN; @@ -207,7 +206,7 @@ impl BaseCircuitProofInputs { .zip(self.proofs.value_proofs.iter()) { let (p, vd) = proof.into(); - w.set_target(pw, &self.value_circuit_set, &p, &vd)?; + w.set_target(pw, &self.value_circuit_set, p, vd)?; } Ok(()) } @@ -314,9 +313,9 @@ pub(crate) mod test { } } pub(crate) fn assign(&self, pw: &mut PartialWitness, pis: &ProofsPi) { - pw.set_target_arr(&self.values_pi, &pis.values_pi.as_ref()); - pw.set_target_arr(&self.contract_pi, &pis.contract_pi.as_ref()); - pw.set_target_arr(&self.blocks_pi, &pis.blocks_pi.as_ref()); + pw.set_target_arr(&self.values_pi, pis.values_pi.as_ref()); + pw.set_target_arr(&self.contract_pi, pis.contract_pi.as_ref()); + pw.set_target_arr(&self.blocks_pi, pis.blocks_pi.as_ref()); } } @@ -412,10 +411,9 @@ pub(crate) mod test { // metadata is addition of contract and value // ToDo: make it a trait once we understand it's sound let weierstrass_to_point = |wp: WeierstrassPoint| { - Point::decode(wp.encode()).map(|p| { + Point::decode(wp.encode()).inspect(|p| { // safety-check assert_eq!(p.to_weierstrass(), wp); - p }) }; let contract_pi = contract_extraction::PublicInputs::from_slice(&self.contract_pi); diff --git a/mp2-v1/src/final_extraction/lengthed_circuit.rs b/mp2-v1/src/final_extraction/lengthed_circuit.rs index 2091213ea..f9e23fa68 100644 --- a/mp2-v1/src/final_extraction/lengthed_circuit.rs +++ b/mp2-v1/src/final_extraction/lengthed_circuit.rs @@ -210,7 +210,7 @@ mod test { let test_circuit = TestLengthedCircuit { pis: pis.clone(), circuit: LengthedCircuit {}, - len_pi: len_pi, + len_pi, }; let len_pi = length_extraction::PublicInputs::::from_slice(&test_circuit.len_pi); let len_dm = len_pi.metadata_point(); diff --git a/mp2-v1/src/final_extraction/mod.rs b/mp2-v1/src/final_extraction/mod.rs index 255b19d5c..cb6e1c6a4 100644 --- a/mp2-v1/src/final_extraction/mod.rs +++ b/mp2-v1/src/final_extraction/mod.rs @@ -11,5 +11,4 @@ pub use public_inputs::PublicInputs; pub(crate) use base_circuit::BaseCircuitProofInputs; pub(crate) use lengthed_circuit::LengthedCircuitInput as LengthedCircuit; pub(crate) use merge_circuit::MergeCircuitInput as MergeCircuit; -use serde::{Deserialize, Serialize}; pub(crate) use simple_circuit::SimpleCircuitInput as SimpleCircuit; diff --git a/mp2-v1/src/final_extraction/public_inputs.rs b/mp2-v1/src/final_extraction/public_inputs.rs index 08bbf5b75..7244e7105 100644 --- a/mp2-v1/src/final_extraction/public_inputs.rs +++ b/mp2-v1/src/final_extraction/public_inputs.rs @@ -48,7 +48,7 @@ pub struct PublicInputs<'a, T> { pub(crate) merge: &'a [T], } -impl<'a> PublicInputCommon for PublicInputs<'a, Target> { +impl PublicInputCommon for PublicInputs<'_, Target> { const RANGES: &'static [PublicInputRange] = &[H_RANGE, PH_RANGE, DV_RANGE, DM_RANGE, BN_RANGE, MERGE_RANGE]; @@ -93,11 +93,11 @@ impl<'a> ExtractionPI<'a> for PublicInputs<'a, Target> { } } -impl<'a> ExtractionPIWrap for PublicInputs<'a, Target> { +impl ExtractionPIWrap for PublicInputs<'_, Target> { type PI<'b> = PublicInputs<'b, Target>; } -impl<'a> PublicInputs<'a, F> { +impl PublicInputs<'_, F> { /// Get the metadata point. pub fn metadata_point(&self) -> WeierstrassPoint { WeierstrassPoint::from_fields(self.dm) @@ -137,7 +137,7 @@ impl<'a, T> PublicInputs<'a, T> { } } -impl<'a> PublicInputs<'a, Target> { +impl PublicInputs<'_, Target> { pub fn generic_register_args(&self, cb: &mut CBuilder) { cb.register_public_inputs(self.h); cb.register_public_inputs(self.ph); @@ -224,7 +224,7 @@ impl<'a, T: Copy> PublicInputs<'a, T> { } pub fn is_merge_raw(&self) -> &[T] { - &self.merge + self.merge } } @@ -251,7 +251,7 @@ mod tests { exp_pi: &'a [F], } - impl<'a> UserCircuit for TestPICircuit<'a> { + impl UserCircuit for TestPICircuit<'_> { type Wires = Vec; fn build(b: &mut CBuilder) -> Self::Wires { diff --git a/mp2-v1/src/indexing/row.rs b/mp2-v1/src/indexing/row.rs index a6d621335..daf10ff5b 100644 --- a/mp2-v1/src/indexing/row.rs +++ b/mp2-v1/src/indexing/row.rs @@ -83,6 +83,7 @@ impl RowTreeKey { } /// CellInfo is the structure saved in the row JSON payload. +/// /// Each cell info is identified by its column ID in the CellCollection. /// The primary information is required to be able to pinpoint each cells to its associated proof. /// This is required to be able to snapsho, go back in time, prove multiple blocks in parallel etc. @@ -103,6 +104,7 @@ impl CellInfo { } /// A collection of cells inserted in the JSON. +/// /// IMPORTANT: This collection MUST CONTAIN the secondary index value, as first element, to easily /// search in JSONB from the SQL. It is also important it is in an easily /// searchable format. diff --git a/mp2-v1/src/length_extraction/branch.rs b/mp2-v1/src/length_extraction/branch.rs index d0d69a1e0..157f0b590 100644 --- a/mp2-v1/src/length_extraction/branch.rs +++ b/mp2-v1/src/length_extraction/branch.rs @@ -176,7 +176,6 @@ pub mod tests { } let length = GFp::from_canonical_u32(value); let dm = compute_metadata_digest(length_slot, variable_slot).to_weierstrass(); - let is_inf = GFp::from_bool(dm.is_inf); // compute the public inputs for the first iteration @@ -201,7 +200,7 @@ pub mod tests { let proof_pi = PublicInputs::::from_slice(&branch_proof.public_inputs); branch_pi = proof_pi.to_vec(); - let root: Vec<_> = keccak256(&node).pack(Endianness::Little).to_fields(); + let root: Vec<_> = keccak256(node).pack(Endianness::Little).to_fields(); assert_eq!(proof_pi.length(), &length); assert_eq!(proof_pi.root_hash_raw(), &root); @@ -223,7 +222,7 @@ pub mod tests { pub pi: &'a [GFp], } - impl<'a> UserCircuit for BranchTestCircuit<'a> { + impl UserCircuit for BranchTestCircuit<'_> { type Wires = BranchTestWires; fn build(cb: &mut CBuilder) -> Self::Wires { diff --git a/mp2-v1/src/length_extraction/extension.rs b/mp2-v1/src/length_extraction/extension.rs index 7e250e03b..db015cec3 100644 --- a/mp2-v1/src/length_extraction/extension.rs +++ b/mp2-v1/src/length_extraction/extension.rs @@ -257,7 +257,7 @@ pub mod tests { pub pi: &'a [GFp], } - impl<'a> UserCircuit for ExtensionTestCircuit<'a> { + impl UserCircuit for ExtensionTestCircuit<'_> { type Wires = ExtensionTestWires; fn build(cb: &mut CBuilder) -> Self::Wires { diff --git a/mp2-v1/src/length_extraction/leaf.rs b/mp2-v1/src/length_extraction/leaf.rs index fb14a556b..531cbd6f5 100644 --- a/mp2-v1/src/length_extraction/leaf.rs +++ b/mp2-v1/src/length_extraction/leaf.rs @@ -216,9 +216,9 @@ pub mod tests { let leaf_proof = prove_circuit(&setup, &leaf_circuit); let leaf_pi = PublicInputs::::from_slice(&leaf_proof.public_inputs); - let root: Vec<_> = keccak256(&node).pack(Endianness::Little).to_fields(); + let root: Vec<_> = keccak256(node).pack(Endianness::Little).to_fields(); - let rlp_headers: Vec> = rlp::decode_list(&node); + let rlp_headers: Vec> = rlp::decode_list(node); let rlp_nibbles = Nibbles::from_compact(&rlp_headers[0]); let t = GFp::from_canonical_usize(MAX_KEY_NIBBLE_LEN - 1) - GFp::from_canonical_usize(rlp_nibbles.nibbles().len()); diff --git a/mp2-v1/src/length_extraction/public_inputs.rs b/mp2-v1/src/length_extraction/public_inputs.rs index 1e4744afc..f6062809c 100644 --- a/mp2-v1/src/length_extraction/public_inputs.rs +++ b/mp2-v1/src/length_extraction/public_inputs.rs @@ -35,7 +35,7 @@ pub struct PublicInputs<'a, T> { pub(crate) n: &'a T, } -impl<'a> PublicInputCommon for PublicInputs<'a, Target> { +impl PublicInputCommon for PublicInputs<'_, Target> { const RANGES: &'static [PublicInputRange] = &[H_RANGE, DM_RANGE, K_RANGE, T_RANGE, N_RANGE]; fn register_args(&self, cb: &mut CBuilder) { @@ -82,7 +82,7 @@ impl<'a> PublicInputs<'a, Target> { } } -impl<'a, T: Clone> PublicInputs<'a, T> { +impl PublicInputs<'_, T> { /// Creates a vector from the parts of the public inputs pub fn to_vec(&self) -> Vec { self.h @@ -149,7 +149,7 @@ impl<'a, T> PublicInputs<'a, T> { } } -impl<'a> PublicInputs<'a, GFp> { +impl PublicInputs<'_, GFp> { /// Creates a [WeierstrassPoint] from the metadata. pub fn metadata_point(&self) -> WeierstrassPoint { WeierstrassPoint::from_fields(self.dm) diff --git a/mp2-v1/src/values_extraction/api.rs b/mp2-v1/src/values_extraction/api.rs index ca9f1523e..010b5ee8a 100644 --- a/mp2-v1/src/values_extraction/api.rs +++ b/mp2-v1/src/values_extraction/api.rs @@ -9,8 +9,8 @@ use super::{ leaf_single::{LeafSingleCircuit, LeafSingleWires}, public_inputs::PublicInputs, }; -use crate::{api::InputNode, MAX_BRANCH_NODE_LEN}; -use anyhow::{bail, Result}; +use crate::{api::InputNode, MAX_BRANCH_NODE_LEN, MAX_LEAF_NODE_LEN}; +use anyhow::{bail, ensure, Result}; use log::debug; use mp2_common::{ default_config, @@ -260,30 +260,25 @@ macro_rules! impl_branch_circuits { // from the public inputs of the children proofs. // Note this is done outside circuits, more as a sanity check. The circuits is enforcing // this condition. - let valid_inputs = child_proofs - .windows(2) - .all(|arr| { - if arr.len() == 1 { - true - } else { - let pi1 = PublicInputs::::new(&arr[0].proof().public_inputs); - let (k1, p1) = pi1.mpt_key_info(); - let pi2 = PublicInputs::::new(&arr[1].proof().public_inputs); - let (k2, p2) = pi2.mpt_key_info(); - let up1 = p1.to_canonical_u64() as usize; - let up2 = p2.to_canonical_u64() as usize; - up1 < k1.len() && up2 < k2.len() && p1 == p2 && k1[..up1] == k2[..up2] - } - }); - if !valid_inputs { - bail!("proofs don't match on the key and/or pointers"); - } - if child_proofs.is_empty() || child_proofs.len() > 16 { - bail!("No child proofs or too many child proofs"); - } - if branch_node.node.len() > MAX_BRANCH_NODE_LEN { - bail!("Branch node too long"); + for arr in child_proofs.windows(2) { + if arr.len() > 1 { + let pi1 = PublicInputs::::new(&arr[0].proof().public_inputs); + let (k1, p1) = pi1.mpt_key_info(); + let pi2 = PublicInputs::::new(&arr[1].proof().public_inputs); + let (k2, p2) = pi2.mpt_key_info(); + let up1 = p1.to_canonical_u64() as usize; + let up2 = p2.to_canonical_u64() as usize; + + ensure!(up1 < k1.len(), "up1 ({}) >= |k1| ({})", up1, k1.len()); + ensure!(up2 < k2.len(), "up2 ({}) >= |k2| ({})", up2, k2.len()); + ensure!(p1 == p2, "p1 ({p1}) != p2 ({p2})"); + ensure!(k1[..up1] == k2[..up1], "k1[..up1] ({:?}) != k[2..up2] ({:?})", &k1[..up1], &k2[..up2]); + } + } + ensure!(!child_proofs.is_empty(), "empty child_proofs"); + ensure!(child_proofs.len() <= 16, "too many child proofs found: {}", child_proofs.len()); + ensure!(branch_node.node.len() <= MAX_BRANCH_NODE_LEN, "branch_node too long: {}", branch_node.node.len()); // We just take the first one, it doesn't matter which one we // take as long as all prefixes and pointers are equal. @@ -340,7 +335,7 @@ macro_rules! impl_branch_circuits { ).map(|p| (p, self.[< b $i>].get_verifier_data().clone()).into()) } )+ - _ => bail!("invalid child proof len"), + _ => bail!("invalid child proof len: {}", child_proofs.len()), } } }} diff --git a/mp2-v1/src/values_extraction/branch.rs b/mp2-v1/src/values_extraction/branch.rs index cbd674706..8b713129f 100644 --- a/mp2-v1/src/values_extraction/branch.rs +++ b/mp2-v1/src/values_extraction/branch.rs @@ -93,7 +93,7 @@ where let mut seen_nibbles = vec![]; for (i, proof_inputs) in inputs.iter().enumerate() { let it = b.constant(GFp::from_canonical_usize(i)); - let should_process = less_than(b, it, n_proof_valid, 4); + let should_process = less_than(b, it, n_proof_valid, 5); // Accumulate the values digest. let child_digest = proof_inputs.values_digest_target(); @@ -250,8 +250,8 @@ mod tests { child_pis: [PublicInputs<'a, F>; N_CHILDREN], } - impl<'a, const NODE_LEN: usize, const N_CHILDREN: usize> UserCircuit - for TestBranchCircuit<'a, NODE_LEN, N_CHILDREN> + impl UserCircuit + for TestBranchCircuit<'_, NODE_LEN, N_CHILDREN> where [(); PAD_LEN(NODE_LEN)]:, { @@ -343,32 +343,32 @@ mod tests { let mut trie = EthTrie::new(Arc::clone(&memdb)); let key: Vec = random_vector(32); - for i in 0..N_REAL { + for (i, child) in children.iter_mut().enumerate().take(N_REAL) { let mut key = key.clone(); key[31] = key[31].wrapping_add(i as u8); let value = random_vector(32); trie.insert(&key, &value).unwrap(); - children[i].key = key; - children[i].value = value; + child.key = key; + child.value = value; } trie.root_hash().unwrap(); let metadata = random_vector(20); - for i in 0..N_REAL { - let proof = trie.get_proof(&children[i].key).unwrap(); + for (_, child) in children.iter_mut().enumerate().take(N_REAL) { + let proof = trie.get_proof(&child.key).unwrap(); assert!(proof.len() == 3); let leaf = proof.last().unwrap(); let ptr = compute_key_ptr(leaf); - let pi = compute_pi(ptr, &children[i].key, &children[i].value, leaf, &metadata); + let pi = compute_pi(ptr, &child.key, &child.value, leaf, &metadata); assert_eq!(pi.len(), PublicInputs::::TOTAL_LEN); - children[i].proof = proof.clone(); - children[i].leaf = leaf.clone(); - children[i].ptr = ptr; - children[i].metadata = metadata.clone(); - children[i].pi = pi; + child.proof = proof.clone(); + child.leaf = leaf.clone(); + child.ptr = ptr; + child.metadata = metadata.clone(); + child.pi = pi; } let node = children[0].proof[1].clone(); @@ -412,20 +412,21 @@ mod tests { } // Check values digest { - let mut branch_acc = Point::NEUTRAL; - for i in 0..N_REAL { - branch_acc += compute_digest(children[i].value.clone()); - } + let branch_acc = children + .iter() + .take(N_REAL) + .map(|child| compute_digest(child.value.clone())) + .fold(Point::NEUTRAL, |acc, digest| acc + digest); assert_eq!(pi.values_digest(), branch_acc.to_weierstrass()); } // Check metadata digest { let branch_acc = compute_digest(children[0].metadata.clone()); - for i in 1..N_REAL { - let child_acc = compute_digest(children[i].metadata.clone()); - assert_eq!(branch_acc, child_acc); - } + children[1..].iter().for_each(|child| { + let child_acc = compute_digest(child.metadata.clone()); + assert_eq!(child_acc, branch_acc); + }); assert_eq!(pi.metadata_digest(), branch_acc.to_weierstrass()); } diff --git a/mp2-v1/src/values_extraction/extension.rs b/mp2-v1/src/values_extraction/extension.rs index 8a33604a4..aea08a230 100644 --- a/mp2-v1/src/values_extraction/extension.rs +++ b/mp2-v1/src/values_extraction/extension.rs @@ -123,7 +123,7 @@ mod tests { exp_pi: PublicInputs<'a, F>, } - impl<'a> UserCircuit for TestExtensionNodeCircuit<'a> { + impl UserCircuit for TestExtensionNodeCircuit<'_> { // Extension node wires + child public inputs type Wires = (ExtensionNodeWires, Vec); diff --git a/mp2-v1/src/values_extraction/public_inputs.rs b/mp2-v1/src/values_extraction/public_inputs.rs index 0b3e0a433..2a0c1238a 100644 --- a/mp2-v1/src/values_extraction/public_inputs.rs +++ b/mp2-v1/src/values_extraction/public_inputs.rs @@ -44,7 +44,7 @@ pub struct PublicInputsArgs<'a> { pub(crate) n: Target, } -impl<'a> PublicInputCommon for PublicInputsArgs<'a> { +impl PublicInputCommon for PublicInputsArgs<'_> { const RANGES: &'static [PublicInputRange] = &[H_RANGE, K_RANGE, T_RANGE, DV_RANGE, DM_RANGE, N_RANGE]; @@ -63,7 +63,7 @@ pub struct PublicInputs<'a, T> { pub(crate) proof_inputs: &'a [T], } -impl<'a> PublicInputs<'a, Target> { +impl PublicInputs<'_, Target> { /// Get the merkle hash of the subtree this proof has processed. pub fn root_hash_target(&self) -> OutputHash { OutputHash::from_targets(self.root_hash_info()) @@ -91,7 +91,7 @@ impl<'a> PublicInputs<'a, Target> { } } -impl<'a> PublicInputs<'a, GFp> { +impl PublicInputs<'_, GFp> { /// Get the merkle hash of the subtree this proof has processed. pub fn root_hash(&self) -> Vec { let hash = self.root_hash_info(); diff --git a/mp2-v1/tests/common/cases/indexing.rs b/mp2-v1/tests/common/cases/indexing.rs index b40ee8017..ee98ae9f9 100644 --- a/mp2-v1/tests/common/cases/indexing.rs +++ b/mp2-v1/tests/common/cases/indexing.rs @@ -1131,7 +1131,7 @@ impl UpdateSimpleStorage { .map(|tuple| { let op: MappingOperation = tuple.into(); let (k, v) = match tuple { - MappingValuesUpdate::Deletion(k, _) => (*k, DEFAULT_ADDRESS.clone()), + MappingValuesUpdate::Deletion(k, _) => (*k, *DEFAULT_ADDRESS), MappingValuesUpdate::Update(k, _, v) | MappingValuesUpdate::Insertion(k, v) => { (*k, Address::from_slice(&v.to_be_bytes_trimmed_vec())) } diff --git a/mp2-v1/tests/common/cases/mod.rs b/mp2-v1/tests/common/cases/mod.rs index 31b60514c..b96859a11 100644 --- a/mp2-v1/tests/common/cases/mod.rs +++ b/mp2-v1/tests/common/cases/mod.rs @@ -1,28 +1,10 @@ //! Define test cases -use crate::common::StorageSlotInfo; -use alloy::primitives::{Address, U256}; use contract::Contract; -use indexing::{TableRowUpdate, TableRowValues}; -use log::debug; -use mp2_common::eth::StorageSlot; -use mp2_v1::{ - indexing::{ - block::BlockPrimaryIndex, - cell::Cell, - row::{RowTreeKey, ToNonce}, - ColumnID, - }, - values_extraction::identifier_for_mapping_key_column, -}; -use serde::{Deserialize, Serialize}; +use mp2_v1::values_extraction::identifier_for_mapping_key_column; use table_source::{ContractExtractionArgs, TableSource}; -use super::{ - rowtree::SecondaryIndexCell, - table::{CellsUpdate, Table}, - TableInfo, -}; +use super::table::Table; pub mod contract; pub mod indexing; diff --git a/mp2-v1/tests/common/cases/planner.rs b/mp2-v1/tests/common/cases/planner.rs index e78268acc..03b06009d 100644 --- a/mp2-v1/tests/common/cases/planner.rs +++ b/mp2-v1/tests/common/cases/planner.rs @@ -1,6 +1,5 @@ use std::{collections::HashSet, future::Future}; -use alloy::{primitives::U256, rpc::types::Block}; use anyhow::Result; use log::info; use mp2_v1::indexing::{ @@ -9,8 +8,7 @@ use mp2_v1::indexing::{ row::{RowPayload, RowTreeKey}, }; use parsil::{assembler::DynamicCircuitPis, ParsilSettings}; -use ryhope::{storage::WideLineage, tree::NodeContext, Epoch, NodePayload}; -use verifiable_db::query::aggregation::QueryBounds; +use ryhope::{storage::WideLineage, tree::NodeContext, Epoch}; use crate::common::{ cases::query::aggregated_queries::prove_non_existence_row, @@ -134,8 +132,8 @@ impl TreeInfo> self, &planner.columns, primary, - &k, - &planner.pis, + k, + planner.pis, &planner.query, ) .await?, @@ -145,13 +143,12 @@ impl TreeInfo> }) } - fn fetch_ctx_and_payload_at( + async fn fetch_ctx_and_payload_at( &self, epoch: Epoch, key: &RowTreeKey, - ) -> impl Future, RowPayload)>> + Send - { - async move { self.ctx_and_payload_at(epoch, key) } + ) -> Option<(NodeContext, RowPayload)> { + self.ctx_and_payload_at(epoch, key) } } @@ -228,8 +225,8 @@ impl<'b> TreeInfo> for RowInfo<'b> { self, &planner.columns, primary, - &k, - &planner.pis, + k, + planner.pis, &planner.query, ) .await?, @@ -239,13 +236,12 @@ impl<'b> TreeInfo> for RowInfo<'b> { }) } - fn fetch_ctx_and_payload_at( + async fn fetch_ctx_and_payload_at( &self, epoch: Epoch, key: &RowTreeKey, - ) -> impl Future, RowPayload)>> + Send - { - async move { self.tree.try_fetch_with_context_at(key, epoch).await } + ) -> Option<(NodeContext, RowPayload)> { + self.tree.try_fetch_with_context_at(key, epoch).await } } @@ -298,13 +294,12 @@ impl TreeInfo> load_or_prove_embedded_index(self, planner, primary, k, v).await } - fn fetch_ctx_and_payload_at( + async fn fetch_ctx_and_payload_at( &self, epoch: Epoch, key: &BlockPrimaryIndex, - ) -> impl Future, IndexNode)>> - + Send { - async move { self.ctx_and_payload_at(epoch, key) } + ) -> Option<(NodeContext, IndexNode)> { + self.ctx_and_payload_at(epoch, key) } } @@ -370,13 +365,12 @@ impl<'b> TreeInfo> for IndexInfo load_or_prove_embedded_index(self, planner, primary, k, v).await } - fn fetch_ctx_and_payload_at( + async fn fetch_ctx_and_payload_at( &self, epoch: Epoch, key: &BlockPrimaryIndex, - ) -> impl Future, IndexNode)>> - + Send { - async move { self.tree.try_fetch_with_context_at(key, epoch).await } + ) -> Option<(NodeContext, IndexNode)> { + self.tree.try_fetch_with_context_at(key, epoch).await } } @@ -400,7 +394,7 @@ async fn load_or_prove_embedded_index< let row_root_proof_key = ProofKey::QueryAggregateRow(( planner.query.query.clone(), planner.query.placeholders.placeholder_values(), - k.clone(), + *k, v.row_tree_root_key.clone(), )); let proof = match planner.ctx.storage.get_proof_exact(&row_root_proof_key) { @@ -413,12 +407,9 @@ async fn load_or_prove_embedded_index< .ctx .storage .get_proof_exact(&row_root_proof_key) - .expect( - format!( - "non-existence root proof not found for key {row_root_proof_key:?}" - ) - .as_str(), - ) + .unwrap_or_else(|_| { + panic!("non-existence root proof not found for key {row_root_proof_key:?}") + }) } }; Some(proof) diff --git a/mp2-v1/tests/common/cases/query/aggregated_queries.rs b/mp2-v1/tests/common/cases/query/aggregated_queries.rs index 57f5d7afc..5a4dda0fe 100644 --- a/mp2-v1/tests/common/cases/query/aggregated_queries.rs +++ b/mp2-v1/tests/common/cases/query/aggregated_queries.rs @@ -84,6 +84,7 @@ pub type RevelationPublicInputs<'a> = PublicInputs<'a, F, MAX_NUM_OUTPUTS, MAX_NUM_ITEMS_PER_OUTPUT, MAX_NUM_PLACEHOLDERS>; /// Execute a query to know all the touched rows, and then call the universal circuit on all rows +#[warn(clippy::too_many_arguments)] pub(crate) async fn prove_query( ctx: &mut TestContext, table: &Table, @@ -108,9 +109,9 @@ pub(crate) async fn prove_query( let mut planner = QueryPlanner { ctx, query: query.clone(), - settings: &settings, + settings, pis: &pis, - table: &table, + table, columns: table.columns.clone(), }; @@ -211,23 +212,24 @@ pub(crate) async fn prove_query( info!("Query proofs done! Generating revelation proof..."); let proof = prove_revelation(ctx, table, &query, &pis, table.index.current_epoch()).await?; info!("Revelation proof done! Checking public inputs..."); + + // get number of matching rows + let num_touched_rows = { + let mut exec_query = parsil::executor::generate_query_keys(&mut parsed, &settings)?; + let query_params = exec_query.convert_placeholders(&query.placeholders); + table + .execute_row_query( + &exec_query + .normalize_placeholder_names() + .to_pgsql_string_with_placeholder(), + &query_params, + ) + .await? + .len() + }; // get `StaticPublicInputs`, i.e., the data about the query available only at query registration time, // to check the public inputs let pis = parsil::assembler::assemble_static(&parsed, &settings)?; - - // get number of matching rows - let mut exec_query = parsil::executor::generate_query_keys(&mut parsed, &settings)?; - let query_params = exec_query.convert_placeholders(&query.placeholders); - let num_touched_rows = table - .execute_row_query( - &exec_query - .normalize_placeholder_names() - .to_pgsql_string_with_placeholder(), - &query_params, - ) - .await? - .len(); - check_final_outputs( proof, ctx, @@ -265,7 +267,7 @@ async fn prove_revelation( let pk = ProofKey::IVC(tree_epoch as BlockPrimaryIndex); ctx.storage.get_proof_exact(&pk)? }; - let input = RevelationCircuitInput::new_revelation_no_results_tree( + let input = RevelationCircuitInput::new_revelation_aggregated( query_proof, indexing_proof, &pis.bounds, @@ -280,6 +282,7 @@ async fn prove_revelation( Ok(proof) } +#[warn(clippy::too_many_arguments)] pub(crate) fn check_final_outputs( revelation_proof: Vec, ctx: &TestContext, @@ -382,7 +385,7 @@ pub(crate) fn check_final_outputs( /// clippy doesn't see that it can not be done #[allow(clippy::needless_lifetimes)] async fn prove_query_on_tree<'a, I, K, V>( - mut planner: &mut QueryPlanner<'a>, + planner: &mut QueryPlanner<'a>, info: I, update: UpdateTree, primary: BlockPrimaryIndex, @@ -443,7 +446,7 @@ where .expect("cache is not full"); let is_satisfying_query = info.is_satisfying_query(k); let embedded_proof = info - .load_or_prove_embedded(&mut planner, primary, k, &node_payload) + .load_or_prove_embedded(planner, primary, k, &node_payload) .await; if node_ctx.is_leaf() && info.is_row_tree() { // NOTE: if it is a leaf of the row tree, then there is no need to prove anything, @@ -456,10 +459,10 @@ where if is_satisfying_query { // unwrap is safe since we are guaranteed the row is satisfying the query info.save_proof( - &mut planner.ctx, + planner.ctx, &query_id, primary, - &k, + k, placeholder_values.clone(), embedded_proof?.unwrap(), )?; @@ -490,12 +493,12 @@ where continue; } assert!( - info.is_satisfying_query(&k), + info.is_satisfying_query(k), "first node in merkle path should always be a valid query one" ); let (node_info, left_info, right_info) = // we can use primary as epoch now that tree stores epoch from genesis - get_node_info(&info, &k, primary as Epoch).await; + get_node_info(&info, k, primary as Epoch).await; ( "querying::aggregation::single", QueryCircuitInput::new_single_path( @@ -522,7 +525,7 @@ where fetch_only_proven_child(node_ctx, planner.ctx, &proven_nodes); let (node_info, left_info, right_info) = get_node_info( &info, - &k, + k, // we can use primary as epoch since storage starts epoch at genesis primary as Epoch, ) @@ -579,7 +582,7 @@ where let (child_pos, child_proof) = fetch_only_proven_child(node_ctx, planner.ctx, &proven_nodes); let (_, left_info, right_info) = - get_node_info(&info, &k, primary as Epoch).await; + get_node_info(&info, k, primary as Epoch).await; let unproven = match child_pos { ChildPosition::Left => right_info, ChildPosition::Right => left_info, @@ -607,7 +610,7 @@ where planner.ctx, &query_id, primary, - &k, + k, placeholder_values.clone(), proof, )?; @@ -694,12 +697,12 @@ where ) } -pub fn generate_non_existence_proof<'a>( +pub fn generate_non_existence_proof( node_info: NodeInfo, left_child_info: Option, right_child_info: Option, primary: BlockPrimaryIndex, - planner: &mut QueryPlanner<'a>, + planner: &mut QueryPlanner<'_>, is_rows_tree_node: bool, ) -> Result> { let index_ids = [ @@ -775,9 +778,9 @@ async fn prove_non_existence_index<'a>( planner, false, ) - .expect( - format!("unable to generate non-existence proof for {current_epoch} -> {primary}").as_str(), - ); + .unwrap_or_else(|_| { + panic!("unable to generate non-existence proof for {current_epoch} -> {primary}") + }); info!("Non-existence circuit proof DONE for {current_epoch} -> {primary} "); planner.ctx.storage.store_proof(proof_key, proof.clone())?; @@ -791,7 +794,7 @@ pub async fn prove_non_existence_row<'a>( let row_tree = &planner.table.row; let (query_for_min, query_for_max) = bracket_secondary_index( &planner.table.public_name, - &planner.settings, + planner.settings, primary as Epoch, &planner.pis.bounds, ); @@ -979,7 +982,7 @@ pub async fn prove_non_existence_row<'a>( .table .execute_row_query(&query.unwrap(), &[]) .await?; - if rows.len() == 0 { + if rows.is_empty() { // no node found, return None info!("Search node for non-existence circuit: no node found"); return Ok(None); @@ -1072,10 +1075,9 @@ pub async fn prove_non_existence_row<'a>( planner, true, ) - .expect( - format!("unable to generate non-existence proof for {primary} -> {to_be_proven_node:?}") - .as_str(), - ); + .unwrap_or_else(|_| { + panic!("unable to generate non-existence proof for {primary} -> {to_be_proven_node:?}") + }); info!("Non-existence circuit proof DONE for {primary} -> {to_be_proven_node:?} "); planner.ctx.storage.store_proof(proof_key, proof.clone())?; @@ -1098,7 +1100,7 @@ pub async fn prove_non_existence_row<'a>( query: planner.query.clone(), pis: planner.pis, columns: planner.columns.clone(), - settings: &planner.settings, + settings: planner.settings, }; prove_query_on_tree(&mut planner, info, proving_tree, primary).await?; @@ -1595,16 +1597,15 @@ async fn check_correct_cells_tree( all_cells: &[ColumnCell], payload: &RowPayload, ) -> Result<()> { - let local_cells = all_cells.iter().cloned().collect::>(); + let local_cells = all_cells.to_vec(); let expected_cells_root = payload .cell_root_hash .clone() - .or(Some(HashOutput::from(*empty_poseidon_hash()))) - .unwrap(); + .unwrap_or(HashOutput::from(*empty_poseidon_hash())); let mut tree = indexing::cell::new_tree().await; tree.in_transaction(|t| { async move { - for (i, cell) in local_cells[2..].into_iter().enumerate() { + for (i, cell) in local_cells[2..].iter().enumerate() { // putting 0 for primary index as it doesn't matter in the hash computation t.store( i + 1, diff --git a/mp2-v1/tests/common/cases/query/mod.rs b/mp2-v1/tests/common/cases/query/mod.rs index 2589b01fa..425297e8b 100644 --- a/mp2-v1/tests/common/cases/query/mod.rs +++ b/mp2-v1/tests/common/cases/query/mod.rs @@ -9,7 +9,7 @@ use anyhow::{Context, Result}; use itertools::Itertools; use log::info; use mp2_v1::{api::MetadataHash, indexing::block::BlockPrimaryIndex}; -use parsil::{parse_and_validate, ParsilSettings, PlaceholderSettings}; +use parsil::{parse_and_validate, utils::ParsilSettingsBuilder, PlaceholderSettings}; use simple_select_queries::{ cook_query_no_matching_rows, cook_query_too_big_offset, cook_query_with_distinct, cook_query_with_matching_rows, cook_query_with_max_num_matching_rows, @@ -72,8 +72,8 @@ pub struct QueryCooking { pub(crate) placeholders: Placeholders, pub(crate) min_block: BlockPrimaryIndex, pub(crate) max_block: BlockPrimaryIndex, - pub(crate) limit: Option, - pub(crate) offset: Option, + pub(crate) limit: Option, + pub(crate) offset: Option, } pub async fn test_query(ctx: &mut TestContext, table: Table, t: TableInfo) -> Result<()> { @@ -121,8 +121,8 @@ async fn query_mapping(ctx: &mut TestContext, table: &Table, info: &TableInfo) - // the maximum allowed value (i.e, MAX_NUM_ITEMS_PER_OUTPUT), as // otherwise query validation on Parsil will fail let num_output_items_wildcard_queries = info.columns.non_indexed_columns().len() - + 2 // primary and secondary indexed columns - + 1 // there is an additional item besides columns of the tables in SELECT + + 2 // primary and secondary indexed columns + + 1 // there is an additional item besides columns of the tables in SELECT ; if num_output_items_wildcard_queries <= MAX_NUM_ITEMS_PER_OUTPUT { let query_info = cook_query_with_wildcard_no_distinct(table, info).await?; @@ -140,10 +140,15 @@ async fn test_query_mapping( query_info: QueryCooking, table_hash: &MetadataHash, ) -> Result<()> { - let settings = ParsilSettings { - context: table, - placeholders: PlaceholderSettings::with_freestanding(MAX_NUM_PLACEHOLDERS - 2), - }; + let settings = ParsilSettingsBuilder::default() + .context(table) + .placeholders(PlaceholderSettings::with_freestanding( + MAX_NUM_PLACEHOLDERS - 2, + )) + .maybe_limit(query_info.limit) + .maybe_offset(query_info.offset) + .build() + .unwrap(); info!("QUERY on the testcase: {}", query_info.query); let mut parsed = parse_and_validate(&query_info.query, &settings)?; diff --git a/mp2-v1/tests/common/cases/query/simple_select_queries.rs b/mp2-v1/tests/common/cases/query/simple_select_queries.rs index 3f8f825b7..a1b0d7d5d 100644 --- a/mp2-v1/tests/common/cases/query/simple_select_queries.rs +++ b/mp2-v1/tests/common/cases/query/simple_select_queries.rs @@ -1,8 +1,5 @@ -use std::collections::HashMap; - use alloy::primitives::U256; use anyhow::{Error, Result}; -use futures::{stream, StreamExt, TryStreamExt}; use itertools::Itertools; use log::info; use mp2_common::types::HashOutput; @@ -11,9 +8,8 @@ use mp2_v1::{ indexing::{block::BlockPrimaryIndex, row::RowTreeKey, LagrangeNode}, }; use parsil::{ - assembler::DynamicCircuitPis, - executor::{generate_query_execution_with_keys, generate_query_keys}, - ParsilSettings, DEFAULT_MAX_BLOCK_PLACEHOLDER, DEFAULT_MIN_BLOCK_PLACEHOLDER, + executor::generate_query_execution_with_keys, DEFAULT_MAX_BLOCK_PLACEHOLDER, + DEFAULT_MIN_BLOCK_PLACEHOLDER, }; use ryhope::{ storage::{pgsql::ToFromBytea, RoEpochKvStorage}, @@ -40,12 +36,12 @@ use crate::common::{ aggregated_queries::{ check_final_outputs, find_longest_lived_key, get_node_info, prove_single_row, }, - GlobalCircuitInput, QueryCircuitInput, RevelationCircuitInput, SqlReturn, SqlType, + GlobalCircuitInput, RevelationCircuitInput, SqlReturn, SqlType, }, }, proof_storage::{ProofKey, ProofStorage}, table::Table, - TableInfo, TestContext, + TableInfo, }; use super::QueryCooking; @@ -133,7 +129,7 @@ pub(crate) async fn prove_query<'a>( }; let column_ids = ColumnIDs::from(&planner.table.columns); let num_matching_rows = matching_rows_input.len(); - let input = RevelationCircuitInput::new_revelation_unproven_offset( + let input = RevelationCircuitInput::new_revelation_tabular( indexing_proof, matching_rows_input, &planner.pis.bounds, @@ -195,8 +191,8 @@ where )))?; let child_pos = node_ctx .iter_children() - .find_position(|child| child.is_some() && child.unwrap() == &previous_node_key); - let is_left_child = child_pos.unwrap().0 == 0; // unwrap is safe + .position(|child| child.map(|c| *c == previous_node_key).unwrap_or(false)); + let is_left_child = child_pos.unwrap() == 0; // unwrap is safe let (left_child_hash, right_child_hash) = if is_left_child { ( Some(previous_node_hash), @@ -279,7 +275,7 @@ pub(crate) async fn cook_query_with_max_num_matching_rows( U256::from(max_block), )); - let limit = MAX_NUM_OUTPUTS; + let limit = MAX_NUM_OUTPUTS as u32; let offset = 0; let query_str = format!( @@ -287,15 +283,14 @@ pub(crate) async fn cook_query_with_max_num_matching_rows( FROM {table_name} WHERE {BLOCK_COLUMN_NAME} >= {DEFAULT_MIN_BLOCK_PLACEHOLDER} AND {BLOCK_COLUMN_NAME} <= {DEFAULT_MAX_BLOCK_PLACEHOLDER} - AND {key_column} = '0x{key_value}' - LIMIT {limit} OFFSET {offset};" + AND {key_column} = '0x{key_value}';" ); Ok(QueryCooking { min_block: min_block as BlockPrimaryIndex, max_block: max_block as BlockPrimaryIndex, query: query_str, placeholders, - limit: Some(limit as u64), + limit: Some(limit), offset: Some(offset), }) } @@ -323,24 +318,25 @@ pub(crate) async fn cook_query_with_matching_rows( U256::from(max_block), )); - let limit = (MAX_NUM_OUTPUTS - 2).min(1); - let offset = max_block - min_block + 1 - limit; // get the matching rows in the last blocks + let limit: u32 = (MAX_NUM_OUTPUTS - 2).min(1).try_into().unwrap(); + let offset: u32 = (max_block - min_block + 1 - limit as usize) + .try_into() + .unwrap(); // get the matching rows in the last blocks let query_str = format!( "SELECT {BLOCK_COLUMN_NAME}, {value_column} + $1 FROM {table_name} WHERE {BLOCK_COLUMN_NAME} >= {DEFAULT_MIN_BLOCK_PLACEHOLDER} AND {BLOCK_COLUMN_NAME} <= {DEFAULT_MAX_BLOCK_PLACEHOLDER} - AND {key_column} = '0x{key_value}' - LIMIT {limit} OFFSET {offset};" + AND {key_column} = '0x{key_value}';" ); Ok(QueryCooking { min_block: min_block as BlockPrimaryIndex, max_block: max_block as BlockPrimaryIndex, query: query_str, placeholders, - limit: Some(limit as u64), - offset: Some(offset as u64), + limit: Some(limit), + offset: Some(offset), }) } @@ -368,7 +364,7 @@ pub(crate) async fn cook_query_too_big_offset( U256::from(max_block), )); - let limit = MAX_NUM_OUTPUTS; + let limit: u32 = MAX_NUM_OUTPUTS.try_into().unwrap(); let offset = 100; let query_str = format!( @@ -376,15 +372,14 @@ pub(crate) async fn cook_query_too_big_offset( FROM {table_name} WHERE {BLOCK_COLUMN_NAME} >= {DEFAULT_MIN_BLOCK_PLACEHOLDER} AND {BLOCK_COLUMN_NAME} <= {DEFAULT_MAX_BLOCK_PLACEHOLDER} - AND {key_column} = '0x{key_value}' - LIMIT {limit} OFFSET {offset};" + AND {key_column} = '0x{key_value}';" ); Ok(QueryCooking { min_block: min_block as BlockPrimaryIndex, max_block: max_block as BlockPrimaryIndex, query: query_str, placeholders, - limit: Some(limit as u64), + limit: Some(limit), offset: Some(offset), }) } @@ -415,7 +410,7 @@ pub(crate) async fn cook_query_no_matching_rows( U256::from(max_block), )); - let limit = MAX_NUM_OUTPUTS; + let limit: u32 = MAX_NUM_OUTPUTS.try_into().unwrap(); let offset = 0; let query_str = format!( @@ -423,15 +418,14 @@ pub(crate) async fn cook_query_no_matching_rows( FROM {table_name} WHERE {BLOCK_COLUMN_NAME} >= {DEFAULT_MIN_BLOCK_PLACEHOLDER} AND {BLOCK_COLUMN_NAME} <= {DEFAULT_MAX_BLOCK_PLACEHOLDER} - AND {key_column} = $1 - LIMIT {limit} OFFSET {offset};" + AND {key_column} = $1;" ); Ok(QueryCooking { min_block: min_block as BlockPrimaryIndex, max_block: max_block as BlockPrimaryIndex, query: query_str, placeholders, - limit: Some(limit as u64), + limit: Some(limit), offset: Some(offset), }) } @@ -459,7 +453,7 @@ pub(crate) async fn cook_query_with_distinct( U256::from(max_block), )); - let limit = MAX_NUM_OUTPUTS; + let limit: u32 = MAX_NUM_OUTPUTS.try_into().unwrap(); let offset = 0; let query_str = format!( @@ -467,15 +461,14 @@ pub(crate) async fn cook_query_with_distinct( FROM {table_name} WHERE {BLOCK_COLUMN_NAME} >= {DEFAULT_MIN_BLOCK_PLACEHOLDER} AND {BLOCK_COLUMN_NAME} <= {DEFAULT_MAX_BLOCK_PLACEHOLDER} - AND {key_column} = '0x{key_value}' - LIMIT {limit} OFFSET {offset};" + AND {key_column} = '0x{key_value}';" ); Ok(QueryCooking { min_block: min_block as BlockPrimaryIndex, max_block: max_block as BlockPrimaryIndex, query: query_str, placeholders, - limit: Some(limit as u64), + limit: Some(limit), offset: Some(offset), }) } @@ -504,7 +497,7 @@ pub(crate) async fn cook_query_with_wildcard( U256::from(max_block), )); - let limit = MAX_NUM_OUTPUTS; + let limit: u32 = MAX_NUM_OUTPUTS.try_into().unwrap(); let offset = 0; let query_str = if distinct { @@ -513,8 +506,7 @@ pub(crate) async fn cook_query_with_wildcard( FROM {table_name} WHERE {BLOCK_COLUMN_NAME} >= {DEFAULT_MIN_BLOCK_PLACEHOLDER} AND {BLOCK_COLUMN_NAME} <= {DEFAULT_MAX_BLOCK_PLACEHOLDER} - AND {key_column} = '0x{key_value}' - LIMIT {limit} OFFSET {offset};" + AND {key_column} = '0x{key_value}';" ) } else { format!( @@ -522,8 +514,7 @@ pub(crate) async fn cook_query_with_wildcard( FROM {table_name} WHERE {BLOCK_COLUMN_NAME} >= {DEFAULT_MIN_BLOCK_PLACEHOLDER} AND {BLOCK_COLUMN_NAME} <= {DEFAULT_MAX_BLOCK_PLACEHOLDER} - AND {key_column} = '0x{key_value}' - LIMIT {limit} OFFSET {offset};" + AND {key_column} = '0x{key_value}';" ) }; Ok(QueryCooking { @@ -531,7 +522,7 @@ pub(crate) async fn cook_query_with_wildcard( max_block: max_block as BlockPrimaryIndex, query: query_str, placeholders, - limit: Some(limit as u64), + limit: Some(limit), offset: Some(offset), }) } diff --git a/mp2-v1/tests/common/cases/table_source.rs b/mp2-v1/tests/common/cases/table_source.rs index 5c8dfbb54..6ee10bb35 100644 --- a/mp2-v1/tests/common/cases/table_source.rs +++ b/mp2-v1/tests/common/cases/table_source.rs @@ -9,7 +9,7 @@ use alloy::{ primitives::{Address, U256}, }; use anyhow::{bail, Result}; -use futures::{future::BoxFuture, FutureExt}; +use futures::{future::BoxFuture, FutureExt, StreamExt}; use itertools::Itertools; use log::{debug, info}; use mp2_common::{ diff --git a/mp2-v1/tests/common/celltree.rs b/mp2-v1/tests/common/celltree.rs index 355a76dc6..e5a510a72 100644 --- a/mp2-v1/tests/common/celltree.rs +++ b/mp2-v1/tests/common/celltree.rs @@ -64,13 +64,12 @@ impl TestContext { column.multiplier, hex::encode(cell.hash.0) ); - let inputs = CircuitInput::CellsTree( - verifiable_db::cells_tree::CircuitInput::leaf_multiplier( + let inputs = + CircuitInput::CellsTree(verifiable_db::cells_tree::CircuitInput::leaf( cell.identifier(), cell.value(), column.multiplier, - ), - ); + )); self.b.bench("indexing::cell_tree::leaf", || { api::generate_proof(self.params(), inputs) }) @@ -89,14 +88,13 @@ impl TestContext { .storage .get_proof_exact(&ProofKey::Cell(proof_key)) .expect("UT guarantees proving in order"); - let inputs = CircuitInput::CellsTree( - verifiable_db::cells_tree::CircuitInput::partial_multiplier( + let inputs = + CircuitInput::CellsTree(verifiable_db::cells_tree::CircuitInput::partial( cell.identifier(), cell.value(), column.multiplier, left_proof.clone(), - ), - ); + )); debug!( "MP2 Proving Cell Tree PARTIAL for id {:?} - value {:?} -> {:?} --> LEFT CHILD HASH {:?}", cell.identifier(), @@ -144,14 +142,13 @@ impl TestContext { hex::encode(cells_tree::extract_hash_from_proof(&right_proof).map(|c|c.to_bytes()).unwrap()) ); - let inputs = CircuitInput::CellsTree( - verifiable_db::cells_tree::CircuitInput::full_multiplier( + let inputs = + CircuitInput::CellsTree(verifiable_db::cells_tree::CircuitInput::full( cell.identifier(), cell.value(), column.multiplier, [left_proof, right_proof], - ), - ); + )); self.b.bench("indexing::cell_tree::full", || { api::generate_proof(self.params(), inputs).context("while proving full node") diff --git a/mp2-v1/tests/common/contract_extraction.rs b/mp2-v1/tests/common/contract_extraction.rs index 8ee9fe3a1..532b0d1c2 100644 --- a/mp2-v1/tests/common/contract_extraction.rs +++ b/mp2-v1/tests/common/contract_extraction.rs @@ -98,11 +98,8 @@ fn prove_leaf( ) -> Vec { let params = ctx.params(); // Generate the proof. - let input = contract_extraction::CircuitInput::new_leaf( - node.clone(), - &storage_root, - contract_address.clone(), - ); + let input = + contract_extraction::CircuitInput::new_leaf(node.clone(), storage_root, *contract_address); let input = CircuitInput::ContractExtraction(input); let proof = ctx .b diff --git a/mp2-v1/tests/common/index_tree.rs b/mp2-v1/tests/common/index_tree.rs index 5b7201066..c134ca4a8 100644 --- a/mp2-v1/tests/common/index_tree.rs +++ b/mp2-v1/tests/common/index_tree.rs @@ -45,7 +45,7 @@ impl TestContext { let mut workplan = ut.into_workplan(); while let Some(Next::Ready(wk)) = workplan.next() { let k = wk.k(); - let (context, node) = t.fetch_with_context(&k).await; + let (context, node) = t.fetch_with_context(k).await; let row_proof_key = RowProofIdentifier { table: table_id.clone(), tree_key: node.row_tree_root_key, @@ -170,7 +170,7 @@ impl TestContext { // here we are simply proving the new updated nodes from the new node to // the root. We fetch the same node but at the previous version of the // tree to prove the update. - let previous_node = t.fetch_at(&k, t.current_epoch() - 1).await; + let previous_node = t.fetch_at(k, t.current_epoch() - 1).await; let left_key = context.left.expect("should always be a left child"); let left_node = t.fetch(&left_key).await; // this should be one of the nodes we just proved in this loop before @@ -201,7 +201,7 @@ impl TestContext { }; let proof_key = IndexProofIdentifier { table: table_id.clone(), - tree_key: k.clone(), + tree_key: *k, }; self.storage .store_proof(ProofKey::Index(proof_key), proof) diff --git a/mp2-v1/tests/common/mod.rs b/mp2-v1/tests/common/mod.rs index b594af5dc..be94e7aff 100644 --- a/mp2-v1/tests/common/mod.rs +++ b/mp2-v1/tests/common/mod.rs @@ -50,7 +50,7 @@ type ColumnGadgetData = type PublicParameters = mp2_v1::api::PublicParameters; fn cell_tree_proof_to_hash(proof: &[u8]) -> HashOutput { - let root_pi = ProofWithVK::deserialize(&proof) + let root_pi = ProofWithVK::deserialize(proof) .expect("while deserializing proof") .proof .public_inputs; @@ -62,7 +62,7 @@ fn cell_tree_proof_to_hash(proof: &[u8]) -> HashOutput { } fn row_tree_proof_to_hash(proof: &[u8]) -> HashOutput { - let root_pi = ProofWithVK::deserialize(&proof) + let root_pi = ProofWithVK::deserialize(proof) .expect("while deserializing proof") .proof .public_inputs; diff --git a/mp2-v1/tests/common/rowtree.rs b/mp2-v1/tests/common/rowtree.rs index 3ce043fb7..7577d4fc3 100644 --- a/mp2-v1/tests/common/rowtree.rs +++ b/mp2-v1/tests/common/rowtree.rs @@ -202,7 +202,7 @@ impl TestContext { hex::encode(row.cell_root_hash.unwrap().0) ); let inputs = CircuitInput::RowsTree( - verifiable_db::row_tree::CircuitInput::leaf_multiplier( + verifiable_db::row_tree::CircuitInput::leaf( id, value, multiplier, @@ -260,7 +260,7 @@ impl TestContext { } let inputs = CircuitInput::RowsTree( - verifiable_db::row_tree::CircuitInput::partial_multiplier( + verifiable_db::row_tree::CircuitInput::partial( id, value, multiplier, @@ -304,7 +304,7 @@ impl TestContext { .get_proof_exact(&ProofKey::Row(right_proof_key.clone())) .expect("UT guarantees proving in order"); let inputs = CircuitInput::RowsTree( - verifiable_db::row_tree::CircuitInput::full_multiplier( + verifiable_db::row_tree::CircuitInput::full( id, value, multiplier, diff --git a/mp2-v1/tests/common/storage_trie.rs b/mp2-v1/tests/common/storage_trie.rs index 949364c58..681bdbda2 100644 --- a/mp2-v1/tests/common/storage_trie.rs +++ b/mp2-v1/tests/common/storage_trie.rs @@ -144,7 +144,7 @@ impl TrieNode { /// Prove a branch node. fn prove_value_branch(&self, ctx: ProvingContext) -> SerializedProof { // Has one child at least and 16 at maximum. - assert!(self.children.len() > 0); + assert!(!self.children.is_empty()); assert!(self.children.len() <= MAX_BRANCH_CHILDREN); let node = self.raw.clone(); @@ -338,7 +338,7 @@ impl TrieNode { /// Prove a branch node. fn prove_length_branch(&self, ctx: ProvingContext) -> SerializedProof { // Has one child at least and 16 at maximum. - assert!(self.children.len() > 0); + assert!(!self.children.is_empty()); assert!(self.children.len() <= MAX_BRANCH_CHILDREN); let node = self.raw.clone(); @@ -361,7 +361,7 @@ impl TrieNode { /// Prove an extension node. fn prove_length_extension(&self, ctx: ProvingContext) -> SerializedProof { // Has one child at least and 16 at maximum. - assert!(self.children.len() > 0); + assert!(!self.children.is_empty()); assert!(self.children.len() <= MAX_BRANCH_CHILDREN); let node = self.raw.clone(); diff --git a/mp2-v1/tests/common/table.rs b/mp2-v1/tests/common/table.rs index 0e60360c9..e7f61e659 100644 --- a/mp2-v1/tests/common/table.rs +++ b/mp2-v1/tests/common/table.rs @@ -515,7 +515,7 @@ impl Table { // introduce this closure to coerce each param to have type `dyn ToSql + Sync` (required by pgSQL APIs) let prepare_param = |param: U256| -> Box { Box::new(param) }; let query_params = params - .into_iter() + .iter() .map(|param| prepare_param(*param)) .collect_vec(); let connection = self.db_pool.get().await.unwrap(); diff --git a/mp2-v1/tests/integrated_tests.rs b/mp2-v1/tests/integrated_tests.rs index eab95228c..2fb22eab1 100644 --- a/mp2-v1/tests/integrated_tests.rs +++ b/mp2-v1/tests/integrated_tests.rs @@ -36,7 +36,8 @@ use parsil::{ assembler::DynamicCircuitPis, parse_and_validate, symbols::{ContextProvider, ZkTable}, - ParsilSettings, PlaceholderSettings, + utils::ParsilSettingsBuilder, + PlaceholderSettings, }; use test_log::test; use verifiable_db::query::universal_circuit::universal_circuit_inputs::Placeholders; @@ -240,10 +241,13 @@ async fn test_andrus_query() -> Result<()> { let query = "select AVG(field1) from primitive1_rows WHERE block_number >= $MIN_BLOCK and block_number <= $MAX_BLOCK"; let zktable_str = r#"{"user_name":"primitive1","name":"primitive1_rows","columns":[{"name":"block_number","kind":"PrimaryIndex","id":15542555334667826467},{"name":"field1","kind":"SecondaryIndex","id":10143644063834010325},{"name":"field2","kind":"Standard","id":14738928498191419754},{"name":"field3","kind":"Standard","id":2724380514203373020},{"name":"field4","kind":"Standard","id":1084192582840933701}]}"#; let table: ZkTable = serde_json::from_str(zktable_str)?; - let settings = ParsilSettings { - context: T(table), - placeholders: PlaceholderSettings::with_freestanding(MAX_NUM_PLACEHOLDERS - 2), - }; + let settings = ParsilSettingsBuilder::default() + .context(T(table)) + .placeholders(PlaceholderSettings::with_freestanding( + MAX_NUM_PLACEHOLDERS - 2, + )) + .build() + .unwrap(); let parsed = parse_and_validate(query, &settings)?; let computed_pis = parsil::assembler::assemble_dynamic(&parsed, &settings, &ph)?; @@ -257,7 +261,7 @@ async fn test_andrus_query() -> Result<()> { info!("Building querying params"); ctx.build_params(ParamsType::Query).unwrap(); - let input = RevelationCircuitInput::new_revelation_no_results_tree( + let input = RevelationCircuitInput::new_revelation_aggregated( root_query_proof, ivc_proof, &computed_pis.bounds, diff --git a/parsil/Cargo.toml b/parsil/Cargo.toml index 4e6ef1570..cc1865142 100644 --- a/parsil/Cargo.toml +++ b/parsil/Cargo.toml @@ -17,9 +17,6 @@ alloy.workspace = true anyhow.workspace = true camelpaste = "0.1.0" log.workspace = true -mp2_common = { path = "../mp2-common" } -plonky2.workspace = true -postgres.workspace = true ryhope = { path = "../ryhope" } serde.workspace = true serde_json.workspace = true diff --git a/parsil/src/assembler.rs b/parsil/src/assembler.rs index 50fb3dcd4..bb4e22c1d 100644 --- a/parsil/src/assembler.rs +++ b/parsil/src/assembler.rs @@ -178,7 +178,7 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { Symbol::Column { payload: id, .. } | Symbol::NamedExpression { payload: id, .. } | Symbol::Expression(id) => { - let (aggregation, output_item) = self.to_output_expression(id, false)?; + let (aggregation, output_item) = Self::to_output_expression(id, false)?; output_items.push(output_item); aggregations.push(aggregation); } @@ -237,7 +237,7 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { match s { Symbol::Column { .. } => false, Symbol::Alias { to, .. } => self.is_symbol_static(to), - Symbol::NamedExpression { payload, .. } => self.is_wire_static(&payload), + Symbol::NamedExpression { payload, .. } => self.is_wire_static(payload), Symbol::Expression(_) => todo!(), Symbol::Wildcard => false, } @@ -261,22 +261,22 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { } /// Return the depth of the given expression, in terms of [`BasicOperation`] it will take to encode. - fn depth(&self, e: &Expr) -> usize { + fn depth(e: &Expr) -> usize { match e { Expr::Identifier(_) | Expr::CompoundIdentifier(_) => 0, - Expr::BinaryOp { left, right, .. } => 1 + self.depth(left).max(self.depth(right)), - Expr::UnaryOp { expr, .. } => 1 + self.depth(expr), - Expr::Nested(e) => self.depth(e), + Expr::BinaryOp { left, right, .. } => 1 + Self::depth(left).max(Self::depth(right)), + Expr::UnaryOp { expr, .. } => 1 + Self::depth(expr), + Expr::Nested(e) => Self::depth(e), Expr::Value(_) => 0, _ => unreachable!(), } } /// Return whether the given `Symbol` encodes the secondary index column. - fn is_symbol_secondary_idx(&self, s: &Symbol) -> bool { + fn is_symbol_secondary_idx(s: &Symbol) -> bool { match s { Symbol::Column { kind, .. } => *kind == ColumnKind::SecondaryIndex, - Symbol::Alias { to, .. } => self.is_symbol_secondary_idx(to), + Symbol::Alias { to, .. } => Self::is_symbol_secondary_idx(to), _ => false, } } @@ -286,10 +286,10 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { fn is_secondary_index(&self, expr: &Expr) -> Result { Ok(match expr { Expr::Identifier(s) => { - self.is_symbol_secondary_idx(&self.scopes.resolve_freestanding(s)?) + Self::is_symbol_secondary_idx(&self.scopes.resolve_freestanding(s)?) } Expr::CompoundIdentifier(c) => { - self.is_symbol_secondary_idx(&self.scopes.resolve_compound(c)?) + Self::is_symbol_secondary_idx(&self.scopes.resolve_compound(c)?) } _ => false, @@ -317,11 +317,9 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { Wire::BasicOperation(id) => { // Safety check assert_eq!(id, 0); - QueryBoundSource::Operation(ops[0].clone()) - } - Wire::Constant(id) => { - QueryBoundSource::Constant(self.constants.ops[id].clone()) + QueryBoundSource::Operation(ops[0]) } + Wire::Constant(id) => QueryBoundSource::Constant(self.constants.ops[id]), Wire::PlaceHolder(ph) => QueryBoundSource::Placeholder(ph), _ => unreachable!(), }, @@ -361,7 +359,7 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { // SID can only be computed from constants and placeholders && self.is_expr_static(right)? // SID can only be defined by up to one level of BasicOperation - && self.depth(right) <= 1 + && Self::depth(right) <= 1 { match op { // $sid > x @@ -371,7 +369,7 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { } else { right }; - let bound = Some(self.expression_to_boundary(&right)?); + let bound = Some(self.expression_to_boundary(right)?); if self.secondary_index_bounds.low.is_some() { // impossible to say which is higher between two @@ -388,7 +386,7 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { } else { right }; - let bound = Some(self.expression_to_boundary(&right)?); + let bound = Some(self.expression_to_boundary(right)?); if self.secondary_index_bounds.high.is_some() { // impossible to say which is lower between two @@ -475,14 +473,15 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { fn find_secondary_index_boundaries(&mut self, expr: &Expr) -> Result<()> { self.maybe_set_secondary_index_boundary(expr)?; match expr { - Expr::BinaryOp { left, op, right } => match op { - BinaryOperator::And => { - self.find_secondary_index_boundaries(left)?; - self.find_secondary_index_boundaries(right)?; - Ok(()) - } - _ => Ok(()), - }, + Expr::BinaryOp { + left, + op: BinaryOperator::And, + right, + } => { + self.find_secondary_index_boundaries(left)?; + self.find_secondary_index_boundaries(right)?; + Ok(()) + } Expr::Nested(e) => self.find_secondary_index_boundaries(e), _ => Ok(()), } @@ -612,7 +611,7 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { Symbol::NamedExpression { payload: id, .. } | Symbol::Expression(id) => match id { Wire::BasicOperation(idx) => InputOperand::PreviousValue(*idx), Wire::ColumnId(idx) => InputOperand::Column(*idx), - Wire::Constant(idx) => InputOperand::Constant(self.constants.get(*idx).clone()), + Wire::Constant(idx) => InputOperand::Constant(*self.constants.get(*idx)), Wire::PlaceHolder(ph) => InputOperand::Placeholder(*ph), Wire::Aggregation(_, _) => unreachable!("an aggregation can not be an operand"), }, @@ -622,7 +621,6 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { /// Create an output and its associated aggregation function from a wire. fn to_output_expression( - &self, wire_id: Wire, in_aggregation: bool, ) -> Result<(AggregationOperation, OutputItem)> { @@ -633,7 +631,7 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { Wire::ColumnId(i) => Ok((AggregationOperation::IdOp, OutputItem::Column(i))), Wire::Aggregation(agg, sub_wire_id) => { ensure!(!in_aggregation, "recursive aggregation detected"); - Ok((agg, self.to_output_expression(*sub_wire_id, true)?.1)) + Ok((agg, Self::to_output_expression(*sub_wire_id, true)?.1)) } Wire::Constant(_) => bail!(ValidationError::UnsupportedFeature( "top-level immediate values".into(), @@ -691,7 +689,7 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { let pis = CircuitPis { result, column_ids: self.columns.clone(), - query_aggregations: root_scope.metadata().aggregation.iter().cloned().collect(), + query_aggregations: root_scope.metadata().aggregation.to_vec(), predication_operations: root_scope.metadata().predicates.ops.clone(), bounds: StaticQueryBounds::without_values( self.secondary_index_bounds.low.clone(), @@ -711,7 +709,7 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { let pis = CircuitPis { result, column_ids: self.columns.clone(), - query_aggregations: root_scope.metadata().aggregation.iter().cloned().collect(), + query_aggregations: root_scope.metadata().aggregation.to_vec(), predication_operations: root_scope.metadata().predicates.ops.clone(), bounds: QueryBounds::new( placeholders, @@ -729,7 +727,7 @@ impl<'a, C: ContextProvider> Assembler<'a, C> { /// place them in a [`CircuitPis`] that may be either build in static mode (i.e. /// no reference to runtime value) at query registration time, or in dynamic /// mode at query execution time. -pub trait BuildableBounds: Sized { +pub trait BuildableBounds: Sized + Serialize { fn without_values(low: Option, high: Option) -> Self; fn with_values( @@ -741,7 +739,7 @@ pub trait BuildableBounds: Sized { /// Similar to [`QueryBounds`], but only containing the static expressions /// defining the query bounds, without any reference to runtime values. -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct StaticQueryBounds { pub min_query_secondary: Option, pub max_query_secondary: Option, @@ -827,9 +825,13 @@ impl CircuitPis { self.result .validate(C::MAX_NUM_RESULT_OPS, C::MAX_NUM_ITEMS_PER_OUTPUT) } + + pub fn to_json(&self) -> Vec { + serde_json::to_vec(self).unwrap() + } } -impl<'a, C: ContextProvider> AstVisitor for Assembler<'a, C> { +impl AstVisitor for Assembler<'_, C> { type Error = anyhow::Error; fn pre_table_factor(&mut self, table_factor: &TableFactor) -> Result<(), Self::Error> { @@ -859,7 +861,7 @@ impl<'a, C: ContextProvider> AstVisitor for Assembler<'a, C> { let table_columns = self .settings .context - .fetch_table(&concrete_table_name)? + .fetch_table(concrete_table_name)? .columns; // Extract the apparent table name (either the concrete one @@ -1047,5 +1049,5 @@ pub fn assemble_dynamic( let mut resolver = Assembler::new(settings); query.visit(&mut resolver)?; - resolver.to_dynamic_inputs(&placeholders) + resolver.to_dynamic_inputs(placeholders) } diff --git a/parsil/src/errors.rs b/parsil/src/errors.rs index 9428382c9..463536b86 100644 --- a/parsil/src/errors.rs +++ b/parsil/src/errors.rs @@ -71,9 +71,6 @@ pub enum ValidationError { #[error("NULL-related ordering specifiers unsupported")] NullRelatedOrdering, - #[error("Only single value expression allowed in LIMIT clause")] - InvalidLimitExpression, - - #[error("LIMIT value specified in the query is too high: maximum value allowed is `{0}`")] - LimitTooHigh(usize), + #[error("Clause `{0}` value should be set in the approporiate parameter at execution time")] + UseInvocationParameter(String), } diff --git a/parsil/src/executor.rs b/parsil/src/executor.rs index b6781750c..c7fda830f 100644 --- a/parsil/src/executor.rs +++ b/parsil/src/executor.rs @@ -25,7 +25,7 @@ use crate::{ /// Safely wraps a [`Query`], ensuring its meaning and the status of its /// placeholders. -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum SafeQuery { /// A query featuring placeholders as defined in a [`PlaceholderRegister`] ZkQuery(Query), @@ -87,7 +87,7 @@ impl AsMut for SafeQuery { /// A data structure wrapping a zkSQL query converted into a pgSQL able to be /// executed on zkTables and its accompanying metadata. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct TranslatedQuery { /// The translated query, should be converted to string pub query: SafeQuery, @@ -186,7 +186,7 @@ struct PlaceholderInterpolator<'a, C: ContextProvider> { settings: &'a ParsilSettings, placeholders: &'a Placeholders, } -impl<'a, C: ContextProvider> AstMutator for PlaceholderInterpolator<'a, C> { +impl AstMutator for PlaceholderInterpolator<'_, C> { type Error = anyhow::Error; fn post_expr(&mut self, expr: &mut Expr) -> Result<()> { @@ -388,7 +388,7 @@ impl<'a, C: ContextProvider> KeyFetcher<'a, C> { Ok(()) } } -impl<'a, C: ContextProvider> AstMutator for KeyFetcher<'a, C> { +impl AstMutator for KeyFetcher<'_, C> { type Error = anyhow::Error; fn post_select(&mut self, select: &mut Select) -> Result<()> { @@ -414,7 +414,7 @@ impl<'a, C: ContextProvider> AstMutator for KeyFetcher<'a, C> { let user_facing_name = &name.0[0].value; // Fetch all the column declared in this table - let table = self.settings.context.fetch_table(&user_facing_name)?; + let table = self.settings.context.fetch_table(user_facing_name)?; let table_columns = &table.columns; // Extract the apparent table name (either the concrete one @@ -537,7 +537,7 @@ impl<'a, C: ContextProvider> Executor<'a, C> { } } -impl<'a, C: ContextProvider> AstMutator for Executor<'a, C> { +impl AstMutator for Executor<'_, C> { type Error = anyhow::Error; fn post_expr(&mut self, expr: &mut Expr) -> Result<()> { @@ -564,7 +564,7 @@ impl<'a, C: ContextProvider> AstMutator for Executor<'a, C> { let concrete_table_name = &name.0[0].value; // Fetch all the column declared in this table - let table = self.settings.context.fetch_table(&concrete_table_name)?; + let table = self.settings.context.fetch_table(concrete_table_name)?; let table_columns = &table.columns; // Extract the apparent table name (either the concrete one @@ -715,11 +715,7 @@ impl<'a, C: ContextProvider> AstMutator for ExecutorWithKey<'a, C> { assert_eq!(select.from.len(), 1); // single table queries let table = &select.from.first().unwrap().relation; match table { - TableFactor::Derived { - lateral, - subquery, - alias, - } => { + TableFactor::Derived { subquery, .. } => { subquery .as_ref() .body @@ -730,7 +726,7 @@ impl<'a, C: ContextProvider> AstMutator for ExecutorWithKey<'a, C> { .iter() .filter_map(|item| { let expr = match item { - SelectItem::ExprWithAlias { expr, alias } => { + SelectItem::ExprWithAlias { alias, .. } => { Expr::Identifier(alias.clone()) } SelectItem::UnnamedExpr(expr) => expr.clone(), @@ -765,7 +761,7 @@ impl<'a, C: ContextProvider> AstMutator for ExecutorWithKey<'a, C> { .flat_map(|item| { match item { SelectItem::UnnamedExpr(expr) => vec![expr.clone()], - SelectItem::ExprWithAlias { expr, alias } => vec![expr.clone()], // we don't care about alias here + SelectItem::ExprWithAlias { expr, .. } => vec![expr.clone()], // we don't care about alias here SelectItem::QualifiedWildcard(_, _) => unreachable!(), SelectItem::Wildcard(_) => replace_wildcard(), } diff --git a/parsil/src/expand.rs b/parsil/src/expand.rs index e1b6445e8..8d063bb97 100644 --- a/parsil/src/expand.rs +++ b/parsil/src/expand.rs @@ -2,14 +2,17 @@ //! operations supported by the circuits. use crate::{ + errors::ValidationError, symbols::ContextProvider, - utils::val_to_expr, + utils::int_to_expr, validate::is_query_with_no_aggregation, visitor::{AstMutator, VisitMut}, ParsilSettings, }; -use alloy::primitives::U256; -use sqlparser::ast::{BinaryOperator, Expr, Query, SetExpr, UnaryOperator, Value}; +use anyhow::ensure; +use sqlparser::ast::{ + BinaryOperator, Expr, Offset, OffsetRows, Query, SetExpr, UnaryOperator, Value, +}; struct Expander<'a, C: ContextProvider> { settings: &'a ParsilSettings, @@ -130,11 +133,12 @@ impl<'a, C: ContextProvider> AstMutator for Expander<'a, C> { })) } } - Expr::UnaryOp { op, expr } => { + Expr::UnaryOp { + op: UnaryOperator::Plus, + expr, + } => { // +E := E - if let UnaryOperator::Plus = op { - *e = *expr.clone(); - } + *e = *expr.clone(); } _ => {} } @@ -143,13 +147,25 @@ impl<'a, C: ContextProvider> AstMutator for Expander<'a, C> { } fn pre_query(&mut self, query: &mut Query) -> anyhow::Result<()> { - // we add LIMIT to the query if not specified by the user - if query.limit.is_none() { - // note that we need to do it only in queries that don't aggregate - // results across rows - if let SetExpr::Select(ref select) = *query.body { - if is_query_with_no_aggregation(select) { - query.limit = Some(val_to_expr(U256::from(C::MAX_NUM_OUTPUTS))); + ensure!( + query.limit.is_none(), + ValidationError::UseInvocationParameter("LIMIT".into()) + ); + ensure!( + query.offset.is_none(), + ValidationError::UseInvocationParameter("OFFSET".into()) + ); + + if let SetExpr::Select(ref select) = *query.body { + if is_query_with_no_aggregation(select) { + query.limit = Some(int_to_expr(self.settings.limit())); + if let Some(offset) = self.settings.offset { + if offset != 0 { + query.offset = Some(Offset { + value: int_to_expr(self.settings.offset()), + rows: OffsetRows::None, + }); + } } } } @@ -157,7 +173,10 @@ impl<'a, C: ContextProvider> AstMutator for Expander<'a, C> { } } -pub fn expand(settings: &ParsilSettings, q: &mut Query) { +pub fn expand( + settings: &ParsilSettings, + q: &mut Query, +) -> anyhow::Result<()> { let mut expander = Expander { settings }; - q.visit_mut(&mut expander).expect("can not fail"); + q.visit_mut(&mut expander) } diff --git a/parsil/src/isolator.rs b/parsil/src/isolator.rs index 7fcf1ce94..66014d903 100644 --- a/parsil/src/isolator.rs +++ b/parsil/src/isolator.rs @@ -34,7 +34,7 @@ impl SecondaryIndexBounds { /// Generate a list of index and operator pattern to detect for a /// [`SecondaryIndexBounds`] instance. - fn to_kinds(&self) -> &[(ColumnKind, RelevantFor)] { + fn kinds(&self) -> &[(ColumnKind, RelevantFor)] { match self { SecondaryIndexBounds::BothSides => &[ (ColumnKind::PrimaryIndex, RelevantFor::Either), @@ -86,10 +86,10 @@ impl<'a, C: ContextProvider> Isolator<'a, C> { } /// Return whether the given `Symbol` encodes the secondary index column. - fn is_symbol_idx(&self, s: &Symbol, idx: ColumnKind) -> bool { + fn is_symbol_idx(s: &Symbol, idx: ColumnKind) -> bool { match s { Symbol::Column { kind, .. } => *kind == idx, - Symbol::Alias { to, .. } => self.is_symbol_idx(to, idx), + Symbol::Alias { to, .. } => Self::is_symbol_idx(to, idx), _ => false, } } @@ -122,9 +122,9 @@ impl<'a, C: ContextProvider> Isolator<'a, C> { } Ok(match expr { - Expr::Identifier(s) => self.is_symbol_idx(&self.scopes.resolve_freestanding(s)?, idx), + Expr::Identifier(s) => Self::is_symbol_idx(&self.scopes.resolve_freestanding(s)?, idx), Expr::CompoundIdentifier(c) => { - self.is_symbol_idx(&self.scopes.resolve_compound(c)?, idx) + Self::is_symbol_idx(&self.scopes.resolve_compound(c)?, idx) } Expr::UnaryOp { expr, .. } => self.contains_index(expr, idx, side)?, Expr::BinaryOp { left, right, op } => { @@ -140,7 +140,7 @@ impl<'a, C: ContextProvider> Isolator<'a, C> { /// expression is relevant to index bounds or if it should be pruned. fn should_keep(&self, expr: &Expr) -> Result { let mut keep = false; - for (idx, side) in self.isolation.to_kinds() { + for (idx, side) in self.isolation.kinds() { keep |= self.contains_index(expr, *idx, *side)?; } Ok(keep) @@ -154,30 +154,29 @@ impl<'a, C: ContextProvider> Isolator<'a, C> { self.isolate(e)?; None } - Expr::BinaryOp { left, right, op } => { - match op { - BinaryOperator::And | BinaryOperator::Or | BinaryOperator::Xor => { - match (self.should_keep(&left)?, self.should_keep(&right)?) { - (true, true) => { - self.isolate(left)?; - self.isolate(right)?; - None - } - (true, false) => { - self.isolate(left)?; - Some(*left.to_owned()) - } - (false, true) => { - self.isolate(right)?; - Some(*right.to_owned()) - } - // NOTE: this cannot be reached, as then the expr - // would never have been explored in the first - // place. - (false, false) => unreachable!(), - } + Expr::BinaryOp { + left, + right, + op: BinaryOperator::And | BinaryOperator::Or | BinaryOperator::Xor, + } => { + match (self.should_keep(left)?, self.should_keep(right)?) { + (true, true) => { + self.isolate(left)?; + self.isolate(right)?; + None + } + (true, false) => { + self.isolate(left)?; + Some(*left.to_owned()) + } + (false, true) => { + self.isolate(right)?; + Some(*right.to_owned()) } - _ => None, + // NOTE: this cannot be reached, as then the expr + // would never have been explored in the first + // place. + (false, false) => unreachable!(), } } Expr::UnaryOp { expr, .. } => { @@ -204,7 +203,7 @@ impl<'a, C: ContextProvider> Isolator<'a, C> { } } -impl<'a, C: ContextProvider> AstMutator for Isolator<'a, C> { +impl AstMutator for Isolator<'_, C> { type Error = anyhow::Error; fn pre_table_factor(&mut self, table_factor: &mut TableFactor) -> Result<()> { @@ -234,7 +233,7 @@ impl<'a, C: ContextProvider> AstMutator for Isolator<'a, C> { let table_columns = self .settings .context - .fetch_table(&concrete_table_name)? + .fetch_table(concrete_table_name)? .columns; // Extract the apparent table name (either the concrete one diff --git a/parsil/src/lib.rs b/parsil/src/lib.rs index aef428f36..499f4b06d 100644 --- a/parsil/src/lib.rs +++ b/parsil/src/lib.rs @@ -21,7 +21,7 @@ pub mod queries; pub mod symbols; #[cfg(test)] mod tests; -mod utils; +pub mod utils; mod validate; mod visitor; diff --git a/parsil/src/placeholders.rs b/parsil/src/placeholders.rs index 26c558e32..322d3197c 100644 --- a/parsil/src/placeholders.rs +++ b/parsil/src/placeholders.rs @@ -68,7 +68,7 @@ impl<'a, C: ContextProvider> PlaceholderValidator<'a, C> { } } -impl<'a, C: ContextProvider> AstVisitor for PlaceholderValidator<'a, C> { +impl AstVisitor for PlaceholderValidator<'_, C> { type Error = anyhow::Error; fn pre_expr(&mut self, expr: &Expr) -> anyhow::Result<()> { diff --git a/parsil/src/queries.rs b/parsil/src/queries.rs index 0e9706b4f..2efeefc1a 100644 --- a/parsil/src/queries.rs +++ b/parsil/src/queries.rs @@ -13,7 +13,7 @@ use verifiable_db::query::{ /// /// * execution_epoch: the epoch (block number) at which the query is executed; /// * query_epoch_bounds: the min. and max. block numbers onto which the query -/// is executed. +/// is executed. pub fn core_keys_for_index_tree( execution_epoch: Epoch, query_epoch_bounds: (NodeIdx, NodeIdx), @@ -48,7 +48,7 @@ pub fn core_keys_for_index_tree( /// * query: the zkQuery, as registered by the end user; /// * settings: the Parsil settings used to parse & execute the query; /// * bounds: the bounds on the prim. and sec. index for this execution of -/// the query; +/// the query; /// * placeholders: the placeholders value for this execution of the query. pub fn core_keys_for_row_tree( query: &str, diff --git a/parsil/src/tests.rs b/parsil/src/tests.rs index 13b0e28fe..6b574f92b 100644 --- a/parsil/src/tests.rs +++ b/parsil/src/tests.rs @@ -1,5 +1,6 @@ use crate::assembler::{assemble_dynamic, DynamicCircuitPis}; use crate::isolator; +use crate::utils::ParsilSettingsBuilder; use crate::{ symbols::FileContextProvider, utils::{parse_and_validate, ParsilSettings, PlaceholderSettings}, @@ -35,6 +36,8 @@ fn must_accept() -> Result<()> { let settings = ParsilSettings { context: TestFileContextProvider::from_file("tests/context.json")?, placeholders: PlaceholderSettings::with_freestanding(3), + limit: None, + offset: None, }; for q in [ @@ -53,7 +56,6 @@ fn must_accept() -> Result<()> { "SELECT foo FROM table2 WHERE block IN (1, 2, 4)", "SELECT bar FROM table2 WHERE NOT block BETWEEN 12 AND 15", "SELECT a, c FROM table2 AS tt (a, b, c)", - "SELECT a+b FROM table2 AS tt (a, b, c) LIMIT 1+2", ] { parse_and_validate(q, &settings)?; } @@ -62,10 +64,11 @@ fn must_accept() -> Result<()> { #[test] fn must_reject() { - let settings = ParsilSettings { - context: TestFileContextProvider::from_file("tests/context.json").unwrap(), - placeholders: PlaceholderSettings::with_freestanding(3), - }; + let settings = ParsilSettingsBuilder::default() + .context(TestFileContextProvider::from_file("tests/context.json").unwrap()) + .placeholders(PlaceholderSettings::with_freestanding(3)) + .build() + .unwrap(); for q in [ // No ORDER BY @@ -105,10 +108,12 @@ fn must_reject() { "SELECT a FROM table2 AS tt (a,b,c) WHERE c+b-c*(a+c)-75 < 42*(a-b*c+a*(b-c)) AND a*56 >= b+63 OR a < b AND (a-b)*(a+b) >= a*c+b-4", // Too many operations in SELECT "SELECT c+b-c*(a+c)-75 + 42*(a-b*c+a*(b-c)), a*56 >= b+63, a < b, (a-b)*(a+b) >= a*c+b-4 FROM table2 as tt (a,b,c)", - // Too high LIMIT + // LIMIT "SELECT a+b FROM t LIMIT 10", - // Invalid LIMIT value "SELECT b*c FROM t LIMIT a", + // OFFSET + "SELECT a+b FROM t OFFSET 10", + "SELECT b*c FROM t OFFSET $1", ] { assert!(dbg!(parse_and_validate(q, &settings)).is_err()) } @@ -116,22 +121,24 @@ fn must_reject() { #[test] fn ref_query() -> Result<()> { - let settings = ParsilSettings { - context: TestFileContextProvider::from_file("tests/context.json")?, - placeholders: PlaceholderSettings::with_freestanding(2), - }; + let settings = ParsilSettingsBuilder::default() + .context(TestFileContextProvider::from_file("tests/context.json").unwrap()) + .placeholders(PlaceholderSettings::with_freestanding(2)) + .build() + .unwrap(); let q = "SELECT AVG(C1+C2/(C2*C3)), SUM(C1+C2), MIN(C1+$1), MAX(C4-2), AVG(C5) FROM T WHERE (C5 > 5 AND C1*C3 <= C4+C5 OR C3 == $2) AND C2 >= 75 AND C2 < 99"; - let query = parse_and_validate(q, &settings)?; + let _query = parse_and_validate(q, &settings)?; Ok(()) } #[test] fn test_serde_circuit_pis() { - let settings = ParsilSettings { - context: TestFileContextProvider::from_file("tests/context.json").unwrap(), - placeholders: PlaceholderSettings::with_freestanding(3), - }; + let settings = ParsilSettingsBuilder::default() + .context(TestFileContextProvider::from_file("tests/context.json").unwrap()) + .placeholders(PlaceholderSettings::with_freestanding(3)) + .build() + .unwrap(); let q = "SELECT AVG(foo) FROM table2"; let query = parse_and_validate(q, &settings).unwrap(); @@ -151,10 +158,11 @@ fn test_serde_circuit_pis() { #[test] fn isolation() { fn isolated_to_string(q: &str, lo_sec: bool, hi_sec: bool) -> String { - let settings = ParsilSettings { - context: TestFileContextProvider::from_file("tests/context.json").unwrap(), - placeholders: PlaceholderSettings::with_freestanding(3), - }; + let settings = ParsilSettingsBuilder::default() + .context(TestFileContextProvider::from_file("tests/context.json").unwrap()) + .placeholders(PlaceholderSettings::with_freestanding(3)) + .build() + .unwrap(); let mut query = parse_and_validate(q, &settings).unwrap(); isolator::isolate_with(&mut query, &settings, lo_sec, hi_sec) diff --git a/parsil/src/utils.rs b/parsil/src/utils.rs index 0fd7ddd03..a45022b55 100644 --- a/parsil/src/utils.rs +++ b/parsil/src/utils.rs @@ -1,5 +1,5 @@ use alloy::primitives::U256; -use anyhow::*; +use anyhow::{bail, ensure}; use sqlparser::ast::{BinaryOperator, Expr, Query, UnaryOperator, Value}; use std::str::FromStr; use verifiable_db::query::computational_hash_ids::PlaceholderIdentifier; @@ -13,50 +13,100 @@ use crate::{ validate::{self}, }; -/// This register handle all operations related to placeholder registration, -/// lookup an validation. -#[derive(Debug, Clone)] -pub struct PlaceholderRegister { - /// The set of available placeholders. - register: Vec<(String, PlaceholderIdentifier)>, +pub struct ParsilSettings { + /// A handle to an object providing a register of the existing virtual + /// tables and their columns. + pub context: C, + pub placeholders: PlaceholderSettings, + pub limit: Option, + pub offset: Option, } -impl PlaceholderRegister { - /// Create a placeholder register with $min_block, $max_block, and `n` - /// freestanding placeholders. - pub fn default(n: usize) -> Self { - Self { - register: vec![ - ( - "$min_block".to_string(), - PlaceholderIdentifier::MinQueryOnIdx1, - ), - ( - "$max_block".to_string(), - PlaceholderIdentifier::MaxQueryOnIdx1, - ), - ] - .into_iter() - .chain((0..n).map(|i| (format!("${i}"), PlaceholderIdentifier::Generic(i)))) - .collect(), - } +impl ParsilSettings { + pub fn builder() -> ParsilSettingsBuilder { + Default::default() } - /// Given a placeholder name, return, if it exists, the associated - /// [`Placeholder`]. - pub(crate) fn resolve(&self, s: &str) -> Option { - self.register - .iter() - .find(|(name, _)| name == s) - .map(|(_, placeholder)| placeholder.to_owned()) + pub fn max_num_outputs() -> usize { + C::MAX_NUM_OUTPUTS + } + + pub fn limit(&self) -> u32 { + self.limit.unwrap_or(C::MAX_NUM_OUTPUTS.try_into().unwrap()) + } + + pub fn offset(&self) -> u32 { + self.offset.unwrap_or(0) } } -#[derive(Debug)] -pub struct ParsilSettings { - /// A handle to an object providing a register of the existing virtual - /// tables and their columns. - pub context: C, - pub placeholders: PlaceholderSettings, +pub struct ParsilSettingsBuilder { + context: Option, + placeholders_settings: Option, + limit: Option, + offset: Option, +} +impl std::default::Default for ParsilSettingsBuilder { + fn default() -> Self { + ParsilSettingsBuilder { + context: None, + placeholders_settings: None, + limit: None, + offset: None, + } + } +} +impl ParsilSettingsBuilder { + pub fn context(mut self, context: C) -> Self { + self.context = Some(context); + self + } + + pub fn placeholders(mut self, placeholders_settings: PlaceholderSettings) -> Self { + self.placeholders_settings = Some(placeholders_settings); + self + } + + pub fn maybe_limit(mut self, limit: Option) -> Self { + self.limit = limit; + self + } + + pub fn maybe_offset(mut self, offset: Option) -> Self { + self.offset = offset; + self + } + + pub fn limit(mut self, limit: u32) -> Self { + self.limit = Some(limit); + self + } + + pub fn offset(mut self, offset: u32) -> Self { + self.offset = Some(offset); + self + } + + pub fn build(mut self) -> anyhow::Result> { + anyhow::ensure!( + self.limit + .map(|l| l <= C::MAX_NUM_OUTPUTS.try_into().unwrap()) + .unwrap_or(true), + anyhow::anyhow!("limit can not be greater than `{}`", C::MAX_NUM_OUTPUTS) + ); + + Ok(ParsilSettings { + context: self + .context + .take() + .ok_or_else(|| anyhow::anyhow!("context is not set"))?, + placeholders: self + .placeholders_settings + .take() + .ok_or_else(|| anyhow::anyhow!("placehoder settings are not set"))?, + limit: self.limit, + offset: self.offset, + }) + } } #[derive(Debug)] @@ -90,7 +140,7 @@ impl PlaceholderSettings { min_block: &str, max_block: &str, n: usize, - ) -> Result { + ) -> anyhow::Result { ensure!( min_block.starts_with('$'), "placeholders must start with '$'" @@ -109,7 +159,7 @@ impl PlaceholderSettings { /// Ensure that the given placeholder is valid, and update the validator /// internal state accordingly. - pub fn resolve_placeholder(&self, name: &str) -> Result { + pub fn resolve_placeholder(&self, name: &str) -> anyhow::Result { if self.min_block_placeholder == name { return Ok(PlaceholderIdentifier::MinQueryOnIdx1); } @@ -140,24 +190,24 @@ impl PlaceholderSettings { pub fn parse_and_validate( query: &str, settings: &ParsilSettings, -) -> Result { +) -> anyhow::Result { let mut query = parser::parse(&settings, query)?; - expand::expand(&settings, &mut query); + expand::expand(&settings, &mut query)?; - placeholders::validate(&settings, &query)?; - validate::validate(&settings, &query)?; - assembler::validate(&query, &settings)?; + placeholders::validate(settings, &query)?; + validate::validate(settings, &query)?; + assembler::validate(&query, settings)?; Ok(query) } /// Convert a string to a U256. Case is not conserved, and the string may be /// prefixed by a radix indicator. -pub fn str_to_u256(s: &str) -> Result { +pub fn str_to_u256(s: &str) -> anyhow::Result { let s = s.to_lowercase(); - U256::from_str(&s).map_err(|e| anyhow!("{s}: invalid U256: {e}")) + U256::from_str(&s).map_err(|e| anyhow::anyhow!("{s}: invalid U256: {e}")) } -pub(crate) fn val_to_expr(x: U256) -> Expr { +pub(crate) fn u256_to_expr(x: U256) -> Expr { if let Result::Ok(x_int) = TryInto::::try_into(x) { Expr::Value(Value::Number(x_int.to_string(), false)) } else { @@ -165,6 +215,14 @@ pub(crate) fn val_to_expr(x: U256) -> Expr { } } +pub(crate) fn int_to_expr + ToString>(x: X) -> Expr { + if let Result::Ok(x_int) = TryInto::::try_into(x) { + Expr::Value(Value::Number(x_int.to_string(), false)) + } else { + Expr::Value(Value::SingleQuotedString(x.to_string())) + } +} + /// Reduce all the parts of an expression that can be computed at compile-time. pub(crate) fn const_reduce(expr: &mut Expr) { #[allow(non_snake_case)] @@ -183,14 +241,14 @@ pub(crate) fn const_reduce(expr: &mut Expr) { } (None, Some(new_right)) => { const_reduce(left); - *right = Box::new(val_to_expr(new_right)); + *right = Box::new(u256_to_expr(new_right)); } (Some(new_left), None) => { const_reduce(right); - *left = Box::new(val_to_expr(new_left)); + *left = Box::new(u256_to_expr(new_left)); } (Some(new_left), Some(new_right)) => { - *expr = val_to_expr(match op { + *expr = u256_to_expr(match op { BinaryOperator::Plus => new_left + new_right, BinaryOperator::Minus => new_left - new_right, BinaryOperator::Multiply => new_left * new_right, @@ -265,11 +323,11 @@ pub(crate) fn const_reduce(expr: &mut Expr) { } } Expr::UnaryOp { op, expr } => { - if let Some(new_e) = const_eval(expr).ok() { + if let Result::Ok(new_e) = const_eval(expr) { match op { - UnaryOperator::Plus => *expr = Box::new(val_to_expr(new_e)), + UnaryOperator::Plus => *expr = Box::new(u256_to_expr(new_e)), UnaryOperator::Not => { - *expr = Box::new(val_to_expr(if new_e.is_zero() { ONE } else { ZERO })); + *expr = Box::new(u256_to_expr(if new_e.is_zero() { ONE } else { ZERO })); } _ => unreachable!(), } @@ -289,7 +347,7 @@ pub(crate) fn const_reduce(expr: &mut Expr) { /// /// NOTE: this will be used (i) in optimization and (ii) when boundaries /// will accept more complex expression. -pub(crate) fn const_eval(expr: &Expr) -> Result { +pub(crate) fn const_eval(expr: &Expr) -> anyhow::Result { #[allow(non_snake_case)] let ONE = U256::from_str_radix("1", 2).unwrap(); const ZERO: U256 = U256::ZERO; diff --git a/parsil/src/validate.rs b/parsil/src/validate.rs index e7a48b3a4..75cdb7df4 100644 --- a/parsil/src/validate.rs +++ b/parsil/src/validate.rs @@ -1,16 +1,13 @@ -use alloy::primitives::U256; -use anyhow::bail; use sqlparser::ast::{ BinaryOperator, Distinct, Expr, FunctionArg, FunctionArgExpr, FunctionArguments, GroupByExpr, JoinOperator, Offset, OffsetRows, OrderBy, OrderByExpr, Query, Select, SelectItem, SetExpr, TableFactor, UnaryOperator, Value, }; -use verifiable_db::test_utils::MAX_NUM_OUTPUTS; use crate::{ errors::ValidationError, symbols::ContextProvider, - utils::{const_eval, str_to_u256, ParsilSettings}, + utils::{str_to_u256, ParsilSettings}, visitor::{AstVisitor, Visit}, }; @@ -27,7 +24,7 @@ macro_rules! ensure { pub struct SqlValidator<'a, C: ContextProvider> { settings: &'a ParsilSettings, } -impl<'a, C: ContextProvider> AstVisitor for SqlValidator<'a, C> { +impl AstVisitor for SqlValidator<'_, C> { type Error = ValidationError; fn pre_unary_operator(&mut self, unary_operator: &UnaryOperator) -> Result<(), Self::Error> { @@ -392,14 +389,6 @@ impl<'a, C: ContextProvider> AstVisitor for SqlValidator<'a, C> { q.order_by.is_none(), ValidationError::UnsupportedFeature("ORDER BY".into()) ); - if let Some(l) = &q.limit { - let limit_value = const_eval(l).map_err(|_| ValidationError::InvalidLimitExpression)?; - let max_limit = U256::from(C::MAX_NUM_OUTPUTS); - ensure!( - limit_value <= max_limit, - ValidationError::LimitTooHigh(C::MAX_NUM_OUTPUTS) - ); - } Ok(()) } } diff --git a/recursion-framework/Cargo.toml b/recursion-framework/Cargo.toml index 4eadbb738..0552c3477 100644 --- a/recursion-framework/Cargo.toml +++ b/recursion-framework/Cargo.toml @@ -7,8 +7,6 @@ edition = "2021" anyhow.workspace = true log.workspace = true plonky2.workspace = true -plonky2_crypto.workspace = true -plonky2_ecgfp5.workspace = true serde.workspace = true mp2_common = { path = "../mp2-common" } @@ -21,4 +19,4 @@ rstest.workspace = true serial_test.workspace = true [features] -original_poseidon = ["mp2_common/original_poseidon"] \ No newline at end of file +original_poseidon = ["mp2_common/original_poseidon"] diff --git a/recursion-framework/src/circuit_builder.rs b/recursion-framework/src/circuit_builder.rs index 710b0dfc6..0ebb0668c 100644 --- a/recursion-framework/src/circuit_builder.rs +++ b/recursion-framework/src/circuit_builder.rs @@ -102,8 +102,8 @@ impl, const D: usize, const NUM_PUBLIC_INPUTS: usize /// `build_circuit` builds a Plonky2 circuit which: /// - Verify `NUM_VERIFIERS` proofs employing the universal verifier. /// - Execute the custom logic specified by the `CLW` implementation - /// Note that the output data structure contains also the wrapping circuit necessary to - /// generate proofs that can be verified recursively with a universal verifier. + /// Note that the output data structure contains also the wrapping circuit necessary to + /// generate proofs that can be verified recursively with a universal verifier. pub fn build_circuit< C: GenericConfig, const NUM_VERIFIERS: usize, @@ -285,9 +285,9 @@ where /// input of the circuit /// - `custom_inputs` are employed as inputs to fill witness data related to the additional logic being /// enforced besides verifying the `NUM_VERIFIERS` proofs with the universal verifier - /// Note that this function will output a proof of the wrapping circuit, which can be directly - /// recursively verified with the universal verifier. This method is publicly exposed through the - /// `generate_proof` method of `RecursiveCircuits` data structure + /// Note that this function will output a proof of the wrapping circuit, which can be directly + /// recursively verified with the universal verifier. This method is publicly exposed through the + /// `generate_proof` method of `RecursiveCircuits` data structure pub(crate) fn generate_proof( &self, input_proofs: [ProofWithPublicInputs; NUM_VERIFIERS], @@ -435,8 +435,8 @@ pub(crate) mod tests { Self { inputs, generator, - _f: PhantomData::default(), - _h: PhantomData::default(), + _f: PhantomData, + _h: PhantomData, } } diff --git a/recursion-framework/src/framework.rs b/recursion-framework/src/framework.rs index 47cb52c61..b6f152a29 100644 --- a/recursion-framework/src/framework.rs +++ b/recursion-framework/src/framework.rs @@ -101,8 +101,8 @@ where /// and `input_verifier_data` contains the corrisponding verifier data /// - `custom_inputs` contains the input necessary to fill the witness data related to the additional logic being /// enforced in the circuit besides verifying the `NUM_VERIFIERS` proofs with the universal verifier - /// Note that this function will already output a proof that can be directly recursively verified with the - /// universal verifier + /// Note that this function will already output a proof that can be directly recursively verified with the + /// universal verifier pub fn generate_proof< const NUM_VERIFIERS: usize, CLW: CircuitLogicWires, @@ -347,7 +347,7 @@ pub(crate) mod tests { ) -> Self { Self { targets: builder_parameters.verify_proof_in_circuit_set(builder), - c: PhantomData::::default(), + c: PhantomData::, } } @@ -397,7 +397,7 @@ pub(crate) mod tests { targets: builder_parameters .0 .verify_proof_fixed_circuit_in_circuit_set(builder, &builder_parameters.1), - c: PhantomData::::default(), + c: PhantomData::, } } diff --git a/recursion-framework/src/framework_testing.rs b/recursion-framework/src/framework_testing.rs index dc4e9e56e..214fce4ec 100644 --- a/recursion-framework/src/framework_testing.rs +++ b/recursion-framework/src/framework_testing.rs @@ -338,14 +338,14 @@ mod tests { let verifier_gadget = RecursiveCircuitsVerifierGagdet::new( config.clone(), - &testing_framework.get_recursive_circuit_set(), + testing_framework.get_recursive_circuit_set(), ); let verifier_circuit = circuit_builder .build_circuit::>(verifier_gadget); let verifier_gadget = RecursiveCircuitsVerifierGagdet::new( config.clone(), - &testing_framework.get_recursive_circuit_set(), + testing_framework.get_recursive_circuit_set(), ); let verifier_circuit_fixed = circuit_builder .build_circuit::>(( diff --git a/recursion-framework/src/universal_verifier_gadget/verifier_gadget.rs b/recursion-framework/src/universal_verifier_gadget/verifier_gadget.rs index 4b603c536..65f8cc11b 100644 --- a/recursion-framework/src/universal_verifier_gadget/verifier_gadget.rs +++ b/recursion-framework/src/universal_verifier_gadget/verifier_gadget.rs @@ -289,7 +289,7 @@ mod tests { } fn get_circuit_data(&self) -> &CircuitData { - &self.wrap_circuit.final_proof_circuit_data() + self.wrap_circuit.final_proof_circuit_data() } } @@ -388,7 +388,7 @@ mod tests { } fn get_circuit_data(&self) -> &CircuitData { - &self.wrap_circuit.final_proof_circuit_data() + self.wrap_circuit.final_proof_circuit_data() } } diff --git a/recursion-framework/src/universal_verifier_gadget/wrap_circuit.rs b/recursion-framework/src/universal_verifier_gadget/wrap_circuit.rs index 3ea103779..010a6338e 100644 --- a/recursion-framework/src/universal_verifier_gadget/wrap_circuit.rs +++ b/recursion-framework/src/universal_verifier_gadget/wrap_circuit.rs @@ -258,7 +258,7 @@ pub(crate) mod test { } fn get_circuit_data(&self) -> &CircuitData { - &self.wrap_circuit.final_proof_circuit_data() + self.wrap_circuit.final_proof_circuit_data() } } diff --git a/recursion-framework/tests/integration.rs b/recursion-framework/tests/integration.rs index a1214db99..e50c71c8b 100644 --- a/recursion-framework/tests/integration.rs +++ b/recursion-framework/tests/integration.rs @@ -161,7 +161,7 @@ fn test_map_reduce_circuits() { let mut dataset_chunk_digests = dataset .chunks(INPUT_CHUNK_SIZE) - .map(|chunk| H::hash_no_pad(chunk)) + .map(H::hash_no_pad) .collect::>(); while dataset_chunk_digests.len() != 1 { let new_dataset_chunk_digests = dataset_chunk_digests diff --git a/ryhope/src/lib.rs b/ryhope/src/lib.rs index 8462e2320..5f44bf9e9 100644 --- a/ryhope/src/lib.rs +++ b/ryhope/src/lib.rs @@ -44,10 +44,18 @@ pub type Epoch = i64; pub trait NodePayload: Debug + Sized + Serialize + for<'a> Deserialize<'a> { /// Set an aggregate value for the current node, computable from the payload /// of its children. - /// - /// Return true if the payload has been modified and must be updated in the - /// storage, false otherwise. - fn aggregate>>(&mut self, _children: I) {} + fn aggregate>>(&mut self, children: I) { + self.aggregate_with_context(children, &mut ()) + } + + /// Set an aggregate value for the current node, computable from the payload + /// of its children and some external generic data. + fn aggregate_with_context>, T>( + &mut self, + _children: I, + _context: &mut T, + ) { + } } impl NodePayload for serde_json::Value { diff --git a/ryhope/src/storage/memory.rs b/ryhope/src/storage/memory.rs index a00f3a66f..f48c0c1af 100644 --- a/ryhope/src/storage/memory.rs +++ b/ryhope/src/storage/memory.rs @@ -37,10 +37,6 @@ impl VersionedStorage where T: Debug + Send + Sync + Clone + Serialize + for<'a> Deserialize<'a>, { - fn new(initial_state: T) -> Self { - Self::new_at(initial_state, 0) - } - fn new_at(initial_state: T, epoch: Epoch) -> Self { Self { in_tx: false, @@ -132,6 +128,12 @@ pub struct VersionedKvStorage { /// The initial epoch epoch_offset: Epoch, } +impl Default for VersionedKvStorage { + fn default() -> Self { + Self::new() + } +} + impl VersionedKvStorage { pub fn new() -> Self { Self::new_at(0) diff --git a/ryhope/src/storage/mod.rs b/ryhope/src/storage/mod.rs index e710fcdc1..043b169ad 100644 --- a/ryhope/src/storage/mod.rs +++ b/ryhope/src/storage/mod.rs @@ -55,6 +55,7 @@ where /// The keys touched by the query itself pub core_keys: Vec<(Epoch, K)>, /// An epoch -> (K -> NodeContext, K -> Payload) mapping + #[allow(clippy::type_complexity)] epoch_lineages: HashMap>, HashMap)>, } @@ -409,7 +410,6 @@ pub trait TreeTransactionalStorage BoxFuture<'_, Result<()>> + Sync>( &mut self, f: F, @@ -455,7 +455,7 @@ pub trait TreeTransactionalStorage: TreeTransactionalStorage { @@ -518,7 +518,7 @@ pub trait MetaOperations: Ok(r) } } - + #[allow(clippy::type_complexity)] fn try_fetch_many_at + Send>( &self, t: &T, diff --git a/ryhope/src/storage/pgsql/mod.rs b/ryhope/src/storage/pgsql/mod.rs index c46d4625c..443e9d443 100644 --- a/ryhope/src/storage/pgsql/mod.rs +++ b/ryhope/src/storage/pgsql/mod.rs @@ -24,6 +24,8 @@ use tracing::*; mod storages; +const MAX_PGSQL_BIGINT: i64 = i64::MAX; + /// A trait that must be implemented by a custom node key. This allows to /// (de)serialize any custom key to and fro a PgSQL BYTEA. pub trait ToFromBytea: Clone + Eq { @@ -491,35 +493,21 @@ where .with_context(|| format!("unable to create table `{table}_meta`")) } - async fn update_all(&self, db_tx: &tokio_postgres::Transaction<'_>) -> Result<()> { - let update_all = format!( - "UPDATE {} SET {VALID_UNTIL}=$1 WHERE {VALID_UNTIL}=$2", - self.table - ); - - db_tx - .query(&update_all, &[&(&self.epoch + 1), &self.epoch]) - .await - .context("while updating timestamps") - .map(|_| ()) - } - - /// Roll-back to `self.epoch` the lifetime of a row having already been extended to `self.epoch + 1`. - async fn rollback_one_row( + /// Close the lifetim of a row to `self.epoch`. + async fn mark_dead( &self, db_tx: &tokio_postgres::Transaction<'_>, key: &T::Key, ) -> Result> { - trace!("[{self}] rolling back {key:?} one epoch"); + trace!("[{self}] marking {key:?} as dead @{}", self.epoch); let rows = db_tx .query( &format!( - "UPDATE {} SET {VALID_UNTIL}={} WHERE {KEY}=$1 AND {VALID_UNTIL}={} RETURNING *", + "UPDATE {} SET {VALID_UNTIL}={} WHERE {KEY}=$1 AND {VALID_UNTIL}=$2 RETURNING *", self.table, self.epoch, - self.epoch + 1 ), - &[&key.to_bytea()], + &[&key.to_bytea(), &MAX_PGSQL_BIGINT], ) .await?; @@ -562,11 +550,6 @@ where // The putative new stamps if everything goes well let new_epoch = self.epoch + 1; - // Pre-emptively extend by 1 the lifetime of the currently alive rows; - // those that should not be alive in the next epoch will be rolled back - // later. - self.update_all(db_tx).await?; - // Collect all the keys found in the caches let mut cached_keys = HashSet::new(); { @@ -604,7 +587,7 @@ where // The node has been removed (Some(None), _) => { // k has been deleted; simply roll-back the lifetime of its row. - self.rollback_one_row(db_tx, &k).await?; + self.mark_dead(db_tx, &k).await?; } // The payload alone has been updated @@ -614,7 +597,7 @@ where ) | (None, Some(Some(CachedValue::Written(new_payload)))) => { // rollback the old value if any - let previous_node = self.rollback_one_row(db_tx, &k).await?.unwrap().0; + let previous_node = self.mark_dead(db_tx, &k).await?.unwrap().0; // write the new value self.new_node(db_tx, &k, previous_node).await?; T::set_at_in_tx( @@ -631,7 +614,7 @@ where (Some(Some(CachedValue::Written(new_node))), maybe_new_payload) => { // insertion or displacement in the tree; the row has to be // duplicated/updated and rolled-back - let previous_state = self.rollback_one_row(db_tx, &k).await?; + let previous_state = self.mark_dead(db_tx, &k).await?; // insert the new row representing the new state of the key... self.new_node(db_tx, &k, new_node.to_owned()).await?; diff --git a/ryhope/src/storage/pgsql/storages.rs b/ryhope/src/storage/pgsql/storages.rs index ff851c4fa..7c3726d9b 100644 --- a/ryhope/src/storage/pgsql/storages.rs +++ b/ryhope/src/storage/pgsql/storages.rs @@ -26,7 +26,7 @@ use tokio::sync::RwLock; use tokio_postgres::{self, NoTls, Row, Transaction}; use tracing::*; -use super::{CachedValue, PayloadInDb, ToFromBytea}; +use super::{CachedValue, PayloadInDb, ToFromBytea, MAX_PGSQL_BIGINT}; pub type DBPool = Pool>; @@ -219,6 +219,7 @@ where ) -> impl Future>>; /// Return the value associated to the given key at the given epoch. + #[allow(clippy::type_complexity)] fn fetch_many_at, I: IntoIterator + Send>( &self, s: &S, @@ -278,10 +279,10 @@ where &format!( "INSERT INTO {} ({KEY}, {VALID_FROM}, {VALID_UNTIL}) - VALUES ($1, $2, $2)", + VALUES ($1, $2, $3)", table ), - &[&k.to_bytea(), &birth_epoch], + &[&k.to_bytea(), &birth_epoch, &MAX_PGSQL_BIGINT], ) .await .map_err(|e| anyhow!("failed to insert new node row: {e:?}")) @@ -346,6 +347,7 @@ where .context("failed to fetch payload for touched keys")?; // Assemble the final result + #[allow(clippy::type_complexity)] let mut epoch_lineages: HashMap< Epoch, (HashMap>, HashMap), @@ -372,50 +374,51 @@ where }) } - fn fetch_many_at, I: IntoIterator + Send>( + async fn fetch_many_at< + S: TreeStorage, + I: IntoIterator + Send, + >( &self, s: &S, db: DBPool, table: &str, data: I, - ) -> impl Future, V)>>> + Send { - async move { - let data = data.into_iter().collect::>(); - let connection = db.get().await.unwrap(); - let immediate_table = data - .iter() - .map(|(epoch, key)| { - format!( - "({epoch}::BIGINT, '\\x{}'::BYTEA)", - hex::encode(key.to_bytea()) - ) - }) - .join(", "); - - let mut r = Vec::new(); - for row in connection - .query( - &dbg!(format!( - "SELECT batch.key, batch.epoch, {table}.{PAYLOAD} FROM - (VALUES {}) AS batch (epoch, key) - LEFT JOIN {table} ON - batch.key = {table}.{KEY} AND {table}.{VALID_FROM} <= batch.epoch AND batch.epoch <= {table}.{VALID_UNTIL}", - immediate_table - )), - &[], - ) - .await - .context("while fetching payload from database")? - .iter() { - let k = Self::Key::from_bytea(row.get::<_, Vec>(0)); - let epoch = row.get::<_, Epoch>(1); - let v = row.get::<_, Option>>(2).map(|x| x.0); - if let Some(v) = v { - r.push((epoch, self.node_context(&k, s).await.unwrap() , v)); - } + ) -> Result, V)>> { + let data = data.into_iter().collect::>(); + let connection = db.get().await.unwrap(); + let immediate_table = data + .iter() + .map(|(epoch, key)| { + format!( + "({epoch}::BIGINT, '\\x{}'::BYTEA)", + hex::encode(key.to_bytea()) + ) + }) + .join(", "); + + let mut r = Vec::new(); + for row in connection + .query( + &dbg!(format!( + "SELECT batch.key, batch.epoch, {table}.{PAYLOAD} FROM + (VALUES {}) AS batch (epoch, key) + LEFT JOIN {table} ON + batch.key = {table}.{KEY} AND {table}.{VALID_FROM} <= batch.epoch AND batch.epoch <= {table}.{VALID_UNTIL}", + immediate_table + )), + &[], + ) + .await + .context("while fetching payload from database")? + .iter() { + let k = Self::Key::from_bytea(row.get::<_, Vec>(0)); + let epoch = row.get::<_, Epoch>(1); + let v = row.get::<_, Option>>(2).map(|x| x.0); + if let Some(v) = v { + r.push((epoch, self.node_context(&k, s).await.unwrap() , v)); } - Ok(r) - } + } + Ok(r) } } @@ -504,12 +507,13 @@ where &format!( "INSERT INTO {} ({KEY}, {VALID_FROM}, {VALID_UNTIL}, {SUBTREE_SIZE}, {PARENT}, {LEFT_CHILD}, {RIGHT_CHILD}) - VALUES ($1, $2, $2, $3, $4, $5, $6)", + VALUES ($1, $2, $3, $4, $5, $6, $7)", table ), &[ &k.to_bytea(), &birth_epoch, + &MAX_PGSQL_BIGINT, &(n.subtree_size as i64), &n.parent.as_ref().map(ToFromBytea::to_bytea), &n.left.as_ref().map(ToFromBytea::to_bytea), @@ -521,135 +525,148 @@ where .map(|_| ()) } - fn wide_lineage_between>( + async fn wide_lineage_between>( &self, _: &S, db: DBPool, table: &str, keys_query: &str, bounds: (Epoch, Epoch), - ) -> impl Future>> { - async move { - ensure!( - !keys_query.contains('$'), - "unexpected placeholder found in keys_query" - ); - // Call the mega-query doing everything - let query = format!( - include_str!("wide_lineage.sql"), - KEY = KEY, - EPOCH = EPOCH, - PAYLOAD = PAYLOAD, - VALID_FROM = VALID_FROM, - VALID_UNTIL = VALID_UNTIL, - PARENT = PARENT, - LEFT_CHILD = LEFT_CHILD, - RIGHT_CHILD = RIGHT_CHILD, - SUBTREE_SIZE = SUBTREE_SIZE, - max_depth = 2, - zk_table = table, - core_keys_query = keys_query, - ); - let connection = db.get().await.unwrap(); - let rows = connection - .query(&query, &[&bounds.0, &bounds.1]) - .await - .with_context(|| { - format!( - "while fetching wide lineage for {table} [[{}, {}]] with: {query}", - bounds.0, bounds.1 - ) - })?; - - // Assemble the final result - let mut core_keys = Vec::new(); - let mut epoch_lineages: HashMap>, HashMap)> = - HashMap::new(); - - for row in &rows { - let is_core = row - .try_get::<_, i32>("is_core") - .context("while fetching core flag from row")? - > 0; - let epoch = row - .try_get::<_, i64>(EPOCH) - .context("while fetching epoch from row")?; - let node = >::node_from_row(row)?; - let payload = Self::payload_from_row(row)?; - if is_core { - core_keys.push((epoch, node.k.clone())); - } + ) -> Result> { + ensure!( + !keys_query.contains('$'), + "unexpected placeholder found in keys_query" + ); + // Call the mega-query doing everything + let query = format!( + include_str!("wide_lineage.sql"), + KEY = KEY, + EPOCH = EPOCH, + PAYLOAD = PAYLOAD, + VALID_FROM = VALID_FROM, + VALID_UNTIL = VALID_UNTIL, + PARENT = PARENT, + LEFT_CHILD = LEFT_CHILD, + RIGHT_CHILD = RIGHT_CHILD, + SUBTREE_SIZE = SUBTREE_SIZE, + max_depth = 2, + zk_table = table, + core_keys_query = keys_query, + ); + let connection = db.get().await.unwrap(); + let rows = connection + .query(&query, &[&bounds.0, &bounds.1]) + .await + .with_context(|| { + format!( + "while fetching wide lineage for {table} [[{}, {}]] with: {query}", + bounds.0, bounds.1 + ) + })?; - let h_epoch = epoch_lineages.entry(epoch).or_default(); - h_epoch.0.insert( - node.k.clone(), - NodeContext { - node_id: node.k.clone(), - parent: node.parent.clone(), - left: node.left.clone(), - right: node.right.clone(), - }, - ); - h_epoch.1.insert(node.k, payload); + // Assemble the final result + let mut core_keys = Vec::new(); + #[allow(clippy::type_complexity)] + let mut epoch_lineages: HashMap< + Epoch, + (HashMap>, HashMap), + > = HashMap::new(); + + for row in &rows { + let is_core = row + .try_get::<_, i32>("is_core") + .context("while fetching core flag from row")? + > 0; + let epoch = row + .try_get::<_, i64>(EPOCH) + .context("while fetching epoch from row")?; + let node = >::node_from_row(row)?; + let payload = Self::payload_from_row(row)?; + if is_core { + core_keys.push((epoch, node.k.clone())); } - Ok(WideLineage { - core_keys, - epoch_lineages, - }) + let h_epoch = epoch_lineages.entry(epoch).or_default(); + h_epoch.0.insert( + node.k.clone(), + NodeContext { + node_id: node.k.clone(), + parent: node.parent.clone(), + left: node.left.clone(), + right: node.right.clone(), + }, + ); + h_epoch.1.insert(node.k, payload); } + + Ok(WideLineage { + core_keys, + epoch_lineages, + }) } - fn fetch_many_at, I: IntoIterator + Send>( + async fn fetch_many_at< + S: TreeStorage, + I: IntoIterator + Send, + >( &self, _s: &S, db: DBPool, table: &str, data: I, - ) -> impl Future, V)>>> + Send { - async move { - let data = data.into_iter().collect::>(); - let connection = db.get().await.unwrap(); - let immediate_table = data - .iter() - .map(|(epoch, key)| { - format!( - "({epoch}::BIGINT, '\\x{}'::BYTEA)", - hex::encode(key.to_bytea()) - ) - }) - .join(", "); - - let mut r = Vec::new(); - for row in connection + ) -> Result, V)>> { + let data = data.into_iter().collect::>(); + let connection = db.get().await.unwrap(); + let immediate_table = data + .iter() + .map(|(epoch, key)| { + format!( + "({epoch}::BIGINT, '\\x{}'::BYTEA)", + hex::encode(key.to_bytea()) + ) + }) + .join(", "); + + let mut r = Vec::new(); + for row in connection .query( - &dbg!(format!( - "SELECT - batch.key, batch.epoch, {table}.{PAYLOAD}, - {table}.{PARENT}, {table}.{LEFT_CHILD}, {table}.{RIGHT_CHILD} - FROM - (VALUES {}) AS batch (epoch, key) - LEFT JOIN {table} ON - batch.key = {table}.{KEY} AND {table}.{VALID_FROM} <= batch.epoch AND batch.epoch <= {table}.{VALID_UNTIL}", - immediate_table - )), + &format!( + "SELECT + batch.key, batch.epoch, {table}.{PAYLOAD}, + {table}.{PARENT}, {table}.{LEFT_CHILD}, {table}.{RIGHT_CHILD} + FROM + (VALUES {}) AS batch (epoch, key) + LEFT JOIN {table} ON + batch.key = {table}.{KEY} AND {table}.{VALID_FROM} <= batch.epoch AND batch.epoch <= {table}.{VALID_UNTIL}", + immediate_table + ), &[], ) - .await - .context("while fetching payload from database")? - .iter() { - let k = Self::Key::from_bytea(row.get::<_, Vec>(0)); - let epoch = row.get::<_, Epoch>(1); - let v = row.get::<_, Option>>(2).map(|x| x.0); - if let Some(v) = v { - r.push((epoch, NodeContext{ node_id: k, parent: row.get::<_, Option>>(3).map(K::from_bytea), left: row.get::<_, Option>>(4).map(K::from_bytea), right: row.get::<_, Option>>(5).map(K::from_bytea) }, v)); - } - } - Ok(r) + .await + .context("while fetching payload from database")? + .iter() + { + let k = Self::Key::from_bytea(row.get::<_, Vec>(0)); + let epoch = row.get::<_, Epoch>(1); + let v = row.get::<_, Option>>(2).map(|x| x.0); + if let Some(v) = v { + r.push(( + epoch, + NodeContext { + node_id: k, + parent: row.get::<_, Option>>(3).map(K::from_bytea), + left: row.get::<_, Option>>(4).map(K::from_bytea), + right: row.get::<_, Option>>(5).map(K::from_bytea), + }, + v, + )); + } } + Ok(r) } } +/// Stores the chronological evolution of a single value in a CoW manner. pub struct CachedDbStore Deserialize<'a>> { /// A pointer to the DB client db: DBPool, @@ -883,7 +900,7 @@ where .transaction() .await .expect("unable to create DB transaction"); - // Roll back all living nodes by 1 + // Roll back all the nodes that would still have been alive db_tx .query( &format!( @@ -1021,7 +1038,7 @@ where .transaction() .await .expect("unable to create DB transaction"); - // Roll back all living nodes by 1 + // Roll back all the nodes that would still have been alive db_tx .query( &format!( @@ -1130,6 +1147,26 @@ where async fn pairs_at(&self, _epoch: Epoch) -> Result> { unimplemented!("should never be used"); } + + async fn fetch(&self, k: &T::Key) -> T::Node { + self.fetch_at(k, self.current_epoch()).await + } + + async fn try_fetch(&self, k: &T::Key) -> Option { + self.try_fetch_at(k, self.current_epoch()).await + } + + async fn fetch_at(&self, k: &T::Key, epoch: Epoch) -> T::Node { + self.try_fetch_at(k, epoch).await.unwrap() + } + + async fn contains(&self, k: &T::Key) -> bool { + self.try_fetch(k).await.is_some() + } + + async fn contains_at(&self, k: &T::Key, epoch: Epoch) -> bool { + self.try_fetch_at(k, epoch).await.is_some() + } } impl EpochKvStorage for NodeProjection where @@ -1173,6 +1210,19 @@ where .insert(k, Some(CachedValue::Written(value))); async { Ok(()) } } + + async fn update_with(&mut self, k: T::Key, updater: F) + where + Self: Sync + Send, + { + let mut v = self.fetch(&k).await; + updater(&mut v); + self.update(k, v).await.unwrap(); + } + + fn rollback(&mut self) -> impl Future> { + self.rollback_to(self.current_epoch() - 1) + } } /// A wrapper around a [`CachedDbTreeStore`] to make it appear as a KV store for diff --git a/ryhope/src/storage/tests.rs b/ryhope/src/storage/tests.rs index 3d1bd6084..c9ef56afc 100644 --- a/ryhope/src/storage/tests.rs +++ b/ryhope/src/storage/tests.rs @@ -50,8 +50,8 @@ async fn _storage_in_memory(initial_epoch: Epoch) -> Result<()> { for i in initial_epoch + 1..initial_epoch + 6 { println!("\nEpoch = {i}"); - let mut ss = s.view_at(i); - s.tree().print(&mut ss).await; + let ss = s.view_at(i); + s.tree().print(&ss).await; s.diff_at(i).await.unwrap().print(); match i - initial_epoch { @@ -108,7 +108,7 @@ async fn _storage_in_pgsql(initial_epoch: Epoch) -> Result<()> { println!("Old one"); s.print_tree().await; - let mut s2 = MerkleTreeKvDb::::new( + let s2 = MerkleTreeKvDb::::new( InitSettings::MustExist, SqlStorageSettings { source: SqlServerConnection::NewConnection(db_url()), @@ -121,14 +121,14 @@ async fn _storage_in_pgsql(initial_epoch: Epoch) -> Result<()> { assert_eq!(s2.root_data().await, s.root_data().await); assert_eq!( - s.tree().size(&mut s2.storage).await, + s.tree().size(&s2.storage).await, s2.tree().size(&s2.storage).await ); for i in initial_epoch + 1..=initial_epoch + 6 { println!("\nEpoch = {i}"); - let mut ss = s.view_at(i); - s.tree().print(&mut ss).await; + let ss = s.view_at(i); + s.tree().print(&ss).await; s.diff_at(i).await.unwrap().print(); match i { @@ -295,8 +295,8 @@ async fn sbbst_storage_in_pgsql() -> Result<()> { for i in 1..=2 { println!("\nEpoch = {i}"); - let mut ss = s2.view_at(i); - s2.tree().print(&mut ss).await; + let ss = s2.view_at(i); + s2.tree().print(&ss).await; s_psql.diff_at(i).await.unwrap().print(); } @@ -671,7 +671,7 @@ async fn test_rollback< // Rollback twice to reach epoch 1 s.rollback_to(1 + initial_epoch) .await - .expect(&format!("failed to rollback to {}", 1 + initial_epoch)); + .unwrap_or_else(|_| panic!("failed to rollback to {}", 1 + initial_epoch)); assert_eq!(s.current_epoch(), 1 + initial_epoch); assert_eq!(s.size().await, 2); for i in 0..=5 { @@ -1014,7 +1014,7 @@ async fn fetch_many() { s.in_transaction(|s| { Box::pin(async { for (i, word) in TEXT1.split(' ').enumerate() { - s.store(word.to_string(), i.try_into().unwrap()).await?; + s.store(word.to_string(), i).await?; } Ok(()) }) @@ -1025,7 +1025,7 @@ async fn fetch_many() { s.in_transaction(|s| { Box::pin(async { for (i, word) in TEXT2.split(' ').enumerate() { - s.store(word.to_string(), i.try_into().unwrap()).await?; + s.store(word.to_string(), i).await?; } Ok(()) }) @@ -1061,6 +1061,9 @@ async fn fetch_many() { (1i64, "restera".to_string(), 12), (2i64, "restera".to_string(), 12), (2i64, "car".to_string(), 0), + // This should not exist, but as we use infinity to mark alive + // nodes, it will still appear + (4i64, "restera".to_string(), 12), ] .into_iter() .collect::>() @@ -1091,7 +1094,7 @@ async fn wide_update_trees() { s.in_transaction(|s| { Box::pin(async { for (i, word) in TEXT1.split(' ').enumerate() { - s.store(word.to_string(), i.try_into().unwrap()).await?; + s.store(word.to_string(), i).await?; } Ok(()) }) @@ -1105,7 +1108,7 @@ async fn wide_update_trees() { s.in_transaction(|s| { Box::pin(async { for (i, word) in TEXT2.split(' ').enumerate() { - s.store(word.to_string(), i.try_into().unwrap()).await?; + s.store(word.to_string(), i).await?; } Ok(()) }) @@ -1151,7 +1154,7 @@ async fn all_pgsql() { s.in_transaction(|s| { Box::pin(async { for (i, word) in TEXT1.split(' ').enumerate() { - s.store(word.to_string(), i.try_into().unwrap()).await?; + s.store(word.to_string(), i).await?; } Ok(()) }) @@ -1172,7 +1175,7 @@ async fn all_pgsql() { s.in_transaction(|s| { Box::pin(async { for (i, word) in TEXT2.split(' ').enumerate() { - s.store(word.to_string(), i.try_into().unwrap()).await?; + s.store(word.to_string(), i).await?; } Ok(()) }) @@ -1220,7 +1223,7 @@ async fn all_memory() { s.in_transaction(|s| { Box::pin(async { for (i, word) in TEXT1.split(' ').enumerate() { - s.store(word.to_string(), i.try_into().unwrap()).await?; + s.store(word.to_string(), i).await?; } Ok(()) }) @@ -1241,7 +1244,7 @@ async fn all_memory() { s.in_transaction(|s| { Box::pin(async { for (i, word) in TEXT2.split(' ').enumerate() { - s.store(word.to_string(), i.try_into().unwrap()).await?; + s.store(word.to_string(), i).await?; } Ok(()) }) diff --git a/ryhope/src/storage/updatetree.rs b/ryhope/src/storage/updatetree.rs index 99502f3f7..32d34cc3e 100644 --- a/ryhope/src/storage/updatetree.rs +++ b/ryhope/src/storage/updatetree.rs @@ -229,7 +229,7 @@ impl UpdateTree { std::iter::once(k).chain( n.children .iter() - .flat_map(|child_i| self.descendants(*child_i).into_iter()), + .flat_map(|child_i| self.descendants(*child_i)), ), ) } @@ -423,7 +423,7 @@ impl UpdatePlan { let i = *self .t .idx - .get(&item.k()) + .get(item.k()) .ok_or_else(|| anyhow!("unknwown key"))?; // May happen when restarting a plan diff --git a/ryhope/src/tests/trees.rs b/ryhope/src/tests/trees.rs index 5d58d9196..bea4a1b48 100644 --- a/ryhope/src/tests/trees.rs +++ b/ryhope/src/tests/trees.rs @@ -138,8 +138,8 @@ mod scapegoat { bs.state_mut().commit_transaction().await.unwrap(); ls.state_mut().commit_transaction().await.unwrap(); - assert_eq!(bbst.depth(&mut bs).await, 7); - assert_eq!(list.depth(&mut ls).await, 127); + assert_eq!(bbst.depth(&bs).await, 7); + assert_eq!(list.depth(&ls).await, 127); Ok(()) } diff --git a/ryhope/src/tree/mod.rs b/ryhope/src/tree/mod.rs index a1ac6be68..2d0b9de56 100644 --- a/ryhope/src/tree/mod.rs +++ b/ryhope/src/tree/mod.rs @@ -18,12 +18,12 @@ pub struct NodePath { impl NodePath { /// Return an iterator over references to the keys forming the full path /// from the root to `target` (included). - pub fn full_path(&self) -> impl Iterator + DoubleEndedIterator { + pub fn full_path(&self) -> impl DoubleEndedIterator { self.ascendance.iter().chain(std::iter::once(&self.target)) } /// Return an iterator over the keys forming the full path from the root to /// `target` (included). - pub fn into_full_path(self) -> impl Iterator + DoubleEndedIterator { + pub fn into_full_path(self) -> impl DoubleEndedIterator { self.ascendance .into_iter() .chain(std::iter::once(self.target)) @@ -58,6 +58,7 @@ pub trait TreeTopology: Default + Send + Sync { /// Return, if it has some, the children of `k`. /// /// Return nothing if `k` is not in the tree. + #[allow(clippy::type_complexity)] fn children>( &self, k: &Self::Key, diff --git a/ryhope/src/tree/sbbst.rs b/ryhope/src/tree/sbbst.rs index 20a0e4512..ecc1f996a 100644 --- a/ryhope/src/tree/sbbst.rs +++ b/ryhope/src/tree/sbbst.rs @@ -29,8 +29,8 @@ //! //! Therefore determining the parent of a node of general value x is achieved by: //! 1. determine the layer i to which x belongs, which is the smaller power of -//! 2 to which x is congruent, i.e. the number of trailing zeros in its binary -//! representation; +//! 2 to which x is congruent, i.e. the number of trailing zeros in its binary +//! representation; //! 2. determine x rank n in the layer l^i, which is equal to (x - 2^i)/2^(i+1); //! 3. if n is even then x parent is n + 2^i, or n - 2^i if n is odd. //! @@ -168,11 +168,7 @@ impl State { pub fn node_context(&self, k: &NodeIdx) -> Option> { if let Some(inner) = self.node_context_inner(&self.inner_idx(*k)) { - let parent_outer = if let Some(parent) = inner.parent { - Some(self.outer_idx(parent)) - } else { - None - }; + let parent_outer = inner.parent.map(|parent| self.outer_idx(parent)); let left_outer = inner.left.map(|left| self.outer_idx(left)); let right_outer = inner.right.map(|right| self.outer_idx(right)); @@ -494,7 +490,7 @@ impl PrintableTree for Tree { } // TODO: Leave the warning for `k`, since we will implement it later. - async fn subtree_to_string>(&self, s: &S, k: &Self::Key) -> String { + async fn subtree_to_string>(&self, s: &S, _k: &Self::Key) -> String { self.tree_to_string(s).await } } diff --git a/verifiable-db/Cargo.toml b/verifiable-db/Cargo.toml index 6e27d0299..be1aa8a40 100644 --- a/verifiable-db/Cargo.toml +++ b/verifiable-db/Cargo.toml @@ -22,8 +22,7 @@ derive_more = "0.99.18" itertools.workspace = true [dev-dependencies] -env_logger.workspace = true -futures = "0.3.30" +futures = "0.3.31" mp2_test = { path = "../mp2-test" } rand.workspace = true serial_test.workspace = true @@ -31,4 +30,3 @@ tokio.workspace = true [features] original_poseidon = ["mp2_common/original_poseidon"] - diff --git a/verifiable-db/src/block_tree/membership.rs b/verifiable-db/src/block_tree/membership.rs index 2b4022ddb..58b65450f 100644 --- a/verifiable-db/src/block_tree/membership.rs +++ b/verifiable-db/src/block_tree/membership.rs @@ -190,7 +190,7 @@ mod tests { child_pi: &'a [F], } - impl<'a> UserCircuit for TestMembershipCircuit<'a> { + impl UserCircuit for TestMembershipCircuit<'_> { // Membership wires + child public inputs type Wires = (MembershipWires, Vec); diff --git a/verifiable-db/src/block_tree/parent.rs b/verifiable-db/src/block_tree/parent.rs index fd0b9330c..08f1ee52c 100644 --- a/verifiable-db/src/block_tree/parent.rs +++ b/verifiable-db/src/block_tree/parent.rs @@ -297,7 +297,7 @@ mod tests { rows_tree_pi: &'a [F], } - impl<'a> UserCircuit for TestParentCircuit<'a> { + impl UserCircuit for TestParentCircuit<'_> { // Parent node wires + extraction public inputs + rows tree public inputs type Wires = (ParentWires, Vec, Vec); diff --git a/verifiable-db/src/block_tree/public_inputs.rs b/verifiable-db/src/block_tree/public_inputs.rs index 4686aea00..8fd73c2d0 100644 --- a/verifiable-db/src/block_tree/public_inputs.rs +++ b/verifiable-db/src/block_tree/public_inputs.rs @@ -55,7 +55,7 @@ pub struct PublicInputs<'a, T> { pub(crate) new_node_digest: &'a [T], } -impl<'a> PublicInputCommon for PublicInputs<'a, Target> { +impl PublicInputCommon for PublicInputs<'_, Target> { const RANGES: &'static [PublicInputRange] = &[ H_NEW_RANGE, H_OLD_RANGE, @@ -81,7 +81,7 @@ impl<'a> PublicInputCommon for PublicInputs<'a, Target> { } } -impl<'a> PublicInputs<'a, F> { +impl PublicInputs<'_, F> { /// Get the new Merkle tree root hash value. pub fn new_merkle_hash_field(&self) -> HashOut { self.h_new.try_into().unwrap() @@ -109,7 +109,7 @@ impl<'a> PublicInputs<'a, F> { } } -impl<'a> PublicInputs<'a, Target> { +impl PublicInputs<'_, Target> { /// Get the new Merkle root hash target. pub fn new_merkle_hash_target(&self) -> HashOutTarget { self.h_new.try_into().unwrap() @@ -234,7 +234,7 @@ mod tests { exp_pi: &'a [F], } - impl<'a> UserCircuit for TestPICircuit<'a> { + impl UserCircuit for TestPICircuit<'_> { type Wires = Vec; fn build(b: &mut CBuilder) -> Self::Wires { diff --git a/verifiable-db/src/cells_tree/api.rs b/verifiable-db/src/cells_tree/api.rs index 63626601c..4dd8febae 100644 --- a/verifiable-db/src/cells_tree/api.rs +++ b/verifiable-db/src/cells_tree/api.rs @@ -36,23 +36,10 @@ pub enum CircuitInput { } impl CircuitInput { - /// Create a circuit input for proving a leaf node. - /// It is not considered a multiplier column. Please use `leaf_multiplier` for registering a - /// multiplier column. - pub fn leaf(identifier: u64, value: U256) -> Self { - CircuitInput::Leaf( - Cell { - identifier: F::from_canonical_u64(identifier), - value, - is_multiplier: false, - } - .into(), - ) - } /// Create a circuit input for proving a leaf node whose value is considered as a multiplier /// depending on the boolean value. /// i.e. it means it's one of the repeated value amongst all the rows - pub fn leaf_multiplier(identifier: u64, value: U256, is_multiplier: bool) -> Self { + pub fn leaf(identifier: u64, value: U256, is_multiplier: bool) -> Self { CircuitInput::Leaf( Cell { identifier: F::from_canonical_u64(identifier), @@ -64,19 +51,7 @@ impl CircuitInput { } /// Create a circuit input for proving a full node of 2 children. - /// It is not considered a multiplier column. Please use `full_multiplier` for registering a - /// multiplier column. - pub fn full(identifier: u64, value: U256, child_proofs: [Vec; 2]) -> Self { - CircuitInput::FullNode(new_child_input( - F::from_canonical_u64(identifier), - value, - false, - child_proofs.to_vec(), - )) - } - - /// Create a circuit input for proving a full node of 2 children. - pub fn full_multiplier( + pub fn full( identifier: u64, value: U256, is_multiplier: bool, @@ -90,17 +65,7 @@ impl CircuitInput { )) } /// Create a circuit input for proving a partial node of 1 child. - /// It is not considered a multiplier column. Please use `partial_multiplier` for registering a - /// multiplier column. - pub fn partial(identifier: u64, value: U256, child_proof: Vec) -> Self { - CircuitInput::PartialNode(new_child_input( - F::from_canonical_u64(identifier), - value, - false, - vec![child_proof], - )) - } - pub fn partial_multiplier( + pub fn partial( identifier: u64, value: U256, is_multiplier: bool, @@ -288,7 +253,7 @@ mod tests { let id = cell.identifier; let value = cell.value; let values_digests = cell.split_values_digest(); - let input = CircuitInput::leaf(id.to_canonical_u64(), value); + let input = CircuitInput::leaf(id.to_canonical_u64(), value, false); // Generate proof. let proof = params.generate_proof(input).unwrap(); @@ -383,7 +348,7 @@ mod tests { let id = cell.identifier; let value = cell.value; let values_digests = cell.split_values_digest(); - let input = CircuitInput::full(id.to_canonical_u64(), value, child_proofs); + let input = CircuitInput::full(id.to_canonical_u64(), value, false, child_proofs); // Generate proof. let proof = params.generate_proof(input).unwrap(); @@ -456,7 +421,7 @@ mod tests { let id = cell.identifier; let value = cell.value; let values_digests = cell.split_values_digest(); - let input = CircuitInput::partial(id.to_canonical_u64(), value, child_proof); + let input = CircuitInput::partial(id.to_canonical_u64(), value, false, child_proof); // Generate proof. let proof = params.generate_proof(input).unwrap(); diff --git a/verifiable-db/src/cells_tree/full_node.rs b/verifiable-db/src/cells_tree/full_node.rs index ccfac89ef..7751fde01 100644 --- a/verifiable-db/src/cells_tree/full_node.rs +++ b/verifiable-db/src/cells_tree/full_node.rs @@ -108,7 +108,7 @@ mod tests { child_pis: &'a [Vec; 2], } - impl<'a> UserCircuit for TestFullNodeCircuit<'a> { + impl UserCircuit for TestFullNodeCircuit<'_> { // Full node wires + child public inputs type Wires = (FullNodeWires, [Vec; 2]); diff --git a/verifiable-db/src/cells_tree/partial_node.rs b/verifiable-db/src/cells_tree/partial_node.rs index ca1c236a1..b865eab86 100644 --- a/verifiable-db/src/cells_tree/partial_node.rs +++ b/verifiable-db/src/cells_tree/partial_node.rs @@ -107,7 +107,7 @@ mod tests { child_pi: &'a [F], } - impl<'a> UserCircuit for TestPartialNodeCircuit<'a> { + impl UserCircuit for TestPartialNodeCircuit<'_> { // Partial node wires + child public inputs type Wires = (PartialNodeWires, Vec); diff --git a/verifiable-db/src/extraction.rs b/verifiable-db/src/extraction.rs index 271de9bee..5fec9d872 100644 --- a/verifiable-db/src/extraction.rs +++ b/verifiable-db/src/extraction.rs @@ -42,7 +42,7 @@ pub mod test { use u256::UInt256Target; use super::*; - impl<'a> ExtractionPIWrap for PublicInputs<'a, Target> { + impl ExtractionPIWrap for PublicInputs<'_, Target> { type PI<'b> = PublicInputs<'b, Target>; } @@ -112,7 +112,7 @@ pub mod test { pub(crate) merge: &'a [T], } - impl<'a> PublicInputCommon for PublicInputs<'a, Target> { + impl PublicInputCommon for PublicInputs<'_, Target> { const RANGES: &'static [PublicInputRange] = &[H_RANGE, PH_RANGE, DV_RANGE, DM_RANGE, BN_RANGE, MERGE_RANGE]; @@ -121,7 +121,7 @@ pub mod test { } } - impl<'a> PublicInputs<'a, GFp> { + impl PublicInputs<'_, GFp> { /// Get the metadata point. pub fn metadata_point(&self) -> WeierstrassPoint { WeierstrassPoint::from_fields(self.dm) @@ -157,7 +157,7 @@ pub mod test { } } - impl<'a> PublicInputs<'a, Target> { + impl PublicInputs<'_, Target> { pub fn generic_register_args(&self, cb: &mut CBuilder) { cb.register_public_inputs(self.h); cb.register_public_inputs(self.ph); diff --git a/verifiable-db/src/ivc/public_inputs.rs b/verifiable-db/src/ivc/public_inputs.rs index 89486c514..649034704 100644 --- a/verifiable-db/src/ivc/public_inputs.rs +++ b/verifiable-db/src/ivc/public_inputs.rs @@ -16,7 +16,7 @@ use std::array::from_fn as create_array; /// - H: new (Merkle) root /// - `DM` : metadata hash representing the extraction of the data from storage slots and insertion in the expected columns of the table being built. -/// It's represented as a hash since more efficient to pass along in public inputs. +/// It's represented as a hash since more efficient to pass along in public inputs. /// - `DV` : order-agnostic digest of the block tree, useful in case we want to build another index tree with a different index column /// - **IVC Information - specific to blockchain:** /// - `$z_0$`: first block number inserted (as u256, represented by 8 32-bit limbs) @@ -39,7 +39,7 @@ pub(crate) const Z0_RANGE: PublicInputRange = DV_RANGE.end..DV_RANGE.end + INDEX pub(crate) const ZI_RANGE: PublicInputRange = Z0_RANGE.end..Z0_RANGE.end + INDEX_LEN; pub(crate) const O_RANGE: PublicInputRange = ZI_RANGE.end..ZI_RANGE.end + PACKED_HASH_LEN; -impl<'a> PublicInputCommon for PublicInputs<'a, Target> { +impl PublicInputCommon for PublicInputs<'_, Target> { const RANGES: &'static [PublicInputRange] = &[H_RANGE, DM_RANGE, DV_RANGE, Z0_RANGE, ZI_RANGE, O_RANGE]; @@ -100,7 +100,7 @@ impl<'a, T: Clone> PublicInputs<'a, T> { } } -impl<'a> PublicInputs<'a, Target> { +impl PublicInputs<'_, Target> { pub fn merkle_hash(&self) -> HashOutTarget { HashOutTarget { elements: self.h.try_into().unwrap(), @@ -123,7 +123,7 @@ impl<'a> PublicInputs<'a, Target> { } } -impl<'a> PublicInputs<'a, F> { +impl PublicInputs<'_, F> { pub fn merkle_root_hash_fields(&self) -> HashOut { HashOut { elements: self.h.try_into().unwrap(), @@ -179,7 +179,7 @@ mod tests { exp_pi: &'a [F], } - impl<'a> UserCircuit for TestPICircuit<'a> { + impl UserCircuit for TestPICircuit<'_> { type Wires = Vec; fn build(b: &mut CircuitBuilder) -> Self::Wires { diff --git a/verifiable-db/src/query/aggregation/child_proven_single_path_node.rs b/verifiable-db/src/query/aggregation/child_proven_single_path_node.rs index 0e85f7a40..7196c4d2d 100644 --- a/verifiable-db/src/query/aggregation/child_proven_single_path_node.rs +++ b/verifiable-db/src/query/aggregation/child_proven_single_path_node.rs @@ -212,7 +212,7 @@ mod tests { child_proof: &'a [F], } - impl<'a> UserCircuit for TestChildProvenSinglePathNodeCircuit<'a> { + impl UserCircuit for TestChildProvenSinglePathNodeCircuit<'_> { type Wires = (ChildProvenSinglePathNodeWires, Vec); fn build(b: &mut CBuilder) -> Self::Wires { @@ -228,7 +228,7 @@ mod tests { fn prove(&self, pw: &mut PartialWitness, wires: &Self::Wires) { self.c.assign(pw, &wires.0); - pw.set_target_arr(&wires.1, &self.child_proof); + pw.set_target_arr(&wires.1, self.child_proof); } } diff --git a/verifiable-db/src/query/aggregation/embedded_tree_proven_single_path_node.rs b/verifiable-db/src/query/aggregation/embedded_tree_proven_single_path_node.rs index c75068baa..cca8e09e0 100644 --- a/verifiable-db/src/query/aggregation/embedded_tree_proven_single_path_node.rs +++ b/verifiable-db/src/query/aggregation/embedded_tree_proven_single_path_node.rs @@ -339,7 +339,7 @@ mod tests { embedded_tree_proof: &'a [F], } - impl<'a> UserCircuit for TestEmbeddedTreeProvenSinglePathNodeCircuit<'a> { + impl UserCircuit for TestEmbeddedTreeProvenSinglePathNodeCircuit<'_> { type Wires = ( EmbeddedTreeProvenSinglePathNodeWires, Vec, @@ -358,7 +358,7 @@ mod tests { fn prove(&self, pw: &mut PartialWitness, wires: &Self::Wires) { self.c.assign(pw, &wires.0); - pw.set_target_arr(&wires.1, &self.embedded_tree_proof); + pw.set_target_arr(&wires.1, self.embedded_tree_proof); } } diff --git a/verifiable-db/src/query/aggregation/full_node_index_leaf.rs b/verifiable-db/src/query/aggregation/full_node_index_leaf.rs index 7fca44739..633d93b57 100644 --- a/verifiable-db/src/query/aggregation/full_node_index_leaf.rs +++ b/verifiable-db/src/query/aggregation/full_node_index_leaf.rs @@ -149,7 +149,7 @@ mod tests { subtree_proof: &'a [F], } - impl<'a> UserCircuit for TestFullNodeIndexLeafCircuit<'a> { + impl UserCircuit for TestFullNodeIndexLeafCircuit<'_> { // Circuit wires + subtree proof type Wires = (FullNodeIndexLeafWires, Vec); diff --git a/verifiable-db/src/query/aggregation/full_node_with_one_child.rs b/verifiable-db/src/query/aggregation/full_node_with_one_child.rs index d204ff842..7bc2bc549 100644 --- a/verifiable-db/src/query/aggregation/full_node_with_one_child.rs +++ b/verifiable-db/src/query/aggregation/full_node_with_one_child.rs @@ -232,7 +232,7 @@ mod tests { child_proof: &'a [F], } - impl<'a> UserCircuit for TestFullNodeWithOneChildCircuit<'a> { + impl UserCircuit for TestFullNodeWithOneChildCircuit<'_> { // Circuit wires + subtree proof + child proof type Wires = ( FullNodeWithOneChildWires, diff --git a/verifiable-db/src/query/aggregation/full_node_with_two_children.rs b/verifiable-db/src/query/aggregation/full_node_with_two_children.rs index 21597c6ce..7a51ef3b0 100644 --- a/verifiable-db/src/query/aggregation/full_node_with_two_children.rs +++ b/verifiable-db/src/query/aggregation/full_node_with_two_children.rs @@ -222,7 +222,7 @@ mod tests { right_child_proof: &'a [F], } - impl<'a> UserCircuit for TestFullNodeWithTwoChildrenCircuit<'a> { + impl UserCircuit for TestFullNodeWithTwoChildrenCircuit<'_> { // Circuit wires + subtree proof + left child proof + right child proof type Wires = ( FullNodeWithTwoChildrenWires, diff --git a/verifiable-db/src/query/aggregation/mod.rs b/verifiable-db/src/query/aggregation/mod.rs index 6e2494a13..6a36be605 100644 --- a/verifiable-db/src/query/aggregation/mod.rs +++ b/verifiable-db/src/query/aggregation/mod.rs @@ -366,14 +366,14 @@ impl QueryHashNonExistenceCircuits { { let computational_hash = if is_rows_tree_node { Identifiers::computational_hash_without_query_bounds( - &column_ids, + column_ids, predicate_operations, results, )? } else { ComputationalHash::from_bytes( (&Identifiers::computational_hash_universal_circuit( - &column_ids, + column_ids, predicate_operations, results, Some((&query_bounds.min_query_secondary).into()), @@ -391,9 +391,9 @@ impl QueryHashNonExistenceCircuits { predicate_operations, results, placeholders, query_bounds )?; let placeholder_hash = if is_rows_tree_node { - placeholder_hash_without_query_bounds(&placeholder_hash_ids, &placeholders) + placeholder_hash_without_query_bounds(&placeholder_hash_ids, placeholders) } else { - placeholder_hash(&placeholder_hash_ids, &placeholders, query_bounds) + placeholder_hash(&placeholder_hash_ids, placeholders, query_bounds) }?; Ok(Self { computational_hash, diff --git a/verifiable-db/src/query/aggregation/non_existence_inter.rs b/verifiable-db/src/query/aggregation/non_existence_inter.rs index 9bccdfc1b..c9287d8fc 100644 --- a/verifiable-db/src/query/aggregation/non_existence_inter.rs +++ b/verifiable-db/src/query/aggregation/non_existence_inter.rs @@ -173,18 +173,18 @@ impl NonExistenceInterNodeCircuit // Enforce that the value associated to the current node is out of the range // specified by the query: // value < MIN_query OR value > MAX_query - let is_value_less_than_min = b.is_less_than_u256(&value, &min_query_value); - let is_value_greater_than_max = b.is_less_than_u256(&max_query_value, &value); + let is_value_less_than_min = b.is_less_than_u256(&value, min_query_value); + let is_value_greater_than_max = b.is_less_than_u256(max_query_value, &value); let is_out_of_range = b.or(is_value_less_than_min, is_value_greater_than_max); b.connect(is_out_of_range.target, ttrue.target); // Enforce that the records found in the subtree rooted in the child node // are all out of the range specified by the query. If left child exists, // ensure left_child_max < MIN_query; if right child exists, ensure right_child_min > MAX_query. - let is_child_less_than_min = b.is_less_than_u256(&left_child_max, &min_query_value); + let is_child_less_than_min = b.is_less_than_u256(&left_child_max, min_query_value); let is_left_child_out_of_range = b.and(left_child_exists, is_child_less_than_min); b.connect(is_left_child_out_of_range.target, left_child_exists.target); - let is_child_greater_than_max = b.is_less_than_u256(&max_query_value, &right_child_min); + let is_child_greater_than_max = b.is_less_than_u256(max_query_value, &right_child_min); let is_right_child_out_of_range = b.and(right_child_exists, is_child_greater_than_max); b.connect( is_right_child_out_of_range.target, @@ -478,7 +478,7 @@ mod tests { let first_placeholder_id = PlaceholderId::Generic(0); - let (min_query, max_query, placeholders) = if is_rows_tree_node { + let (min_query, max_query, _placeholders) = if is_rows_tree_node { let dummy_min_query_primary = U256::ZERO; //dummy value, circuit will employ only bounds for secondary index let dummy_max_query_primary = U256::MAX; //dummy value, circuit will employ only bounds for secondary index let placeholders = Placeholders::from(( @@ -488,7 +488,7 @@ mod tests { )); let query_bounds = QueryBounds::new( - &&placeholders, + &placeholders, Some(QueryBoundSource::Constant(min_query_value)), Some(QueryBoundSource::Placeholder(first_placeholder_id)), ) @@ -733,7 +733,7 @@ mod tests { #[test] fn test_query_agg_non_existence_for_index_tree_leaf_node() { // Generate the random operations. - let mut ops: [_; MAX_NUM_RESULTS] = random_aggregation_operations(); + let ops: [_; MAX_NUM_RESULTS] = random_aggregation_operations(); test_non_existence_inter_circuit(false, false, false, ops); } @@ -741,7 +741,7 @@ mod tests { #[test] fn test_query_agg_non_existence_for_row_tree_full_node() { // Generate the random operations. - let mut ops: [_; MAX_NUM_RESULTS] = random_aggregation_operations(); + let ops: [_; MAX_NUM_RESULTS] = random_aggregation_operations(); test_non_existence_inter_circuit(true, true, true, ops); } diff --git a/verifiable-db/src/query/aggregation/partial_node.rs b/verifiable-db/src/query/aggregation/partial_node.rs index cce28ddc6..3cfd312cd 100644 --- a/verifiable-db/src/query/aggregation/partial_node.rs +++ b/verifiable-db/src/query/aggregation/partial_node.rs @@ -312,7 +312,7 @@ mod tests { child_proof: &'a [F], } - impl<'a> UserCircuit for TestPartialNodeCircuit<'a> { + impl UserCircuit for TestPartialNodeCircuit<'_> { // Circuit wires + query proof + child proof type Wires = (PartialNodeWires, Vec, Vec); diff --git a/verifiable-db/src/query/api.rs b/verifiable-db/src/query/api.rs index b318eb27b..96c77a8bf 100644 --- a/verifiable-db/src/query/api.rs +++ b/verifiable-db/src/query/api.rs @@ -265,12 +265,12 @@ where .take(MAX_NUM_RESULTS) .collect_vec(); let min_query = if is_rows_tree_node { - QueryBound::new_secondary_index_bound(placeholders, &query_bounds.min_query_secondary()) + QueryBound::new_secondary_index_bound(placeholders, query_bounds.min_query_secondary()) } else { QueryBound::new_primary_index_bound(placeholders, true) }?; let max_query = if is_rows_tree_node { - QueryBound::new_secondary_index_bound(placeholders, &query_bounds.max_query_secondary()) + QueryBound::new_secondary_index_bound(placeholders, query_bounds.max_query_secondary()) } else { QueryBound::new_primary_index_bound(placeholders, false) }?; @@ -880,7 +880,7 @@ mod tests { second_operand: Some(InputOperand::Column(2)), op: Operation::AddOp, }]; - let aggregation_op_ids = vec![AggregationOperation::SumOp.to_id() as u64]; + let aggregation_op_ids = vec![AggregationOperation::SumOp.to_id()]; let output_items = vec![OutputItem::ComputedValue(0)]; let results = ResultStructure::new_for_query_with_aggregation( result_operations, @@ -1078,7 +1078,7 @@ mod tests { .into(); // check some public inputs for root proof let check_pis = |root_proof_pis: &[F], node_info: NodeInfo, column_values: &[Vec]| { - let pis = PublicInputs::::from_slice(&root_proof_pis); + let pis = PublicInputs::::from_slice(root_proof_pis); assert_eq!( pis.tree_hash(), node_info.compute_node_hash(primary_index_id), @@ -1357,14 +1357,11 @@ mod tests { // bigger than `max_query_primary` let column_values = [min_query_primary / 2] .into_iter() - .chain( - [ - max_query_primary * 2, - max_query_primary * 3, - max_query_primary * 4, - ] - .into_iter(), - ) + .chain([ + max_query_primary * 2, + max_query_primary * 3, + max_query_primary * 4, + ]) .map(|index| gen_row(index, IndexValueBounds::InRange)) .collect_vec(); diff --git a/verifiable-db/src/query/computational_hash_ids.rs b/verifiable-db/src/query/computational_hash_ids.rs index 19abf702b..b1d78c4a2 100644 --- a/verifiable-db/src/query/computational_hash_ids.rs +++ b/verifiable-db/src/query/computational_hash_ids.rs @@ -183,14 +183,13 @@ impl Identifiers { .into_iter() .flat_map(|query_bound| { query_bound - .map(|bound| match bound { + .and_then(|bound| match bound { QueryBoundSource::Placeholder(id) => Some(vec![id]), QueryBoundSource::Operation(op) => { Some(op.extract_placeholder_ids()) } QueryBoundSource::Constant(_) => None, }) - .flatten() // If None, return a placeholder that is for sure already in the set .unwrap_or(vec![PlaceholderIdentifier::MinQueryOnIdx1]) }), @@ -235,7 +234,7 @@ impl ToField for Identifiers { } } /// Data structure to provide identifiers of columns of a table to compute computational hash -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct ColumnIDs { pub(crate) primary: F, pub(crate) secondary: F, diff --git a/verifiable-db/src/query/merkle_path.rs b/verifiable-db/src/query/merkle_path.rs index dc4caebc0..050bbadc8 100644 --- a/verifiable-db/src/query/merkle_path.rs +++ b/verifiable-db/src/query/merkle_path.rs @@ -13,7 +13,7 @@ use mp2_common::{ }, types::HashOutput, u256::{CircuitBuilderU256, UInt256Target, WitnessWriteU256}, - utils::{Fieldable, SelectHashBuilder, ToTargets}, + utils::{SelectHashBuilder, ToTargets}, D, F, }; use plonky2::{ diff --git a/verifiable-db/src/query/public_inputs.rs b/verifiable-db/src/query/public_inputs.rs index d0bff59ff..f43204b18 100644 --- a/verifiable-db/src/query/public_inputs.rs +++ b/verifiable-db/src/query/public_inputs.rs @@ -276,7 +276,7 @@ impl<'a, T: Clone, const S: usize> PublicInputs<'a, T, S> { } } -impl<'a, const S: usize> PublicInputCommon for PublicInputs<'a, Target, S> { +impl PublicInputCommon for PublicInputs<'_, Target, S> { const RANGES: &'static [PublicInputRange] = &Self::PI_RANGES; fn register_args(&self, cb: &mut CBuilder) { @@ -296,7 +296,7 @@ impl<'a, const S: usize> PublicInputCommon for PublicInputs<'a, Target, S> { } } -impl<'a, const S: usize> PublicInputs<'a, Target, S> { +impl PublicInputs<'_, Target, S> { pub fn tree_hash_target(&self) -> HashOutTarget { HashOutTarget::try_from(self.to_hash_raw()).unwrap() // safe to unwrap as we know the slice has correct length } @@ -380,7 +380,7 @@ impl<'a, const S: usize> PublicInputs<'a, Target, S> { } } -impl<'a, const S: usize> PublicInputs<'a, F, S> { +impl PublicInputs<'_, F, S> { pub fn tree_hash(&self) -> HashOut { HashOut::try_from(self.to_hash_raw()).unwrap() // safe to unwrap as we know the slice has correct length } @@ -488,7 +488,7 @@ mod tests { pis: &'a [F], } - impl<'a> UserCircuit for TestPublicInputs<'a> { + impl UserCircuit for TestPublicInputs<'_> { type Wires = Vec; fn build(c: &mut CircuitBuilder) -> Self::Wires { diff --git a/verifiable-db/src/query/universal_circuit/universal_circuit_inputs.rs b/verifiable-db/src/query/universal_circuit/universal_circuit_inputs.rs index b3665eead..ee314ae59 100644 --- a/verifiable-db/src/query/universal_circuit/universal_circuit_inputs.rs +++ b/verifiable-db/src/query/universal_circuit/universal_circuit_inputs.rs @@ -205,7 +205,7 @@ impl BasicOperation { }); [first_id, second_id.flatten()] .into_iter() - .filter_map(|id| id) + .flatten() .collect_vec() } diff --git a/verifiable-db/src/query/universal_circuit/universal_query_circuit.rs b/verifiable-db/src/query/universal_circuit/universal_query_circuit.rs index df7a1c452..7cd8ed9c0 100644 --- a/verifiable-db/src/query/universal_circuit/universal_query_circuit.rs +++ b/verifiable-db/src/query/universal_circuit/universal_query_circuit.rs @@ -137,7 +137,7 @@ impl QueryBoundTarget { impl QueryBoundTargetInputs { pub(crate) fn assign(&self, pw: &mut PartialWitness, bound: &QueryBound) { - bound.operation.assign(pw, &self); + bound.operation.assign(pw, self); } } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -359,8 +359,8 @@ impl QueryBound { max_query: &QueryBoundSource, computational_hash: &ComputationalHash, ) -> Result { - let min_query_op = Self::get_basic_operation(&min_query)?; - let max_query_op = Self::get_basic_operation(&max_query)?; + let min_query_op = Self::get_basic_operation(min_query)?; + let max_query_op = Self::get_basic_operation(max_query)?; // initialize computational hash cache with the empty hash associated to the only input value (hardcoded to 0 // in the circuit) of the basic operation components employed for query bounds let mut cache = ComputationalHashCache::new_from_column_hash( @@ -587,13 +587,13 @@ where T::new(&selectors, &results.output_ids, results.output_ids.len())?; let min_query = QueryBound::new_secondary_index_bound( - &placeholders, - &query_bounds.min_query_secondary(), + placeholders, + query_bounds.min_query_secondary(), )?; let max_query = QueryBound::new_secondary_index_bound( - &placeholders, - &query_bounds.max_query_secondary(), + placeholders, + query_bounds.max_query_secondary(), )?; Ok(Self { @@ -1008,9 +1008,9 @@ pub(crate) fn placeholder_hash( // a constant or a placeholder. This information is available in `query_bounds`, so we just // process it let min_query = - QueryBound::new_secondary_index_bound(placeholders, &query_bounds.min_query_secondary())?; + QueryBound::new_secondary_index_bound(placeholders, query_bounds.min_query_secondary())?; let max_query = - QueryBound::new_secondary_index_bound(placeholders, &query_bounds.max_query_secondary())?; + QueryBound::new_secondary_index_bound(placeholders, query_bounds.max_query_secondary())?; Ok(QueryBound::add_secondary_query_bounds_to_placeholder_hash( &min_query, &max_query, @@ -1561,7 +1561,7 @@ mod tests { params .generate_proof(input) .and_then(|p| ProofWithVK::deserialize(&p)) - .and_then(|p| Ok(p.proof().clone())) + .map(|p| p.proof().clone()) .unwrap() } else { run_circuit::(circuit.clone()) @@ -1943,7 +1943,7 @@ mod tests { params .generate_proof(input) .and_then(|p| ProofWithVK::deserialize(&p)) - .and_then(|p| Ok(p.proof().clone())) + .map(|p| p.proof().clone()) .unwrap() } else { run_circuit::(circuit.clone()) diff --git a/verifiable-db/src/results_tree/binding/binding_results.rs b/verifiable-db/src/results_tree/binding/binding_results.rs index 49cdc0d19..00454fc16 100644 --- a/verifiable-db/src/results_tree/binding/binding_results.rs +++ b/verifiable-db/src/results_tree/binding/binding_results.rs @@ -17,7 +17,7 @@ use mp2_common::{ }; use plonky2::iop::target::Target; use serde::{Deserialize, Serialize}; -use std::{iter::once, slice}; +use std::slice; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct BindingResultsWires; @@ -123,7 +123,7 @@ mod tests { results_construction_proof: &'a [F], } - impl<'a> UserCircuit for TestBindingResultsCircuit<'a> { + impl UserCircuit for TestBindingResultsCircuit<'_> { // Query proof + results construction proof type Wires = (Vec, Vec); @@ -199,7 +199,7 @@ mod tests { }; // H(res_id || pQ.C) - let inputs = once(&res_id.to_field()) + let inputs = std::iter::once(&res_id.to_field()) .chain(query_pi.to_computational_hash_raw()) .cloned() .collect_vec(); diff --git a/verifiable-db/src/results_tree/binding/public_inputs.rs b/verifiable-db/src/results_tree/binding/public_inputs.rs index fa55cc0ad..eee9756c5 100644 --- a/verifiable-db/src/results_tree/binding/public_inputs.rs +++ b/verifiable-db/src/results_tree/binding/public_inputs.rs @@ -156,7 +156,7 @@ impl<'a, T: Clone> PublicInputs<'a, T> { } } -impl<'a> PublicInputCommon for PublicInputs<'a, Target> { +impl PublicInputCommon for PublicInputs<'_, Target> { const RANGES: &'static [PublicInputRange] = &Self::PI_RANGES; fn register_args(&self, cb: &mut CBuilder) { @@ -169,7 +169,7 @@ impl<'a> PublicInputCommon for PublicInputs<'a, Target> { } } -impl<'a> PublicInputs<'a, Target> { +impl PublicInputs<'_, Target> { pub fn results_tree_hash_target(&self) -> HashOutTarget { HashOutTarget::try_from(self.to_results_tree_hash_raw()).unwrap() } @@ -195,7 +195,7 @@ impl<'a> PublicInputs<'a, Target> { } } -impl<'a> PublicInputs<'a, F> { +impl PublicInputs<'_, F> { pub fn results_tree_hash(&self) -> HashOut { HashOut::try_from(self.to_results_tree_hash_raw()).unwrap() } @@ -245,7 +245,7 @@ mod tests { pis: &'a [F], } - impl<'a> UserCircuit for TestPublicInputs<'a> { + impl UserCircuit for TestPublicInputs<'_> { type Wires = Vec; fn build(c: &mut CircuitBuilder) -> Self::Wires { diff --git a/verifiable-db/src/results_tree/construction/leaf_node.rs b/verifiable-db/src/results_tree/construction/leaf_node.rs index 33a0e6220..947d9fa34 100644 --- a/verifiable-db/src/results_tree/construction/leaf_node.rs +++ b/verifiable-db/src/results_tree/construction/leaf_node.rs @@ -107,7 +107,7 @@ mod tests { subtree_proof: &'a [F], } - impl<'a> UserCircuit for TestLeafNodeCircuit<'a> { + impl UserCircuit for TestLeafNodeCircuit<'_> { // Circuit wires + subtree proof type Wires = (LeafNodeWires, Vec); diff --git a/verifiable-db/src/results_tree/construction/node_with_one_child.rs b/verifiable-db/src/results_tree/construction/node_with_one_child.rs index 294658a68..69005d64c 100644 --- a/verifiable-db/src/results_tree/construction/node_with_one_child.rs +++ b/verifiable-db/src/results_tree/construction/node_with_one_child.rs @@ -314,7 +314,7 @@ mod tests { child_proof: &'a [F], } - impl<'a> UserCircuit for TestNodeWithOneChildCircuit<'a> { + impl UserCircuit for TestNodeWithOneChildCircuit<'_> { // Circuit wires + subtree proof + child proof type Wires = (NodeWithOneChildWires, Vec, Vec); diff --git a/verifiable-db/src/results_tree/construction/node_with_two_children.rs b/verifiable-db/src/results_tree/construction/node_with_two_children.rs index 15f237a3c..1c49fff40 100644 --- a/verifiable-db/src/results_tree/construction/node_with_two_children.rs +++ b/verifiable-db/src/results_tree/construction/node_with_two_children.rs @@ -269,7 +269,7 @@ mod tests { right_child_proof: &'a [F], } - impl<'a> UserCircuit for TestNodeWithTwoChildrenCircuit<'a> { + impl UserCircuit for TestNodeWithTwoChildrenCircuit<'_> { // Circuit wires + subtree proof + left child proof + right child proof type Wires = ( NodeWithTwoChildrenWires, diff --git a/verifiable-db/src/results_tree/construction/public_inputs.rs b/verifiable-db/src/results_tree/construction/public_inputs.rs index 920946f2f..7ae969d26 100644 --- a/verifiable-db/src/results_tree/construction/public_inputs.rs +++ b/verifiable-db/src/results_tree/construction/public_inputs.rs @@ -241,7 +241,7 @@ impl<'a, T: Clone, const S: usize> PublicInputs<'a, T, S> { } } -impl<'a, const S: usize> PublicInputCommon for PublicInputs<'a, Target, S> { +impl PublicInputCommon for PublicInputs<'_, Target, S> { const RANGES: &'static [PublicInputRange] = &Self::PI_RANGES; fn register_args(&self, cb: &mut CBuilder) { @@ -259,7 +259,7 @@ impl<'a, const S: usize> PublicInputCommon for PublicInputs<'a, Target, S> { } } -impl<'a, const S: usize> PublicInputs<'a, Target, S> { +impl PublicInputs<'_, Target, S> { pub fn tree_hash_target(&self) -> HashOutTarget { HashOutTarget::try_from(self.to_tree_hash_raw()).unwrap() } @@ -315,7 +315,7 @@ impl<'a, const S: usize> PublicInputs<'a, Target, S> { } } -impl<'a, const S: usize> PublicInputs<'a, F, S> { +impl PublicInputs<'_, F, S> { pub fn tree_hash(&self) -> HashOut { HashOut::try_from(self.to_tree_hash_raw()).unwrap() } @@ -396,7 +396,7 @@ mod tests { pis: &'a [F], } - impl<'a> UserCircuit for TestPublicInputs<'a> { + impl UserCircuit for TestPublicInputs<'_> { type Wires = Vec; fn build(c: &mut CircuitBuilder) -> Self::Wires { diff --git a/verifiable-db/src/results_tree/construction/results_tree_with_duplicates.rs b/verifiable-db/src/results_tree/construction/results_tree_with_duplicates.rs index 366aed39c..190e1c0a0 100644 --- a/verifiable-db/src/results_tree/construction/results_tree_with_duplicates.rs +++ b/verifiable-db/src/results_tree/construction/results_tree_with_duplicates.rs @@ -299,7 +299,7 @@ mod tests { assert_eq!(pi.index_ids(), ids[..2]); // No duplicates - assert_eq!(pi.no_duplicates_flag(), false); + assert!(!pi.no_duplicates_flag()); // Accumulator let accumulator_inputs: Vec<_> = iter::once(ids[0]) diff --git a/verifiable-db/src/results_tree/construction/results_tree_without_duplicates.rs b/verifiable-db/src/results_tree/construction/results_tree_without_duplicates.rs index f04304a34..7fc2860fa 100644 --- a/verifiable-db/src/results_tree/construction/results_tree_without_duplicates.rs +++ b/verifiable-db/src/results_tree/construction/results_tree_without_duplicates.rs @@ -334,7 +334,7 @@ mod tests { assert_eq!(pi.index_ids(), ids[..2]); // No duplicates - assert_eq!(pi.no_duplicates_flag(), true); + assert!(pi.no_duplicates_flag()); // Accumulator let accumulator_inputs: Vec<_> = iter::once(ids[0]) diff --git a/verifiable-db/src/revelation/api.rs b/verifiable-db/src/revelation/api.rs index 664bfb8d4..21837dd7f 100644 --- a/verifiable-db/src/revelation/api.rs +++ b/verifiable-db/src/revelation/api.rs @@ -5,7 +5,6 @@ use anyhow::{ensure, Result}; use itertools::Itertools; use mp2_common::{ - array::ToField, default_config, poseidon::H, proof::{deserialize_proof, ProofWithVK}, @@ -29,28 +28,24 @@ use crate::{ self, aggregation::QueryBounds, api::{CircuitInput as QueryCircuitInput, Parameters as QueryParams}, - computational_hash_ids::{ColumnIDs, PlaceholderIdentifier}, - universal_circuit::{ - universal_circuit_inputs::{ - BasicOperation, PlaceholderId, Placeholders, ResultStructure, - }, - universal_query_circuit::QueryBound, + computational_hash_ids::ColumnIDs, + universal_circuit::universal_circuit_inputs::{ + BasicOperation, Placeholders, ResultStructure, }, PI_LEN as QUERY_PI_LEN, }, revelation::{ - placeholders_check::{CheckPlaceholderGadget, CheckedPlaceholder}, + placeholders_check::CheckPlaceholderGadget, revelation_unproven_offset::{ generate_dummy_row_proof_inputs, RecursiveCircuitWires as RecursiveCircuitWiresUnprovenOffset, }, }, - test_utils::MAX_NUM_OUTPUTS, }; use super::{ revelation_unproven_offset::{ - self, RecursiveCircuitInputs as RecursiveCircuitInputsUnporvenOffset, + RecursiveCircuitInputs as RecursiveCircuitInputsUnporvenOffset, RevelationCircuit as RevelationCircuitUnprovenOffset, RowPath, }, revelation_without_results_tree::{ @@ -283,9 +278,9 @@ where /// IVC set of circuit /// - `query_bounds`: bounds on values of primary and secondary indexes specified in the query /// - `placeholders`: set of placeholders employed in the query. They must be less than `MAX_NUM_PLACEHOLDERS` - /// - `placeholder_hash_ids`: Identifiers of the placeholders employed to compute the placeholder hash; they can be - /// obtained by the method `ids_for_placeholder_hash` of `query::api::Parameters` - pub fn new_revelation_no_results_tree( + /// - `predicate_operations`: Operations employed in the query to compute the filtering predicate in the `WHERE` clause + /// - `results_structure`: Data about the operations and items returned in the `SELECT` clause of the query + pub fn new_revelation_aggregated( query_proof: Vec, preprocessing_proof: Vec, query_bounds: &QueryBounds, @@ -336,7 +331,7 @@ where /// - `results_structure`: Data about the operations and items returned in the `SELECT` clause of the query /// - `limit, offset`: limit and offset values specified in the query /// - `distinct`: Flag specifying whether the DISTINCT keyword was specified in the query - pub fn new_revelation_unproven_offset( + pub fn new_revelation_tabular( preprocessing_proof: Vec, matching_rows: Vec, query_bounds: &QueryBounds, @@ -344,8 +339,8 @@ where column_ids: &ColumnIDs, predicate_operations: &[BasicOperation], results_structure: &ResultStructure, - limit: u64, - offset: u64, + limit: u32, + offset: u32, ) -> Result where [(); MAX_NUM_COLUMNS + MAX_NUM_RESULT_OPS]:, @@ -660,7 +655,7 @@ mod tests { let preprocessing_pi = PreprocessingPI::from_slice(&preprocessing_proof.public_inputs); let preprocessing_proof = serialize_proof(&preprocessing_proof).unwrap(); - let input = CircuitInput::new_revelation_no_results_tree( + let input = CircuitInput::new_revelation_aggregated( query_proof, preprocessing_proof, test_data.query_bounds(), diff --git a/verifiable-db/src/revelation/mod.rs b/verifiable-db/src/revelation/mod.rs index 1f925d596..9dfe32ca5 100644 --- a/verifiable-db/src/revelation/mod.rs +++ b/verifiable-db/src/revelation/mod.rs @@ -196,7 +196,6 @@ pub(crate) mod tests { { // Convert the entry count to an Uint256. let entry_count = U256::from(query_pi.num_matching_rows().to_canonical_u64()); - let mut overflow = false; let [op_avg, op_count] = [AggregationOperation::AvgOp, AggregationOperation::CountOp].map(|op| op.to_field()); @@ -208,14 +207,7 @@ pub(crate) mod tests { let op = ops[i]; if op == op_avg { - match value.checked_div(entry_count) { - Some(dividend) => dividend, - None => { - // Set the overflow flag to true if the divisor is zero. - overflow = true; - U256::ZERO - } - } + value.checked_div(entry_count).unwrap_or(U256::ZERO) } else if op == op_count { entry_count } else { @@ -223,6 +215,6 @@ pub(crate) mod tests { } }); - (result, query_pi.overflow_flag() || overflow) + (result, query_pi.overflow_flag()) } } diff --git a/verifiable-db/src/revelation/public_inputs.rs b/verifiable-db/src/revelation/public_inputs.rs index 4c7ec3d29..c387d6de6 100644 --- a/verifiable-db/src/revelation/public_inputs.rs +++ b/verifiable-db/src/revelation/public_inputs.rs @@ -227,8 +227,8 @@ impl<'a, T: Clone, const L: usize, const S: usize, const PH: usize> PublicInputs } } -impl<'a, const L: usize, const S: usize, const PH: usize> PublicInputCommon - for PublicInputs<'a, Target, L, S, PH> +impl PublicInputCommon + for PublicInputs<'_, Target, L, S, PH> { const RANGES: &'static [PublicInputRange] = &Self::PI_RANGES; @@ -246,7 +246,7 @@ impl<'a, const L: usize, const S: usize, const PH: usize> PublicInputCommon } } -impl<'a, const L: usize, const S: usize, const PH: usize> PublicInputs<'a, Target, L, S, PH> { +impl PublicInputs<'_, Target, L, S, PH> { pub fn original_block_hash_target(&self) -> [Target; PACKED_HASH_LEN] { self.to_original_block_hash_raw().try_into().unwrap() } @@ -305,7 +305,7 @@ impl<'a, const L: usize, const S: usize, const PH: usize> PublicInputs<'a, Targe } } -impl<'a, const L: usize, const S: usize, const PH: usize> PublicInputs<'a, F, L, S, PH> { +impl PublicInputs<'_, F, L, S, PH> { pub fn original_block_hash(&self) -> [F; PACKED_HASH_LEN] { self.to_original_block_hash_raw().try_into().unwrap() } @@ -405,7 +405,7 @@ mod tests { pis: &'a [F], } - impl<'a> UserCircuit for TestPublicInputs<'a> { + impl UserCircuit for TestPublicInputs<'_> { type Wires = Vec; fn build(c: &mut CircuitBuilder) -> Self::Wires { diff --git a/verifiable-db/src/revelation/revelation_unproven_offset.rs b/verifiable-db/src/revelation/revelation_unproven_offset.rs index 52959063e..15241c814 100644 --- a/verifiable-db/src/revelation/revelation_unproven_offset.rs +++ b/verifiable-db/src/revelation/revelation_unproven_offset.rs @@ -29,7 +29,7 @@ use mp2_common::{ }; use plonky2::{ field::types::PrimeField64, - hash::hash_types::{HashOut, HashOutTarget}, + hash::hash_types::HashOutTarget, iop::{ target::{BoolTarget, Target}, witness::{PartialWitness, WitnessWrite}, @@ -52,8 +52,8 @@ use crate::{ ivc::PublicInputs as OriginalTreePublicInputs, query::{ aggregation::{ChildPosition, NodeInfo, QueryBounds, QueryHashNonExistenceCircuits}, - api::{CircuitInput as QueryCircuitInput, Parameters}, - computational_hash_ids::{AggregationOperation, ColumnIDs, Identifiers, ResultIdentifier}, + api::CircuitInput as QueryCircuitInput, + computational_hash_ids::{AggregationOperation, ColumnIDs, ResultIdentifier}, merkle_path::{MerklePathGadget, MerklePathTargetInputs}, public_inputs::PublicInputs as QueryProofPublicInputs, universal_circuit::{ @@ -217,8 +217,8 @@ pub struct RevelationCircuit< deserialize_with = "deserialize_long_array" )] results: [U256; S * L], - limit: u64, - offset: u64, + limit: u32, + offset: u32, /// Boolean flag specifying whether DISTINCT keyword must be applied to results distinct: bool, /// Input values employed by the `CheckPlaceholderGadget` @@ -292,8 +292,8 @@ where index_ids: [u64; 2], item_ids: &[F], results: [Vec; L], - limit: u64, - offset: u64, + limit: u32, + offset: u32, distinct: bool, placeholder_inputs: CheckPlaceholderGadget, ) -> Result { @@ -837,7 +837,7 @@ mod tests { group_hashing::map_to_curve_point, types::{HashOutput, CURVE_TARGET_LEN}, u256::is_less_than_or_equal_to_u256_arr, - utils::{Fieldable, ToFields}, + utils::ToFields, C, D, F, }; use mp2_test::{ @@ -953,7 +953,7 @@ mod tests { const PP: usize = 30; let ops = random_aggregation_operations::(); let mut row_pis = random_aggregation_public_inputs(&ops); - let mut rng = &mut thread_rng(); + let rng = &mut thread_rng(); let mut original_tree_pis = (0..NUM_PREPROCESSING_IO) .map(|_| rng.gen()) .collect::>() diff --git a/verifiable-db/src/revelation/revelation_without_results_tree.rs b/verifiable-db/src/revelation/revelation_without_results_tree.rs index 03bbcd4f4..f041f0a02 100644 --- a/verifiable-db/src/revelation/revelation_without_results_tree.rs +++ b/verifiable-db/src/revelation/revelation_without_results_tree.rs @@ -6,9 +6,8 @@ use crate::{ computational_hash_ids::AggregationOperation, public_inputs::PublicInputs as QueryProofPublicInputs, }, - revelation::{placeholders_check::check_placeholders, PublicInputs}, + revelation::PublicInputs, }; -use alloy::primitives::U256; use anyhow::Result; use itertools::Itertools; use mp2_common::{ @@ -17,18 +16,15 @@ use mp2_common::{ poseidon::{flatten_poseidon_hash_target, H}, proof::ProofWithVK, public_inputs::PublicInputCommon, - serialization::{ - deserialize, deserialize_array, deserialize_long_array, serialize, serialize_array, - serialize_long_array, - }, + serialization::{deserialize, serialize}, types::CBuilder, - u256::{CircuitBuilderU256, UInt256Target, WitnessWriteU256}, + u256::{CircuitBuilderU256, UInt256Target}, utils::ToTargets, C, D, F, }; use plonky2::{ iop::{ - target::{BoolTarget, Target}, + target::Target, witness::{PartialWitness, WitnessWrite}, }, plonk::{ @@ -45,13 +41,9 @@ use recursion_framework::{ }, }; use serde::{Deserialize, Serialize}; -use std::array; use super::{ - placeholders_check::{ - CheckPlaceholderGadget, CheckPlaceholderInputWires, CheckedPlaceholder, - CheckedPlaceholderTarget, NUM_SECONDARY_INDEX_PLACEHOLDERS, - }, + placeholders_check::{CheckPlaceholderGadget, CheckPlaceholderInputWires}, NUM_PREPROCESSING_IO, NUM_QUERY_IO, PI_LEN as REVELATION_PI_LEN, }; @@ -295,6 +287,7 @@ mod tests { random_original_tree_proof, }, }; + use alloy::primitives::U256; use mp2_common::{poseidon::flatten_poseidon_hash_value, utils::ToFields, C, D}; use mp2_test::circuit::{run_circuit, UserCircuit}; use plonky2::{field::types::Field, plonk::config::Hasher}; @@ -329,7 +322,7 @@ mod tests { original_tree_proof: &'a [F], } - impl<'a> UserCircuit for TestRevelationWithoutResultsTreeCircuit<'a> { + impl UserCircuit for TestRevelationWithoutResultsTreeCircuit<'_> { // Circuit wires + query proof + original tree proof (IVC proof) type Wires = ( RevelationWithoutResultsTreeWires, @@ -516,7 +509,7 @@ mod tests { fn test_revelation_without_results_tree_for_no_op_avg_with_no_entries() { // Initialize the all operations to SUM or COUNT (not AVG). let mut rng = thread_rng(); - let ops = array::from_fn(|_| { + let ops = std::array::from_fn(|_| { [AggregationOperation::SumOp, AggregationOperation::CountOp] .choose(&mut rng) .unwrap() diff --git a/verifiable-db/src/row_tree/api.rs b/verifiable-db/src/row_tree/api.rs index 4bbdf6bee..7994859fb 100644 --- a/verifiable-db/src/row_tree/api.rs +++ b/verifiable-db/src/row_tree/api.rs @@ -182,14 +182,6 @@ pub enum CircuitInput { impl CircuitInput { pub fn leaf( - identifier: u64, - value: U256, - row_unique_data: HashOutput, - cells_proof: Vec, - ) -> Result { - Self::leaf_multiplier(identifier, value, false, row_unique_data, cells_proof) - } - pub fn leaf_multiplier( identifier: u64, value: U256, is_multiplier: bool, @@ -205,24 +197,6 @@ impl CircuitInput { } pub fn full( - identifier: u64, - value: U256, - row_unique_data: HashOutput, - left_proof: Vec, - right_proof: Vec, - cells_proof: Vec, - ) -> Result { - Self::full_multiplier( - identifier, - value, - false, - row_unique_data, - left_proof, - right_proof, - cells_proof, - ) - } - pub fn full_multiplier( identifier: u64, value: U256, is_multiplier: bool, @@ -241,24 +215,6 @@ impl CircuitInput { }) } pub fn partial( - identifier: u64, - value: U256, - is_child_left: bool, - row_unique_data: HashOutput, - child_proof: Vec, - cells_proof: Vec, - ) -> Result { - Self::partial_multiplier( - identifier, - value, - false, - is_child_left, - row_unique_data, - child_proof, - cells_proof, - ) - } - pub fn partial_multiplier( identifier: u64, value: U256, is_multiplier: bool, @@ -401,6 +357,7 @@ mod test { let input = CircuitInput::partial( id.to_canonical_u64(), value, + false, is_left, row_unique_data, child_proof_buff.clone(), @@ -469,6 +426,7 @@ mod test { let input = CircuitInput::full( id.to_canonical_u64(), value, + false, row_unique_data, child_proof[0].to_vec(), child_proof[1].to_vec(), @@ -532,6 +490,7 @@ mod test { let input = CircuitInput::leaf( id.to_canonical_u64(), value, + false, row_unique_data, p.cells_proof_vk().serialize()?, )?;