Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade sp1 to 4.0.0 #51

Merged
merged 6 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 'mock' for generating mock proofs locally, 'local' for generating proofs locally, 'network' for generating proofs using the proving network.
SP1_PROVER=local
# If using the proving network, set to your whitelisted private key. For more information, see:
# https://docs.succinct.xyz/prover-network/setup.html#key-setup
SP1_PRIVATE_KEY=
# https://docs.succinct.xyz/docs/generating-proofs/prover-network/key-setup
NETWORK_PRIVATE_KEY=
86 changes: 42 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,28 @@ inside Solidity.

### Retrieve the Verification Key

To retrieve your `programVKey` for your on-chain contract, run the following command:
To retrieve your `programVKey` for your on-chain contract, run the following command in `script`:

```sh
cargo prove vkey --program fibonacci-program
cargo run --release --bin vkey
```

## Using the Prover Network

We highly recommend using the Succinct prover network for any non-trivial programs or benchmarking purposes. For more information, see the [setup guide](https://docs.succinct.xyz/generating-proofs/prover-network.html).
We highly recommend using the Succinct prover network for any non-trivial programs or benchmarking purposes. For more information, see the [setup guide](https://docs.succinct.xyz/docs/generating-proofs/prover-network).

To get started, copy the example environment file:

```sh
cp .env.example .env
```

Then, set the `SP1_PROVER` environment variable to `network` and set the `SP1_PRIVATE_KEY`
Then, set the `SP1_PROVER` environment variable to `network` and set the `NETWORK_PRIVATE_KEY`
environment variable to your whitelisted private key.

For example, to generate an EVM-compatible proof using the prover network, run the following
command:

```sh
SP1_PROVER=network SP1_PRIVATE_KEY=... cargo run --release --bin evm
SP1_PROVER=network NETWORK_PRIVATE_KEY=... cargo run --release --bin evm
```
2 changes: 1 addition & 1 deletion contracts/lib/forge-std
2 changes: 1 addition & 1 deletion contracts/lib/sp1-contracts
Submodule sp1-contracts updated 44 files
+1,390 −1,573 Cargo.lock
+1 −1 Cargo.toml
+21 −10 README.md
+3 −2 contracts/deployments/1.json
+3 −2 contracts/deployments/10.json
+3 −2 contracts/deployments/11155111.json
+3 −2 contracts/deployments/11155420.json
+3 −2 contracts/deployments/17000.json
+3 −2 contracts/deployments/42161.json
+3 −2 contracts/deployments/421614.json
+3 −2 contracts/deployments/534351.json
+3 −2 contracts/deployments/534352.json
+3 −2 contracts/deployments/8453.json
+3 −2 contracts/deployments/84532.json
+21 −0 contracts/script/deploy/SP1VerifierGatewayGroth16.s.sol
+1 −1 contracts/script/deploy/SP1VerifierGatewayPlonk.s.sol
+2 −2 contracts/script/deploy/v1.0.1/SP1Verifier.s.sol
+2 −2 contracts/script/deploy/v1.0.7-testnet/SP1Verifier.s.sol
+2 −2 contracts/script/deploy/v1.0.8-testnet/SP1Verifier.s.sol
+2 −2 contracts/script/deploy/v1.1.0/SP1Verifier.s.sol
+2 −2 contracts/script/deploy/v1.2.0-rc1/SP1VerifierGroth16.s.sol
+2 −2 contracts/script/deploy/v1.2.0-rc1/SP1VerifierPlonk.s.sol
+2 −2 contracts/script/deploy/v1.2.0/SP1VerifierGroth16.s.sol
+2 −2 contracts/script/deploy/v1.2.0/SP1VerifierPlonk.s.sol
+2 −2 contracts/script/deploy/v2.0.0/SP1VerifierGroth16.s.sol
+2 −2 contracts/script/deploy/v2.0.0/SP1VerifierPlonk.s.sol
+2 −2 contracts/script/deploy/v3.0.0-rc1/SP1VerifierGroth16.s.sol
+2 −2 contracts/script/deploy/v3.0.0-rc1/SP1VerifierPlonk.s.sol
+2 −2 contracts/script/deploy/v3.0.0-rc3/SP1VerifierGroth16.s.sol
+2 −2 contracts/script/deploy/v3.0.0-rc3/SP1VerifierPlonk.s.sol
+2 −2 contracts/script/deploy/v3.0.0-rc4/SP1VerifierGroth16.s.sol
+2 −2 contracts/script/deploy/v3.0.0-rc4/SP1VerifierPlonk.s.sol
+2 −2 contracts/script/deploy/v3.0.0/SP1VerifierGroth16.s.sol
+2 −2 contracts/script/deploy/v3.0.0/SP1VerifierPlonk.s.sol
+38 −0 contracts/script/deploy/v4.0.0-rc.3/SP1VerifierGroth16.s.sol
+38 −0 contracts/script/deploy/v4.0.0-rc.3/SP1VerifierPlonk.s.sol
+1 −1 contracts/src/SP1MockVerifier.sol
+1 −1 contracts/src/SP1VerifierGateway.sol
+1 −1 contracts/src/v3.0.0/Groth16Verifier.sol
+578 −0 contracts/src/v4.0.0-rc.3/Groth16Verifier.sol
+1,379 −0 contracts/src/v4.0.0-rc.3/PlonkVerifier.sol
+57 −0 contracts/src/v4.0.0-rc.3/SP1VerifierGroth16.sol
+59 −0 contracts/src/v4.0.0-rc.3/SP1VerifierPlonk.sol
+1 −1 rust-toolchain
4 changes: 2 additions & 2 deletions contracts/src/fixtures/groth16-fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"a": 6765,
"b": 10946,
"n": 20,
"vkey": "0x00467584e2e560847e9e96b5102c082f5e07155429c6622988799df9d95dbb47",
"vkey": "0x005aa1cbc05f992604b4f375159054d79b76501cf214b1fec6724ea14eceaf78",
"publicValues": "0x00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000001a6d0000000000000000000000000000000000000000000000000000000000002ac2",
"proof": "0x090690900091bc3f08015e1ed96bee4e8c7a3ab074bfaa54129b1c63a9c6e478ec63255d3028cceaeed53e04bf0ee42f58ff0980ff00212e52a2a1d85b69b1268f5030820bc4589b0566e8a3f0738fa64405c10ee7347e58afbf4f1f431b327e5ba522c32f83c0c6e9e5bc37dfe2b31ae2bead89e0c7d8a0df1226b005d75f2e252b104a030d532c73f896df2328ce3322c055bda3b979dda22568ef85761b1d82bdcbec230f2838693d3663a0bd00006fa0f0dd4ea0e14b8b44273b0e8575e5478fa8d92a910cc26e0cdff4869f3fac686f91d245839368dbeadc9daaa4062ad1b3772523b284a3c41d60328f30461e03a465f4d6ec8d0fdfeeba176b8d0c7c82167c18"
"proof": "0x11b6a09d26e2118c306f7c64b4445c077f90764aaf4c3f0b5195ab76135914a2ba0e62be02216ef9ee42db956a50745c57dc6754a616995e6df07f027b32aafd83d9a9c30d129ff8fd534a67fe6a2fa1807f49e3045f8e85269fc90880da3a8063c45d500228c65c2772dd994f30db4ecb6745ab63ef7ea6e8b3ef6e9b600db7330b95c30a2ad71b04e752d8a045e15f803c3be01c0816f07823471294f204bc876d652f189720fa96d811da3e9d83acf730fef4da8bfd685530dd3867190e26e1ccf4d81b68ff5cf9bb36c36d522eac43653f7c3be5a3f022b680983fb04495633146062481a668712b472d6f18ac56f0eda3fedc9a5ee38d3679ef4aa4b3ea9e6208b7"
}
4 changes: 2 additions & 2 deletions contracts/src/fixtures/plonk-fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"a": 6765,
"b": 10946,
"n": 20,
"vkey": "0x00467584e2e560847e9e96b5102c082f5e07155429c6622988799df9d95dbb47",
"vkey": "0x005aa1cbc05f992604b4f375159054d79b76501cf214b1fec6724ea14eceaf78",
"publicValues": "0x00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000001a6d0000000000000000000000000000000000000000000000000000000000002ac2",
"proof": "0x54bdcae32122ba5d63ecb7d08cf7e217531928202417f27aa006e67ab53721eb386323bd1548e7a98de06f907d6067c9069866a6e8ca4a81a8553566abee9c2903efec8d0d3a52e9e717313d6fb5076bf3865cd8705a40b2613563b1d10f13adbeced54b179c997b00339169940341b4bb6ea21cd43992779b03e9a17fe6925f6273774e1b37fe45304344f3c66efee0b283cc6f8bb5d50e1f711d869080191284b5b93d10eafd8c57fab7d77ff15918e5e7fd93ed7ae6edc8629464aee148934e719c761e932ac3e956d05c70f9f2d2145c0b72f5e96127311b0b5ff805683091ec1f391beaffe65cf81e0613902331c700fcb0659c0c57e2f5d48d7e4eec04309060221f29322fc530473f367d34f38b47747afd4397acf8f75219ed6d393a468822b5152de3687df40b6ffebe49fbf0ceda8b54042283e454586875bb602b26a1175e165bdd7b6f29206896396e864904bb3cf5d375c84f311e5c557918dedccf27c30f43b11922ac6c9c0901634269de7d8ec9543ff834167149db30cd87b5c00c8d28cabf65079b6be84e5d013f514775e16d078215751f30547561ded0d2af784c0cbefb1fbd6149c09ed6eb0844265b1b0d038acd6b389cba9b3d6335e31567c706acf8cb896be0b70ce13eeb65990e69e29a48b85de56e2cda40d154034633f321f266a6af27e1adebe64e89a451bbeabb5fc0d9cf22c66c76710f599f39434b12f8ce865dda948710bed1755df69588eb5b0c21fb0f929b1bff7b7358c4cb1c271a65be960be28f2af49f3be51ddd6a4e552a3c1bb57204cd020d1057ae15602a43eb67628c5697ef5b181ded7e76a1f26997bca92ba31ef7337b63326a31cb1a13ec5b1d81605d83dbbf17f9699ebe3f2a2afa211dd09cf5de084d29ab28c212d9017f24ce6697e36d8c84b82970e1dedf5c74a821b73fce661c2a0bf1408f2c557c0e8962ad59cca1931cb276d3566e6f4a9411102cbf486c83aced09563d22a891e9abd3b6cee11963269c1f32f6131e97852584736ca8dbf7c6f9e34f660f79c2b9cd21515608ccc90af5e5689df83f623c08bc49284d93d4cfbf4ca60c2e2d8c1cb71195ac41b0788267d5af7092b421963519a1bb2e23774e7648344b19334175fa8031c8562bfb5209242b0a35282cbc7d05f96f4bf24318b6c37f0727f359fd9cf136abc923abbffc906a32cfb0e6d16ce61cc2d20748c2460f6844"
"proof": "0x1b34fe110b653a5bb2e727aacca6d4c9de41249fbd7586b9aa02af98399a3b3fd1666cec0c8473bae000e399aecaab29ecd01dcf66e08e638a7a7bae517ef9ed22be23df12c942a19b734fba23b60c1bbd9abca4f98c56dc118a0fc872ae921b54438e25185909e44fd21ab07cebba1de255741b72e8bad0620f05aebad4f765b1cbba112b4379c851beaac58afb53b98ff31dc9292c0163fdac2068608f197ff0be1c050857edec30d56a0373109031afc35e54b0b6383ee7944c8e3f1d08040fc0f5721fb16d8af362b7aff5855d2f6c4a843003a7b8020728114de8e4ef6dedbd532b1f7e65dbf48e8cc592cf8163f5de468e24e904d67b7ae3f58f7edc14fc38a60317b175cd23772ca939ffd13e9d7390cb4c811384d746fa874d4a84117c25c3ab2e124b51764997fefd97605bdfcf60f634bd0d3f47efb8d68ac077b8cac612bb15e2d52dc1662680acd46432e3415dbc936673a0060164f80d2a55d6e6a0eec709f763b91500f52ae86229b6f155aa7aa4a6350373b459027d959fbc8eeabc2d04a1e18f91b62d4094a6279def15868b9f01ed81be16b65e607f7eeb938c1018276c666be3300a1de112fbf3e3ebdf49c9daffab4711a11fecca183830639bbb1bfc81381e005f2c1d7702b2cc579719a32a2e8b8144cded8f19edb24ad709a01a49867454a0e9fe6253dbb04b4fd9484b2a2fa10fa974ff327b93ccf6f71a61061c2fd03794cb3badac3326b32467122480cf2810135832b89f8891248ff1c8035256d4e18515e1986d0995e6d945b02e88cace743fe19b86e7ac366c8448fb1dee3630fb6f57be5abded070ed4f04af597886e4d8f5188bcfb1d9fbca9f45b2223d5821917f386acf5ce74098e52f971257b5ad06039311e85f2bf4d3f6a7f300548634ba8c77666ad320f998cf42e6efa3fb84571959d055b394a7b9ede590ce87fda92632f6ece014fb9bd9b3ea3a919fc7139bc59003fa9f33a4342f46e2ca3d09e3d10af3d06906af1fea935bb06143d7525daa6a0cd5352d098d9af7c196d44286c029bf773f5dd8bcee23b60c44c2f7632224b880d4b856a9aaa0e832e2be26a5eb31a4f3697fdac727722eb76da934054937d29f44a01959fd571332a58e27cc753247c57817b338e30397fecff0fe609f6dae12cd54aae72a55ce60d46b7bb14ceba9b0e69f35be38547f7a3f71dbaea85459449daa1353f338fcf"
}
45 changes: 44 additions & 1 deletion contracts/test/Fibonacci.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,50 @@ struct SP1ProofFixtureJson {
bytes32 vkey;
}

