|
| 1 | +--- |
| 2 | +title: MultiGov Deployment to Solana |
| 3 | +description: Learn how to deploy the MultiGov Staking Program on Solana, including setup, funding, deployment, and configuration steps. |
| 4 | +--- |
| 5 | + |
| 6 | +# Deploy MultiGov on Solana |
| 7 | + |
| 8 | +This guide provides instructions on how to set up and deploy the **MultiGov Staking Program** on Solana. Before proceeding with the deployment, ensure that MultiGov aligns with your project's governance needs by reviewing the system [architecture](/docs/learn/governance/architecture/){target=\_blank}. |
| 9 | + |
| 10 | +Once your project setup is complete, follow this guide to configure, compile, and deploy the necessary Solana programs and supporting accounts. This deployment enables decentralized governance participation on Solana as a spoke chain within the MultiGov system. |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +To deploy MultiGov on Solana, ensure you have the following installed: |
| 15 | + |
| 16 | + - Install [Git](https://git-scm.com/downloads){target=\_blank} |
| 17 | + - Install [Node.js](https://nodejs.org/){target=\_blank} **`v20.10.0`** |
| 18 | + - Install [Solana CLI](https://docs.anza.xyz/cli/install/){target=\_blank} **`v1.18.20`** |
| 19 | + - Install [Anchor](https://www.anchor-lang.com/docs/installation){target=\_blank} **`v0.30.1`** |
| 20 | + - Install [Rust](https://www.rust-lang.org/tools/install){target=\_blank} **`v1.80.1`** |
| 21 | + - Install [Docker](https://www.docker.com/get-started/){target=\_blank} |
| 22 | + - Clone the repository: |
| 23 | + ```bash |
| 24 | + git clone https://github.com/wormhole-foundation/multigov.git |
| 25 | + cd multigov/solana/ |
| 26 | + ``` |
| 27 | + |
| 28 | +## Build the Project |
| 29 | + |
| 30 | +To create a verifiable build of the MultiGov Staking Program, run the following command: |
| 31 | + |
| 32 | +```bash |
| 33 | +./scripts/build_verifiable_staking_program.sh |
| 34 | +``` |
| 35 | + |
| 36 | +Once the build is complete, the compiled artifacts will be available in the `target` folder. |
| 37 | + |
| 38 | +## Set Up the Deployer Account |
| 39 | + |
| 40 | +For a successful deployment, you need a funded deployer account on Solana. This account will store the program and execute deployment transactions. |
| 41 | + |
| 42 | +In this section, you will create a new keypair, check the account balance, and ensure it has enough SOL tokens to cover deployment costs. If needed, you can fund the account using different methods before deploying. |
| 43 | + |
| 44 | +### Generate a New Keypair |
| 45 | + |
| 46 | +To create a new keypair and save it to a file, run the following command: |
| 47 | + |
| 48 | +```bash |
| 49 | +solana-keygen new --outfile ./app/keypairs/deployer.json |
| 50 | +``` |
| 51 | + |
| 52 | +### Check the Deployer Account Address |
| 53 | + |
| 54 | +To retrieve the public address of the newly created keypair, run the following command: |
| 55 | + |
| 56 | +```bash |
| 57 | +solana address -k ./app/keypairs/deployer.json |
| 58 | +``` |
| 59 | + |
| 60 | +### Check the Deployer Account Balance |
| 61 | + |
| 62 | +To verify the current balance of the deployer account, run the following command: |
| 63 | + |
| 64 | +```bash |
| 65 | +solana balance -k ./app/keypairs/deployer.json |
| 66 | +``` |
| 67 | + |
| 68 | +!!! important |
| 69 | + When deploying the MultiGov Staking Program, the deployer account must have enough SOL to cover deployment costs and transaction fees. |
| 70 | + |
| 71 | + - 7.60219224 SOL for deployment costs |
| 72 | + - 0.00542 SOL for transaction fees |
| 73 | + |
| 74 | +### Fund the Deployer Account |
| 75 | + |
| 76 | +If the account does not have enough SOL, use one of the following methods to add funds. |
| 77 | + |
| 78 | + - **Transfer SOL from another account** - if you already have SOL in another account, transfer it using a wallet (Phantom, Solflare, etc.) or in the terminal |
| 79 | + |
| 80 | + ```bash |
| 81 | + solana transfer <deployer_account_address> <amount> --from /path/to/funder.json |
| 82 | + ``` |
| 83 | + |
| 84 | + - **Request an airdrop (devnet only)** - if deploying to devnet, you can request free SOL |
| 85 | + |
| 86 | + ```bash |
| 87 | + solana airdrop 2 -k ./app/keypairs/deployer.json |
| 88 | + ``` |
| 89 | + |
| 90 | + - **Use a Solana faucet (devnet only)** - you can use online faucets to receive 10 free SOL |
| 91 | + |
| 92 | + - [Solana Faucet](https://faucet.solana.com/){target=\_blank} |
| 93 | + |
| 94 | +## Deploy the MultiGov Staking Program |
| 95 | + |
| 96 | +With the deployer account set up and funded, you can deploy the MultiGov Staking Program to the Solana blockchain. This step involves deploying the program, verifying the deployment, and ensuring the necessary storage and metadata are correctly configured. Once the IDL is initialized, the program will be ready for further setup and interaction. |
| 97 | + |
| 98 | +### Deploy the Program |
| 99 | + |
| 100 | +Deploy the MultiGov Staking Program using **Anchor**: |
| 101 | + |
| 102 | +```bash |
| 103 | +anchor deploy --provider.cluster https://api.devnet.solana.com --provider.wallet ./app/keypairs/deployer.json |
| 104 | +``` |
| 105 | + |
| 106 | +### Verify the Deployment |
| 107 | + |
| 108 | +After deployment, check if the program is successfully deployed by running the following command: |
| 109 | + |
| 110 | +```bash |
| 111 | +solana program show INSERT_PROGRAM_ID |
| 112 | +``` |
| 113 | + |
| 114 | +### Extend Program Storage |
| 115 | + |
| 116 | +If the deployed program requires additional storage space for updates or functionality, extend the program storage using the following command: |
| 117 | + |
| 118 | +```bash |
| 119 | +solana program extend INSERT_PROGRAM_ID 800000 |
| 120 | +``` |
| 121 | + |
| 122 | +### Initialize the IDL |
| 123 | + |
| 124 | +To associate an IDL file with the deployed program, run the following command: |
| 125 | + |
| 126 | +```bash |
| 127 | +anchor idl init --provider.cluster https://api.devnet.solana.com --filepath ./target/idl/staking.json INSERT_PROGRAM_ID |
| 128 | +``` |
| 129 | + |
| 130 | +## Configure the Staking Program |
| 131 | + |
| 132 | +The final step after deploying the MultiGov Staking Program is configuring it for proper operation. This includes running a series of deployment scripts to initialize key components and set important governance parameters. These steps ensure that staking, governance, and cross-chain communication function as expected. |
| 133 | + |
| 134 | +### Run Deployment Scripts |
| 135 | + |
| 136 | +After deploying the program and initializing the IDL, execute the following scripts **in order** to set up the staking environment and necessary accounts. |
| 137 | + |
| 138 | +1. Initialize the MultiGov Staking Program with default settings: |
| 139 | + |
| 140 | + ```bash |
| 141 | + npx ts-node app/deploy/01_init_staking.ts |
| 142 | + ``` |
| 143 | + |
| 144 | +2. Create an Account Lookup Table (ALT) to optimize transaction processing: |
| 145 | + |
| 146 | + ```bash |
| 147 | + npx ts-node app/deploy/02_create_account_lookup_table.ts |
| 148 | + ``` |
| 149 | + |
| 150 | +3. Set up airlock accounts: |
| 151 | + |
| 152 | + ```bash |
| 153 | + npx ts-node app/deploy/03_create_airlock.ts |
| 154 | + ``` |
| 155 | + |
| 156 | +4. Deploy a metadata collector: |
| 157 | + |
| 158 | + ```bash |
| 159 | + npx ts-node app/deploy/04_create_spoke_metadata_collector.ts |
| 160 | + ``` |
| 161 | + |
| 162 | +5. Configure vote weight window lengths: |
| 163 | + |
| 164 | + ```bash |
| 165 | + npx ts-node app/deploy/05_initializeVoteWeightWindowLengths.ts |
| 166 | + ``` |
| 167 | + |
| 168 | +6. Deploy the message executor for handling governance messages: |
| 169 | + |
| 170 | + ```bash |
| 171 | + npx ts-node app/deploy/06_create_message_executor.ts |
| 172 | + ``` |
| 173 | + |
| 174 | +### Set MultiGov Staking Program Key Parameters |
| 175 | + |
| 176 | +When deploying MultiGov on Solana, several key parameters need to be set. Here are the most important configuration points: |
| 177 | + |
| 178 | + - `maxCheckpointsAccountLimit` ++"u64"++ - the maximum number of checkpoints an account can have. For example, `654998` is used in production, while `15` might be used for testing |
| 179 | + - `hubChainId` `u16` - the chain ID of the hub network where proposals are primarily managed. For example, `10002` for Sepolia testnet |
| 180 | + - `hubProposalMetadata` ++"[u8; 20]"++ - an array of bytes representing the address of the Hub Proposal Metadata contract on Ethereum. This is used to identify proposals from the hub |
| 181 | + - `voteWeightWindowLength` ++"u64"++ - specifies the length of the checkpoint window in seconds in which the minimum voting weight is taken. The window ends at the vote start for a proposal and begins at the vote start minus the vote weight window. The vote weight window helps solve problems such as manipulating votes in a chain |
| 182 | + - `votingTokenMint` ++"Pubkey"++ - the mint address of the token used for voting |
| 183 | + - `governanceAuthority` ++"Pubkey"++ - the account's public key with the authority to govern the staking system. The `governanceAuthority` should not be the default Pubkey, as this would indicate an uninitialized or incorrectly configured setup |
| 184 | + - `vestingAdmin` ++"Pubkey"++ - the account's public key for managing vesting operations. The `vestingAdmin` should not be the default Pubkey, as this would indicate an uninitialized or incorrectly configured setup |
| 185 | + - `hubDispatcher` ++"Pubkey"++ - the Solana public key derived from an Ethereum address on the hub chain that dispatches messages to the spoke chains. This is crucial for ensuring that only authorized messages from the hub are executed on the spoke |
0 commit comments