Skip to content
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

cmd/geth: add hbss to pbss convert tool #1882

Merged
merged 1 commit into from
Oct 5, 2023

Conversation

fynnss
Copy link
Contributor

@fynnss fynnss commented Sep 20, 2023

Description

add hbss to pbss convert tool for generate bsc snapshot more quickly.

Rationale

If starts from the genesis block to make the bsc snaoshot, it will takes 1.5~2 months.

if using the convert tools and convert hbss trie node to pbss trie node, it will takes 2~3 days.

Example

./geth db hash2path --datadir ./node 1000 
./geth db prune-hash-trie  --datadir ./node
./geth db compact --datadir ./node

NOTICE: it will take a long time to iterate the entrie databse.

Changes

Notable changes:

  • add hash2path/prune-hash-trie tools for convert and prune the hbss trie node
  • add trieGet/trieDelete for pbss to debug and handle exceptions

@fynnss fynnss force-pushed the add_hash_trie_node_prune_tool branch 3 times, most recently from 2c99dfe to 82fe65e Compare September 20, 2023 09:28
@fynnss fynnss force-pushed the add_hash_trie_node_prune_tool branch from d21a74a to ac1779a Compare September 21, 2023 08:50
@fynnss fynnss changed the title feat: add hash trie node prune tool cmd/geth: add hash trie node prune tool Sep 21, 2023
@fynnss fynnss self-assigned this Sep 21, 2023
@fynnss fynnss added the r4r ready for review label Sep 21, 2023
@fynnss fynnss removed their assignment Sep 21, 2023
@fynnss fynnss force-pushed the add_hash_trie_node_prune_tool branch 3 times, most recently from ac71133 to 85097dd Compare September 22, 2023 10:28
@fynnss fynnss force-pushed the add_hash_trie_node_prune_tool branch from 85097dd to f60e666 Compare September 25, 2023 03:34
@fynnss fynnss changed the title cmd/geth: add hash trie node prune tool cmd/geth: add hbss to pbss convert tool Sep 25, 2023
@fynnss fynnss force-pushed the add_hash_trie_node_prune_tool branch from f60e666 to cd8817c Compare September 25, 2023 03:42
config := trie.HashDefaults
triedb := trie.NewDatabase(db, config)
triedb.Cap(0)
fmt.Println("triedb scheme: ", triedb.Scheme())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log is better, consistent with other cmds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and ditto to other fmt.Println

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

db := utils.MakeChainDatabase(ctx, stack, false, false)
defer db.Close()

scheme := ctx.String(utils.StateSchemeFlag.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to ParseStateScheme?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tool may be used in the scenarios that the database which both the HBSS and PBSS trienode exist, so flags are required

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ParseStateScheme is uesed to handle utils.StateSchemeFlag.

@joeylichang joeylichang force-pushed the pbss_active branch 2 times, most recently from 4145f32 to e4b69f7 Compare September 26, 2023 07:47
@fynnss fynnss force-pushed the add_hash_trie_node_prune_tool branch from e928905 to b260cc9 Compare September 26, 2023 09:13
@fynnss fynnss changed the base branch from pbss_active to develop September 26, 2023 09:13
@fynnss fynnss force-pushed the add_hash_trie_node_prune_tool branch 3 times, most recently from 6d75830 to 5c6dd3e Compare September 26, 2023 10:57
}

func ancientInspect(ctx *cli.Context) error {
func inspect(ctx *cli.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change the function of inspect?

from code logic, new logic is totally for different usage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Made a mistake when rebase code.

@fynnss fynnss force-pushed the add_hash_trie_node_prune_tool branch from 5c6dd3e to e3a7214 Compare September 26, 2023 12:44
Copy link

@RenRick RenRick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joeylichang
Copy link
Contributor

LGTM

@NathanBSC
Copy link
Contributor

LGTM

@fynnss fynnss merged commit c26a303 into bnb-chain:develop Oct 5, 2023
5 checks passed
This was referenced Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r4r ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants