-
Notifications
You must be signed in to change notification settings - Fork 100
v7 to v9 config migration script #669
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
Open
so-schen
wants to merge
46
commits into
master
Choose a base branch
from
sc/upgrade-test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 39 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
ed3c6dc
rpc config migration v7 to v8
so-schen bdc4e3c
rpc config migration v7 to v8
so-schen 8af24f4
show diff after migration
so-schen bf02ca3
packaging script
so-schen 5367ec0
support migrate path choices
so-schen ce4392a
support migrate path choices
so-schen 9e2d0e3
support migrate path choices
so-schen 714fbce
add pytest to check diff
so-schen d882201
improve ux
so-schen 9f0d675
restore v7.1.8 template
so-schen f1aa83d
update cli help ui
so-schen e37634f
add readme
so-schen 711bbd2
add migrate smrsetting
so-schen 67c8501
refactor
so-schen b4cc37e
update readme
so-schen b221ad3
address comments
so-schen 710b4df
prepare v9 mainnet rpc config template
so-schen 21e08af
prepare v9 mainnet smr settings template
so-schen 8bd12e8
update docs
so-schen 1ecfe57
update docs
so-schen ce726ac
migrate to v9 using templating
so-schen f79fe03
migrate to smr settings v9 using templating
so-schen b20842f
update readme
so-schen 58ef54f
Merge pull request #670 from Entropy-Foundation/sc/upgrade-config-tem…
so-schen fa0774a
support dump template to toml file in cli
so-schen 1007cb1
wip: packaing toml file
so-schen 700e56d
package toml in pip, impl scan updates
so-schen 5161f9e
fmt
so-schen 0a2c4b6
scanning all parmaeters
so-schen 17d501f
Merge pull request #671 from Entropy-Foundation/sc/script-integration
so-schen 1f7af5b
add docs
so-schen f884b17
update readme example
so-schen b1d2091
rename dir
so-schen 9c7f76a
add back
so-schen 4ba2e84
add
so-schen 5d366dc
update docs
so-schen 1fc2cb9
update err handling
so-schen 1dc5842
update docs
so-schen 829f5e5
add docs and print
so-schen 5bc69c7
Update node_management/config_migration/src/rpc_config/rpc_config_v9_…
so-schen db185ea
chore: remove codes
so-schen db87a3b
address comments
so-schen a496619
enable_pruning = true for rpc
so-schen 7f1330e
add config only migration script for operator
so-schen 3f7c5ec
keep originl value in chain instance
so-schen 72be37d
fix test
so-schen 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 hidden or 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,13 @@ | ||
# Ignore all files in the ruff cache directory | ||
**/.ruff_cache | ||
|
||
**/build/ | ||
|
||
# egg-info | ||
**/*.egg-info/ | ||
|
||
# python cache | ||
**/__pycache__/ | ||
|
||
# pytest | ||
**/.hypothesis/ |
This file contains hidden or 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,220 @@ | ||
|
||
### Usage Example | ||
|
||
|
||
alias rpc-v8=~/Documents/share/repo/smr-moonshot-testnet/target/devopt/rpc_node | ||
alias rpc-v9=~/Documents/share/repo/smr-moonshot/target/release/rpc_node | ||
|
||
alias supra-v8="~/Documents/share/repo/smr-moonshot-testnet/target/devopt/supra" | ||
alias supra-v9="~/Documents/share/repo/smr-moonshot/target/release/supra" | ||
|
||
|
||
1. Install the `migrate-config` tool | ||
|
||
```sh | ||
pip install . | ||
``` | ||
|
||
2. Migrate rpc | ||
|
||
```sh | ||
# Migrate rpc config from v7 to v9 | ||
migrate-config rpc -p v7-v9 -f config.toml -t config.toml | ||
# Migrate db from v7 to v8 | ||
rpc-v8 migrate-db config.toml | ||
# Migrate db from v8 to v9 | ||
rpc-v9 migrate-db config.toml | ||
``` | ||
|
||
3. Migrate smr/validator | ||
|
||
```sh | ||
# Migrate cli profile from v7 to v8 | ||
supra-v8 migrate --network localnet | ||
cp validator_identity.pem node_identity.pem | ||
# Migrate cli profile from v8 to v9 | ||
supra-v9 profile migrate | ||
|
||
# Migrate smr_settings from v7 to v9 | ||
migrate-config smr -p v7-v9 -f smr_settings.toml -t smr_settings.toml | ||
# Migrate db from v7 to v9 | ||
supra-v9 data migrate -p smr_settings.toml | ||
``` | ||
|
||
|
||
### Migrate from v7 to v9 example flow | ||
|
||
#### RPC | ||
|
||
1. Config migration | ||
|
||
$ migrate-config rpc -p v7-v9 -f config.toml -t config.toml | ||
|
||
Running migration function: migrate_v7_to_v9 | ||
|
||
Scanning root level configuration ... | ||
✓ `consensus_access_tokens` not found in original config, using new version's default value: [] | ||
`allowed_origin = <AoT [{'url': 'https://rpc-mainnet.supra.com', ...` is not recommended for new version. | ||
Do you want to apply the recommended config: `allowed_origin = <AoT [{'url': 'https://rpc-mainnet.supra.com', ...`? [y/N]: y | ||
✓ Apply recommended config: `allowed_origin = <AoT [{'url': 'https://rpc-mainnet.supra.com', ...` | ||
|
||
Scanning chain state assembler configuration ... | ||
✓ `certified_block_cache_bucket_size` not found in original config, using new version's default value: 50 | ||
|
||
Scanning archive configuration ... | ||
✓ `enable_pruning` not found in original config, using new version's default value: False | ||
`enable_snapshots = True` is not recommended for new version. | ||
Do you want to apply the recommended config: `enable_snapshots = False`? [y/N]: y | ||
✓ Apply recommended config: `enable_snapshots = False` | ||
|
||
Scanning ledger configuration ... | ||
✓ `enable_pruning` not found in original config, using new version's default value: False | ||
✓ `enable_snapshots` not found in original config, using new version's default value: False | ||
|
||
Scanning chain store configuration ... | ||
✓ `enable_pruning` not found in original config, using new version's default value: False | ||
`enable_snapshots = True` is not recommended for new version. | ||
Do you want to apply the recommended config: `enable_snapshots = False`? [y/N]: y | ||
✓ Apply recommended config: `enable_snapshots = False` | ||
|
||
Scanning snapshot configuration ... | ||
Warning: [database_setup.prune_config] table not found in v7 config. Skipping migration. | ||
Writing new config to /tmp/newconfig.toml | ||
|----------------- Begin diff v7 vs v9 -----------------| | ||
.. | ||
|----------------- End diff v7 vs v9 -----------------| | ||
|
||
###################################################################### | ||
# Config migrated from tests/config_v7.1.8.toml to /tmp/newconfig.toml. | ||
# | ||
# Please review the diff above for changes made during migration. | ||
# | ||
# Please ensure to use the new config file for target binary version. | ||
###################################################################### | ||
|
||
2. DB migration | ||
|
||
**You need to have both v8 and v9 `rpc_node` binary to run the db migration.** | ||
|
||
$ rpc-v8 migrate-db config.toml | ||
|
||
[================================================================================================================================================================================================] 100/100 | ||
MigrationReport { drop_cf: ["tx_block_info"], migrate_kv: {"tx_block_info__txn_hash_to_block_hash": 8537} } | ||
|
||
$ rpc-v9 migrate-db config.toml | ||
|
||
Counting the number of entries in certified_block... | ||
Migrating certified_block to certified_block_dehydrated: [00:00:00] ████████████████████ 243/243 00:00:00 | ||
Counting the number of entries in uncommitted_block... | ||
Preparing to clean up uncommitted_block: [00:00:00] ████████████████████ 244/244 00:00:00 | ||
Cleaning up uncommitted_block: [00:00:00] ████████████████████ 0/0 00:00:00 | ||
Counting the number of entries in certified_block... | ||
Counting the number of entries in certified_block_dehydrated... | ||
Counting the number of entries in uncommitted_block... | ||
Counting the number of entries in qc... | ||
Verifying certified_block_dehydrated: [00:00:00] ████████████████████ 244/244 00:00:00 | ||
Counting the number of entries to remove from prune_index... | ||
Cleaning up prune index: [00:00:00] ████████████████████ 244/244 00:00:00 | ||
Counting the number of entries in block_to_transaction... | ||
Migrating block_to_transaction: [00:00:00] ████████████████████ 8537/8537 00:00:00 | ||
dropped: | ||
- certified_block | ||
- block_to_tx | ||
migrated: | ||
block_to_tx -> block_to_tx_ordered: Migrated 8537 records, up to 239 block height | ||
certified_block -> certified_block_dehydrated: Migrated 244 records, up to 244 block height | ||
databases_checked: | ||
- chain_store | ||
- archive | ||
|
||
#### SMR | ||
|
||
1. Profile/Identity migration | ||
|
||
**You need both v8 and v9 supra binary to run the profile migratino.** | ||
|
||
$ supra-v8 migrate --network mainnet | ||
|
||
$ cp validator_identity.pem node_identity.pem | ||
|
||
$ supra-v9 profile migrate | ||
|
||
2. Config migration | ||
|
||
$ migrate-config smr -p v7-v9 -f smr_settings.toml -t smr_settings.toml | ||
|
||
Running migration function: migrate_v7_to_v9 | ||
|
||
Scanning node root configuration ... | ||
`connection_refresh_timeout_sec = 2` is not recommended for new version. | ||
Do you want to apply the recommended config: `connection_refresh_timeout_sec = 1`? [y/N]: y | ||
✓ Apply recommended config: `connection_refresh_timeout_sec = 1` | ||
|
||
Scanning ledger configuration ... | ||
✓ `enable_pruning` not found in original config, using new version's default value: True | ||
✓ `enable_snapshots` not found in original config, using new version's default value: False | ||
|
||
Scanning chain store configuration ... | ||
✓ `enable_snapshots` not found in original config, using new version's default value: False | ||
|
||
Scanning prune configuration ... | ||
|
||
Scanning mempool configuration ... | ||
`max_batch_delay_ms = 1500` is not recommended for new version. | ||
Do you want to apply the recommended config: `max_batch_delay_ms = 500`? [y/N]: y | ||
✓ Apply recommended config: `max_batch_delay_ms = 500` | ||
|
||
Scanning moonshot configuration ... | ||
`message_recency_bound_rounds = 20` is not recommended for new version. | ||
Do you want to apply the recommended config: `message_recency_bound_rounds = 1000`? [y/N]: y | ||
✓ Apply recommended config: `message_recency_bound_rounds = 1000` | ||
`sync_retry_delay_ms = 2000` is not recommended for new version. | ||
Do you want to apply the recommended config: `sync_retry_delay_ms = 1000`? [y/N]: y | ||
✓ Apply recommended config: `sync_retry_delay_ms = 1000` | ||
`timeout_delay_ms = 5000` is not recommended for new version. | ||
Do you want to apply the recommended config: `timeout_delay_ms = 3500`? [y/N]: y | ||
✓ Apply recommended config: `timeout_delay_ms = 3500` | ||
Writing new config to /tmp/new_smr.toml | ||
|----------------- Begin diff v7 vs v9 -----------------| | ||
--- v7 | ||
+++ v9 | ||
.. | ||
|----------------- End diff v7 vs v9 -----------------| | ||
|
||
###################################################################### | ||
# Config migrated from tests/smr_settings_v7.1.x.toml to /tmp/new_smr.toml. | ||
# | ||
# Please review the diff above for changes made during migration. | ||
# | ||
# Please ensure to use the new config file for target binary version. | ||
###################################################################### | ||
|
||
3. DB migration | ||
|
||
**You need v9 supra binary to run the db migration.** | ||
|
||
$ supra-v9 data migrate -p smr_settings.toml | ||
|
||
Counting the number of entries in certified_block... | ||
Migrating certified_block to certified_block_dehydrated: [00:00:00] ████████████████████ 69/69 00:00:00 | ||
Counting the number of entries in uncommitted_block... | ||
Preparing to clean up uncommitted_block: [00:00:00] ████████████████████ 74/74 00:00:00 | ||
Cleaning up uncommitted_block: [00:00:00] ████████████████████ 4/4 00:00:00 | ||
Counting the number of entries in certified_block... | ||
Counting the number of entries in certified_block_dehydrated... | ||
Counting the number of entries in uncommitted_block... | ||
Counting the number of entries in qc... | ||
Verifying certified_block_dehydrated: [00:00:00] ████████████████████ 70/70 00:00:00 | ||
Counting the number of entries to remove from prune_index... | ||
Cleaning up prune index: [00:00:00] ████████████████████ 70/70 00:00:00 | ||
dropped: | ||
- certified_block | ||
migrated: | ||
certified_block -> certified_block_dehydrated: Migrated 70 records, up to 244 block height | ||
databases_checked: | ||
- chain_store | ||
|
||
|
||
### Test harness of migrate-config script | ||
|
||
`PYTHONPATH=src pytest` |
This file contains hidden or 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,27 @@ | ||
[project] | ||
name = "migrate-config" | ||
version = "0.1.0" | ||
description = "Unified CLI tool to migrate Supra RPC and SMR configs." | ||
readme = "README.md" | ||
requires-python = ">=3.10" | ||
dependencies = [ | ||
"tomlkit>=0.13.2", | ||
"click>=8.0.0" | ||
] | ||
|
||
[project.scripts] | ||
migrate-config = "cli.main:main" | ||
|
||
[build-system] | ||
requires = ["setuptools>=61.0", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools] | ||
package-dir = {"" = "src"} | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["src"] | ||
|
||
[tool.setuptools.package-data] | ||
rpc_config = ["rpc_config_v9_1_x_mainnet_template.toml"] | ||
smr_settings = ["smr_settings_v9_1_x_mainnet_template.toml"] |
Empty file.
This file contains hidden or 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,77 @@ | ||
import click | ||
from rpc_config.migrate_path import RPC_CONFIG_MIGRATE_PATH | ||
from rpc_config.migrate_path import run_migration as migrate_rpc_config | ||
from smr_settings.migrate_path import SMR_SETTINGS_MIGRATE_PATH | ||
from smr_settings.migrate_path import run_migration as migrate_smr_config | ||
import common.globals | ||
|
||
|
||
@click.group() | ||
def main(): | ||
"""Migration CLI for Supra configs.""" | ||
|
||
|
||
@main.command() | ||
@click.option( | ||
"--migrate-path", | ||
"-p", | ||
required=True, | ||
type=click.Choice(RPC_CONFIG_MIGRATE_PATH, case_sensitive=True), | ||
help=f"Migration path (choices: {', '.join(RPC_CONFIG_MIGRATE_PATH)})", | ||
) | ||
@click.option( | ||
"--from-file", | ||
"-f", | ||
required=True, | ||
type=click.Path(exists=True), | ||
help="Source config file", | ||
) | ||
@click.option( | ||
"--to-file", "-t", required=True, type=click.Path(), help="Output config file" | ||
) | ||
@click.option( | ||
"--assume-yes", | ||
"-y", | ||
is_flag=True, | ||
default=False, | ||
help="Assume yes for all prompts (default: False)", | ||
) | ||
def rpc(migrate_path, from_file, to_file, assume_yes): | ||
"""Migrate RPC config.""" | ||
common.globals.ASSUME_YES = assume_yes | ||
migrate_rpc_config(migrate_path, from_file, to_file) | ||
|
||
|
||
@main.command() | ||
@click.option( | ||
"--migrate-path", | ||
"-p", | ||
required=True, | ||
type=click.Choice(SMR_SETTINGS_MIGRATE_PATH, case_sensitive=True), | ||
help=f"Migration path (choices: {', '.join(SMR_SETTINGS_MIGRATE_PATH)})", | ||
) | ||
@click.option( | ||
"--from-file", | ||
"-f", | ||
required=True, | ||
type=click.Path(exists=True), | ||
help="Source config file", | ||
) | ||
@click.option( | ||
"--to-file", "-t", required=True, type=click.Path(), help="Output config file" | ||
) | ||
@click.option( | ||
"--assume-yes", | ||
"-y", | ||
is_flag=True, | ||
default=False, | ||
help="Assume yes for all prompts (default: False)", | ||
) | ||
def smr(migrate_path, from_file, to_file, assume_yes): | ||
"""Migrate SMR config.""" | ||
common.globals.ASSUME_YES = assume_yes | ||
migrate_smr_config(migrate_path, from_file, to_file) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Empty file.
This file contains hidden or 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 @@ | ||
ASSUME_YES = False |
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.
Uh oh!
There was an error while loading. Please reload this page.