Skip to content
Closed
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
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",
"V4_0_0_RC3_SP1_VERIFIER_GROTH16": "0x9bc3E27B1DB9BAd4CF43d23Be914fc2eEf7aefc4"
}
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/v4.0.0-rc.3/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 = "V4_0_0_RC3_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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"chainInfo": {
"chainId": 31337,
"deploymentBlock": 0
"deploymentBlock": 3
},
"permissions": {
"alignedLayerAggregator": "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65",
Expand Down
4 changes: 2 additions & 2 deletions contracts/scripts/anvil/deploy_aligned_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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 --load-state state/eigenlayer-deployed-anvil-state.json --dump-state state/alignedlayer-deployed-anvil-state.json &
# Start anvil chain in the background and dump its state to a json file upon exit
anvil --load-state state/sp1-deployed-anvil-state.json --dump-state state/alignedlayer-deployed-anvil-state.json &

cd ../../

Expand Down
46 changes: 46 additions & 0 deletions contracts/scripts/anvil/deploy_sp1_contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/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 --load-state state/eigenlayer-deployed-anvil-state.json --dump-state state/sp1-deployed-anvil-state.json &

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

sleep 1

export CHAINS='DEVNET'
export RPC_DEVNET='http://localhost:8545'

# Anvil account #2
export OWNER='0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC'
export VERIFIER_PRIVATE_KEY="0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"

# Deploy Groth16 SP1 verifier gateway
forge script script/deploy/SP1VerifierGatewayGroth16Deployer.s.sol:SP1VerifierGatewayScript \
--rpc-url $RPC_DEVNET \
--private-key $VERIFIER_PRIVATE_KEY \
--broadcast

# Deploy Groth16 SP1 verifier
forge script ./script/deploy/SP1VerifierGroth16Deployer.s.sol:SP1VerifierScript \
--rpc-url $RPC_DEVNET \
--private-key $VERIFIER_PRIVATE_KEY \
--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

Large diffs are not rendered by default.

Loading
Loading