-
Notifications
You must be signed in to change notification settings - Fork 97
feat: migrate governance scripts from deployment-scripts branch #853
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
evgeniko
wants to merge
24
commits into
main
Choose a base branch
from
feat/governance-scripts
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 11 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
784b473
solana: add governance SDK module for VAA execution
evgeniko d458340
solana: add governance scripts infrastructure (env, helpers, config)
evgeniko 2ce452e
solana: add executeGovernanceVaa scripts (ledger single, ledger batch…
evgeniko b2856fc
solana: add governance ownership transfer and diagnostic scripts
evgeniko 4fd8134
evm: add ts-scripts package scaffolding and config
evgeniko f3a5109
evm: add ts-scripts environment and config loading
evgeniko 074bd5b
evm: add governance scripts (execute VAA, create message)
evgeniko 21930b6
evm: add transceiver config reading script
evgeniko 3f4eac9
docs: add deployment documentation and governance shell script
evgeniko ca2d12a
fix: restore mainnet RPC URL, fix trailing newlines, update lockfile
evgeniko 9e273fc
fix: trim ContractsJson type to only governance-relevant contracts
evgeniko e877da1
fix: trim contracts.json to only governance-relevant contract addresses
evgeniko 2997b16
fix: move governance.ts out of SDK, address CI and review feedback
evgeniko cbfeff5
style: run prettier on all migrated files
evgeniko 69c2af9
style: fix remaining prettier issues (match repo prettier 3.6.2)
evgeniko 22bfeaa
fix: remove readTransceiverConfig and NttTransceiverProxies (not need…
evgeniko fe0aa64
fix: remove unused files (deployments.md, verify shell script, ntt co…
evgeniko 797559b
fix: fix typos in error message and log output
evgeniko 2c9b54d
fix: remove scripts that depend on old NTT SDK class (needs adaptatio…
evgeniko 5a1fcca
fix: restore migrated governance script inputs
evgeniko d808335
refactor: move Solana scripts to separate private package
evgeniko a049830
fix: update lockfile, trim managers.json to used fields, fix prettier
evgeniko 99f6787
fix: remove createGovernanceMessage script and its unused dependencies
evgeniko 702cb47
fix: bump ethers to ^5.8.0 and pin elliptic to 6.6.1 for security fixes
evgeniko 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,156 @@ | ||
| ## NTT Deployment: | ||
| This document serves as an example of a possible order of execution of commands to perform a full deployment of NTT on Solana + one or more EVMs. | ||
|
|
||
| ### Requirements: | ||
| NTT needs the following contracts to be able to operate. This doc assumes that these contracts are already deployed by the time you execute this deployment. | ||
|
|
||
| Deployed by NTT deployment owner: | ||
| - an ntt token | ||
|
|
||
| Deployed by wormhole: | ||
| - wormhole core layer | ||
| - wormhole relayer (you can use wormhole's public one or deploy your own) | ||
|
|
||
| ### High level description of the process: | ||
| To have a multi-chain NTT setup working a few things need to happen. | ||
| - Deploy managers on EVM | ||
| - Register managers on NTT Token | ||
| - Deploy Transceivers on EVM | ||
| - Deploy NTT Program on Solana | ||
| - Set Mint authority to NTT program | ||
| - Initialize NTT program on Solana | ||
| - Cross register managers (let each manager know about the other managers) | ||
| - Cross register transceivers | ||
|
|
||
| ## EVM Deployment: | ||
|
|
||
| ### Environments & Configuration: | ||
| These scripts are implemented in way that helps keep track of the deployed addresses by reading contract addresses from json files that can be commited to the repository. Multiple environments are supported through the use of the `ENV` environment variable. | ||
| To create or use a new env all that needs to be done is to create a new directory on `evm/ts-scripts/config/<my-env>` with the name of the env you want to use and then set the environment variable ENV to the same value (ie on linux: `export ENV="my-env"`) | ||
| Inside the configuration directory, there needs to be a few files that will contain all the configuration you need to set up a full NTT deployment: | ||
| - `chains.json` contains the configuration used by the deployment runner such as what rpcs will be used or what chains will it run scripts against | ||
| - `contracts.json` this file contains the addresses of all contracts related to this deployment and will be used any time a script needs to know about the address of other of the contracts. Addresses of contracts will be written to this file as the deployment progress (ie after deploying managers we'll add the manager addresses here) | ||
| - `managers.json` contains the configuration that will be applied to managers | ||
| - `transceivers.json` contains the configuration that will be applied to transceivers | ||
| - `peers.json` contains the configuration that will be used for contract cross-registrations | ||
|
|
||
| > When a script deploys new contracts, it outputs the resulting addresseses on the directory `ts-scripts/output/<scripts-name>/<timestamp>.json (aside from logging them). Whenever we need to configure the addresses of a contract that we have just deployed we'll fetch the new addresses from those files. | ||
|
|
||
| ### Deployment Steps: | ||
| - create/update `evm/config/<env>/contracts.json` as needed | ||
| - create/update `evm/config/<env>/managers.json` as needed | ||
| - create/update `evm/config/<env>/transceivers.json` as needed | ||
| - Set environment variables: | ||
| ``` | ||
| export FOUNDRY_PROFILE=prod | ||
| export WALLET_KEY="ledger" | ||
| export LEDGER_BIP32_PATH="" | ||
| export ENV=testnet | ||
| ``` | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| - Build: | ||
| ```shell | ||
| make build-evm-prod | ||
| cd evm/ts-scripts | ||
| npm install | ||
| cd .. | ||
| npm --prefix ./ts-scripts run build # builds typescript bindings to evm/ts-scripts/output | ||
| ``` | ||
| - Deploy Managers: | ||
| ```shell | ||
| bash -c ./ts-scripts/shell/deploy-managers.sh | ||
| # | ||
| # Use the addresses to update the `contracts.json` file | ||
| # | ||
| ``` | ||
| - Now that you have deployed your manager, you can go to your token deployment and configure the token to be managed by the managers you have deployed (aka, call `setMinter` on the token to the manager address). | ||
| - Deploy Transceivers: | ||
| ```shell | ||
| bash -c ./ts-scripts/shell/deploy-transceivers.sh | ||
| # | ||
| # Use the addresses to update the `contracts.json` file | ||
| # | ||
| ``` | ||
| - Configure Managers: | ||
| ```shell | ||
| bash -c ./ts-scripts/shell/configure-managers.sh | ||
| ``` | ||
|
|
||
| ## Solana Deployment: | ||
| - set environment: | ||
| ```shell | ||
| # Runner Configurations: | ||
| export SOLANA_RPC_URL="" | ||
| export WORMHOLE_PROGRAM_ID="" # wormhole core layer program id | ||
| export LEDGER_DERIVATION_PATH="" # derivation path | ||
|
|
||
| # Deployment configuration: | ||
| export MINT_ADDRESS="" # the program id of your spl token | ||
| ``` | ||
| - Create and set the pub key of the program: | ||
| ```shell | ||
| solana-keygen grind --ignore-case --starts-with ntt:1 | ||
| ``` | ||
| - use the pub key created to replace the `declare_id!` macro value on `lib.rs` | ||
| - export the pub-key of the program: | ||
| ``` | ||
| export NTT_PROGRAM_ID=<your-program-key> | ||
| ``` | ||
| - Build: | ||
| ``` | ||
| cd solana | ||
| anchor build --arch sbf -- --features "mainnet" # if you are deploying to tesnet, you should use "solana-devnet" instead of mainnet | ||
| ``` | ||
| - Deploy: | ||
| ``` | ||
| solana program -k usb://ledger?key=<your derivation path> deploy --url $SOLANA_RPC_URL --program-id "$NTT_PROGRAM_ID.json" target/deploy/example_native_token_transfers.so | ||
| ``` | ||
| - Initialize the program: | ||
| ``` shell | ||
| make build | ||
| npx tsx ./ts/scripts/initializeNtt.ts | ||
| # | ||
| # The script will print the manager emitter address PDA. You can always derive | ||
| # this pda again, but might be easier if you take note of it at this point. | ||
| # You'll need it later to do cross-registrations. | ||
| # | ||
| ``` | ||
|
|
||
| ## Cross Registrations: | ||
|
|
||
| ### EVM cross Registrations: | ||
| - Create or update evm/config/<env>/peers.json (this file contains the data of all peers that the different evm deployments should know about. Note that the evm cross-registration script can find the addresses of its evm peers, but it can't find the solana peer address, so for solana you'll need to add two extra properties `managerAddress` and `transceiverAddress`. They correspond to the solana ntt deployment program-id and the manager-emitter-address PDA (the one printed during solana program initialization) | ||
| - Run update peers script: | ||
| ```shell | ||
| bash -c ./ts-scripts/shell/update-peer-addresses.sh | ||
| ``` | ||
|
|
||
| ### Solana Cross Registrations: | ||
| - update `evmNttDeployments` on solana/ts/scripts/env.ts with the addresses of your EVM managers and transceivers. | ||
| - Run cross registrations script: | ||
| ```shell | ||
| npx tsx ./ts/scripts/updatePeers.ts | ||
| ``` | ||
|
|
||
| ## Contract Bytecode Verification: | ||
|
|
||
| ### EVM verification: | ||
| On evm there are scripts that verify the deployed contracts. To run them you'll need a file with the etherscan scanners keys per each of the supported chains. | ||
| Such file should have this structure: | ||
| ```json | ||
| [ | ||
| { | ||
| "chainId": 6, | ||
| "etherscan": "YOUR-ETTHERSCAN-API_KEY" | ||
| } | ||
| ] | ||
| ``` | ||
| Run verification scripts: | ||
| ``` | ||
| export SCANNER_TOKENS_FILE_PATH="the/path/to/file/above" | ||
| bash -c ./evm/ts-scripts/shell/verify-managers.sh | ||
| bash -c ./evm/ts-scripts/shell/verify-transceivers.sh | ||
| ``` | ||
| Finally, go to the etherscan scanner of the different chains and link the verified proxy to the verified implementation. | ||
|
|
||
| ### Solana Verification: | ||
| TODO | ||
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 @@ | ||
| forge-build |
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,3 @@ | ||
| WALLET_KEY= | ||
| LEDGER_BIP32_PATH= | ||
| GUARDIAN_KEY= | ||
|
evgeniko marked this conversation as resolved.
|
||
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,4 @@ | ||
| output | ||
| contract-bindings | ||
| .env.testnet | ||
| .env.mainnet | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
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
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.