Skip to content

Commit 96b4cc8

Browse files
committing up to deploy problem
1 parent fac89df commit 96b4cc8

File tree

3 files changed

+113
-110
lines changed

3 files changed

+113
-110
lines changed
Lines changed: 82 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
First, we must navigate into the `deployment/` directory and create a new `deploy_parameters.json` by copying the example
1+
## Configure deployment parameters
2+
3+
1. `cd` to the `deployment/` directory and create a new `deploy_parameters.json` by copying the example
24

35
```bash
4-
~/cdk-validium/cdk-validium-contracts-0.0.2 % cd deployment
5-
~/cdk-validium/cdk-validium-contracts-0.0.2/deployment % cp deploy_parameters.json.example deploy_parameters.json
6+
cd /cdk-validium/cdk-validium-contracts-0.0.2/deployment
7+
cp deploy_parameters.json.example deploy_parameters.json
68
```
79

8-
### Configure deployment parameters
9-
10-
There are several fields that need to be changed inside `deploy_parameters.json`.
11-
- trustedSequencer
12-
- trustedAggregator
13-
- admin
14-
- cdkValidiumOwner
15-
- initialCDKValidiumDeployerOwner
16-
- trustedSequencerURL
17-
- forkID
10+
!!! info "Parameters that need to be updated in `deploy_parameters.json`"
11+
- `trustedSequencer`
12+
- `trustedAggregator`
13+
- `admin`
14+
- `cdkValidiumOwner`
15+
- `initialCDKValidiumDeployerOwner`
16+
- `trustedSequencerURL`
17+
- `forkID`
1818

19-
We can run this `jq` script to streamline the process of replacing these fields:
19+
2. Run the following `jq` script to streamline the process of replacing these fields:
2020

2121
```bash
2222
source /tmp/cdk/.env
2323
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
2424
```
2525

26-
Your complete `deploy_parameters.json` should look similar to this:
26+
3. The complete `deploy_parameters.json` should look something like this:
2727

