Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: freeze testnet verifiers and add script #15

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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.
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
Loading