|
| 1 | +# Deployment |
| 2 | + |
| 3 | +This document contains instructions on deploying the contracts to a specific chain. |
| 4 | + |
| 5 | +## Setup |
| 6 | + |
| 7 | +First make a copy of the [.env.example](./.env.example): |
| 8 | + |
| 9 | +```sh |
| 10 | +cp .env.example .env |
| 11 | +``` |
| 12 | + |
| 13 | +And then fill in your `.env` file with all the variables needed for configuring the contracts. |
| 14 | + |
| 15 | +Also, set these terminal parameters needed to deploy to a specific chain: |
| 16 | + |
| 17 | +```sh |
| 18 | +export PRIVATE_KEY= |
| 19 | +export ETH_RPC_URL= |
| 20 | +export ETHERSCAN_API_KEY= |
| 21 | +``` |
| 22 | + |
| 23 | +Then add a `{CHAIN_ID}.json` file in the [deployments](./deployments) directory for the chain you are deploying to. This command will automatically create it with an empty JSON `{}` if it doesn't exist: |
| 24 | + |
| 25 | +```sh |
| 26 | +CHAIN_ID=$(cast chain-id --rpc-url $ETH_RPC_URL); mkdir -p ./deployments && [ -f "./deployments/${CHAIN_ID}.json" ] || echo '{}' > "./deployments/${CHAIN_ID}.json" |
| 27 | +``` |
| 28 | + |
| 29 | +Then you should add the `VKEY` and `GENESIS_STATE_ROOT` to the `{CHAIN_ID}.json` file: |
| 30 | + |
| 31 | +```json |
| 32 | +{ |
| 33 | + "VKEY": "0x00379594d327723819f32e812d869de681100f77f766869b8d672072ab73e27c", |
| 34 | + "GENESIS_STATE_ROOT": "0x7f1150ec996e291947d4a9a30a49155b5f042042f841f25db4d41da04cef63f4" |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +Ensure these match the actual vkey and genesis state root for the Rust vApp program. |
| 39 | + |
| 40 | +Note: the production version of these contracts were deployed using foundry [v1.3.0](https://github.com/foundry-rs/foundry/releases/tag/v1.3.0). |
| 41 | + |
| 42 | +For the below commands, you can append `--verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY` to the above commands to automatically verify the contracts on Etherscan. |
| 43 | + |
| 44 | +### Pre-deployed contracts |
| 45 | + |
| 46 | +Also fill out `{CHAIN_ID}.json` with any pre-deployed contracts. For example, if there is an existing `PROVE` and `VERIFIER` those keys would be filled: |
| 47 | + |
| 48 | +```json |
| 49 | +{ |
| 50 | + "VKEY": "0x00379594d327723819f32e812d869de681100f77f766869b8d672072ab73e27c", |
| 51 | + "GENESIS_STATE_ROOT": "0x7f1150ec996e291947d4a9a30a49155b5f042042f841f25db4d41da04cef63f4", |
| 52 | + "PROVE": "0x6BEF15D938d4E72056AC92Ea4bDD0D76B1C4ad29", |
| 53 | + "VERIFIER": "0x397A5f7f3dBd538f23DE225B51f532c34448dA9B" |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +The scripts and steps below make the assumption that the `PROVE` and `VERIFIER` contracts are already deployed. |
| 58 | + |
| 59 | +## Deploy |
| 60 | + |
| 61 | +### Bulk atomic deployment (Production) |
| 62 | + |
| 63 | +To avoid frontrunning the `initialize` functions, **must** use the `AtomicDeployer` contract to deploy and initialize the contracts atomically. |
| 64 | + |
| 65 | +Deploy all contracts atomically at once: |
| 66 | + |
| 67 | +```sh |
| 68 | +FOUNDRY_PROFILE=deploy forge script AllAtomicScript --private-key $PRIVATE_KEY --broadcast --rpc-url $ETH_RPC_URL |
| 69 | +``` |
| 70 | + |
| 71 | +### Bulk deployment (Testing) |
| 72 | + |
| 73 | +Deploy all contracts at once: |
| 74 | + |
| 75 | +```sh |
| 76 | +FOUNDRY_PROFILE=deploy forge script AllScript --private-key $PRIVATE_KEY --broadcast --rpc-url $ETH_RPC_URL |
| 77 | +``` |
| 78 | + |
| 79 | +### Individual deployment (Testing) |
| 80 | + |
| 81 | +Deploy the SuccinctStaking contract: |
| 82 | + |
| 83 | +```sh |
| 84 | +FOUNDRY_PROFILE=deploy forge script SuccinctStakingScript --private-key $PRIVATE_KEY --rpc-url $ETH_RPC_URL --verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY |
| 85 | +``` |
| 86 | + |
| 87 | +This DOES NOT initalize the contract - this will be done in a later step once references to other contracts are available. |
| 88 | + |
| 89 | +Deploy the $iPROVE contract (assumes $PROVE is already deployed): |
| 90 | + |
| 91 | +```sh |
| 92 | +FOUNDRY_PROFILE=deploy forge script IntermediateSuccinctScript --private-key $PRIVATE_KEY --rpc-url $ETH_RPC_URL --verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY |
| 93 | +``` |
| 94 | + |
| 95 | +Deploy the SuccinctGovernor contract: |
| 96 | + |
| 97 | +```sh |
| 98 | +FOUNDRY_PROFILE=deploy forge script SuccinctGovernorScript --private-key $PRIVATE_KEY --rpc-url $ETH_RPC_URL --verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY |
| 99 | +``` |
| 100 | + |
| 101 | +Deploy the SuccinctVApp implementation and proxy contracts (assumes verifier is already deployed): |
| 102 | + |
| 103 | +```sh |
| 104 | +FOUNDRY_PROFILE=deploy forge script SuccinctVAppScript --private-key $PRIVATE_KEY --rpc-url $ETH_RPC_URL --verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY |
| 105 | +``` |
| 106 | + |
| 107 | +If the SP1VerifierGateway is not already deployed, follow steps in [sp1-contracts](https://github.com/succinctlabs/sp1-contracts) to deploy it and fill out the address in your `{CHAIN_ID}.json` file. |
| 108 | + |
| 109 | +Initalize the SuccinctStaking contract: |
| 110 | + |
| 111 | +```sh |
| 112 | +FOUNDRY_PROFILE=deploy forge script SuccinctStakingScript --sig "initialize()" --private-key $PRIVATE_KEY --broadcast --rpc-url $ETH_RPC_URL |
| 113 | +``` |
| 114 | + |
| 115 | +### Post-deployment |
| 116 | + |
| 117 | +At this point, you should have all the predicted addresses in your `{CHAIN_ID}.json` file. You should now re-run these with the `--broadcast` flag to actually deploy the contracts. |
| 118 | + |
| 119 | +Run the integrity check: |
| 120 | + |
| 121 | +```sh |
| 122 | +FOUNDRY_PROFILE=deploy forge script PostDeploymentScript --rpc-url $ETH_RPC_URL |
| 123 | +``` |
| 124 | + |
| 125 | +If that passes without reverting, the contracts have been successfully deployed and initalized. The addresses are in the `{CHAIN_ID}.json` file. |
| 126 | + |
| 127 | +## Verification |
| 128 | + |
| 129 | +If any of the contracts failed to verify on Etherscan, you can manually verify them by copying the the flatten source code and uploading it to Etherscan. |
| 130 | + |
| 131 | +To do this, go to the address on Etherscan and click "Verify Contract". Choose: |
| 132 | + |
| 133 | +* Compiler: "Solidity (Single File)" |
| 134 | +* Compiler Version: "0.8.28" |
| 135 | +* License: "MIT" |
| 136 | + |
| 137 | +Then flatten the contract you're verifying, for example the SuccinctStaking contract: |
| 138 | + |
| 139 | +```sh |
| 140 | +forge flatten src/SuccinctStaking.sol |
| 141 | +``` |
| 142 | + |
| 143 | +Copy the output into the "Contract Code" field. |
| 144 | + |
| 145 | +Then enter the compiler settings from the [foundry.toml](./foundry.toml) file's `[profile.deploy]` section. |
| 146 | + |
| 147 | +If any constructor arguements were used but not shown in the "Constructor Arguments" field, use `cast abi-encode` with the appropriate signature to encode them, for example: |
| 148 | + |
| 149 | +```sh |
| 150 | +cast abi-encode "constructor(address)" 0xbD74E9B0Dcb0317E26505CA93757c29d564B533B |
| 151 | +``` |
| 152 | + |
| 153 | +strip the `0x` prefix from this output and paste it into the "Constructor Arguments" field. |
0 commit comments