-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,633 additions
and
8 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
load("@crate_index//:defs.bzl", "aliases", "all_crate_deps") | ||
load("@rules_rust//rust:defs.bzl", "rust_binary") | ||
|
||
package(default_visibility = [ | ||
"//:__pkg__", | ||
"//tests/e2e/ledger:__pkg__", | ||
]) | ||
|
||
rust_binary( | ||
name = "genesis-from-db", | ||
srcs = glob(include = ["src/**/*.rs"]), | ||
aliases = aliases(), | ||
proc_macro_deps = all_crate_deps( | ||
proc_macro = True, | ||
), | ||
deps = all_crate_deps( | ||
normal = True, | ||
) + [ | ||
"//src/many-error", | ||
"//src/many-ledger:many-ledger-lib", | ||
"//src/many-modules", | ||
"//src/many-types", | ||
], | ||
) |
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,32 @@ | ||
[package] | ||
name = "genesis-from-db" | ||
version = "0.1.5" # managed by release.sh | ||
edition = "2021" | ||
description = "Create new genesis file from existing storage." | ||
license-file = "../../LICENSE" | ||
homepage = "https://liftedinit.org/" | ||
repository = "https://github.com/liftedinit/many-rs.git" | ||
authors = ["The Lifted Initiative <[email protected]>"] | ||
|
||
[[bin]] | ||
name = "genesis-from-db" | ||
doc = false | ||
|
||
[dependencies] | ||
base64 = "0.21.2" | ||
clap = { version = "3.2.25", features = ["derive"] } | ||
const_format = "0.2.31" | ||
hex = "0.4.3" | ||
many-error = { path = "../many-error", version = "0.1.5" } # managed by release.sh | ||
many-ledger = { path = "../many-ledger", version = "0.1.5" } # managed by release.sh | ||
many-modules = { path = "../many-modules", version = "0.1.5" } # managed by release.sh | ||
many-types = { path = "../many-types", version = "0.1.5" } # managed by release.sh | ||
merk = { git = "https://github.com/liftedinit/merk.git", rev = "857bf81963d9282ab03438da5013e1f816bd9da1" } | ||
minicbor = "0.19.1" | ||
serde = "1.0.163" | ||
serde_derive = "1.0.163" | ||
serde_json = "1.0.96" | ||
strum = "0.24.1" | ||
strum_macros = "0.24.3" | ||
tracing = "0.1.37" | ||
tracing-subscriber = "0.3.17" |
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,57 @@ | ||
# genesis-from-db | ||
|
||
This is a tool to extract the genesis data from a RocksDB store. | ||
This tool requires the persistent storage to have the following migrations activated: | ||
- Data migration | ||
- Memo migration | ||
- Token migration | ||
|
||
This tool will extract | ||
- The IDStore seed | ||
- The IDStore keys | ||
- The symbols | ||
- The token identity | ||
- The account identity | ||
- The balances | ||
- The accounts | ||
and create a genesis file, i.e., `ledger_state.json`. | ||
|
||
It also has the ability to extract | ||
- Events | ||
- Multisig transactions | ||
|
||
and output the result as JSON. | ||
|
||
This tool will NOT extract | ||
- The data attributes (recalculated at block 1) | ||
- The data info (recalculated at block 1) | ||
- The token extended info (not used in the genesis) | ||
- The next subresource id (recalculated) | ||
- Kvstore-related data | ||
|
||
The new genesis file can be used to start a new ledger with the same state as the original ledger. The following | ||
migrations will need to be activated from block 0 | ||
- Data migration | ||
- Memo migration | ||
- Token migration | ||
|
||
## Usage | ||
|
||
```sh | ||
# Create a new genesis file from the database | ||
$ genesis-from-db storage.db genesis > ledger_state.json | ||
|
||
# Extract events from the database | ||
$ genesis-from-db storage.db events > events.json | ||
|
||
# Extract multisig transactions from the database | ||
$ genesis-from-db storage.db multisig > multisig.json | ||
``` | ||
|
||
## Known issues | ||
- Only Memo containing a single `String` are supported | ||
- ExtendedInfo are mocked | ||
- Only Ledger is supported, i.e., no KvStore, Compute, ... | ||
- Only the Multisig `Feature` attributes are extracted | ||
- Unsupported Events/Multisig will trigger a panic | ||
- Only the MFX token is supported |
Oops, something went wrong.