Skip to content

Commit 61f45c9

Browse files
committed
Add deploy sp1 script
1 parent e62624b commit 61f45c9

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
import {BaseScript} from "./utils/Base.s.sol";
5+
import {SP1VerifierGateway} from "../../lib/sp1-contracts/contracts/src/SP1VerifierGateway.sol";
6+
7+
contract SP1VerifierGatewayScript is BaseScript {
8+
string internal constant KEY = "SP1_VERIFIER_GATEWAY_GROTH16";
9+
10+
function run() external multichain(KEY) broadcaster {
11+
// Read config
12+
bytes32 CREATE2_SALT = readBytes32("CREATE2_SALT");
13+
address OWNER = readAddress("OWNER");
14+
15+
// Deploy contract
16+
address gateway = address(new SP1VerifierGateway{salt: CREATE2_SALT}(OWNER));
17+
18+
// Write addresss
19+
writeAddress(KEY, gateway);
20+
}
21+
}
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 "../../lib/sp1-contracts/contracts/src/v3.0.0/SP1VerifierGroth16.sol";
6+
import {SP1VerifierGateway} from "../../lib/sp1-contracts/contracts/src/SP1VerifierGateway.sol";
7+
import {ISP1VerifierWithHash} from "../../lib/sp1-contracts/contracts/src/ISP1Verifier.sol";
8+
9+
contract SP1VerifierScript is BaseScript {
10+
string internal constant KEY = "V3_0_0_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_GROTH16");
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_GROTH16");
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Deploy Groth16 SP1 verifier gateway
2+
forge script script/deploy/SP1VerifierGatewayGroth16Deployer.s.sol:SP1VerifierGatewayScript \
3+
--rpc-url "http://localhost:8545" \
4+
--private-key "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a" \
5+
--broadcast
6+
7+
# Deploy Groth16 SP1 verifier
8+
forge script ./script/deploy/SP1VerifierGroth16Deployer.s.sol:SP1VerifierScript \
9+
--rpc-url "http://localhost:8545" \
10+
--private-key "0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6" \
11+
--broadcast \
12+
--verify --verifier etherscan --multi

0 commit comments

Comments
 (0)