Skip to content

Commit 141b717

Browse files
authored
Merge pull request 0xPolygon#326 from 0xPolygon/cdk/migration
CDK: migration steps for partners
2 parents 4e09945 + 42ef244 commit 141b717

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

docs/cdk/how-to/migrate/fork.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
This document shows Polygon partners how to migrate an isolated CDK stack.
2+
3+
## Process to upgrade forks for isolated CDK chains
4+
5+
In order to avoid reorgs and other undesirable scenarios, all L2 transactions must be verified before upgrading a fork. Verification means that all batches are closed, sequenced, and verified on L1.
6+
7+
Follow the steps to verify all batches for upgrading.
8+
9+
1. Stop the sequencer.
10+
2. Enforce the sequencer to stop at a specific `batch_num`.
11+
12+
1. In the statedb, get WIP batch number:
13+
14+
`SELECT batch_num, wip FROM state.batch WHERE wip IS true;`
15+
16+
Result = X (write down X for later)
17+
18+
2. Edit node config:
19+
20+
1. `Sequencer.Finalizer.HaltOnBatchNumber = X+1`
21+
2. `Sequencer.BatchMaxDeltaTimestamp = “120s” # 1800s`
22+
3. `SequenceSender.WaitPeriodSendSequence = "10s" # 60s`
23+
4. `SequenceSender.LastBatchVirtualizationTimeMaxWaitPeriod = “30s” # 600s`
24+
25+
3. Restart sequencer, sequence-sender.
26+
27+
4. Check sequencer halted when reaching batch `X+1` (this is obvious in the logs).
28+
29+
5. Wait until all pending batches are virtualized (X):
30+
31+
`SELECT batch_num FROM state.virtual_batch ORDER BY batch_num DESC LIMIT 1;` → X
32+
33+
6. Wait until the aggregator has aggregated proofs for all the batches:
34+
35+
1. `SELECT batch_num FROM state.verified_batch ORDER BY batch_num DESC LIMIT 1;` → Y (if Y == X) you can skip next steps until `3. Prepare (**do not apply**) new versions according to the version matrix`
36+
37+
2. `SELECT batch_num, batch_num_final FROM state.proof WHERE NOT generating AND batch_num = Y AND batch_num_final = X` wait until this query returns a row, remove `WHERE` conditions to get a sense of progress.
38+
39+
7. Edit node config to force the aggregator into sending the already aggregated proof ASAP:
40+
41+
`Aggregator.VerifyProofInterval = "5m”`. Then restart aggregator.
42+
43+
8. Wait until the proof is settled on-chain:
44+
45+
`SELECT batch_num FROM state.verified_batch ORDER BY batch_num DESC LIMIT 1;` → X
46+
47+
3. Prepare (**do not apply**) new versions according to the version matrix.
48+
49+
4. Stop all services (node, prover/executor, bridge).
50+
51+
52+
## Update software
53+
54+
1. Start synchronizer's new version.
55+
56+
2. Wait until synchornizer receives a fork id event (check table `state.fork_id`).
57+
58+
3. Edit node config file (node v0.6.2 version):
59+
60+
1. `Sequencer.Finalizer.HaltOnBatchNumber = 0`
61+
62+
4. Start all node components, executors, provers, and bridge with new versions.
63+
64+
5. Check batches ≥ X are virtualized and verified.
65+
66+
6. Edit new node config (restore previous values):
67+
68+
1. `Aggregator.VerifyProofInterval = "25m”` # restore previous value
69+
2. `Sequencer.BatchMaxDeltaTimestamp = “1800s”`
70+
3. `SequenceSender.WaitPeriodSendSequence = "60s”` # restore previous value
71+
4. `SequenceSender.LastBatchVirtualizationTimeMaxWaitPeriod = “600s”` # restore previous value
72+
73+
7. Restart sequencer, sequence-sender, and aggregator.

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ nav:
8383
- Start services: cdk/get-started/deploy-rollup/start-services.md
8484
- Connect to CDK testnet: cdk/get-started/connect-testnet.md
8585
- How to:
86+
- Migrate:
87+
- Fork migration: cdk/how-to/migrate/fork.md
8688
- Use a native token: cdk/how-to/use-native-token.md
8789
- Manage allowlists with policies: cdk/how-to/manage-policies.md
8890
- Quickly test a running stack: cdk/how-to/quick-test-stack.md

0 commit comments

Comments
 (0)