Skip to content

Commit 1694126

Browse files
feat: v3.0.0-rc4 + simplify artifacts flow + better documentation (#30)
Co-authored-by: mattstam <codeguy0112358@gmail.com>
1 parent a6f13bf commit 1694126

14 files changed

+2267
-78
lines changed

Cargo.lock

Lines changed: 29 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ path = "src/bin/artifacts.rs"
1111
anyhow = "1.0.86"
1212
dotenv = "0.15.0"
1313
log = "0.4.21"
14-
sp1-sdk = "3.0.0-rc3"
14+
sp1-sdk = "3.0.0-rc4"

UPDATE_CONTRACTS.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
# Update SP1 Contracts with New SP1 Version
1+
# Add a new SP1 Version to `sp1-contracts`
22

33
This section outlines the steps required to update the SP1 contracts repository with a new SP1 version. Follow these instructions to ensure the SP1 contracts are correctly updated and aligned with the latest version.
44

5+
## Add SP1 Verifier Contracts
6+
7+
Let's add the verifier contracts for a new `sp1-sdk` tag.
8+
59
1. Change the version tag in `Cargo.toml` to the target `sp1` version.
610

711
```toml
@@ -15,11 +19,23 @@ sp1-sdk = "<SP1_TAG>"
1519
cargo update
1620

1721
cargo run --bin artifacts --release
22+
23+
...
24+
25+
[sp1] plonk circuit artifacts for version v3.0.0-rc4 do not exist at /Users/ratankaliani/.sp1/circuits/plonk/v3.0.0-rc4. downloading...
26+
⠦ [00:00:08] [#######>---------------------] 272.01 MiB/1.07 GiB (29.22 MiB/s, 28s)
1827
```
1928
20-
3. Open a PR to commit the changes to `main`.
21-
4. After merging to `main`, create a release tag with the same version as the `sp1` tag used.
29+
This will download the circuit artifacts for the SP1 version, and write the verifier contracts to `/contracts/src/{SP1_CIRCUIT_VERSION}`.
30+
31+
## Create a new release
32+
33+
For users to use the contracts associated with a specific `sp1-sdk` tag, we need to create a new release.
34+
35+
1. Open a PR to add the changes to `main`.
36+
2. After merging to `main`, create a release tag with the same version as the `sp1` tag used (e.g `2.0.0`). For release candidates (e.g. `v3.0.0-rc4`), the release tag should be a **pre-release** tag.
37+
3. Now users will be able to install contracts for this version with `forge install succinctlabs/sp1-contracts@VERSION`. By default, `forge install` will install the latest release.
2238
23-
## Miscellaneous
39+
## Appendix
2440
2541
The SP1 Solidity contract artifacts are included in each release of `sp1`. You can see how these are included in the `sp1` repository [here](https://github.com/succinctlabs/sp1/blob/21455d318ae383b317c92e10709bbfc313d8f1df/recursion/gnark-ffi/src/plonk_bn254.rs#L57-L96).

contracts/.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ ETHERSCAN_API_URL_BASE_SEPOLIA=https://api-sepolia.basescan.org/api
4444
ETHERSCAN_API_URL_OPTIMISM=https://api-optimistic.etherscan.io/api
4545
ETHERSCAN_API_URL_OPTIMISM_SEPOLIA=https://api-sepolia-optimistic.etherscan.io/api
4646
ETHERSCAN_API_URL_SCROLL=https://api.scrollscan.com/api
47-
ETHERSCAN_API_URL_SCROLL_SEPOLIA=https://api-sepolia.scrollscan.com/api
47+
ETHERSCAN_API_URL_SCROLL_SEPOLIA=https://api-sepolia.scrollscan.com/api
48+
49+
## Contract Deployer Private Key
50+
PRIVATE_KEY=

contracts/deployments/11155111.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
"V2_0_0_SP1_VERIFIER_PLONK": "0xaeE21CeadF7A03b3034DAE4f190bFE5F861b6ebf",
1313
"V3_0_0_RC1_SP1_VERIFIER_GROTH16": "0x8dB92f28D7C30154d38E55DbA1054b5A7Fc5A829",
1414
"V3_0_0_RC3_SP1_VERIFIER_GROTH16": "0x890E1c4ff98453f1201e5cB65F6C588FD28748b0",
15-
"V3_0_0_RC3_SP1_VERIFIER_PLONK": "0x31aeD863BecC509B9e16403c52C07560A0d4ecBf"
15+
"V3_0_0_RC3_SP1_VERIFIER_PLONK": "0x31aeD863BecC509B9e16403c52C07560A0d4ecBf",
16+
"V3_0_0_RC4_SP1_VERIFIER_GROTH16": "0xbEe24654bF5D675D88e504a0DC148022664Ce436",
17+
"V3_0_0_RC4_SP1_VERIFIER_PLONK": "0xAF58C8Feee48f9952A444cD897Fd16e99000a4E1"
1618
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
import {BaseScript} from "../../utils/Base.s.sol";
5+
import {SP1Verifier} from "../../../src/v3.0.0-rc4/SP1VerifierGroth16.sol";
6+
import {SP1VerifierGateway} from "../../../src/SP1VerifierGateway.sol";
7+
import {ISP1VerifierWithHash} from "../../../src/ISP1Verifier.sol";
8+
9+
contract SP1VerifierScript is BaseScript {
10+
string internal constant KEY = "V3_0_0_RC4_SP1_VERIFIER_GROTH16";
11+
12+
function run() external multichain(KEY) broadcaster {
13+
// Read config
14+
bytes32 CREATE2_SALT = readBytes32("CREATE2_SALT");
15+
address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY");
16+
17+
// Deploy contract
18+
address verifier = address(new SP1Verifier{salt: CREATE2_SALT}());
19+
20+
// Add the verifier to the gateway
21+
SP1VerifierGateway gateway = SP1VerifierGateway(SP1_VERIFIER_GATEWAY);
22+
gateway.addRoute(verifier);
23+
24+
// Write address
25+
writeAddress(KEY, verifier);
26+
}
27+
28+
function freeze() external multichain(KEY) broadcaster {
29+
// Read config
30+
address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY");
31+
address SP1_VERIFIER = readAddress(KEY);
32+
33+
// Freeze the verifier on the gateway
34+
SP1VerifierGateway gateway = SP1VerifierGateway(SP1_VERIFIER_GATEWAY);
35+
bytes4 selector = bytes4(ISP1VerifierWithHash(SP1_VERIFIER).VERIFIER_HASH());
36+
gateway.freezeRoute(selector);
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
import {BaseScript} from "../../utils/Base.s.sol";
5+
import {SP1Verifier} from "../../../src/v3.0.0-rc4/SP1VerifierPlonk.sol";
6+
import {SP1VerifierGateway} from "../../../src/SP1VerifierGateway.sol";
7+
import {ISP1VerifierWithHash} from "../../../src/ISP1Verifier.sol";
8+
9+
contract SP1VerifierScript is BaseScript {
10+
string internal constant KEY = "V3_0_0_RC4_SP1_VERIFIER_PLONK";
11+
12+
function run() external multichain(KEY) broadcaster {
13+
// Read config
14+
bytes32 CREATE2_SALT = readBytes32("CREATE2_SALT");
15+
address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY");
16+
17+
// Deploy contract
18+
address verifier = address(new SP1Verifier{salt: CREATE2_SALT}());
19+
20+
// Add the verifier to the gateway
21+
SP1VerifierGateway gateway = SP1VerifierGateway(SP1_VERIFIER_GATEWAY);
22+
gateway.addRoute(verifier);
23+
24+
// Write address
25+
writeAddress(KEY, verifier);
26+
}
27+
28+
function freeze() external multichain(KEY) broadcaster {
29+
// Read config
30+
address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY");
31+
address SP1_VERIFIER = readAddress(KEY);
32+
33+
// Freeze the verifier on the gateway
34+
SP1VerifierGateway gateway = SP1VerifierGateway(SP1_VERIFIER_GATEWAY);
35+
bytes4 selector = bytes4(ISP1VerifierWithHash(SP1_VERIFIER).VERIFIER_HASH());
36+
gateway.freezeRoute(selector);
37+
}
38+
}

0 commit comments

Comments
 (0)