-
Notifications
You must be signed in to change notification settings - Fork 414
feat: Add ZK and TEE hash upgrade template #687
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
Open
mw2000
wants to merge
4
commits into
main
Choose a base branch
from
mw2000/zk-tee-hash-template
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,22 @@ | ||
| # Required: Git commit hash for https://github.com/base/contracts | ||
| BASE_CONTRACTS_COMMIT=e225648a7ed538e7e28c041d44f3b7a606ba7743 | ||
|
|
||
| # Network-specific addresses are automatically loaded from {network}/.env via include ../.env. | ||
|
|
||
| # Multiproof configuration. | ||
| # The scripts use DISPUTE_GAME_FACTORY_PROXY + GAME_TYPE as the source of truth | ||
| # to recover the live AggregateVerifier and its current immutables. | ||
| GAME_TYPE= | ||
|
|
||
| # Verifier deployment inputs. | ||
| TEE_IMAGE_HASH= | ||
| ZK_RANGE_HASH= | ||
| ZK_AGGREGATE_HASH= | ||
|
|
||
| # Re-exported for task simulation UI. The signer-tool invokes forge directly and | ||
| # does not pick up variables coming from the Makefile's include ../.env. | ||
| PROXY_ADMIN_OWNER= | ||
| DISPUTE_GAME_FACTORY_PROXY= | ||
|
|
||
| # Validation generation | ||
| RECORD_STATE_DIFF=true | ||
116 changes: 116 additions & 0 deletions
116
setup-templates/template-upgrade-zk-and-tee-hash/FACILITATOR.md
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,116 @@ | ||
| # Facilitator Guide | ||
|
|
||
| Guide for facilitators managing this task. | ||
|
|
||
| ## Deployment prerequisites | ||
|
|
||
| Before collecting signatures, complete the EOA-authorized phase: | ||
|
|
||
| ```bash | ||
| cd contract-deployments | ||
| git pull | ||
| cd <network>/<date>-upgrade-zk-and-tee-hash | ||
| make deps | ||
| make deploy-aggregate-verifier VERIFIER_API_KEY=... | ||
| ``` | ||
|
|
||
| `make deploy-aggregate-verifier` runs `DeployAggregateVerifier`: | ||
|
|
||
| - redeploys `AggregateVerifier` with the same immutables as the existing one, overriding `TEE_IMAGE_HASH`, `ZK_RANGE_HASH`, and `ZK_AGGREGATE_HASH` | ||
| - reuses the existing `ZkVerifier` from the current onchain AggregateVerifier | ||
| - writes `aggregateVerifier` to `addresses.json` | ||
|
|
||
| Expected `addresses.json` keys: | ||
|
|
||
| - `aggregateVerifier` | ||
|
|
||
| ## Task origin signing | ||
|
|
||
| After setting up the task, generate cryptographic attestations to prove who created and facilitated the task. These signatures are stored in `<network>/signatures/<task-name>/`. | ||
|
|
||
| ### Task creator | ||
|
|
||
| ```bash | ||
| make sign-as-task-creator | ||
| ``` | ||
|
|
||
| ### Base facilitator | ||
|
|
||
| ```bash | ||
| make sign-as-base-facilitator | ||
| ``` | ||
|
|
||
| ### Security Council facilitator | ||
|
|
||
| ```bash | ||
| make sign-as-sc-facilitator | ||
| ``` | ||
|
|
||
| ## Generate validation files | ||
|
|
||
| ```bash | ||
| cd contract-deployments | ||
| git pull | ||
| cd <network>/<date>-upgrade-zk-and-tee-hash | ||
| make deps | ||
| make gen-validation-update-verifier-hashes-cb | ||
| make gen-validation-update-verifier-hashes-sc | ||
| ``` | ||
|
|
||
| This produces: | ||
|
|
||
| - `validations/base-signer.json` | ||
| - `validations/security-council-signer.json` | ||
|
|
||
| ## Execute the transaction | ||
|
|
||
| ### 1. Update repo | ||
|
|
||
| ```bash | ||
| cd contract-deployments | ||
| git pull | ||
| cd <network>/<date>-upgrade-zk-and-tee-hash | ||
| make deps | ||
| ``` | ||
|
|
||
| ### 2. Collect signatures for `CB_MULTISIG` | ||
|
|
||
| Concatenate all signatures and export as the `SIGNATURES` environment variable: | ||
|
|
||
| ```bash | ||
| export SIGNATURES="[SIGNATURE1][SIGNATURE2]..." | ||
| ``` | ||
|
|
||
| Then run: | ||
|
|
||
| ```bash | ||
| SIGNATURES=$SIGNATURES make approve-update-verifier-hashes-cb | ||
| ``` | ||
|
|
||
| ### 3. Collect signatures for `BASE_SECURITY_COUNCIL` | ||
|
|
||
| Concatenate all signatures and export as the `SIGNATURES` environment variable: | ||
|
|
||
| ```bash | ||
| export SIGNATURES="[SIGNATURE1][SIGNATURE2]..." | ||
| ``` | ||
|
|
||
| Then run: | ||
|
|
||
| ```bash | ||
| SIGNATURES=$SIGNATURES make approve-update-verifier-hashes-sc | ||
| ``` | ||
|
|
||
| ### 4. Execute upgrade batch | ||
|
|
||
| ```bash | ||
| make execute-update-verifier-hashes | ||
| ``` | ||
|
|
||
| Post-checks enforced by script: | ||
|
|
||
| - `DisputeGameFactory.gameImpls(gameType)` equals the newly deployed `aggregateVerifier` | ||
| - `aggregateVerifier.TEE_IMAGE_HASH()` equals the configured `TEE_IMAGE_HASH` | ||
| - `aggregateVerifier.ZK_RANGE_HASH()` equals the configured `ZK_RANGE_HASH` | ||
| - `aggregateVerifier.ZK_AGGREGATE_HASH()` equals the configured `ZK_AGGREGATE_HASH` | ||
| - all other AggregateVerifier immutables (`ZK_VERIFIER`, `TEE_VERIFIER`, `DELAYED_WETH`, `CONFIG_HASH`, etc.) match the previous AggregateVerifier |
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,79 @@ | ||
| include ../../Makefile | ||
| include ../../Multisig.mk | ||
| include ../.env | ||
| include .env | ||
|
|
||
| SIGNER_TOOL_PATH = ../../signer-tool | ||
| RPC_URL = $(L1_RPC_URL) | ||
| DEPLOYER = $(shell $(MISE_EXEC) cast wallet address --ledger --mnemonic-derivation-path $(LEDGER_HD_PATH)) | ||
| UPDATE_VERIFIER_HASHES_SCRIPT_NAME = script/UpdateVerifierHashes.s.sol:UpdateVerifierHashes | ||
| UPDATE_VERIFIER_HASHES_CB_SENDER = $(shell $(MISE_EXEC) cast call $(CB_MULTISIG) "getOwners()(address[])" --rpc-url $(L1_RPC_URL) | tr -d '[]' | cut -d',' -f1) | ||
| UPDATE_VERIFIER_HASHES_SC_SENDER = $(shell $(MISE_EXEC) cast call $(BASE_SECURITY_COUNCIL) "getOwners()(address[])" --rpc-url $(L1_RPC_URL) | tr -d '[]' | cut -d',' -f1) | ||
|
|
||
| .PHONY: deps | ||
| deps: install-eip712sign clean-lib forge-deps clone-oz-upgradeable checkout-base-contracts-commit task-extra-deps | ||
|
|
||
| .PHONY: task-extra-deps | ||
| task-extra-deps: | ||
| $(MISE_EXEC) forge install --no-git github.com/base/op-enclave@a2d5398f04c3a8e4df929d58ee638ba4a037bfec | ||
| $(MISE_EXEC) forge install --no-git github.com/risc0/risc0-ethereum@a78ac4a52fe9cfa14120c3b496430f0d42e1d8d3 | ||
| $(MISE_EXEC) forge install --no-git github.com/succinctlabs/sp1-contracts@22c4a47cd0a388cb4e25b4f2513954e4275c74ca | ||
| git clone --no-checkout https://github.com/OpenZeppelin/openzeppelin-contracts.git lib/openzeppelin-contracts-v5 && \ | ||
| cd lib/openzeppelin-contracts-v5 && git checkout dbb6104ce834628e473d2173bbc9d47f81a9eec3 && rm -rf .git | ||
| git clone --no-checkout https://github.com/Vectorized/solady.git lib/solady-v0.0.245 && \ | ||
| cd lib/solady-v0.0.245 && git checkout e0ef35adb0ccd1032794731a995cb599bba7b537 && rm -rf .git | ||
|
|
||
| .PHONY: validate-config | ||
| validate-config: | ||
| @test -n "$(BASE_CONTRACTS_COMMIT)" || (echo "BASE_CONTRACTS_COMMIT required" && exit 1) | ||
| @test -n "$(GAME_TYPE)" || (echo "GAME_TYPE required" && exit 1) | ||
| @test -n "$(TEE_IMAGE_HASH)" || (echo "TEE_IMAGE_HASH required" && exit 1) | ||
| @test -n "$(ZK_RANGE_HASH)" || (echo "ZK_RANGE_HASH required" && exit 1) | ||
| @test -n "$(ZK_AGGREGATE_HASH)" || (echo "ZK_AGGREGATE_HASH required" && exit 1) | ||
| @test -n "$(PROXY_ADMIN_OWNER)" || (echo "PROXY_ADMIN_OWNER required" && exit 1) | ||
| @test -n "$(DISPUTE_GAME_FACTORY_PROXY)" || (echo "DISPUTE_GAME_FACTORY_PROXY required" && exit 1) | ||
| @echo "Configuration validated successfully" | ||
|
|
||
| ## | ||
| # Deployment (EOA) | ||
| ## | ||
| .PHONY: deploy-aggregate-verifier | ||
| deploy-aggregate-verifier: validate-config | ||
| ifndef VERIFIER_API_KEY | ||
| $(error VERIFIER_API_KEY is not set) | ||
| endif | ||
| $(MISE_EXEC) forge script --rpc-url $(L1_RPC_URL) script/DeployAggregateVerifier.s.sol:DeployAggregateVerifier \ | ||
| --ledger --hd-paths $(LEDGER_HD_PATH) --broadcast --verify \ | ||
| --verifier custom \ | ||
| --verifier-url "https://api.etherscan.io/v2/api?chainid=$(L1_CHAIN_ID)" \ | ||
| --verifier-api-key $(VERIFIER_API_KEY) \ | ||
| -vvvv --sender $(DEPLOYER) | ||
|
|
||
| ## | ||
| # Update verifier hashes (multisig) | ||
| ## | ||
| .PHONY: gen-validation-update-verifier-hashes-cb | ||
| gen-validation-update-verifier-hashes-cb: validate-config deps-signer-tool | ||
| $(call GEN_VALIDATION,$(UPDATE_VERIFIER_HASHES_SCRIPT_NAME),$(CB_MULTISIG),$(UPDATE_VERIFIER_HASHES_CB_SENDER),base-signer.json,) | ||
|
|
||
| .PHONY: gen-validation-update-verifier-hashes-sc | ||
| gen-validation-update-verifier-hashes-sc: validate-config deps-signer-tool | ||
| $(call GEN_VALIDATION,$(UPDATE_VERIFIER_HASHES_SCRIPT_NAME),$(BASE_SECURITY_COUNCIL),$(UPDATE_VERIFIER_HASHES_SC_SENDER),security-council-signer.json,) | ||
|
|
||
| .PHONY: approve-update-verifier-hashes-cb | ||
| approve-update-verifier-hashes-cb: validate-config | ||
| approve-update-verifier-hashes-cb: SCRIPT_NAME := $(UPDATE_VERIFIER_HASHES_SCRIPT_NAME) | ||
| approve-update-verifier-hashes-cb: | ||
| $(call MULTISIG_APPROVE,$(CB_MULTISIG),$(SIGNATURES)) | ||
|
|
||
| .PHONY: approve-update-verifier-hashes-sc | ||
| approve-update-verifier-hashes-sc: validate-config | ||
| approve-update-verifier-hashes-sc: SCRIPT_NAME := $(UPDATE_VERIFIER_HASHES_SCRIPT_NAME) | ||
| approve-update-verifier-hashes-sc: | ||
| $(call MULTISIG_APPROVE,$(BASE_SECURITY_COUNCIL),$(SIGNATURES)) | ||
|
|
||
| .PHONY: execute-update-verifier-hashes | ||
| execute-update-verifier-hashes: validate-config | ||
| execute-update-verifier-hashes: SCRIPT_NAME := $(UPDATE_VERIFIER_HASHES_SCRIPT_NAME) | ||
| execute-update-verifier-hashes: | ||
| $(call MULTISIG_EXECUTE,0x) |
65 changes: 65 additions & 0 deletions
65
setup-templates/template-upgrade-zk-and-tee-hash/README.md
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,65 @@ | ||
| # Upgrade ZK and TEE Hash | ||
|
|
||
| Status: READY TO SIGN | ||
|
|
||
| ## Description | ||
|
|
||
| This template updates the TEE and ZK verifier hashes of a multiproof implementation by: | ||
|
|
||
| - redeploying `AggregateVerifier` with identical immutables, overriding `TEE_IMAGE_HASH`, `ZK_RANGE_HASH`, and `ZK_AGGREGATE_HASH` | ||
| - pointing `DisputeGameFactory.gameImpls(gameType)` at the new `AggregateVerifier` | ||
|
|
||
| ## Setup | ||
|
|
||
| From the repository root: | ||
|
|
||
| ```bash | ||
| make setup-upgrade-zk-and-tee-hash network=<network> | ||
| cd <network>/<date>-upgrade-zk-and-tee-hash | ||
| ``` | ||
|
|
||
| Fill in all required values in `.env`: | ||
|
|
||
| - `BASE_CONTRACTS_COMMIT` | ||
| - `GAME_TYPE` | ||
| - `TEE_IMAGE_HASH` | ||
| - `ZK_RANGE_HASH` | ||
| - `ZK_AGGREGATE_HASH` | ||
| - `PROXY_ADMIN_OWNER` | ||
| - `DISPUTE_GAME_FACTORY_PROXY` | ||
|
|
||
| Then install dependencies and build: | ||
|
|
||
| ```bash | ||
| make deps | ||
| forge build | ||
| ``` | ||
|
|
||
| ## Procedure | ||
|
|
||
| ### Sign task | ||
|
|
||
| #### 1. Update repo | ||
|
|
||
| ```bash | ||
| cd contract-deployments | ||
| git pull | ||
| ``` | ||
|
|
||
| #### 2. Run signing tool | ||
|
|
||
| ```bash | ||
| cd contract-deployments | ||
| make sign-task | ||
| ``` | ||
|
|
||
| #### 3. Open the UI at [http://localhost:3000](http://localhost:3000) | ||
|
|
||
| - Select the correct signer role from the list of available users to sign. | ||
| - After completion, close the signer tool with `Ctrl + C`. | ||
|
|
||
| #### 4. Send signature to facilitator | ||
|
|
||
| Copy the signature output and send it to the designated facilitator via the agreed communication channel. | ||
|
|
||
| For facilitator instructions, see `FACILITATOR.md`. |
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.