diff --git a/README.md b/README.md index 1d05296..d7312d4 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ Then you can use the `forge script` command and specify the specific contract yo FOUNDRY_PROFILE=deploy forge script ./script/deploy/SP1VerifierGateway.s.sol:SP1VerifierGatewayScript --private-key $PRIVATE_KEY --verify --verifier etherscan --multi --broadcast ``` +### Adding Verifiers + To deploy a specific SP1 Verifier version and add it to the gateway, run: ```bash @@ -62,6 +64,18 @@ Change `v1.0.8-testnet` to the desired version to add. To re-verify already existing deployments, remove the `--broadcast` flag. +### Freezing Verifiers + +> **BE CAREFUL** When a freezing a verifier. Once it is frozen, it cannot be unfrozen, and it can no longer be routed to. + +To freeze a verifier on the gateway, run: + +```bash +FOUNDRY_PROFILE=deploy forge script ./script/deploy/v1.0.8-testnet/SP1Verifier.s.sol:SP1VerifierScript --private-key $PRIVATE_KEY --verify --verifier etherscan --multi --broadcast --sig "freeze()" +``` + +Change `v1.0.8-testnet` to the desired version to freeze. + ## For Developers: Integrate SP1 Contracts This repository contains the EVM contracts for verifying SP1 PLONK EVM proofs. @@ -73,3 +87,7 @@ Note: you should ensure that all the contracts are on Solidity version `0.8.20`. ## For Contributors To update the SP1 contracts, please refer to the [`update`](./UPDATE_CONTRACTS.md) file. + +## Security + +SP1 Contracts has undergone an audit from [Veridise](https://www.veridise.com/). The audit report is available [here](./audits). diff --git a/audits/veridise.pdf b/audits/veridise.pdf new file mode 100644 index 0000000..13be1c6 Binary files /dev/null and b/audits/veridise.pdf differ diff --git a/contracts/script/deploy/v1.0.0-rc1/SP1Verifier.s.sol b/contracts/script/deploy/v1.0.0-rc1/SP1Verifier.s.sol index 98712be..247d862 100644 --- a/contracts/script/deploy/v1.0.0-rc1/SP1Verifier.s.sol +++ b/contracts/script/deploy/v1.0.0-rc1/SP1Verifier.s.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.20; import {BaseScript} from "../../utils/Base.s.sol"; import {SP1Verifier} from "../../../src/v1.0.0-rc1/SP1Verifier.sol"; import {SP1VerifierGateway} from "../../../src/SP1VerifierGateway.sol"; +import {ISP1VerifierWithHash} from "../../../src/ISP1Verifier.sol"; contract SP1VerifierScript is BaseScript { string internal constant KEY = "V1_0_0_rc1_SP1_VERIFIER"; @@ -23,4 +24,15 @@ contract SP1VerifierScript is BaseScript { // Write address writeAddress(KEY, verifier); } + + function freeze() external multichain(KEY) broadcaster { + // Read config + address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY"); + 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); + } } diff --git a/contracts/script/deploy/v1.0.7-testnet/SP1Verifier.s.sol b/contracts/script/deploy/v1.0.7-testnet/SP1Verifier.s.sol index e6d1544..5f43674 100644 --- a/contracts/script/deploy/v1.0.7-testnet/SP1Verifier.s.sol +++ b/contracts/script/deploy/v1.0.7-testnet/SP1Verifier.s.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.20; import {BaseScript} from "../../utils/Base.s.sol"; import {SP1Verifier} from "../../../src/v1.0.7-testnet/SP1Verifier.sol"; import {SP1VerifierGateway} from "../../../src/SP1VerifierGateway.sol"; +import {ISP1VerifierWithHash} from "../../../src/ISP1Verifier.sol"; contract SP1VerifierScript is BaseScript { string internal constant KEY = "V1_0_7_TESTNET_SP1_VERIFIER"; @@ -23,4 +24,15 @@ contract SP1VerifierScript is BaseScript { // Write address writeAddress(KEY, verifier); } + + function freeze() external multichain(KEY) broadcaster { + // Read config + address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY"); + 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); + } } diff --git a/contracts/script/deploy/v1.0.8-testnet/SP1Verifier.s.sol b/contracts/script/deploy/v1.0.8-testnet/SP1Verifier.s.sol index 0d65cd4..2e547f3 100644 --- a/contracts/script/deploy/v1.0.8-testnet/SP1Verifier.s.sol +++ b/contracts/script/deploy/v1.0.8-testnet/SP1Verifier.s.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.20; import {BaseScript} from "../../utils/Base.s.sol"; import {SP1Verifier} from "../../../src/v1.0.8-testnet/SP1Verifier.sol"; import {SP1VerifierGateway} from "../../../src/SP1VerifierGateway.sol"; +import {ISP1VerifierWithHash} from "../../../src/ISP1Verifier.sol"; contract SP1VerifierScript is BaseScript { string internal constant KEY = "V1_0_8_TESTNET_SP1_VERIFIER"; @@ -23,4 +24,15 @@ contract SP1VerifierScript is BaseScript { // Write address writeAddress(KEY, verifier); } + + function freeze() external multichain(KEY) broadcaster { + // Read config + address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY"); + 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); + } } diff --git a/contracts/script/deploy/v1.0.9-testnet.rc2/SP1Verifier.s.sol b/contracts/script/deploy/v1.0.9-testnet.rc2/SP1Verifier.s.sol deleted file mode 100644 index 98712be..0000000 --- a/contracts/script/deploy/v1.0.9-testnet.rc2/SP1Verifier.s.sol +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -import {BaseScript} from "../../utils/Base.s.sol"; -import {SP1Verifier} from "../../../src/v1.0.0-rc1/SP1Verifier.sol"; -import {SP1VerifierGateway} from "../../../src/SP1VerifierGateway.sol"; - -contract SP1VerifierScript is BaseScript { - string internal constant KEY = "V1_0_0_rc1_SP1_VERIFIER"; - - function run() external multichain(KEY) broadcaster { - // Read config - bytes32 CREATE2_SALT = readBytes32("CREATE2_SALT"); - address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY"); - - // 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); - } -} diff --git a/contracts/script/utils/Base.s.sol b/contracts/script/utils/Base.s.sol index 7de1e9d..cdf3891 100644 --- a/contracts/script/utils/Base.s.sol +++ b/contracts/script/utils/Base.s.sol @@ -28,7 +28,7 @@ abstract contract BaseScript is Script { // Switch to the chain using the RPC vm.createSelectFork(chain); - console.log("Deploying %s to %s", KEY, chain); + console.log("Running %s script on %s", KEY, chain); _; }