|
| 1 | +## Configure deployment parameters |
| 2 | + |
| 3 | +1. `cd` to the `deployment/` directory and create a new `deploy_parameters.json` by copying the example |
| 4 | + |
| 5 | + ```bash |
| 6 | + cd deployment/ |
| 7 | + cp deploy_parameters.json.example deploy_parameters.json |
| 8 | + ``` |
| 9 | + |
| 10 | +2. Run the following `jq` script to streamline the process of replacing these fields: |
| 11 | + |
| 12 | + ```bash |
| 13 | + source /tmp/cdk/.env |
| 14 | + jq --arg TEST_ADDRESS "$TEST_ADDRESS" '.trustedSequencerURL = "http://127.0.0.1:8123" | .trustedSequencer = $TEST_ADDRESS | .trustedAggregator = $TEST_ADDRESS | .admin = $TEST_ADDRESS | .cdkValidiumOwner = $TEST_ADDRESS | .initialCDKValidiumDeployerOwner = $TEST_ADDRESS | .timelockAddress = $TEST_ADDRESS | .forkID = 6' ./deploy_parameters.json.example > ./deploy_parameters.json |
| 15 | + ``` |
| 16 | + |
| 17 | +3. The complete `deploy_parameters.json` should look something like this, where all the addresses are equal to the generated address except for `maticTokenAddress`: |
| 18 | + |
| 19 | + ```bash |
| 20 | + nano ~/cdk-validium/cdk-validium-contracts-0.0.2/deployment/deploy_parameters.json |
| 21 | + # ~/cdk-validium/cdk-validium-contracts-0.0.2/deployment/deploy_parameters.json |
| 22 | + { |
| 23 | + "realVerifier": false, |
| 24 | + "trustedSequencerURL": "http://127.0.0.1:8123, |
| 25 | + "networkName": "cdk-validium", |
| 26 | + "version":"0.0.1", |
| 27 | + "trustedSequencer":"0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", |
| 28 | + "chainID": 1001, |
| 29 | + "trustedAggregator":"0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", |
| 30 | + "trustedAggregatorTimeout": 604799, |
| 31 | + "pendingStateTimeout": 604799, |
| 32 | + "forkID": 6, |
| 33 | + "admin":"0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", |
| 34 | + "cdkValidiumOwner": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", |
| 35 | + "timelockAddress": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", |
| 36 | + "minDelayTimelock": 3600, |
| 37 | + "salt": "0x0000000000000000000000000000000000000000000000000000000000000000", |
| 38 | + "initialCDKValidiumDeployerOwner" :"0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", |
| 39 | + "maticTokenAddress":"0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", |
| 40 | + "cdkValidiumDeployerAddress":"", |
| 41 | + "deployerPvtKey": "", |
| 42 | + "maxFeePerGas":"", |
| 43 | + "maxPriorityFeePerGas":"", |
| 44 | + "multiplierGas": "", |
| 45 | + "setupEmptyCommittee": true, |
| 46 | + "committeeTimelock": false |
| 47 | + } |
| 48 | + ``` |
| 49 | +
|
| 50 | +## Deploy contracts |
| 51 | +
|
| 52 | +### `CDKValidiumDeployer` |
| 53 | +
|
| 54 | +This is a factory contract that deploys the deterministic contracts required by the system and must be deployed first. |
| 55 | +
|
| 56 | +The address of the contracts it creates depends on the salt and the `initialCDKValidiumDeployerOwner` inside `deploy_parameters.json`. |
| 57 | +
|
| 58 | +1. From the same `deployment` directory, run the deploy script. |
| 59 | +
|
| 60 | + ```bash |
| 61 | + npm run deploy:deployer:CDKValidium:sepolia |
| 62 | + ``` |
| 63 | +
|
| 64 | + You should see something similar to this: |
| 65 | +
|
| 66 | + ```bash |
| 67 | + cdkValidiumDeployer deployed on: 0x87572242776ccb6c98F4Cf1ff20f7e5a4e4142fF |
| 68 | + ``` |
| 69 | +
|
| 70 | +2. Now we can deploy the rest of the contract suite. |
| 71 | +
|
| 72 | + ```bash |
| 73 | + npm run deploy:testnet:CDKValidium:sepolia |
| 74 | + ``` |
| 75 | +
|
| 76 | + !!! info |
| 77 | + This may take several minutes depending on network conditions. |
| 78 | +
|
| 79 | + !!! warning |
| 80 | + If you see this message, you can safely ignore it: |
| 81 | + |
| 82 | + ```sh |
| 83 | + cp: cannot stat '.openzeppelin/sepolia.json': No such file or directory |
| 84 | + ``` |
| 85 | +
|
| 86 | +3. On successful deployment, you should see a new directory named `deployments` containing a directory storing the information about your deployment. For example: |
| 87 | +
|
| 88 | + ```bash |
| 89 | + # ~/cdk-validium/cdk-validium-contracts-0.0.2/deployments/sepolia_1705429054/deploy_output.json |
| 90 | + { |
| 91 | + "cdkValidiumAddress": "0x37eEBCa90363b0952e03a64979B64AAE3b8C9631", |
| 92 | + "polygonZkEVMBridgeAddress": "0x3485bfA6F27e54a8FF9782032fdbC7C555c178E4", |
| 93 | + "polygonZkEVMGlobalExitRootAddress": "0x8330E90c82F4BDDfa038041B898DE2d900e6246C", |
| 94 | + "cdkDataCommitteeContract": "0xb49d901748c3E278a634c05E0c500b23db992fb0", |
| 95 | + "maticTokenAddress": "0x20db28Bb7C779a06E4081e55808cc5DE35cca303", |
| 96 | + "verifierAddress": "0xb01Be1534d1eF82Ba98DCd5B33A3A331B6d119D0", |
| 97 | + "cdkValidiumDeployerContract": "0x87572242776ccb6c98F4Cf1ff20f7e5a4e4142fF", |
| 98 | + "deployerAddress": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", |
| 99 | + "timelockContractAddress": "0xDa476BD0B6A660cd08239dEb620F701877688c6F", |
| 100 | + "deploymentBlockNumber": 5097689, |
| 101 | + "genesisRoot": "0xf07cd7c4f7df7092241ccb2072d9ac9e800a87513df628245657950b3af78f94", |
| 102 | + "trustedSequencer": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", |
| 103 | + "trustedSequencerURL": "http://127.0.0.1:8123", |
| 104 | + "chainID": 1001, |
| 105 | + "networkName": "cdk-validium", |
| 106 | + "admin": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", |
| 107 | + "trustedAggregator": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE", |
| 108 | + "proxyAdminAddress": "0x828E55268524c13dB25FD33f2Be45D2771f1EeA4", |
| 109 | + "forkID": 6, |
| 110 | + "salt": "0x0000000000000000000000000000000000000000000000000000000000000000", |
| 111 | + "version": "0.0.1" |
| 112 | + } |
| 113 | + ``` |
| 114 | +
|
| 115 | +4. In the `~/cdk-validium/cdk-validium-contracts-0.0.2/deployment/` folder, you should also see a `genesis.json` file. |
| 116 | +
|
| 117 | + !!! info |
| 118 | + We use the info in `genesis.json` and `deploy_output.json` to configure the `cdk-validium-node` node. |
| 119 | +
|
| 120 | + !!! warning "Deployment failure" |
| 121 | + - Since there are deterministic addresses, you cannot deploy twice on the same network using the same `salt` and `initialCDKValidiumDeployerOwner` inside `deploy_parameters.json`. Changing one of them is enough to make a new deployment. |
| 122 | + - It's mandatory to delete the `~/cdk-validium/cdk-validium-contracts-0.0.2/.openzeppelin` upgradability information in order to make a new deployment. |
| 123 | +
|
| 124 | +## Verify contracts |
| 125 | +
|
| 126 | +When deploying to Sepolia, the contracts should automatically verify based on other live deployments on the network with similar bytecode. If the contracts have not been verified on Etherscan, run the following commands from the `/cdk-validium/cdk-validium-contracts-0.0.2/deployment` directory. |
| 127 | +
|
| 128 | +1. To verify the contract factory: |
| 129 | +
|
| 130 | + ```bash |
| 131 | + npm run verify:deployer:CDKValidium:sepolia |
| 132 | + ``` |
| 133 | +
|
| 134 | +2. To verify the rest of the contract suite: |
| 135 | +
|
| 136 | + ```bash |
| 137 | + npm run verify:CDKValidium:sepolia |
| 138 | + ``` |
| 139 | +
|
| 140 | +## Use a different node provider |
| 141 | +
|
| 142 | +If you would rather use a different node provider than Infura, modify the contents of `~/cdk-validium/cdk-validium-contracts-0.0.2/hardhat.config.js` and `cdk-validium-contracts-0.0.2/.env` . |
| 143 | +
|
| 144 | +For example, using Alchemy: |
| 145 | +
|
| 146 | +```bash |
| 147 | +MNEMONIC="island debris exhaust typical clap debate exhaust little verify mean sausage entire" |
| 148 | +INFURA_PROJECT_ID="" # or blank if not using Infura |
| 149 | +ETHERSCAN_API_KEY="1234567890abcdefghijklmnopqr" # or blank if not verify contracts |
| 150 | +ALCHEMY_PROJECT_ID="dGPpsDzM9KpFTEnqMO44rvIXcc0fmgxr" # add this line |
| 151 | +``` |
| 152 | +
|
| 153 | +```bash |
| 154 | +sepolia: { |
| 155 | + url: `https://eth-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_PROJECT_ID}`, # rpc value changed here |
| 156 | + accounts: { |
| 157 | + mnemonic: process.env.MNEMONIC || DEFAULT_MNEMONIC, |
| 158 | + path: "m/44'/60'/0'/0", |
| 159 | + initialIndex: 0, |
| 160 | + count: 20, |
| 161 | + }, |
| 162 | + }, |
| 163 | +``` |
0 commit comments