-
Notifications
You must be signed in to change notification settings - Fork 623
feat(rollup-relayer): add a tool to analyze chunk/batch/bundle proposing #1645
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
Merged
colinlyguo
merged 22 commits into
develop
from
feat-add-chunk-batch-bundle-proposing-tool
Apr 23, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4e5839f
add proposer tool
colinlyguo 8167b75
tweaks
colinlyguo 8112a12
fix goimport
colinlyguo 36690d1
tweaks
colinlyguo b2a935f
Merge branch 'develop' into feat-add-chunk-batch-bundle-proposing-tool
colinlyguo d12c2b4
add descriptions of proposer tool
colinlyguo 0836a1d
remove db-client
colinlyguo 9fc3ad5
address AI's comment
colinlyguo 78cf923
support start from a specific l2 block
colinlyguo c0138d2
tweak comments
colinlyguo be3f189
address comments
colinlyguo 818add4
address comments
colinlyguo f24cc7c
separate configs
colinlyguo 11ab6c7
tweak
colinlyguo 9571c89
tweak
colinlyguo b80e59a
refactor
colinlyguo c6b779f
tweak
colinlyguo 934f4bb
address AI's comments
colinlyguo 9d6ca3c
chore: auto version bump [bot]
colinlyguo 6e7bc38
fix wrong error message
colinlyguo 7e688e8
add more comments
colinlyguo 48a0625
tweaks
colinlyguo 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
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
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
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,93 @@ | ||
package app | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"os/signal" | ||
|
||
"github.com/scroll-tech/da-codec/encoding" | ||
"github.com/scroll-tech/go-ethereum/log" | ||
"github.com/urfave/cli/v2" | ||
|
||
"scroll-tech/common/utils" | ||
"scroll-tech/common/version" | ||
|
||
"scroll-tech/rollup/internal/config" | ||
"scroll-tech/rollup/internal/controller/watcher" | ||
) | ||
|
||
var app *cli.App | ||
|
||
func init() { | ||
// Set up proposer-tool app info. | ||
app = cli.NewApp() | ||
app.Action = action | ||
app.Name = "proposer-tool" | ||
app.Usage = "The Scroll Proposer Tool" | ||
app.Version = version.Version | ||
app.Flags = append(app.Flags, utils.CommonFlags...) | ||
app.Flags = append(app.Flags, utils.RollupRelayerFlags...) | ||
app.Flags = append(app.Flags, utils.ProposerToolFlags...) | ||
app.Commands = []*cli.Command{} | ||
app.Before = func(ctx *cli.Context) error { | ||
return utils.LogSetup(ctx) | ||
} | ||
} | ||
|
||
func action(ctx *cli.Context) error { | ||
// Load config file. | ||
cfgFile := ctx.String(utils.ConfigFileFlag.Name) | ||
cfg, err := config.NewConfigForReplay(cfgFile) | ||
if err != nil { | ||
log.Crit("failed to load config file", "config file", cfgFile, "error", err) | ||
} | ||
|
||
subCtx, cancel := context.WithCancel(ctx.Context) | ||
|
||
startL2BlockHeight := ctx.Uint64(utils.StartL2BlockFlag.Name) | ||
|
||
genesisPath := ctx.String(utils.Genesis.Name) | ||
genesis, err := utils.ReadGenesis(genesisPath) | ||
if err != nil { | ||
log.Crit("failed to read genesis", "genesis file", genesisPath, "error", err) | ||
} | ||
|
||
minCodecVersion := encoding.CodecVersion(ctx.Uint(utils.MinCodecVersionFlag.Name)) | ||
|
||
// sanity check config | ||
if cfg.L2Config.BatchProposerConfig.MaxChunksPerBatch <= 0 { | ||
log.Crit("cfg.L2Config.BatchProposerConfig.MaxChunksPerBatch must be greater than 0") | ||
} | ||
if cfg.L2Config.ChunkProposerConfig.MaxL2GasPerChunk <= 0 { | ||
log.Crit("cfg.L2Config.ChunkProposerConfig.MaxL2GasPerChunk must be greater than 0") | ||
} | ||
|
||
proposerTool, err := watcher.NewProposerTool(subCtx, cancel, cfg, startL2BlockHeight, minCodecVersion, genesis.Config) | ||
if err != nil { | ||
log.Crit("failed to create proposer tool", "startL2BlockHeight", startL2BlockHeight, "minCodecVersion", minCodecVersion, "error", err) | ||
} | ||
proposerTool.Start() | ||
|
||
log.Info("Start proposer-tool successfully", "version", version.Version) | ||
|
||
// Catch CTRL-C to ensure a graceful shutdown. | ||
interrupt := make(chan os.Signal, 1) | ||
signal.Notify(interrupt, os.Interrupt) | ||
|
||
// Wait until the interrupt signal is received from an OS signal. | ||
<-interrupt | ||
|
||
cancel() | ||
proposerTool.Stop() | ||
|
||
return nil | ||
} | ||
|
||
// Run proposer tool cmd instance. | ||
func Run() { | ||
if err := app.Run(os.Args); err != nil { | ||
_, _ = fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
} |
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,7 @@ | ||
package main | ||
|
||
import "scroll-tech/rollup/cmd/proposer_tool/app" | ||
|
||
func main() { | ||
app.Run() | ||
} |
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,40 @@ | ||
version: '3' | ||
|
||
services: | ||
db: | ||
image: postgres:14 | ||
environment: | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=postgres | ||
- POSTGRES_DB=scroll | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U postgres"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
proposer-tool: | ||
build: | ||
context: .. | ||
dockerfile: ./rollup/proposer_tool.Dockerfile | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
command: [ | ||
"--config", "/app/conf/proposer-tool-config.json", | ||
"--genesis", "/app/conf/proposer-tool-genesis.json", | ||
"--min-codec-version", "4", | ||
"--start-l2-block", "10000", | ||
"--log.debug", "--verbosity", "3" | ||
] | ||
volumes: | ||
- ./proposer-tool-config.json:/app/conf/proposer-tool-config.json | ||
- ./proposer-tool-genesis.json:/app/conf/proposer-tool-genesis.json | ||
restart: unless-stopped | ||
|
||
volumes: | ||
postgres_data: |
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.