From 54df676a878551af8032f0656948d359297170ae Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Mon, 18 Nov 2024 01:41:30 +0100 Subject: [PATCH 01/19] add execute function --- zkvm/src/lib.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index 175d77c..8e54a60 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -1,4 +1,4 @@ -use risc0_zkvm::{default_prover, sha::Digest, ExecutorEnv, Receipt}; +use risc0_zkvm::{default_prover, sha::Digest, ExecutorEnv, Receipt, default_executor}; pub fn prove(input_vec: Vec, elf: &[u8]) -> (u64, Receipt) { let mut builder = ExecutorEnv::builder(); @@ -17,6 +17,21 @@ pub fn prove(input_vec: Vec, elf: &[u8]) -> (u64, R (digest, receipt) } +// This only executes the program and does not generate a receipt. +pub fn execute(input_vec: Vec, elf: &[u8]) { + let mut builder = ExecutorEnv::builder(); + + for input in input_vec { + builder.write(&input).unwrap(); + } + + let env = builder.build().unwrap(); + + let exec = default_executor(); + + exec.execute(env, elf).unwrap(); +} + pub fn verify(receipt: Receipt, image_id: impl Into) { receipt .verify(image_id) From b8a80cc06fb1f12c981d5330d96a87c70074f58d Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Mon, 18 Nov 2024 02:06:37 +0100 Subject: [PATCH 02/19] add result to execute --- zkvm/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index 8e54a60..eddd4fc 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -18,7 +18,7 @@ pub fn prove(input_vec: Vec, elf: &[u8]) -> (u64, R } // This only executes the program and does not generate a receipt. -pub fn execute(input_vec: Vec, elf: &[u8]) { +pub fn execute serde::Deserialize<'de>>(input_vec: Vec, elf: &[u8]) -> T { let mut builder = ExecutorEnv::builder(); for input in input_vec { @@ -28,8 +28,12 @@ pub fn execute(input_vec: Vec, elf: &[u8]) { let env = builder.build().unwrap(); let exec = default_executor(); + let session = exec.execute(env, elf).unwrap(); - exec.execute(env, elf).unwrap(); + // We read the result committed to the journal by the guest code. + let result: T = session.journal.decode().unwrap(); + + result } pub fn verify(receipt: Receipt, image_id: impl Into) { From 63d60596f0560cb2c575cbe2936c256f6a721647 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Mon, 18 Nov 2024 02:07:57 +0100 Subject: [PATCH 03/19] add execute_simple_sum test --- zkvm/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index eddd4fc..595991c 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -91,4 +91,14 @@ mod tests { verify(receipt, MULTIPLICATION_ID); assert_eq!(digest, message * message_2); } + + #[test] + fn execute_simple_sum() { + let message: u64 = 1; + let message_2: u64 = 2; + + let result = execute(vec![message, message_2], SUMMATION_ELF); + assert_eq!(result, message + message_2); + } + } From b985de5c83ff54159a6681e9e95a1295914907fe Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Mon, 18 Nov 2024 02:08:08 +0100 Subject: [PATCH 04/19] add execute_bigger_sum test --- zkvm/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index 595991c..b53bfa1 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -101,4 +101,12 @@ mod tests { assert_eq!(result, message + message_2); } + #[test] + fn execute_bigger_sum() { + let message: u64 = 123476; + let message_2: u64 = 2342384; + + let result = execute(vec![message, message_2], SUMMATION_ELF); + assert_eq!(result, message + message_2); + } } From cdee9d6924de2fa8f6cd00df4051822f0eb00a1b Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Mon, 18 Nov 2024 02:08:58 +0100 Subject: [PATCH 05/19] tests renaming --- zkvm/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index b53bfa1..dd29f12 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -49,7 +49,7 @@ mod tests { use test_methods::{SUMMATION_ELF, SUMMATION_ID}; #[test] - fn simple_sum() { + fn prove_simple_sum() { let message = 1; let message_2 = 2; @@ -60,7 +60,7 @@ mod tests { } #[test] - fn bigger_sum() { + fn prove_bigger_sum() { let message = 123476; let message_2 = 2342384; @@ -71,7 +71,7 @@ mod tests { } #[test] - fn simple_multiplication() { + fn prove_simple_multiplication() { let message = 1; let message_2 = 2; @@ -82,7 +82,7 @@ mod tests { } #[test] - fn bigger_multiplication() { + fn prove_bigger_multiplication() { let message = 3498; let message_2 = 438563; From 79b9d1f9350f8fc280191b20f14f4dabeb5708ba Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Mon, 18 Nov 2024 02:09:13 +0100 Subject: [PATCH 06/19] cargo fmt --- zkvm/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index dd29f12..f6da9ce 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -1,4 +1,4 @@ -use risc0_zkvm::{default_prover, sha::Digest, ExecutorEnv, Receipt, default_executor}; +use risc0_zkvm::{default_executor, default_prover, sha::Digest, ExecutorEnv, Receipt}; pub fn prove(input_vec: Vec, elf: &[u8]) -> (u64, Receipt) { let mut builder = ExecutorEnv::builder(); @@ -18,7 +18,10 @@ pub fn prove(input_vec: Vec, elf: &[u8]) -> (u64, R } // This only executes the program and does not generate a receipt. -pub fn execute serde::Deserialize<'de>>(input_vec: Vec, elf: &[u8]) -> T { +pub fn execute serde::Deserialize<'de>>( + input_vec: Vec, + elf: &[u8], +) -> T { let mut builder = ExecutorEnv::builder(); for input in input_vec { From 00885e6aaad7c4c9158bcfe5ca7a925c17f174ba Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Mon, 18 Nov 2024 02:21:42 +0100 Subject: [PATCH 07/19] add big calculation elf --- zkvm/test_methods/guest/src/bin/big_calculation.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 zkvm/test_methods/guest/src/bin/big_calculation.rs diff --git a/zkvm/test_methods/guest/src/bin/big_calculation.rs b/zkvm/test_methods/guest/src/bin/big_calculation.rs new file mode 100644 index 0000000..b546857 --- /dev/null +++ b/zkvm/test_methods/guest/src/bin/big_calculation.rs @@ -0,0 +1,14 @@ +use risc0_zkvm::{ + guest::env, +}; + +fn main() { + let lhs: u128 = env::read(); + let rhs: u128 = env::read(); + let mut res = 1; + for i in 0..lhs { + res *= rhs; + res += lhs; + } + env::commit(&(res)); +} From 097245e25b2b7eb7c1f8e1c7cc3f7767e87faa12 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Mon, 18 Nov 2024 02:22:07 +0100 Subject: [PATCH 08/19] add execute_big_calculation --- zkvm/src/lib.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index f6da9ce..035204b 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -50,6 +50,7 @@ mod tests { use super::*; use test_methods::{MULTIPLICATION_ELF, MULTIPLICATION_ID}; use test_methods::{SUMMATION_ELF, SUMMATION_ID}; + use test_methods::{BIG_CALCULATION_ELF, BIG_CALCULATION_ID}; #[test] fn prove_simple_sum() { @@ -112,4 +113,24 @@ mod tests { let result = execute(vec![message, message_2], SUMMATION_ELF); assert_eq!(result, message + message_2); } + + #[test] + fn execute_big_calculation() { + let message: u128 = 1; + let message_2: u128 = 2; + + let result = execute(vec![message, message_2], BIG_CALCULATION_ELF); + assert_eq!(result, big_calculation(message, message_2)); + } + + + fn big_calculation(lhs: u128, rhs: u128) -> u128 { + let mut res = 1_u128; + for _ in 0..lhs { + res *= rhs; + res += lhs; + } + + res + } } From d2a8cfe4503324ad53e4ae1806f492b9b0fc3d2c Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Mon, 18 Nov 2024 02:22:14 +0100 Subject: [PATCH 09/19] add execute_big_calculation_long --- zkvm/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index 035204b..3b2b4ba 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -123,6 +123,14 @@ mod tests { assert_eq!(result, big_calculation(message, message_2)); } + #[test] + fn execute_big_calculation_long() { + let message: u128 = 20; + let message_2: u128 = 10; + + let result = execute(vec![message, message_2], BIG_CALCULATION_ELF); + assert_eq!(result, big_calculation(message, message_2)); + } fn big_calculation(lhs: u128, rhs: u128) -> u128 { let mut res = 1_u128; From 9f913d0105b5e73f1702e2ef3d06c4ca16c40043 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 25 Nov 2024 07:37:01 +0200 Subject: [PATCH 10/19] fix: trying scripts --- .github/workflows/ci.yml | 11 ++--------- ci_scripts/build-ubuntu.sh | 4 ++++ 2 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 ci_scripts/build-ubuntu.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 752af4a..2738171 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,16 +30,9 @@ jobs: profile: minimal toolchain: nightly override: true - - name: install risc0 + - name: build ubuntu test if: success() || failure() - run: | - curl -L https://risczero.com/install | bash - - name: install risc0 step 2 - if: success() || failure() - run: | - source /home/runner/.bashrc && rzup install && source /home/runner/.bashrc - - uses: Swatinem/rust-cache@v2 - - run: cargo build + run: ./ci_scripts/build-ubuntu.sh lint: strategy: diff --git a/ci_scripts/build-ubuntu.sh b/ci_scripts/build-ubuntu.sh new file mode 100644 index 0000000..21ab9c0 --- /dev/null +++ b/ci_scripts/build-ubuntu.sh @@ -0,0 +1,4 @@ +curl -L https://risczero.com/install | bash +source /home/runner/.bashrc +rzup install +cargo build \ No newline at end of file From 959000e4189749821eacd4d9b979d0f0940ecc60 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 25 Nov 2024 07:39:22 +0200 Subject: [PATCH 11/19] fix: ci test 1 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2738171..a590ccf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: override: true - name: build ubuntu test if: success() || failure() - run: ./ci_scripts/build-ubuntu.sh + run: chmod 777 ./ci_scripts/build-ubuntu.sh && ./ci_scripts/build-ubuntu.sh lint: strategy: From 3991086c34f8cc3b8320b3bda02bd8c68cfc17ff Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 25 Nov 2024 07:44:33 +0200 Subject: [PATCH 12/19] fix: ci test 2 --- ci_scripts/build-ubuntu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci_scripts/build-ubuntu.sh b/ci_scripts/build-ubuntu.sh index 21ab9c0..bf71a72 100644 --- a/ci_scripts/build-ubuntu.sh +++ b/ci_scripts/build-ubuntu.sh @@ -1,4 +1,4 @@ +set -e curl -L https://risczero.com/install | bash -source /home/runner/.bashrc -rzup install +/home/runner/.risc0/bin/rzup install cargo build \ No newline at end of file From ecdb8c4c68811a99f0576ad1d4fd985bfcb59ed1 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 25 Nov 2024 07:49:30 +0200 Subject: [PATCH 13/19] fix: ci test 3 --- .github/workflows/ci.yml | 155 ++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 77 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a590ccf..e1f4ef4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,8 @@ jobs: build: strategy: matrix: - platform: [ ubuntu-latest, macos-latest ] + # platform: [ ubuntu-latest, macos-latest ] + platform: [ ubuntu-latest ] runs-on: ${{ matrix.platform }} timeout-minutes: 60 @@ -30,84 +31,84 @@ jobs: profile: minimal toolchain: nightly override: true - - name: build ubuntu test + - name: build - ${{ matrix.platform }} test if: success() || failure() run: chmod 777 ./ci_scripts/build-ubuntu.sh && ./ci_scripts/build-ubuntu.sh - lint: - strategy: - matrix: - platform: [ ubuntu-latest ] - runs-on: ${{ matrix.platform }} - timeout-minutes: 60 + # lint: + # strategy: + # matrix: + # platform: [ ubuntu-latest ] + # runs-on: ${{ matrix.platform }} + # timeout-minutes: 60 - name: lint - ${{ matrix.crate }} - ${{ matrix.platform }} - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - components: rustfmt, clippy - - uses: Swatinem/rust-cache@v2 - - name: cargo fmt - if: success() || failure() - run: cargo fmt -- --check - - name: cargo clippy - if: success() || failure() - run: | - cargo clippy --release -- -D warnings - - name: install risc0 - if: success() || failure() - run: | - curl -L https://risczero.com/install | bash - - name: install risc0 step 2 - if: success() || failure() - run: | - source /home/runner/.bashrc && rzup install && source /home/runner/.bashrc - - name: install taplo - if: success() || failure() - run: | - cargo install taplo-cli --locked - - name: taplo fmt - if: success() || failure() - run: | - taplo fmt --check - test: - strategy: - matrix: - platform: [ ubuntu-latest ] - runs-on: ${{ matrix.platform }} - timeout-minutes: 60 + # name: lint - ${{ matrix.crate }} - ${{ matrix.platform }} + # steps: + # - name: Checkout sources + # uses: actions/checkout@v3 + # - name: Install stable toolchain + # uses: actions-rs/toolchain@v1 + # with: + # profile: minimal + # toolchain: nightly + # override: true + # components: rustfmt, clippy + # - uses: Swatinem/rust-cache@v2 + # - name: cargo fmt + # if: success() || failure() + # run: cargo fmt -- --check + # - name: cargo clippy + # if: success() || failure() + # run: | + # cargo clippy --release -- -D warnings + # - name: install risc0 + # if: success() || failure() + # run: | + # curl -L https://risczero.com/install | bash + # - name: install risc0 step 2 + # if: success() || failure() + # run: | + # source /home/runner/.bashrc && rzup install && source /home/runner/.bashrc + # - name: install taplo + # if: success() || failure() + # run: | + # cargo install taplo-cli --locked + # - name: taplo fmt + # if: success() || failure() + # run: | + # taplo fmt --check + # test: + # strategy: + # matrix: + # platform: [ ubuntu-latest ] + # runs-on: ${{ matrix.platform }} + # timeout-minutes: 60 - name: test - ${{ matrix.crate }} - ${{ matrix.platform }} - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - uses: Swatinem/rust-cache@v2 - - name: install risc0 - if: success() || failure() - run: | - curl -L https://risczero.com/install | bash - - name: install risc0 step 2 - if: success() || failure() - run: | - source /home/runner/.bashrc && rzup install && source /home/runner/.bashrc - - name: test mempool - if: success() || failure() - run: cargo test -p mempool - - name: test storage - if: success() || failure() - run: cargo test -p storage - - name: test zkvm - if: success() || failure() - run: cargo test -p zkvm + # name: test - ${{ matrix.crate }} - ${{ matrix.platform }} + # steps: + # - name: Checkout sources + # uses: actions/checkout@v3 + # - name: Install stable toolchain + # uses: actions-rs/toolchain@v1 + # with: + # profile: minimal + # toolchain: nightly + # override: true + # - uses: Swatinem/rust-cache@v2 + # - name: install risc0 + # if: success() || failure() + # run: | + # curl -L https://risczero.com/install | bash + # - name: install risc0 step 2 + # if: success() || failure() + # run: | + # source /home/runner/.bashrc && rzup install && source /home/runner/.bashrc + # - name: test mempool + # if: success() || failure() + # run: cargo test -p mempool + # - name: test storage + # if: success() || failure() + # run: cargo test -p storage + # - name: test zkvm + # if: success() || failure() + # run: cargo test -p zkvm From f5f9e406eaeaa703af3179e9cac483033cd523f9 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 25 Nov 2024 08:07:53 +0200 Subject: [PATCH 14/19] fix: ci test 4 --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++-------- ci_scripts/build-macos.sh | 4 ++++ 2 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 ci_scripts/build-macos.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1f4ef4..21a6889 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,15 +14,11 @@ on: name: General jobs: - build: - strategy: - matrix: - # platform: [ ubuntu-latest, macos-latest ] - platform: [ ubuntu-latest ] - runs-on: ${{ matrix.platform }} + build-ubuntu-latest: + runs-on: ubuntu-latest timeout-minutes: 60 - name: build - ${{ matrix.platform }} + name: build - ubuntu-latest steps: - uses: actions/checkout@v3 - name: Install stable toolchain @@ -31,10 +27,28 @@ jobs: profile: minimal toolchain: nightly override: true - - name: build - ${{ matrix.platform }} test + - name: build - ubuntu-latest if: success() || failure() run: chmod 777 ./ci_scripts/build-ubuntu.sh && ./ci_scripts/build-ubuntu.sh + + build-macos-latest: + runs-on: macos-latest + timeout-minutes: 60 + + name: build - macos-latest + steps: + - uses: actions/checkout@v3 + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + - name: build - macos-latest + if: success() || failure() + run: chmod 777 ./ci_scripts/build-macos.sh && ./ci_scripts/build-macos.sh + # lint: # strategy: # matrix: diff --git a/ci_scripts/build-macos.sh b/ci_scripts/build-macos.sh new file mode 100644 index 0000000..506fec6 --- /dev/null +++ b/ci_scripts/build-macos.sh @@ -0,0 +1,4 @@ +set -e +curl -L https://risczero.com/install | bash +/Users/.risc0/bin/rzup install +cargo build \ No newline at end of file From 57045a68ac3a90fcff9933e9366dda3e6a8153b5 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 25 Nov 2024 08:13:30 +0200 Subject: [PATCH 15/19] fix: ci test 5 --- .github/workflows/ci.yml | 63 ++++++++++++++------------------------- ci_scripts/build-macos.sh | 2 +- ci_scripts/lint-ubuntu.sh | 9 ++++++ 3 files changed, 32 insertions(+), 42 deletions(-) create mode 100644 ci_scripts/lint-ubuntu.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21a6889..715b985 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,48 +49,29 @@ jobs: if: success() || failure() run: chmod 777 ./ci_scripts/build-macos.sh && ./ci_scripts/build-macos.sh - # lint: - # strategy: - # matrix: - # platform: [ ubuntu-latest ] - # runs-on: ${{ matrix.platform }} - # timeout-minutes: 60 + lint: + strategy: + matrix: + platform: [ ubuntu-latest ] + runs-on: ${{ matrix.platform }} + timeout-minutes: 60 + + name: lint - ${{ matrix.crate }} - ${{ matrix.platform }} + steps: + - name: Checkout sources + uses: actions/checkout@v3 + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt, clippy + - name: lint - ubuntu-latest + if: success() || failure() + run: chmod 777 ./ci_scripts/lint-ubuntu.sh && ./ci_scripts/lint-ubuntu.sh + - # name: lint - ${{ matrix.crate }} - ${{ matrix.platform }} - # steps: - # - name: Checkout sources - # uses: actions/checkout@v3 - # - name: Install stable toolchain - # uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # toolchain: nightly - # override: true - # components: rustfmt, clippy - # - uses: Swatinem/rust-cache@v2 - # - name: cargo fmt - # if: success() || failure() - # run: cargo fmt -- --check - # - name: cargo clippy - # if: success() || failure() - # run: | - # cargo clippy --release -- -D warnings - # - name: install risc0 - # if: success() || failure() - # run: | - # curl -L https://risczero.com/install | bash - # - name: install risc0 step 2 - # if: success() || failure() - # run: | - # source /home/runner/.bashrc && rzup install && source /home/runner/.bashrc - # - name: install taplo - # if: success() || failure() - # run: | - # cargo install taplo-cli --locked - # - name: taplo fmt - # if: success() || failure() - # run: | - # taplo fmt --check # test: # strategy: # matrix: diff --git a/ci_scripts/build-macos.sh b/ci_scripts/build-macos.sh index 506fec6..e3332f6 100644 --- a/ci_scripts/build-macos.sh +++ b/ci_scripts/build-macos.sh @@ -1,4 +1,4 @@ set -e curl -L https://risczero.com/install | bash -/Users/.risc0/bin/rzup install +/Users/runner/.risc0/bin/rzup install cargo build \ No newline at end of file diff --git a/ci_scripts/lint-ubuntu.sh b/ci_scripts/lint-ubuntu.sh new file mode 100644 index 0000000..e139cdd --- /dev/null +++ b/ci_scripts/lint-ubuntu.sh @@ -0,0 +1,9 @@ +set -e + +curl -L https://risczero.com/install | bash +/home/runner/.risc0/bin/rzup install +cargo install taplo-cli --locked + +cargo fmt -- --check +cargo clippy --release -- -D warnings +taplo fmt --check \ No newline at end of file From 765ad6e60b5213e0c12e4c2e41315e7df37db926 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 25 Nov 2024 10:37:49 +0200 Subject: [PATCH 16/19] fix: ci test 6 --- ci_scripts/lint-ubuntu.sh | 40 +++++++++++++++++++++++++++++++++++++++ zkvm/src/lib.rs | 4 ++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ci_scripts/lint-ubuntu.sh b/ci_scripts/lint-ubuntu.sh index e139cdd..9275065 100644 --- a/ci_scripts/lint-ubuntu.sh +++ b/ci_scripts/lint-ubuntu.sh @@ -5,5 +5,45 @@ curl -L https://risczero.com/install | bash cargo install taplo-cli --locked cargo fmt -- --check + +cd accounts cargo clippy --release -- -D warnings +cd .. + +cd consensus +cargo clippy --release -- -D warnings +cd .. + +cd mempool +cargo clippy --release -- -D warnings +cd .. + +cd networking +cargo clippy --release -- -D warnings +cd .. + +cd rpc_primitives +cargo clippy --release -- -D warnings +cd .. + +cd sequencer_core +cargo clippy --release -- -D warnings +cd .. + +cd sequencer_rpc +cargo clippy --release -- -D warnings +cd .. + +cd sequencer_runner +cargo clippy --release -- -D warnings +cd .. + +cd storage +cargo clippy --release -- -D warnings +cd .. + +cd utxo +cargo clippy --release -- -D warnings +cd .. + taplo fmt --check \ No newline at end of file diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index 3b2b4ba..14841d3 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -48,9 +48,9 @@ pub fn verify(receipt: Receipt, image_id: impl Into) { #[cfg(test)] mod tests { use super::*; + use test_methods::{BIG_CALCULATION_ELF, BIG_CALCULATION_ID}; use test_methods::{MULTIPLICATION_ELF, MULTIPLICATION_ID}; use test_methods::{SUMMATION_ELF, SUMMATION_ID}; - use test_methods::{BIG_CALCULATION_ELF, BIG_CALCULATION_ID}; #[test] fn prove_simple_sum() { @@ -140,5 +140,5 @@ mod tests { } res - } + } } From b249a50a342f3cb0fa088dcf34f34fad98cbb646 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 25 Nov 2024 11:02:57 +0200 Subject: [PATCH 17/19] fix: ci test 7 --- .github/workflows/ci.yml | 53 ++++++++++++++------------------------- ci_scripts/lint-ubuntu.sh | 41 ------------------------------ ci_scripts/test-ubuntu.sh | 6 +++++ 3 files changed, 25 insertions(+), 75 deletions(-) create mode 100644 ci_scripts/test-ubuntu.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 715b985..4f0d53e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,38 +72,23 @@ jobs: run: chmod 777 ./ci_scripts/lint-ubuntu.sh && ./ci_scripts/lint-ubuntu.sh - # test: - # strategy: - # matrix: - # platform: [ ubuntu-latest ] - # runs-on: ${{ matrix.platform }} - # timeout-minutes: 60 + test: + strategy: + matrix: + platform: [ ubuntu-latest ] + runs-on: ${{ matrix.platform }} + timeout-minutes: 60 - # name: test - ${{ matrix.crate }} - ${{ matrix.platform }} - # steps: - # - name: Checkout sources - # uses: actions/checkout@v3 - # - name: Install stable toolchain - # uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # toolchain: nightly - # override: true - # - uses: Swatinem/rust-cache@v2 - # - name: install risc0 - # if: success() || failure() - # run: | - # curl -L https://risczero.com/install | bash - # - name: install risc0 step 2 - # if: success() || failure() - # run: | - # source /home/runner/.bashrc && rzup install && source /home/runner/.bashrc - # - name: test mempool - # if: success() || failure() - # run: cargo test -p mempool - # - name: test storage - # if: success() || failure() - # run: cargo test -p storage - # - name: test zkvm - # if: success() || failure() - # run: cargo test -p zkvm + name: test - ${{ matrix.crate }} - ${{ matrix.platform }} + steps: + - name: Checkout sources + uses: actions/checkout@v3 + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + - name: test ubuntu-latest + if: success() || failure() + run: chmod 777 ./ci_scripts/test-ubuntu.sh && ./ci_scripts/test-ubuntu.sh diff --git a/ci_scripts/lint-ubuntu.sh b/ci_scripts/lint-ubuntu.sh index 9275065..6f71b24 100644 --- a/ci_scripts/lint-ubuntu.sh +++ b/ci_scripts/lint-ubuntu.sh @@ -5,45 +5,4 @@ curl -L https://risczero.com/install | bash cargo install taplo-cli --locked cargo fmt -- --check - -cd accounts -cargo clippy --release -- -D warnings -cd .. - -cd consensus -cargo clippy --release -- -D warnings -cd .. - -cd mempool -cargo clippy --release -- -D warnings -cd .. - -cd networking -cargo clippy --release -- -D warnings -cd .. - -cd rpc_primitives -cargo clippy --release -- -D warnings -cd .. - -cd sequencer_core -cargo clippy --release -- -D warnings -cd .. - -cd sequencer_rpc -cargo clippy --release -- -D warnings -cd .. - -cd sequencer_runner -cargo clippy --release -- -D warnings -cd .. - -cd storage -cargo clippy --release -- -D warnings -cd .. - -cd utxo -cargo clippy --release -- -D warnings -cd .. - taplo fmt --check \ No newline at end of file diff --git a/ci_scripts/test-ubuntu.sh b/ci_scripts/test-ubuntu.sh new file mode 100644 index 0000000..53fc7bc --- /dev/null +++ b/ci_scripts/test-ubuntu.sh @@ -0,0 +1,6 @@ +set -e + +curl -L https://risczero.com/install | bash +/home/runner/.risc0/bin/rzup install + +cargo test --release \ No newline at end of file From 293dbd95db5a7eb660a9b505eceac99613f818c5 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 25 Nov 2024 11:25:33 +0200 Subject: [PATCH 18/19] fix: ci test 8 --- .github/workflows/ci.yml | 108 +++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f0d53e..3d58b9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,22 +14,22 @@ on: name: General jobs: - build-ubuntu-latest: - runs-on: ubuntu-latest - timeout-minutes: 60 + # build-ubuntu-latest: + # runs-on: ubuntu-latest + # timeout-minutes: 60 - name: build - ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - name: build - ubuntu-latest - if: success() || failure() - run: chmod 777 ./ci_scripts/build-ubuntu.sh && ./ci_scripts/build-ubuntu.sh + # name: build - ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - name: Install stable toolchain + # uses: actions-rs/toolchain@v1 + # with: + # profile: minimal + # toolchain: nightly + # override: true + # - name: build - ubuntu-latest + # if: success() || failure() + # run: chmod 777 ./ci_scripts/build-ubuntu.sh && ./ci_scripts/build-ubuntu.sh build-macos-latest: @@ -49,46 +49,46 @@ jobs: if: success() || failure() run: chmod 777 ./ci_scripts/build-macos.sh && ./ci_scripts/build-macos.sh - lint: - strategy: - matrix: - platform: [ ubuntu-latest ] - runs-on: ${{ matrix.platform }} - timeout-minutes: 60 + # lint: + # strategy: + # matrix: + # platform: [ ubuntu-latest ] + # runs-on: ${{ matrix.platform }} + # timeout-minutes: 60 - name: lint - ${{ matrix.crate }} - ${{ matrix.platform }} - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - components: rustfmt, clippy - - name: lint - ubuntu-latest - if: success() || failure() - run: chmod 777 ./ci_scripts/lint-ubuntu.sh && ./ci_scripts/lint-ubuntu.sh + # name: lint - ${{ matrix.crate }} - ${{ matrix.platform }} + # steps: + # - name: Checkout sources + # uses: actions/checkout@v3 + # - name: Install stable toolchain + # uses: actions-rs/toolchain@v1 + # with: + # profile: minimal + # toolchain: nightly + # override: true + # components: rustfmt, clippy + # - name: lint - ubuntu-latest + # if: success() || failure() + # run: chmod 777 ./ci_scripts/lint-ubuntu.sh && ./ci_scripts/lint-ubuntu.sh - test: - strategy: - matrix: - platform: [ ubuntu-latest ] - runs-on: ${{ matrix.platform }} - timeout-minutes: 60 + # test: + # strategy: + # matrix: + # platform: [ ubuntu-latest ] + # runs-on: ${{ matrix.platform }} + # timeout-minutes: 60 - name: test - ${{ matrix.crate }} - ${{ matrix.platform }} - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - name: test ubuntu-latest - if: success() || failure() - run: chmod 777 ./ci_scripts/test-ubuntu.sh && ./ci_scripts/test-ubuntu.sh + # name: test - ${{ matrix.crate }} - ${{ matrix.platform }} + # steps: + # - name: Checkout sources + # uses: actions/checkout@v3 + # - name: Install stable toolchain + # uses: actions-rs/toolchain@v1 + # with: + # profile: minimal + # toolchain: nightly + # override: true + # - name: test ubuntu-latest + # if: success() || failure() + # run: chmod 777 ./ci_scripts/test-ubuntu.sh && ./ci_scripts/test-ubuntu.sh From b640471da871798dbcdd111c5988559ca9613326 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Mon, 25 Nov 2024 11:27:42 +0200 Subject: [PATCH 19/19] fix: ci test 9 --- .github/workflows/ci.yml | 111 +++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 64 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d58b9a..b717c10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,29 +14,11 @@ on: name: General jobs: - # build-ubuntu-latest: - # runs-on: ubuntu-latest - # timeout-minutes: 60 - - # name: build - ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - name: Install stable toolchain - # uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # toolchain: nightly - # override: true - # - name: build - ubuntu-latest - # if: success() || failure() - # run: chmod 777 ./ci_scripts/build-ubuntu.sh && ./ci_scripts/build-ubuntu.sh - - - build-macos-latest: - runs-on: macos-latest + build-ubuntu-latest: + runs-on: ubuntu-latest timeout-minutes: 60 - name: build - macos-latest + name: build - ubuntu-latest steps: - uses: actions/checkout@v3 - name: Install stable toolchain @@ -45,50 +27,51 @@ jobs: profile: minimal toolchain: nightly override: true - - name: build - macos-latest + - name: build - ubuntu-latest if: success() || failure() - run: chmod 777 ./ci_scripts/build-macos.sh && ./ci_scripts/build-macos.sh - - # lint: - # strategy: - # matrix: - # platform: [ ubuntu-latest ] - # runs-on: ${{ matrix.platform }} - # timeout-minutes: 60 - - # name: lint - ${{ matrix.crate }} - ${{ matrix.platform }} - # steps: - # - name: Checkout sources - # uses: actions/checkout@v3 - # - name: Install stable toolchain - # uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # toolchain: nightly - # override: true - # components: rustfmt, clippy - # - name: lint - ubuntu-latest - # if: success() || failure() - # run: chmod 777 ./ci_scripts/lint-ubuntu.sh && ./ci_scripts/lint-ubuntu.sh + run: chmod 777 ./ci_scripts/build-ubuntu.sh && ./ci_scripts/build-ubuntu.sh - # test: - # strategy: - # matrix: - # platform: [ ubuntu-latest ] - # runs-on: ${{ matrix.platform }} - # timeout-minutes: 60 + lint: + strategy: + matrix: + platform: [ ubuntu-latest ] + runs-on: ${{ matrix.platform }} + timeout-minutes: 60 - # name: test - ${{ matrix.crate }} - ${{ matrix.platform }} - # steps: - # - name: Checkout sources - # uses: actions/checkout@v3 - # - name: Install stable toolchain - # uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # toolchain: nightly - # override: true - # - name: test ubuntu-latest - # if: success() || failure() - # run: chmod 777 ./ci_scripts/test-ubuntu.sh && ./ci_scripts/test-ubuntu.sh + name: lint - ${{ matrix.crate }} - ${{ matrix.platform }} + steps: + - name: Checkout sources + uses: actions/checkout@v3 + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt, clippy + - name: lint - ubuntu-latest + if: success() || failure() + run: chmod 777 ./ci_scripts/lint-ubuntu.sh && ./ci_scripts/lint-ubuntu.sh + + + test: + strategy: + matrix: + platform: [ ubuntu-latest ] + runs-on: ${{ matrix.platform }} + timeout-minutes: 60 + + name: test - ${{ matrix.crate }} - ${{ matrix.platform }} + steps: + - name: Checkout sources + uses: actions/checkout@v3 + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + - name: test ubuntu-latest + if: success() || failure() + run: chmod 777 ./ci_scripts/test-ubuntu.sh && ./ci_scripts/test-ubuntu.sh