contract FibonacciTest is Test {
contract FibonacciGroth16Test is Test {
using stdJson for string;

address verifier;
Fibonacci public fibonacci;

function loadFixture() public view returns (SP1ProofFixtureJson memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/src/fixtures/groth16-fixture.json");
string memory json = vm.readFile(path);
bytes memory jsonBytes = json.parseRaw(".");
return abi.decode(jsonBytes, (SP1ProofFixtureJson));
}

function setUp() public {
SP1ProofFixtureJson memory fixture = loadFixture();

verifier = address(new SP1VerifierGateway(address(1)));
fibonacci = new Fibonacci(verifier, fixture.vkey);
}

function test_ValidFibonacciProof() public {
SP1ProofFixtureJson memory fixture = loadFixture();

vm.mockCall(verifier, abi.encodeWithSelector(SP1VerifierGateway.verifyProof.selector), abi.encode(true));

(uint32 n, uint32 a, uint32 b) = fibonacci.verifyFibonacciProof(fixture.publicValues, fixture.proof);
assert(n == fixture.n);
assert(a == fixture.a);
assert(b == fixture.b);
}

function testFail_InvalidFibonacciProof() public view {
SP1ProofFixtureJson memory fixture = loadFixture();

// Create a fake proof.
bytes memory fakeProof = new bytes(fixture.proof.length);

fibonacci.verifyFibonacciProof(fixture.publicValues, fakeProof);
}
}


contract FibonacciPlonkTest is Test {
using stdJson for string;

address verifier;
Expand Down
2 changes: 1 addition & 1 deletion program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ edition = "2021"

[dependencies]
alloy-sol-types = { workspace = true }
sp1-zkvm = "4.0.0-rc.11"
sp1-zkvm = "4.0.0"
fibonacci-lib = { path = "../lib" }
9 changes: 7 additions & 2 deletions script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ path = "src/bin/main.rs"
name = "evm"
path = "src/bin/evm.rs"

[[bin]]
name = "vkey"
path = "src/bin/vkey.rs"

[dependencies]
sp1-sdk = "4.0.0-rc.11"
sp1-sdk = "4.0.0"
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
serde = { version = "1.0.200", default-features = false, features = ["derive"] }
clap = { version = "4.0", features = ["derive", "env"] }
tracing = "0.1.40"
hex = "0.4.3"
alloy-sol-types = { workspace = true }
fibonacci-lib = { path = "../lib" }
dotenv = "0.15.0"

[build-dependencies]
sp1-helper = "4.0.0-rc.11"
sp1-build = "4.0.0"
2 changes: 1 addition & 1 deletion script/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use sp1_helper::build_program_with_args;
use sp1_build::build_program_with_args;

fn main() {
build_program_with_args("../program", Default::default())
Expand Down
Loading
Loading