Skip to content

Commit

Permalink
feat: freeze testnet verifiers and add script
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam committed Jul 22, 2024
1 parent e8cfde8 commit ae210de
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 27 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -60,6 +62,18 @@ FOUNDRY_PROFILE=deploy forge script ./script/deploy/v1.0.8-testnet/SP1Verifier.s

Change `v1.0.8-testnet` to the desired version to add.

### Freezing Verifiers

> **BE CAREFUL** When a freezing a verifier. Once it is frozen, it cannot be unfrozen, and it can no longer be able to 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.

To re-verify already existing deployments, remove the `--broadcast` flag.

## For Developers: Integrate SP1 Contracts
Expand All @@ -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).
Binary file added audits/veridise.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions contracts/script/deploy/v1.0.0-rc1/SP1Verifier.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
}
}
12 changes: 12 additions & 0 deletions contracts/script/deploy/v1.0.7-testnet/SP1Verifier.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
}
}
12 changes: 12 additions & 0 deletions contracts/script/deploy/v1.0.8-testnet/SP1Verifier.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
}
}
26 changes: 0 additions & 26 deletions contracts/script/deploy/v1.0.9-testnet.rc2/SP1Verifier.s.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/script/utils/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

_;
}
Expand Down

0 comments on commit ae210de

Please sign in to comment.