-
Notifications
You must be signed in to change notification settings - Fork 396
Feat/sp1 contracts #1841
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
Closed
Closed
Feat/sp1 contracts #1841
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bd3fee0
Add deploy sp1 script
Mechanix97 2afe5a8
forge install: sp1-contracts
Mechanix97 cd2311c
Add sp1-contracts to remmaping.txt
Mechanix97 c698a2c
Fix base script path in deployers
Mechanix97 b08337d
Add makefile command
Mechanix97 2af21b9
Fix deployers aux files and keys
Mechanix97 168b216
Fix devnet instead of testnet
Mechanix97 9e8d6a7
fix: deploy sp1 verifier and aligned contracts
JuArce a56319b
Fix v4.0.0-rc3
Mechanix97 78ec891
Add json state files and fix deployment json
Mechanix97 c67b5b1
Update 31337.json remove v3.0.0 address
Mechanix97 261418e
Add comment specifying the anvin account
Mechanix97 9ae2d20
Merge branch 'feat/sp1-contracts' of github.com:yetanotherco/aligned_…
Mechanix97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule sp1-contracts
added at
26651f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
contracts/script/deploy/SP1VerifierGatewayGroth16Deployer.s.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 & | ||
|
|
||
| # cd to /contracts | ||
| cd ../../ | ||
|
|
||
| sleep 1 | ||
|
|
||
| export CHAINS='TESTNET' | ||
|
Mechanix97 marked this conversation as resolved.
Outdated
|
||
| export RPC_TESTNET='http://localhost:8545' | ||
|
Mechanix97 marked this conversation as resolved.
Outdated
|
||
| export OWNER='0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC' | ||
|
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" \ | ||
|
Mechanix97 marked this conversation as resolved.
Outdated
|
||
| --private-key "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a" \ | ||
|
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" \ | ||
|
Mechanix97 marked this conversation as resolved.
Outdated
|
||
| --private-key "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a" \ | ||
|
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
587
contracts/scripts/anvil/state/sp1-deployed-anvil-state.json
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.