-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathSP1VerifierGroth16Deployer.s.sol
More file actions
38 lines (30 loc) · 1.55 KB
/
SP1VerifierGroth16Deployer.s.sol
File metadata and controls
38 lines (30 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {BaseScript} from "../../lib/sp1-contracts/contracts/script/utils/Base.s.sol";
import {SP1Verifier} from "../../lib/sp1-contracts/contracts/src/v3.0.0/SP1VerifierGroth16.sol";
import {SP1VerifierGateway} from "../../lib/sp1-contracts/contracts/src/SP1VerifierGateway.sol";
import {ISP1VerifierWithHash} from "../../lib/sp1-contracts/contracts/src/ISP1Verifier.sol";
contract SP1VerifierScript is BaseScript {
string internal constant KEY = "V3_0_0_SP1_VERIFIER_GROTH16";
function run() external multichain(KEY) broadcaster {
// Read config
bytes32 CREATE2_SALT = readBytes32("CREATE2_SALT");
address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY_GROTH16");
// Deploy contract
address verifier = address(new SP1Verifier{salt: CREATE2_SALT}());
// Add the verifier to the gateway
SP1VerifierGateway gateway = SP1VerifierGateway(SP1_VERIFIER_GATEWAY);
gateway.addRoute(verifier);
// Write address
writeAddress(KEY, verifier);
}
function freeze() external multichain(KEY) broadcaster {
// Read config
address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY_GROTH16");
address SP1_VERIFIER = readAddress(KEY);
// Freeze the verifier on the gateway
SP1VerifierGateway gateway = SP1VerifierGateway(SP1_VERIFIER_GATEWAY);
bytes4 selector = bytes4(ISP1VerifierWithHash(SP1_VERIFIER).VERIFIER_HASH());
gateway.freezeRoute(selector);
}
}