diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 123c5d45..e86db271 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -18,6 +18,10 @@ runs: go-version: "1.22" cache-dependency-path: "**/go.sum" + - name: Install protobuf-compiler + shell: bash + run: sudo apt-get install -y protobuf-compiler + - name: Print go version shell: bash run: go version diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml index eb27abfe..37654d4b 100644 --- a/.github/workflows/book.yml +++ b/.github/workflows/book.yml @@ -118,6 +118,7 @@ jobs: deploy: runs-on: ubuntu-latest needs: [lint, build] + if: github.ref_name == 'develop' && github.event_name == 'push' # Grant GITHUB_TOKEN the permissions required to make a Pages deployment permissions: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..41bccd70 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,67 @@ +name: PR + +on: + push: + branches: [develop] + pull_request: + branches: + - "**" + merge_group: + +jobs: + test-x86_64: + name: Test on x86_64 + runs-on: ubuntu-latest + env: + CARGO_NET_GIT_FETCH_WITH_CLI: "true" + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Setup CI + uses: ./.github/actions/setup + + - name: Run cargo check + uses: actions-rs/cargo@v1 + with: + command: check + toolchain: nightly-2024-04-17 + args: --all-targets --all-features + + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test + toolchain: nightly-2024-04-17 + args: --release + env: + RUSTFLAGS: -Copt-level=3 -Cdebug-assertions -Coverflow-checks=y -Cdebuginfo=0 -C target-cpu=native + RUST_BACKTRACE: 1 + + lint: + name: Formatting & Clippy + runs-on: ubuntu-latest + env: + CARGO_NET_GIT_FETCH_WITH_CLI: "true" + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Setup CI + uses: ./.github/actions/setup + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + env: + CARGO_INCREMENTAL: 1 + + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-features --all-targets -- -D warnings -A incomplete-features + env: + CARGO_INCREMENTAL: 1 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..a327a411 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,19 @@ +{ + "editor.inlineSuggest.enabled": true, + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer", + "editor.formatOnSave": true, + "editor.hover.enabled": true + }, + "editor.rulers": [ + 100 + ], + "rust-analyzer.linkedProjects": [ + "Cargo.toml", + ], + //"rust-analyzer.showUnlinkedFileNotification": false, + // "rust-analyzer.showUnlinkedFileNotification": false, + // "rust-analyzer.check.workspace": false, + // "rust-analyzer.check.invocationStrategy": "once", + // "rust-analyzer.cargo.buildScripts.invocationStrategy": "once", +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index e2b9bfc0..1dd28d5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,9 +125,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytes" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "cargo-zisk" @@ -149,13 +149,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.104" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" dependencies = [ "jobserver", "libc", - "once_cell", ] [[package]] @@ -166,9 +165,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -176,9 +175,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", @@ -223,7 +222,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e8356ce685a1eca358fb8abbaaa1f9086f4fbd55" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#cf2ddfefe2b36394913fe4021a600e68afb427fb" dependencies = [ "log", "pilout", @@ -495,9 +494,9 @@ checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "git2" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" +checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" dependencies = [ "bitflags", "libc", @@ -537,9 +536,9 @@ dependencies = [ [[package]] name = "http-body" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http", @@ -572,9 +571,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", @@ -738,9 +737,9 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libgit2-sys" -version = "0.16.2+1.7.2" +version = "0.17.0+1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" +checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" dependencies = [ "cc", "libc", @@ -755,7 +754,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -1069,7 +1068,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -1091,7 +1090,7 @@ dependencies = [ [[package]] name = "pilout" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e8356ce685a1eca358fb8abbaaa1f9086f4fbd55" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#cf2ddfefe2b36394913fe4021a600e68afb427fb" dependencies = [ "bytes", "log", @@ -1178,7 +1177,7 @@ dependencies = [ [[package]] name = "proofman" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e8356ce685a1eca358fb8abbaaa1f9086f4fbd55" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#cf2ddfefe2b36394913fe4021a600e68afb427fb" dependencies = [ "common", "env_logger", @@ -1352,9 +1351,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ "bitflags", ] @@ -1489,9 +1488,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.10" +version = "0.23.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" dependencies = [ "once_cell", "ring", @@ -1659,7 +1658,7 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "stark" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e8356ce685a1eca358fb8abbaaa1f9086f4fbd55" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#cf2ddfefe2b36394913fe4021a600e68afb427fb" dependencies = [ "common", "log", @@ -1676,7 +1675,7 @@ dependencies = [ [[package]] name = "starks-lib-c" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e8356ce685a1eca358fb8abbaaa1f9086f4fbd55" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#cf2ddfefe2b36394913fe4021a600e68afb427fb" dependencies = [ "log", ] @@ -1701,9 +1700,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.68" +version = "2.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" dependencies = [ "proc-macro2", "quote", @@ -1733,9 +1732,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" [[package]] name = "tempfile" @@ -1751,18 +1750,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -1804,9 +1803,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -1819,9 +1818,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", "bytes", @@ -1932,7 +1931,7 @@ dependencies = [ [[package]] name = "transcript" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e8356ce685a1eca358fb8abbaaa1f9086f4fbd55" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#cf2ddfefe2b36394913fe4021a600e68afb427fb" dependencies = [ "starks-lib-c", ] @@ -2006,7 +2005,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "util" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e8356ce685a1eca358fb8abbaaa1f9086f4fbd55" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#cf2ddfefe2b36394913fe4021a600e68afb427fb" dependencies = [ "colored", "sysinfo", @@ -2020,9 +2019,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.3.1" +version = "8.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" +checksum = "2990d9ea5967266ea0ccf413a4aa5c42a93dbcfda9cb49a97de6931726b12566" dependencies = [ "anyhow", "cfg-if", @@ -2128,7 +2127,7 @@ dependencies = [ [[package]] name = "wchelpers" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e8356ce685a1eca358fb8abbaaa1f9086f4fbd55" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#cf2ddfefe2b36394913fe4021a600e68afb427fb" dependencies = [ "common", ] @@ -2181,7 +2180,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ "windows-core", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -2190,7 +2189,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -2208,7 +2207,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -2228,18 +2227,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2250,9 +2249,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -2262,9 +2261,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -2274,15 +2273,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -2292,9 +2291,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -2304,9 +2303,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -2316,9 +2315,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -2328,9 +2327,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winreg" diff --git a/book/getting_started/install.md b/book/getting_started/install.md index 34d04725..6bc00284 100644 --- a/book/getting_started/install.md +++ b/book/getting_started/install.md @@ -2,6 +2,8 @@ ## Requirements * [Rust (Nightly)](https://www.rust-lang.org/tools/install) +* [xz]() +* [jq]() ## Option 1: Prebuilt Binaries (Recommended) diff --git a/cli/build.rs b/cli/build.rs index 594550b4..c2f550fb 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -1,7 +1,3 @@ fn main() { - vergen::EmitBuilder::builder() - .build_timestamp() - .git_sha(true) - .emit() - .unwrap(); + vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); } diff --git a/cli/src/bin/cargo-zisk.rs b/cli/src/bin/cargo-zisk.rs index b2a38ea1..aee8b142 100644 --- a/cli/src/bin/cargo-zisk.rs +++ b/cli/src/bin/cargo-zisk.rs @@ -1,15 +1,17 @@ use anyhow::{anyhow, Context, Result}; -use cargo_zisk::commands::build_toolchain::BuildToolchainCmd; -use cargo_zisk::commands::install_toolchain::InstallToolchainCmd; -use cargo_zisk::commands::new::NewCmd; -use cargo_zisk::ZISK_VERSION_MESSAGE; +use cargo_zisk::{ + commands::{ + build_toolchain::BuildToolchainCmd, install_toolchain::InstallToolchainCmd, new::NewCmd, + }, + ZISK_VERSION_MESSAGE, +}; use clap::{Parser, Subcommand}; -use std::env; -use std::process::{Command, Stdio}; +use std::{ + env, + process::{Command, Stdio}, +}; -use std::fs::File; -use std::io::{self, Read, Write}; -use std::path::Path; +use std::{fs::File, io::Write, path::Path}; // Main enum defining cargo subcommands. #[derive(Parser)] @@ -60,7 +62,7 @@ pub enum ZiskSdkCommands { // Implement the run functionality for ZiskRun impl ZiskRun { fn run(&self) -> Result<()> { - let mut runner_command: String = String::new(); + let runner_command: String; // Construct the cargo run command let mut command = Command::new("cargo"); command.args(["+zisk", "run"]); @@ -122,9 +124,8 @@ impl ZiskRun { gdb_command ); } - - env::set_var("CARGO_TARGET_RISCV64IMA_POLYGON_ZISKOS_ELF_RUNNER", runner_command.to_string()); + env::set_var("CARGO_TARGET_RISCV64IMA_POLYGON_ZISKOS_ELF_RUNNER", runner_command); // Verify the environment variable is set println!( "CARGO_TARGET_RISCV64IMA_POLYGON_ZISKOS_ELF_RUNNER: {}", @@ -136,7 +137,6 @@ impl ZiskRun { // Add any additional arguments passed to the run command command.args(&self.args); - println!("running {:?}", command); // Set up the command to inherit the parent's stdout and stderr command.stdout(Stdio::inherit()); command.stderr(Stdio::inherit()); diff --git a/cli/src/commands/build_toolchain.rs b/cli/src/commands/build_toolchain.rs index 46485375..6d59db0c 100644 --- a/cli/src/commands/build_toolchain.rs +++ b/cli/src/commands/build_toolchain.rs @@ -29,10 +29,7 @@ impl BuildToolchainCmd { let repo_url = match github_access_token { Ok(github_access_token) => { println!("Detected GITHUB_ACCESS_TOKEN, using it to clone rust."); - format!( - "https://{}@github.com/eduadiez/rust", - github_access_token - ) + format!("https://{}@github.com/eduadiez/rust", github_access_token) } Err(_) => { println!("No GITHUB_ACCESS_TOKEN detected. If you get throttled by Github, set it to bypass the rate limit."); @@ -50,10 +47,7 @@ impl BuildToolchainCmd { ]) .current_dir(&temp_dir) .run()?; - Command::new("git") - .args(["reset", "--hard"]) - .current_dir(&dir) - .run()?; + Command::new("git").args(["reset", "--hard"]).current_dir(&dir).run()?; Command::new("git") .args(["submodule", "update", "--init", "--recursive", "--progress"]) .current_dir(&dir) @@ -63,11 +57,8 @@ impl BuildToolchainCmd { }; // Install our config.toml. let ci = std::env::var("CI").unwrap_or("false".to_string()) == "true"; - let config_toml = if ci { - include_str!("config-ci.toml") - } else { - include_str!("config.toml") - }; + let config_toml = + if ci { include_str!("config-ci.toml") } else { include_str!("config.toml") }; let config_file = rust_dir.join("config.toml"); std::fs::write(&config_file, config_toml) .with_context(|| format!("while writing configuration to {:?}", config_file))?; @@ -86,10 +77,7 @@ impl BuildToolchainCmd { .run()?; // Remove the existing toolchain from rustup, if it exists. - match Command::new("rustup") - .args(["toolchain", "remove", RUSTUP_TOOLCHAIN_NAME]) - .run() - { + match Command::new("rustup").args(["toolchain", "remove", RUSTUP_TOOLCHAIN_NAME]).run() { Ok(_) => println!("Successfully removed existing toolchain."), Err(_) => println!("No existing toolchain to remove."), } @@ -111,7 +99,7 @@ impl BuildToolchainCmd { ); // Copy over the stage2-tools-bin directory to the toolchain bin directory. - /* + /* let tools_bin_dir = toolchain_dir.parent().unwrap().join("stage2-tools-bin"); let target_bin_dir = toolchain_dir.join("bin"); for tool in tools_bin_dir.read_dir()? { diff --git a/cli/src/commands/install_toolchain.rs b/cli/src/commands/install_toolchain.rs index f5d44e9e..2b8d6e7e 100644 --- a/cli/src/commands/install_toolchain.rs +++ b/cli/src/commands/install_toolchain.rs @@ -4,9 +4,11 @@ use clap::Parser; use dirs::home_dir; use rand::{distributions::Alphanumeric, Rng}; use reqwest::Client; -use std::fs::{self}; -use std::io::Read; -use std::process::Command; +use std::{ + fs::{self}, + io::Read, + process::Command, +}; #[cfg(target_family = "unix")] use std::os::unix::fs::PermissionsExt; @@ -16,10 +18,7 @@ use crate::{ }; #[derive(Parser)] -#[command( - name = "install-toolchain", - about = "Install the cargo-zisk toolchain." -)] +#[command(name = "install-toolchain", about = "Install the cargo-zisk toolchain.")] pub struct InstallToolchainCmd {} impl InstallToolchainCmd { @@ -37,10 +36,10 @@ impl InstallToolchainCmd { if let Ok(entry) = entry { let entry_path = entry.path(); let entry_name = entry_path.file_name().unwrap(); - if entry_path.is_dir() - && entry_name != "bin" - && entry_name != "circuits" - && entry_name != "toolchains" + if entry_path.is_dir() && + entry_name != "bin" && + entry_name != "circuits" && + entry_name != "toolchains" { if let Err(err) = fs::remove_dir_all(&entry_path) { println!("Failed to remove directory {:?}: {}", entry_path, err); @@ -83,12 +82,7 @@ impl InstallToolchainCmd { // Download the toolchain. let mut file = fs::File::create(toolchain_archive_path)?; - rt.block_on(download_file( - &client, - toolchain_download_url.as_str(), - &mut file, - )) - .unwrap(); + rt.block_on(download_file(&client, toolchain_download_url.as_str(), &mut file)).unwrap(); // Remove the existing toolchain from rustup, if it exists. let mut child = Command::new("rustup") @@ -113,22 +107,14 @@ impl InstallToolchainCmd { fs::create_dir_all(toolchain_dir.clone())?; Command::new("tar") .current_dir(&root_dir) - .args([ - "-xzf", - &toolchain_asset_name, - "-C", - &toolchain_dir.to_string_lossy(), - ]) + .args(["-xzf", &toolchain_asset_name, "-C", &toolchain_dir.to_string_lossy()]) .status()?; // Move the toolchain to a randomly named directory in the 'toolchains' folder let toolchains_dir = root_dir.join("toolchains"); fs::create_dir_all(&toolchains_dir)?; - let random_string: String = rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(10) - .map(char::from) - .collect(); + let random_string: String = + rand::thread_rng().sample_iter(&Alphanumeric).take(10).map(char::from).collect(); let new_toolchain_dir = toolchains_dir.join(random_string); fs::rename(&toolchain_dir, &new_toolchain_dir)?; diff --git a/cli/src/commands/new.rs b/cli/src/commands/new.rs index 0b4774e3..1dcaa89e 100644 --- a/cli/src/commands/new.rs +++ b/cli/src/commands/new.rs @@ -41,10 +41,7 @@ impl NewCmd { " \x1b[1m{}\x1b[0m {} ({})", Paint::green("Initialized"), self.name, - std::fs::canonicalize(root) - .expect("failed to canonicalize") - .to_str() - .unwrap() + std::fs::canonicalize(root).expect("failed to canonicalize").to_str().unwrap() ); Ok(()) diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 00000000..b5a99df7 --- /dev/null +++ b/clippy.toml @@ -0,0 +1,4 @@ +msrv = "1.79" +# bytes::Bytes is included by default and alloy_primitives::Bytes is a wrapper around it, +# so it is safe to ignore it as well +ignore-interior-mutability = ["bytes::Bytes", "alloy_primitives::Bytes"] diff --git a/common/src/lib.rs b/common/src/lib.rs index a672f569..45e8bc0d 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,5 +1,5 @@ -mod zisk_opcodes; mod rom; +mod zisk_opcodes; -pub use zisk_opcodes::*; pub use rom::*; +pub use zisk_opcodes::*; diff --git a/common/src/rom.rs b/common/src/rom.rs index 950877b7..abad3d0d 100644 --- a/common/src/rom.rs +++ b/common/src/rom.rs @@ -128,7 +128,9 @@ where let value: IndexMap = Deserialize::deserialize(deserializer)?; value .into_iter() - .map(|(k, v)| serde_json::from_value(v).map(|inst| (k, inst)).map_err(serde::de::Error::custom)) + .map(|(k, v)| { + serde_json::from_value(v).map(|inst| (k, inst)).map_err(serde::de::Error::custom) + }) .collect() } diff --git a/riscv/riscv2zisk/src/lib.rs b/riscv/riscv2zisk/src/lib.rs index e69de29b..8b137891 100644 --- a/riscv/riscv2zisk/src/lib.rs +++ b/riscv/riscv2zisk/src/lib.rs @@ -0,0 +1 @@ + diff --git a/rustfmt.toml b/rustfmt.toml index 911fa052..66b2930c 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,5 +1,11 @@ -fn_params_layout = "Tall" +reorder_imports = true +imports_granularity = "Crate" use_small_heuristics = "Max" -max_width = 120 -reorder_modules = false -reorder_imports = false \ No newline at end of file +comment_width = 100 +wrap_comments = true +binop_separator = "Back" +trailing_comma = "Vertical" +trailing_semicolon = false +use_field_init_shorthand = true +format_code_in_doc_comments = true +doc_comment_code_block_width = 100 \ No newline at end of file diff --git a/simulator/src/lib.rs b/simulator/src/lib.rs index e69de29b..8b137891 100644 --- a/simulator/src/lib.rs +++ b/simulator/src/lib.rs @@ -0,0 +1 @@ + diff --git a/state-machines/main/src/lib.rs b/state-machines/main/src/lib.rs index b28bc1ac..2a337469 100644 --- a/state-machines/main/src/lib.rs +++ b/state-machines/main/src/lib.rs @@ -1,5 +1,4 @@ #[allow(dead_code, unused)] - mod main_sm; mod main_trace; diff --git a/state-machines/main/src/main_sm.rs b/state-machines/main/src/main_sm.rs index 456b3f79..3c923822 100644 --- a/state-machines/main/src/main_sm.rs +++ b/state-machines/main/src/main_sm.rs @@ -18,19 +18,24 @@ impl MainSM { _sm.insert(code.to_string(), Rc::clone(&s)); } } - let main = Rc::new(Self { sm: _sm }); + Rc::new(Self { sm: _sm }) - wcm.register_component(Rc::clone(&main) as Rc>); - wcm.register_executor(Rc::clone(&main) as Rc>); - - main + // wcm.register_component(Rc::clone(&main) as Rc>); + // wcm.register_executor(Rc::clone(&main) as Rc>); } } impl WCComponent for MainSM { - fn calculate_witness(&self, stage: u32, air_instance: &AirInstance, pctx: &mut ProofCtx, ectx: &ExecutionCtx) {} + fn calculate_witness( + &self, + stage: u32, + air_instance: &AirInstance, + pctx: &mut ProofCtx, + ectx: &ExecutionCtx, + ) { + } - fn calculate_plan(&self, ectx: &mut ExecutionCtx) {} + fn suggest_plan(&self, ectx: &mut ExecutionCtx) {} } impl WCExecutor for MainSM { diff --git a/state-machines/main/src/main_trace.rs b/state-machines/main/src/main_trace.rs index 5d6602df..bc31274b 100644 --- a/state-machines/main/src/main_trace.rs +++ b/state-machines/main/src/main_trace.rs @@ -1,4 +1,4 @@ -use proofman::trace; use p3_goldilocks::Goldilocks; +use proofman::trace; trace!(MainTrace0 { a: Goldilocks, b: Goldilocks }); diff --git a/state-machines/mem/src/lib.rs b/state-machines/mem/src/lib.rs index 0dfd42ee..88373ca5 100644 --- a/state-machines/mem/src/lib.rs +++ b/state-machines/mem/src/lib.rs @@ -1,5 +1,4 @@ #[allow(dead_code, unused)] - mod mem_sm; mod mem_trace; diff --git a/state-machines/mem/src/mem_sm.rs b/state-machines/mem/src/mem_sm.rs index 9868b5d9..a71bb914 100644 --- a/state-machines/mem/src/mem_sm.rs +++ b/state-machines/mem/src/mem_sm.rs @@ -11,22 +11,26 @@ pub struct MemSM { impl MemSM { pub fn new(wcm: &mut WCManager) -> Rc { - let mem_sm = Rc::new(MemSM { inputs: RefCell::new(Vec::new()) }); - wcm.register_component(Rc::clone(&mem_sm) as Rc>); + Rc::new(MemSM { inputs: RefCell::new(Vec::new()) }) + // wcm.register_component(Rc::clone(&mem_sm) as Rc>); - mem_sm + // mem_sm } } impl WCOpCalculator for MemSM { // 0:x, 1:module - fn calculate_verify(&self, verify: bool, values: Vec) -> Result, Box> { + fn calculate_verify( + &self, + verify: bool, + values: Vec, + ) -> Result, Box> { let (x, module) = (values[0], values[1]); let x_mod = x % module; if verify { - self.inputs.borrow_mut().push((x.into(), x_mod.into())); + self.inputs.borrow_mut().push((x, x_mod)); } Ok(vec![x_mod]) @@ -38,7 +42,14 @@ impl WCOpCalculator for MemSM { } impl WCComponent for MemSM { - fn calculate_witness(&self, stage: u32, air_instance: &AirInstance, pctx: &mut ProofCtx, _ectx: &ExecutionCtx) {} + fn calculate_witness( + &self, + stage: u32, + air_instance: &AirInstance, + pctx: &mut ProofCtx, + _ectx: &ExecutionCtx, + ) { + } - fn calculate_plan(&self, ectx: &mut ExecutionCtx) {} + fn suggest_plan(&self, ectx: &mut ExecutionCtx) {} } diff --git a/state-machines/mem/src/mem_trace.rs b/state-machines/mem/src/mem_trace.rs index 7f198682..b205dc51 100644 --- a/state-machines/mem/src/mem_trace.rs +++ b/state-machines/mem/src/mem_trace.rs @@ -1,4 +1,4 @@ -use proofman::trace; use p3_goldilocks::Goldilocks; +use proofman::trace; trace!(MemTrace0 { x: Goldilocks, q: Goldilocks, x_mod: Goldilocks }); diff --git a/witness-computation/src/pil_helpers/pilout.rs b/witness-computation/src/pil_helpers/pilout.rs index 4ec3afe6..df7ec124 100644 --- a/witness-computation/src/pil_helpers/pilout.rs +++ b/witness-computation/src/pil_helpers/pilout.rs @@ -1,10 +1,10 @@ -use common::WCPilOut; +use common::WCPilout; -pub struct FibonacciVadcopPilout; +pub struct ZiskPilout; -impl FibonacciVadcopPilout { - pub fn get_fibonacci_vadcop_pilout() -> WCPilOut { - let mut pilout = WCPilOut::new("Zisk", 2, b"zisk-hash".to_vec()); +impl ZiskPilout { + pub fn get_pilout() -> WCPilout { + let mut pilout = WCPilout::new("Zisk", 2, b"zisk-hash".to_vec()); let air_group = pilout.add_air_group(Some("Main")); air_group.add_air(Some("FibonacciSquare"), 10); diff --git a/witness-computation/src/pil_helpers/public_inputs.rs b/witness-computation/src/pil_helpers/public_inputs.rs index fd0bb045..0b13bc0c 100644 --- a/witness-computation/src/pil_helpers/public_inputs.rs +++ b/witness-computation/src/pil_helpers/public_inputs.rs @@ -13,7 +13,11 @@ impl ZiskPublicInputs { impl From<&[u8]> for ZiskPublicInputs { fn from(input_bytes: &[u8]) -> Self { const U64_SIZE: usize = std::mem::size_of::(); - assert_eq!(input_bytes.len(), U64_SIZE * 3, "Input bytes length must be 3 * size_of::()"); + assert_eq!( + input_bytes.len(), + U64_SIZE * 3, + "Input bytes length must be 3 * size_of::()" + ); ZiskPublicInputs { a: u64::from_le_bytes(input_bytes[0..U64_SIZE].try_into().unwrap()), diff --git a/witness-computation/src/zisk_wc.rs b/witness-computation/src/zisk_wc.rs index 9d5ee456..1df61d5d 100644 --- a/witness-computation/src/zisk_wc.rs +++ b/witness-computation/src/zisk_wc.rs @@ -1,22 +1,28 @@ use std::rc::Rc; -use common::{ExecutionCtx, ProofCtx, WCPilOut}; +use common::{ExecutionCtx, ProofCtx, WCPilout}; use p3_field::AbstractField; use p3_goldilocks::Goldilocks; use proofman::WCManager; use sm_main::MainSM; use sm_mem::MemSM; -use wchelpers::{WCLibrary, WCOpCalculator}; +use wchelpers::{WCExecutor, WCLibrary, WCOpCalculator}; -use crate::FibonacciVadcopPilout; +use crate::ZiskPilout; -pub struct FibonacciVadcop { +pub struct ZiskWC { pub wcm: WCManager, pub main_sm: Rc, pub mem_sm: Rc, } -impl FibonacciVadcop { +impl Default for ZiskWC { + fn default() -> Self { + Self::new() + } +} + +impl ZiskWC { pub fn new() -> Self { let mut wcm = WCManager::new(); @@ -25,11 +31,11 @@ impl FibonacciVadcop { let sm = vec![Rc::clone(&mem_sm) as Rc]; let main_sm = MainSM::new(&mut wcm, sm); - FibonacciVadcop { wcm, main_sm, mem_sm } + ZiskWC { wcm, main_sm, mem_sm } } } -impl WCLibrary for FibonacciVadcop { +impl WCLibrary for ZiskWC { fn start_proof(&mut self, pctx: &mut ProofCtx, ectx: &mut ExecutionCtx) { self.wcm.start_proof(pctx, ectx); } @@ -42,22 +48,35 @@ impl WCLibrary for FibonacciVadcop { self.wcm.calculate_plan(ectx); } - fn initialize_air_instances(&mut self, pctx: &mut ProofCtx, ectx: &ExecutionCtx) { - for id in ectx.owned_instances.iter() { - pctx.air_instances.push((&ectx.instances[*id]).into()); - } + fn start_execute(&mut self, pctx: &mut ProofCtx, ectx: &mut ExecutionCtx) { + self.wcm.start_execute(pctx, ectx); + } + + fn execute(&self, pctx: &mut ProofCtx, ectx: &mut ExecutionCtx) { + self.main_sm.execute(pctx, ectx); } + + fn end_execute(&mut self, pctx: &mut ProofCtx, ectx: &mut ExecutionCtx) { + self.wcm.end_execute(pctx, ectx); + } + + // fn initialize_air_instances(&mut self, pctx: &mut ProofCtx, ectx: &ExecutionCtx) { + // for id in ectx.owned_instances.iter() { + // pctx.air_instances.push((&ectx.instances[*id]).into()); + // } + // } + fn calculate_witness(&mut self, stage: u32, pctx: &mut ProofCtx, ectx: &ExecutionCtx) { self.wcm.calculate_witness(stage, pctx, ectx); } - fn get_pilout(&self) -> WCPilOut { - FibonacciVadcopPilout::get_fibonacci_vadcop_pilout() + fn pilout(&self) -> WCPilout { + ZiskPilout::get_pilout() } } #[no_mangle] -pub extern "Rust" fn init_library<'a>() -> Box> { +pub extern "Rust" fn init_library() -> Box> { env_logger::builder() .format_timestamp(None) .format_level(true) @@ -65,5 +84,5 @@ pub extern "Rust" fn init_library<'a>() -> Box> { .filter_level(log::LevelFilter::Trace) .init(); - Box::new(FibonacciVadcop::new()) + Box::new(ZiskWC::new()) } diff --git a/ziskos/entrypoint/src/lib.rs b/ziskos/entrypoint/src/lib.rs index 9eed5298..df49c28f 100644 --- a/ziskos/entrypoint/src/lib.rs +++ b/ziskos/entrypoint/src/lib.rs @@ -1,4 +1,5 @@ #![feature(asm_const)] +#![allow(unexpected_cfgs)] pub mod ziskos_definitions; @@ -26,14 +27,14 @@ pub fn read_input() -> Vec { // Convert the slice to a u64 (little-endian) let size: u64 = u64::from_le_bytes(bytes.try_into().unwrap()); - let input = unsafe { core::slice::from_raw_parts((INPUT_ADDR as *const u8).add(8), size as usize) }; + let input = + unsafe { core::slice::from_raw_parts((INPUT_ADDR as *const u8).add(8), size as usize) }; input.to_vec() } #[cfg(not(target_os = "ziskos"))] pub fn read_input() -> Vec { - use std::fs::File; - use std::io::Read; + use std::{fs::File, io::Read}; let mut file = File::open("output/input.bin").unwrap(); let mut buffer = Vec::new(); @@ -76,7 +77,7 @@ pub fn write_output(write_ptr: &[u8], _nbytes: usize) { }; // Create the output string - let output = format!("{}", write_str); + let output = write_str.to_string(); // Print the output string print!("{}", output); @@ -84,8 +85,8 @@ pub fn write_output(write_ptr: &[u8], _nbytes: usize) { #[cfg(target_os = "ziskos")] mod ziskos { - use core::arch::asm; use crate::ziskos_definitions::ziskos_config::*; + use core::arch::asm; #[no_mangle] #[link_section = ".text.init"] @@ -222,11 +223,3 @@ mod ziskos { ptr } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() {} -}