-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Archive Node Online Migration #1863
Merged
Merged
Changes from 11 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
e58f02a
Archive Node Online Migration
Kbhat1 27a1676
Add migrate-iavl flag for online migration
Kbhat1 c28c783
Update sei cosmos
Kbhat1 3ac501f
Add QMS for online migration (#1870)
yzang2019 30a8311
Add migrate-height flag to start cmd
Kbhat1 e75b222
Bump seidb
Kbhat1 fa3c6b6
Reduce logging
Kbhat1 f5defc1
Archive Migration doc
Kbhat1 0cc3b81
Update form
Kbhat1 241632b
Update
Kbhat1 387c96d
Export metric
Kbhat1 a586dbc
latest height
Kbhat1 0b9647b
Update start module logic
Kbhat1 8dc5c9d
Remove migrate SS command
Kbhat1 df491b9
Enable ss store
Kbhat1 1f5ec16
Update archive node migration docs
Kbhat1 e304dc0
More migration doc updates
Kbhat1 8f928f7
Update metrics in readme
Kbhat1 1acc2df
Merge main
Kbhat1 98ab03c
Remove dex
Kbhat1 9f17ea7
Merge branch 'main' into ArchiveNodeMigrationOnline
Kbhat1 95137f7
Add Faq section
Kbhat1 de06161
Add requirements section
Kbhat1 95b6762
Systemd instructions
Kbhat1 240ccb1
Minor add to readme
Kbhat1 3fea70e
Add more examples for migration height
Kbhat1 2e3376a
Bump sei cosmos
Kbhat1 e2714b5
Update error log
Kbhat1 58498de
Merge branch 'main' into ArchiveNodeMigrationOnline
Kbhat1 9a538af
Update command sc migration background
Kbhat1 ec3d810
Merge branch 'main' into ArchiveNodeMigrationOnline
Kbhat1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
# SeiDB Archive Migration Guide | ||
|
||
## Overview | ||
SeiDB is the next generation of chain storage in SeiV2. | ||
One issue for running SeiDB on archive nodes is that we need to keep the full state of the chain, so we can't | ||
state sync it and clear out previous iavl data. | ||
|
||
In order to run an archive node with SeiDB, we need to run a migration from iavl to sei-db. | ||
|
||
The overall process will work as follows: | ||
Kbhat1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
1. Stop archive node and note down its height, call it MIGRATION_HEIGHT | ||
Kbhat1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
2. Update config to enable SeiDB (state committment + state store) | ||
Kbhat1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3. Run sc migration at the MIGRATION_HEIGHT | ||
Kbhat1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
4. Re start seid with `--migrate-iavl` enabled (migrating state store in background) | ||
5. Verify migration at various sampled heights once state store is complete | ||
6. Stop seid, clear out iavl and restart seid normally, now only using SeiDB fully | ||
Kbhat1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
You may need to ensure you have sufficient disk space available, as during the migration process, both IAVL and SeiDB state stores will need to be maintained simultaneously. This could potentially double your storage requirements temporarily. | ||
|
||
|
||
## Migration Steps | ||
|
||
### Step 1: Stop Node and note down latest height | ||
Stop the seid process and note down the latest height. Save it as an env var $MIGRATION_HEIGHT. | ||
```bash | ||
systemctl stop seid | ||
MIGRATION_HEIGHT=<> | ||
``` | ||
|
||
### Step 2: Add SeiDB Configurations | ||
We can enable SeiDB by adding the following configs to app.toml file. | ||
Usually you can find this file under ~/.sei/config/app.toml. | ||
```bash | ||
############################################################################# | ||
### SeiDB Configuration ### | ||
############################################################################# | ||
|
||
[state-commit] | ||
# Enable defines if the SeiDB should be enabled to override existing IAVL db backend. | ||
sc-enable = true | ||
|
||
# AsyncCommitBuffer defines the size of asynchronous commit queue, this greatly improve block catching-up | ||
# performance, <=0 means synchronous commit. | ||
sc-async-commit-buffer = 100 | ||
|
||
# SnapshotKeepRecent defines how many memiavl snapshots (beyond the latest one) to keep | ||
# Recommend to set to 1 to make sure IBC relayers work. | ||
sc-keep-recent = 1 | ||
|
||
# SnapshotInterval defines the number of blocks interval the memiavl snapshot is taken, default to 10000 blocks. | ||
# Adjust based on your needs: | ||
# Setting this too low could lead to lot of extra heavy disk IO | ||
# Setting this too high could lead to slow restart | ||
sc-snapshot-interval = 10000 | ||
|
||
# SnapshotWriterLimit defines the max concurrency for taking memiavl snapshot | ||
sc-snapshot-writer-limit = 1 | ||
|
||
# CacheSize defines the size of the LRU cache for each store on top of the tree, default to 100000. | ||
sc-cache-size = 100000 | ||
|
||
[state-store] | ||
# Enable defines if the state-store should be enabled for historical queries. | ||
# In order to use state-store, you need to make sure to enable state-commit at the same time. | ||
# Validator nodes should turn this off. | ||
# State sync node or full nodes should turn this on. | ||
ss-enable = true | ||
|
||
# DBBackend defines the backend database used for state-store. | ||
# Supported backends: pebbledb, rocksdb | ||
# defaults to pebbledb (recommended) | ||
ss-backend = "pebbledb" | ||
|
||
# AsyncWriteBuffer defines the async queue length for commits to be applied to State Store | ||
# Set <= 0 for synchronous writes, which means commits also need to wait for data to be persisted in State Store. | ||
# defaults to 100 | ||
ss-async-write-buffer = 100 | ||
|
||
# KeepRecent defines the number of versions to keep in state store | ||
# Setting it to 0 means keep everything, default to 100000 | ||
ss-keep-recent = 0 | ||
|
||
# PruneIntervalSeconds defines the minimum interval in seconds + some random delay to trigger pruning. | ||
# It is more efficient to trigger pruning less frequently with large interval. | ||
# default to 600 seconds | ||
ss-prune-interval = 600 | ||
|
||
# ImportNumWorkers defines the concurrency for state sync import | ||
# defaults to 1 | ||
ss-import-num-workers = 1 | ||
``` | ||
|
||
|
||
### Step 3: Run SC Migration | ||
|
||
```bash | ||
seid tools migrate-iavl --target-db SC --home-dir /root/.sei | ||
Kbhat1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
This may take a couple hours to run. You will see logs of form | ||
`Start restoring SC store for height` | ||
|
||
|
||
### Step 4: Restart seid with background SS migration | ||
```bash | ||
seid start --migrate-iavl --migrate-height $MIGRATION_HEIGHT --chain-id pacific-1 | ||
Kbhat1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
Seid will run normally and the migration will run in the background. Data from iavl | ||
will be written to SS and new writes will be directed at SS not iavl. | ||
|
||
You will see logs of form | ||
`SeiDB Archive Migration: Iterating through %s module...` and | ||
`SeiDB Archive Migration: Last 1,000,000 iterations took:...` | ||
|
||
|
||
NOTE: While this is running, any historical queries will be routed to iavl if | ||
they are for a height BEFORE the migrate-height. Any queries on heights | ||
AFTER the migrate-height will be routed to state store (pebbbledb). | ||
|
||
|
||
### Step 5: Verify State Store Migration after completion | ||
Once State Store Migration is complete, you will see logs of form | ||
`SeiDB Archive Migration: DB scanning completed. Total time taken:...` | ||
|
||
You DO NOT immediately need to do anything. Your node will continue to run | ||
and will operate normally. However we added a verification tool that will iterate through | ||
all keys in iavl at a specific height and verify they exist in State Store. | ||
|
||
You should run the following command for a selection of different heights | ||
```bash | ||
seid tools verify-migration --version $VERIFICATION_HEIGHT | ||
``` | ||
|
||
This will output `Verification Succeeded` if the verification was successful. | ||
|
||
|
||
### Step 6: Clear out Iavl and restart seid | ||
Once the verification is complete, we can proceed to clear out the iavl and | ||
restart seid normally. | ||
|
||
```bash | ||
systemctl stop seid | ||
rm -rf ~/.sei/data/application.db | ||
seid start --chain-id pacific-1 | ||
``` | ||
|
||
|
||
## FAQ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Spawning a Go routine Note