-
Notifications
You must be signed in to change notification settings - Fork 12
pbss implemention #161
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
base: main
Are you sure you want to change the base?
pbss implemention #161
Changes from 48 commits
1485d89
44392b7
cb759c6
fade32f
4814a62
0a527a0
01f4ce7
811ebab
bcf0b6c
6c25201
62f89aa
5bf5bcb
bafb670
7a2557b
5be65e2
84eaac3
0beacac
feb48bb
a0ed014
bba1e75
d92fee3
b1210db
c72970d
b37cd5f
ce557df
ccd7590
207825a
bb12ec6
6e33fa4
570a566
b4f0316
9109d84
d554540
49904bf
9c0f993
6d9401f
0f62c7a
dea4aa8
d8f08de
6d086c5
eb305cb
e844e22
804cb32
1e734d8
284315c
c78b876
8b62f63
409206c
f4cd325
8f1fd9a
65ef219
3eb34e6
eb9937d
034e32a
66e494e
948d2a6
ebf6d61
3e97152
5dbe405
e6e8be9
d2ec13b
a8a321c
2005ed8
3cef223
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Push Docker Image | ||
|
||
on: | ||
push: | ||
tags: | ||
- morph-v* | ||
|
||
env: | ||
IMAGE_NAME: go-ethereum | ||
|
||
jobs: | ||
# Push image to GitHub Packages. | ||
push: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Build the Docker image | ||
run: docker build . --file Dockerfile -t "${IMAGE_NAME}" | ||
|
||
- name: Log into registry | ||
run: echo "${{ secrets.PACKAGE_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Push image | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository }} | ||
|
||
# Change all uppercase to lowercase | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "morph-v" prefix from tag name | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^morph-v//') | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:latest | ||
docker push $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:latest |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -70,6 +70,7 @@ Remove blockchain and state databases`, | |||||||||||||||||||||||||||||||||||||||||||||||||
dbDumpFreezerIndex, | ||||||||||||||||||||||||||||||||||||||||||||||||||
dbImportCmd, | ||||||||||||||||||||||||||||||||||||||||||||||||||
dbExportCmd, | ||||||||||||||||||||||||||||||||||||||||||||||||||
dbHbss2PbssCmd, | ||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
dbInspectCmd = cli.Command{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -254,6 +255,18 @@ WARNING: This is a low-level operation which may cause database corruption!`, | |||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
Description: "Exports the specified chain data to an RLP encoded stream, optionally gzip-compressed.", | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
dbHbss2PbssCmd = cli.Command{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
Action: hbss2pbss, | ||||||||||||||||||||||||||||||||||||||||||||||||||
Name: "hbss-to-pbss", | ||||||||||||||||||||||||||||||||||||||||||||||||||
ArgsUsage: "<jobnum (optional)>", | ||||||||||||||||||||||||||||||||||||||||||||||||||
Flags: []cli.Flag{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
utils.DataDirFlag, | ||||||||||||||||||||||||||||||||||||||||||||||||||
utils.SyncModeFlag, | ||||||||||||||||||||||||||||||||||||||||||||||||||
utils.AncientFlag, | ||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
Usage: "Convert Hash-Base to Path-Base trie node.", | ||||||||||||||||||||||||||||||||||||||||||||||||||
Description: `This command iterates the entire trie node database and convert the hash-base node to path-base node.`, | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+268
to
+279
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix argument handling or update usage text. The command definition specifies Either update the implementation to accept and use the optional jobnum argument: - if ctx.NArg() > 0 {
+ if ctx.NArg() > 1 {
log.Error("Too many arguments given")
return errors.New("too many arguments")
}
+
+ jobnum := 0
+ if ctx.NArg() == 1 {
+ var err error
+ jobnum, err = strconv.Atoi(ctx.Args().Get(0))
+ if err != nil {
+ log.Error("Invalid jobnum argument", "err", err)
+ return err
+ }
+ // TODO: Use jobnum parameter in conversion
+ } Or remove the unused argument from the command definition: - ArgsUsage: "<jobnum (optional)>",
+ ArgsUsage: "", 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
func removeDB(ctx *cli.Context) error { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -706,3 +719,38 @@ func exportChaindata(ctx *cli.Context) error { | |||||||||||||||||||||||||||||||||||||||||||||||||
db := utils.MakeChainDatabase(ctx, stack, true) | ||||||||||||||||||||||||||||||||||||||||||||||||||
return utils.ExportChaindata(ctx.Args().Get(1), kind, exporter(db), stop) | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
func hbss2pbss(ctx *cli.Context) error { | ||||||||||||||||||||||||||||||||||||||||||||||||||
stack, config := makeConfigNode(ctx) | ||||||||||||||||||||||||||||||||||||||||||||||||||
defer stack.Close() | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
chaindb := utils.MakeChainDatabase(ctx, stack, false) | ||||||||||||||||||||||||||||||||||||||||||||||||||
h2p, err := trie.NewHbss2Pbss(chaindb, stack.ResolvePath(""), stack.ResolvePath(config.Eth.TrieCleanCacheJournal)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
if ctx.NArg() > 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||
log.Error("Too many arguments given") | ||||||||||||||||||||||||||||||||||||||||||||||||||
return errors.New("too many arguments") | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
lastStateID := rawdb.ReadPersistentStateID(chaindb) | ||||||||||||||||||||||||||||||||||||||||||||||||||
if lastStateID == 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||
h2p.Run() | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+748
to
+752
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Add logging for skipped conversion. The conversion only runs when Add an informative log message: lastStateID := rawdb.ReadPersistentStateID(chaindb)
if lastStateID == 0 {
h2p.Run()
+ } else {
+ log.Info("Skipping conversion: path-based state already exists", "stateID", lastStateID)
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||
// prune hbss trie node | ||||||||||||||||||||||||||||||||||||||||||||||||||
err = rawdb.PruneHashTrieNodeInDataBase(chaindb) | ||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||
log.Error("Prune Hash trie node in database failed", "error", err) | ||||||||||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
err = h2p.Compact() | ||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||
log.Error("Compact trie node failed", "error", err) | ||||||||||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -75,6 +75,7 @@ import ( | |||||||||||||||||
"github.com/morph-l2/go-ethereum/params" | ||||||||||||||||||
"github.com/morph-l2/go-ethereum/rollup/tracing" | ||||||||||||||||||
"github.com/morph-l2/go-ethereum/rpc" | ||||||||||||||||||
"github.com/morph-l2/go-ethereum/trie" | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
func init() { | ||||||||||||||||||
|
@@ -851,6 +852,16 @@ var ( | |||||||||||||||||
Name: "rpc.getlogs.maxrange", | ||||||||||||||||||
Usage: "Limit max fetched block range for `eth_getLogs` method", | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
StateSchemeFlag = &cli.StringFlag{ | ||||||||||||||||||
Name: "state.scheme", | ||||||||||||||||||
Usage: "Scheme to use for storing zktrie state ('hash' or 'path')", | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
PathDBSyncFlag = cli.BoolFlag{ | ||||||||||||||||||
Name: "pathdb.sync", | ||||||||||||||||||
Usage: "Sync flush nodes cache to disk in path schema", | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+873
to
+876
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix terminology: "schema" → "scheme". The usage text says "path schema" but should be "path scheme" for consistency with the state scheme terminology used throughout the codebase (e.g., Apply this diff: PathDBSyncFlag = cli.BoolFlag{
Name: "pathdb.sync",
- Usage: "Sync flush nodes cache to disk in path schema",
+ Usage: "Sync flush nodes cache to disk in path scheme",
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
// MakeDataDir retrieves the currently requested data directory, terminating | ||||||||||||||||||
|
@@ -1718,6 +1729,19 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { | |||||||||||||||||
cfg.EthDiscoveryURLs = SplitAndTrim(urls) | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
if ctx.GlobalIsSet(PathDBSyncFlag.Name) { | ||||||||||||||||||
cfg.PathSyncFlush = true | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
scheme, err := ParseCLIAndConfigStateScheme(ctx.String(StateSchemeFlag.Name), cfg.StateScheme) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Line 1754 uses Apply this diff: - scheme, err := ParseCLIAndConfigStateScheme(ctx.String(StateSchemeFlag.Name), cfg.StateScheme)
+ scheme, err := ParseCLIAndConfigStateScheme(ctx.GlobalString(StateSchemeFlag.Name), cfg.StateScheme) 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||
if err != nil { | ||||||||||||||||||
Fatalf("%v", err) | ||||||||||||||||||
} | ||||||||||||||||||
cfg.StateScheme = scheme | ||||||||||||||||||
if cfg.StateScheme == rawdb.PathScheme { | ||||||||||||||||||
trie.GenesisStateInPathZkTrie = true | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+1759
to
+1761
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major 🧩 Analysis chainSetting global variable as a side effect may cause issues. Setting
Consider whether this global should be set elsewhere (e.g., during trie initialization) or if it should be passed as a parameter rather than mutating global state. Run the following script to check where else this global variable is accessed or modified: 🏁 Script executed: #!/bin/bash
# Description: Find all references to GenesisStateInPathZkTrie to understand its usage pattern
rg -n "GenesisStateInPathZkTrie" --type go -C 3 Length of output: 1975 Remove redundant global state mutation from config setup. The assignment at lines 1759-1761 duplicates identical logic already present in 🤖 Prompt for AI Agents
|
||||||||||||||||||
|
||||||||||||||||||
// Override any default configs for hard coded networks. | ||||||||||||||||||
switch { | ||||||||||||||||||
case ctx.GlobalBool(MainnetFlag.Name): | ||||||||||||||||||
|
@@ -1765,6 +1789,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { | |||||||||||||||||
// disable prefetch | ||||||||||||||||||
log.Info("Prefetch disabled") | ||||||||||||||||||
cfg.NoPrefetch = true | ||||||||||||||||||
|
||||||||||||||||||
// cheked for path zktrie | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo: "cheked" → "checked". The comment contains a typo that appears three times in the file (lines 1807, 1827, and 1847). Apply this diff at line 1807: - // cheked for path zktrie
+ // checked for path zktrie
if cfg.StateScheme == rawdb.PathScheme && !cfg.Genesis.Config.Morph.ZktrieEnabled() { Repeat the same fix at lines 1827 and 1847. Also applies to: 1827-1827, 1847-1847 🤖 Prompt for AI Agents
|
||||||||||||||||||
if cfg.StateScheme == rawdb.PathScheme && !cfg.Genesis.Config.Morph.ZktrieEnabled() { | ||||||||||||||||||
log.Crit("Must cooperate with zktrie enable to use --state.scheme=path") | ||||||||||||||||||
} | ||||||||||||||||||
case ctx.GlobalBool(MorphHoleskyFlag.Name): | ||||||||||||||||||
if !ctx.GlobalIsSet(NetworkIdFlag.Name) { | ||||||||||||||||||
cfg.NetworkId = 2810 | ||||||||||||||||||
|
@@ -1780,6 +1809,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { | |||||||||||||||||
// disable prefetch | ||||||||||||||||||
log.Info("Prefetch disabled") | ||||||||||||||||||
cfg.NoPrefetch = true | ||||||||||||||||||
|
||||||||||||||||||
// cheked for path zktrie | ||||||||||||||||||
if cfg.StateScheme == rawdb.PathScheme && !cfg.Genesis.Config.Morph.ZktrieEnabled() { | ||||||||||||||||||
log.Crit("Must cooperate with zktrie enable to use --state.scheme=path") | ||||||||||||||||||
} | ||||||||||||||||||
case ctx.GlobalBool(DeveloperFlag.Name): | ||||||||||||||||||
if !ctx.GlobalIsSet(NetworkIdFlag.Name) { | ||||||||||||||||||
cfg.NetworkId = 1337 | ||||||||||||||||||
|
@@ -2147,3 +2181,22 @@ func MigrateFlags(action func(ctx *cli.Context) error) func(*cli.Context) error | |||||||||||||||||
return action(ctx) | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// ParseCLIAndConfigStateScheme parses state scheme in CLI and config. | ||||||||||||||||||
func ParseCLIAndConfigStateScheme(cliScheme, cfgScheme string) (string, error) { | ||||||||||||||||||
if cliScheme == "" { | ||||||||||||||||||
if cfgScheme != "" { | ||||||||||||||||||
log.Info("Use config state scheme", "config", cfgScheme) | ||||||||||||||||||
} | ||||||||||||||||||
return cfgScheme, nil | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
if !rawdb.ValidateStateScheme(cliScheme) { | ||||||||||||||||||
return "", fmt.Errorf("invalid state scheme in CLI: %s", cliScheme) | ||||||||||||||||||
} | ||||||||||||||||||
if cfgScheme == "" || cliScheme == cfgScheme { | ||||||||||||||||||
log.Info("Use CLI state scheme", "CLI", cliScheme) | ||||||||||||||||||
return cliScheme, nil | ||||||||||||||||||
} | ||||||||||||||||||
return "", fmt.Errorf("incompatible state scheme, CLI: %s, config: %s", cliScheme, cfgScheme) | ||||||||||||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.