Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
[submodule "claim_contracts/lib/openzeppelin-contracts"]
path = claim_contracts/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "contracts/lib/sp1-contracts"]
path = contracts/lib/sp1-contracts
url = https://github.com/succinctlabs/sp1-contracts
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ anvil_deploy_eigen_contracts:
@echo "Deploying Eigen Contracts..."
. contracts/scripts/anvil/deploy_eigen_contracts.sh

anvil_deploy_sp1_contracts:
@echo "Deploying SP1 Contracts..."
. contracts/scripts/anvil/deploy_sp1_contracts.sh

anvil_deploy_aligned_contracts:
@echo "Deploying Aligned Contracts..."
. contracts/scripts/anvil/deploy_aligned_contracts.sh
Expand Down
5 changes: 5 additions & 0 deletions contracts/deployments/31337.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"CREATE2_SALT": "0x0000000000000000000000000000000000000000000000000000000000000009",
"SP1_VERIFIER_GATEWAY_GROTH16": "0x3c380a84855AFe756E7FB33fe59ae81466B19027",
"V3_0_0_SP1_VERIFIER_GROTH16": "0x6e325f6cEC3EeBD6cC1b68d2a6e93342a161e174"
}
6 changes: 5 additions & 1 deletion contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ out = "out"
libs = ["lib"]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
fs_permissions = [{ access = "read-write", path = "./script/output"}, {access = "read", path = "./script/deploy"}]
fs_permissions = [
{ access = "read-write", path = "./script/output"},
{access = "read", path = "./script/deploy"},
{ access = "read-write", path = "./deployments"},
]
1 change: 1 addition & 0 deletions contracts/lib/sp1-contracts
Submodule sp1-contracts added at 26651f
1 change: 1 addition & 0 deletions contracts/remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ eigenlayer-scripts/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/script/
forge-std/=lib/forge-std/src/
@openzeppelin/contracts/=lib/eigenlayer-middleware/lib/openzeppelin-contracts/contracts/
@openzeppelin-upgrades/contracts/=lib/eigenlayer-middleware/lib/openzeppelin-contracts-upgradeable/contracts/
@sp1-contracts/=lib/sp1-contracts/contracts/src/
21 changes: 21 additions & 0 deletions contracts/script/deploy/SP1VerifierGatewayGroth16Deployer.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {BaseScript} from "../../lib/sp1-contracts/contracts/script/utils/Base.s.sol";
import {SP1VerifierGateway} from "../../lib/sp1-contracts/contracts/src/SP1VerifierGateway.sol";

contract SP1VerifierGatewayScript is BaseScript {
string internal constant KEY = "SP1_VERIFIER_GATEWAY_GROTH16";

function run() external multichain(KEY) broadcaster {
// Read config
bytes32 CREATE2_SALT = readBytes32("CREATE2_SALT");
address OWNER = readAddress("OWNER");

// Deploy contract
address gateway = address(new SP1VerifierGateway{salt: CREATE2_SALT}(OWNER));

// Write addresss
writeAddress(KEY, gateway);
}
}
38 changes: 38 additions & 0 deletions contracts/script/deploy/SP1VerifierGroth16Deployer.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
}
}
43 changes: 43 additions & 0 deletions contracts/scripts/anvil/deploy_sp1_contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# cd to the directory of this script so that this can be run from anywhere
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
# At this point we are in tests/integration
cd "$parent_path"

# Start an empty anvil chain in the background and dump its state to a json file upon exit
anvil --dump-state state/sp1-deployed-anvil-state.json &
Comment thread
Mechanix97 marked this conversation as resolved.
Outdated

# cd to /contracts
cd ../../

sleep 1

export CHAINS='TESTNET'
Comment thread
Mechanix97 marked this conversation as resolved.
Outdated
export RPC_TESTNET='http://localhost:8545'
Comment thread
Mechanix97 marked this conversation as resolved.
Outdated
export OWNER='0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC'
Comment thread
Mechanix97 marked this conversation as resolved.
Outdated

# Deploy Groth16 SP1 verifier gateway
forge script script/deploy/SP1VerifierGatewayGroth16Deployer.s.sol:SP1VerifierGatewayScript \
--rpc-url "http://localhost:8545" \
Comment thread
Mechanix97 marked this conversation as resolved.
Outdated
--private-key "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a" \
Comment thread
Mechanix97 marked this conversation as resolved.
Outdated
--broadcast

# # Deploy Groth16 SP1 verifier
forge script ./script/deploy/SP1VerifierGroth16Deployer.s.sol:SP1VerifierScript \
--rpc-url "http://localhost:8545" \
Comment thread
Mechanix97 marked this conversation as resolved.
Outdated
--private-key "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a" \
Comment thread
Mechanix97 marked this conversation as resolved.
Outdated
--broadcast


# Kill the anvil process to save state
pkill anvil

# Anvil adds a block state, making the code to fail. We don't care about this, just the accounts and the deployed code
cd "$parent_path"

jq 'del(.block)' state/sp1-deployed-anvil-state.json > state/sp1-deployed-anvil-state-tmp.json

cp -f state/sp1-deployed-anvil-state-tmp.json state/sp1-deployed-anvil-state.json

rm state/sp1-deployed-anvil-state-tmp.json
587 changes: 587 additions & 0 deletions contracts/scripts/anvil/state/sp1-deployed-anvil-state.json

Large diffs are not rendered by default.

Loading