2828
```bash
2929
cat ~/cdk-validium/cdk-validium-contracts-0.0.2/deployment/deploy_parameters.json
@@ -56,95 +56,102 @@ cat ~/cdk-validium/cdk-validium-contracts-0.0.2/deployment/deploy_parameters.jso
5656
}
5757
```
5858
59-
Now we have set the configuration for our contracts, lets deploy!
59+
## Deploy and verify contracts
6060
61-
The first step is deploying and verifying the `CDKValidiumDeployer`, this will be the factory for deterministic contracts, the address of the contracts will depend on the salt and the `initialCDKValidiumDeployerOwner` inside `deploy_parameters.json`.
61+
### `CDKValidiumDeployer`
6262
63-
```bash
64-
~/cdk-validium/cdk-validium-contracts-0.0.2/deployment % npm run deploy:deployer:CDKValidium:sepolia
65-
```
63+
This contract is a factory that deploys the deterministic contracts required by the system and must be deployed first.
6664
67-
On successful deployment of `CDKValidiumDeployer`, you should see something similar to this:
65+
The address of the contracts it creates depends on the salt and the `initialCDKValidiumDeployerOwner` inside `deploy_parameters.json`.
6866
69-
```bash
70-
cdkValidiumDeployer deployed on: 0x87572242776ccb6c98F4Cf1ff20f7e5a4e4142fF
71-
```
67+
1. Run the deploy script.
7268
73-
Now we can move forward and deploy the rest of the contract suite:
69+
```bash
70+
npm run deploy:deployer:CDKValidium:sepolia
71+
```
7472
75-
```bash
76-
~/cdk-validium/cdk-validium-contracts-0.0.2/deployment % npm run deploy:testnet:CDKValidium:sepolia
77-
```
73+
You should see something similar to this:
7874
79-
Please note this can take several minutes depending on network conditions.
75+
```bash
76+
cdkValidiumDeployer deployed on: 0x87572242776ccb6c98F4Cf1ff20f7e5a4e4142fF
77+
```
8078
81-
On successful deployment, a new directory named `deployments` should have been created. Inside that directory, another was created with information about your deployment.
79+
2. Now we can deploy the rest of the contract suite.
8280
83-
```bash
84-
# ~/cdk-validium/cdk-validium-contracts-0.0.2/deployments/sepolia_1705429054/deploy_output.json
85-
{
86-
"cdkValidiumAddress": "0x37eEBCa90363b0952e03a64979B64AAE3b8C9631",
87-
"polygonZkEVMBridgeAddress": "0x3485bfA6F27e54a8FF9782032fdbC7C555c178E4",
88-
"polygonZkEVMGlobalExitRootAddress": "0x8330E90c82F4BDDfa038041B898DE2d900e6246C",
89-
"cdkDataCommitteeContract": "0xb49d901748c3E278a634c05E0c500b23db992fb0",
90-
"maticTokenAddress": "0x20db28Bb7C779a06E4081e55808cc5DE35cca303",
91-
"verifierAddress": "0xb01Be1534d1eF82Ba98DCd5B33A3A331B6d119D0",
92-
"cdkValidiumDeployerContract": "0x87572242776ccb6c98F4Cf1ff20f7e5a4e4142fF",
93-
"deployerAddress": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE",
94-
"timelockContractAddress": "0xDa476BD0B6A660cd08239dEb620F701877688c6F",
95-
"deploymentBlockNumber": 5097689,
96-
"genesisRoot": "0xf07cd7c4f7df7092241ccb2072d9ac9e800a87513df628245657950b3af78f94",
97-
"trustedSequencer": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE",
98-
"trustedSequencerURL": "http://127.0.0.1:8123",
99-
"chainID": 1001,
100-
"networkName": "cdk-validium",
101-
"admin": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE",
102-
"trustedAggregator": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE",
103-
"proxyAdminAddress": "0x828E55268524c13dB25FD33f2Be45D2771f1EeA4",
104-
"forkID": 6,
105-
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
106-
"version": "0.0.1"
107-
}
108-
```
81+
```bash
82+
npm run deploy:testnet:CDKValidium:sepolia
83+
```
10984
110-
In addition to `deploy_output.json`, a `genesis.json` should have been generated in `~/cdk-validium/cdk-validium-contracts-0.0.2/deployment/`
111-
We will take the outputs of `genesis.json` and `deploy_output.json` and use them to configure our node in the next steps of setup and deployment of `cdk-validium-node`.
85+
!!! info
86+
This may take several minutes depending on network conditions.
11287
88+
3. On successful deployment, you should see a new directory named `deployments` containing a directory storing the information about your deployment. For example:
11389
114-
Congrats! You’ve deployed the CDK Validium contracts!
90+
```bash
91+
# ~/cdk-validium/cdk-validium-contracts-0.0.2/deployments/sepolia_1705429054/deploy_output.json
92+
{
93+
"cdkValidiumAddress": "0x37eEBCa90363b0952e03a64979B64AAE3b8C9631",
94+
"polygonZkEVMBridgeAddress": "0x3485bfA6F27e54a8FF9782032fdbC7C555c178E4",
95+
"polygonZkEVMGlobalExitRootAddress": "0x8330E90c82F4BDDfa038041B898DE2d900e6246C",
96+
"cdkDataCommitteeContract": "0xb49d901748c3E278a634c05E0c500b23db992fb0",
97+
"maticTokenAddress": "0x20db28Bb7C779a06E4081e55808cc5DE35cca303",
98+
"verifierAddress": "0xb01Be1534d1eF82Ba98DCd5B33A3A331B6d119D0",
99+
"cdkValidiumDeployerContract": "0x87572242776ccb6c98F4Cf1ff20f7e5a4e4142fF",
100+
"deployerAddress": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE",
101+
"timelockContractAddress": "0xDa476BD0B6A660cd08239dEb620F701877688c6F",
102+
"deploymentBlockNumber": 5097689,
103+
"genesisRoot": "0xf07cd7c4f7df7092241ccb2072d9ac9e800a87513df628245657950b3af78f94",
104+
"trustedSequencer": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE",
105+
"trustedSequencerURL": "http://127.0.0.1:8123",
106+
"chainID": 1001,
107+
"networkName": "cdk-validium",
108+
"admin": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE",
109+
"trustedAggregator": "0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE",
110+
"proxyAdminAddress": "0x828E55268524c13dB25FD33f2Be45D2771f1EeA4",
111+
"forkID": 6,
112+
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
113+
"version": "0.0.1"
114+
}
115+
```
115116
116-
### 2. Verifying contracts
117+
4. In addition to the `deploy_output.json` file, you should see a `genesis.json` file in `~/cdk-validium/cdk-validium-contracts-0.0.2/deployment/`.
117118
118-
If deploying to Sepolia, the contracts should be automatically verified based on other live deployments on the network with similar bytecode. If you see that the contracts have not been verified on Etherscan. Run the following commands:
119+
We will take the outputs of `genesis.json` and `deploy_output.json` and use them to configure the `cdk-validium-node` node.
119120
120-
To verify the contract factory:
121+
!!! warning "Deployment failure"
122+
- 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.
123+
- It's mandatory to delete the `~/cdk-validium/cdk-validium-contracts-0.0.2/.openzeppelin` upgradability information in order to make a new deployment.
121124
122-
```bash
123-
~/cdk-validium/cdk-validium-contracts-0.0.2/deployment % npm run verify:deployer:CDKValidium:sepolia
124-
```
125+
## Verifying contracts
125126
126-
To verify the rest of the contract suite:
127+
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.
127128
128-
```bash
129-
~/cdk-validium/cdk-validium-contracts-0.0.2/deployment % npm run verify:CDKValidium:sepolia
130-
```
129+
1. To verify the contract factory:
130+
131+
```bash
132+
npm run verify:deployer:CDKValidium:sepolia
133+
```
134+
135+
2. To verify the rest of the contract suite:
131136
132-
### Using a different node provider
137+
```bash
138+
npm run verify:CDKValidium:sepolia
139+
```
133140
134-
If you prefer to use a different node provider than Infura, the contents of `~/cdk-validium/cdk-validium-contracts-0.0.2/hardhat.config.js` and `.env` can be modified to fit your provider.
141+
## Using a different node provider
135142
136-
For example using Alchemy:
143+
Modify the contents of `~/cdk-validium/cdk-validium-contracts-0.0.2/hardhat.config.js` and `cdk-validium-contracts-0.0.2/.env` if you prefer to use a different node provider than Infura.
144+
145+
For example, using Alchemy:
137146
138147
```bash
139-
# ~/cdk-validium/cdk-validium-contracts-0.0.2/.env
140148
MNEMONIC="island debris exhaust typical clap debate exhaust little verify mean sausage entire"
141149
INFURA_PROJECT_ID="" # or blank if not using Infura
142150
ETHERSCAN_API_KEY="1234567890abcdefghijklmnopqr" # or blank if not verify contracts
143151
ALCHEMY_PROJECT_ID="dGPpsDzM9KpFTEnqMO44rvIXcc0fmgxr" # add this line
144152
```
145153
146154
```bash
147-
# ~/cdk-validium/cdk-validium-contracts-0.0.2/hardhat.config.js
148155
sepolia: {
149156
url: `https://eth-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_PROJECT_ID}`, # rpc value changed here
150157
accounts: {
@@ -154,10 +161,4 @@ sepolia: {
154161
count: 20,
155162
},
156163
},
157-
```
158-
159-
### Deployment failure
160-
161-
- Since there are deterministic address 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.
162-
163-
- It's mandatory to delete the `~/cdk-validium/cdk-validium-contracts-0.0.2/.openzeppelin` upgradability information in order to make a new deployment
164+
```

docs/cdk/get-started/deploy-validium/prerequisites.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Make sure you have the following software:
1919

2020
You will need the following:
2121

22-
- A Sepolia node RPC URL: e.g. https://goerli.infura.io/v3/YOUR-INFURA-API-KEY
23-
- An account address holding minimum 2 Sepolia ETH.
22+
- A Sepolia node RPC URL: e.g. https://sepolia.infura.io/v3/YOUR-INFURA-API-KEY
23+
- An account holding minimum 2 Sepolia ETH that you can send to a generated address within CDK.
2424

2525
### Faucets
2626

@@ -32,15 +32,15 @@ Use a public faucet to get Sepolia test ETH.
3232

3333
## Configuration files
3434

35-
Create a folder inside `/tmp/` named `/cdk/` that will store all the configuration files.
35+
Create a folder in `/tmp/cdk/` to store configuration files.
3636

3737
```bash
3838
mkdir /tmp/cdk/
3939
```
4040

4141
## Environment variables
4242

43-
Create a `.env` file to store environment variables.
43+
Create a `.env` file to store environment variables we will use later on.
4444

4545
```bash
4646
nano /tmp/cdk/.env
Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Download the `cdk-validium-contracts`
1+
## Download the validium repo
22

3-
1. Create a new directory to store the `cdk-validium-contracts` and the `cdk-validium-node` and cd into it.
3+
1. Create a new directory and cd into it.
44

55
```bash
66
mkdir cdk-validium
@@ -10,43 +10,40 @@
1010
2. Download the `0.0.2` release from the [cdk-validium-contracts github repo](https://github.com/0xPolygon/cdk-validium-contracts/releases/tag/v0.0.2-RC1).
1111

1212
!!! note
13-
It is available in both `.tar.gz` and `.zip` formats
13+
The download is available in both `.tar.gz` and `.zip` formats.
1414

1515
```bash
16-
~/cdk-validium % curl -L -o cdk-validium-contracts.tar.gz https://github.com/0xPolygon/cdk-validium-contracts/archive/refs/tags/v0.0.2.tar.gz
17-
18-
tar -xzf cdk-validium-contracts.tar.gz
16+
curl -L -o cdk-validium-contracts.tar.gz https://github.com/0xPolygon/cdk-validium-contracts/archive/refs/tags/v0.0.2.tar.gz
1917
```
2018

21-
## Prepare the environment
22-
23-
`cd` into `cdk-validium-contracts-0.0.2/`
19+
3. Extract the files and cd into the repo.
2420

25-
```bash
26-
~/cdk-validium % cd cdk-validium-contracts-0.0.2/
27-
```
21+
```bash
22+
tar -xzf cdk-validium-contracts.tar.gz
23+
cd cdk-validium-contracts-0.0.2/
24+
```
2825

29-
### Install the dependencies
26+
## Install the dependencies
3027

3128
```bash
32-
~/cdk-validium/cdk-validium-contracts-0.0.2 % npm install
29+
npm install
3330
```
3431

35-
### Create the .env configuration
32+
## Create the .env configuration
3633

3734
1. Copy the environment configuration example file into a new `.env` file.
3835

3936
```bash
40-
~/cdk-validium/cdk-validium-contracts-0.0.2 % cp .env.example .env
37+
cp .env.example .env
38+
nano .env
4139
```
4240

43-
2. The file requires the following environment variables.
41+
2. Add the environment variables.
4442

4543
```bash
46-
# ~/cdk-validium/cdk-validium-contracts-0.0.2/.env
47-
MNEMONIC="<generated mnemonic>" # see instructions below
44+
MNEMONIC="<generated mnemonic>" # see instructions below in step 3
4845
INFURA_PROJECT_ID="<INFURA_PROJECT_ID>" # Generate a project id on [Infura](https://www.infura.io/)
49-
ETHERSCAN_API_KEY="<ETHERSCAN_API_KEY>" # Generate a project id on [Etherscan](https://etherscan.io)
46+
ETHERSCAN_API_KEY="<ETHERSCAN_API_KEY>" # Generate an API key on [Etherscan](https://etherscan.io)
5047
```
5148

5249
3. Generate a new mnemonic using `cast`.
@@ -55,7 +52,8 @@
5552
cast wallet new-mnemonic --words 12
5653
```
5754

58-
*note: if command **`new-mnemonic`** is not found, update foundry using **`foundryup`***
55+
!!! important
56+
If the command `new-mnemonic` is not found, update foundry with `foundryup` and try again.
5957

6058
The output should look something like this:
6159

@@ -68,15 +66,19 @@
6866
Private key: 0x3b01870a8449ada951f59c0275670bea1fc145954ee7cb1d46f7d21533600726
6967
```
7068

71-
4. Copy and paste the newly generated `Phrase` into the `MNEMONIC` field inside `.env`
69+
4. Copy and paste the newly generated `Phrase` into the `MNEMONIC` field inside `cdk-validium-contracts-0.0.2/.env`
7270

71+
5. Send 2 Sepolia ETH to the generated address.
7372

74-
5. Load the variables into `/tmp/cdk.env`. This is an important step and allows us to use `jq` and `tomlq` later on to setup our configuration files.
73+
6. Add the following variables to `/tmp/cdk/.env`.
7574

7675
```bash
7776
# /tmp/cdk/.env
78-
TEST_ADDRESS=0x8Ea797e7f349dA91078B1d833C534D2c392BB7FE
79-
TEST_PRIVATE_KEY=0x3b01870a8449ada951f59c0275670bea1fc145954ee7cb1d46f7d21533600726
77+
TEST_ADDRESS=<the address generated by cast>
78+
TEST_PRIVATE_KEY=<the private key generated by cast>
8079
L1_URL=https://sepolia.infura.io/v3/<YOUR INFURA PROJECT ID>
8180
L1_WS_URL=wss://sepolia.infura.io/ws/v3/<YOUR INFURA PROJECT ID>
8281
```
82+
!!! important
83+
This step allows us to use `jq` and `tomlq` later on to setup our configuration files.
84+

0 commit comments

Comments
 (0)