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

Add 'export preimages' command #406

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmd/opera/launcher/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ Requires a first argument of the file to write to.
Optional second and third arguments control the first and
last epoch to write. If the file ends with .gz, the output will
be gzipped
`,
},
{
Name: "preimages",
Usage: "Export blockchain account preimages",
ArgsUsage: "<filename>",
Action: utils.MigrateFlags(exportPreimages),
Flags: []cli.Flag{
DataDirFlag,
},
Description: `
opera export preimages

Requires a first argument of the file to write to.
`,
},
{
Expand Down
16 changes: 16 additions & 0 deletions cmd/opera/launcher/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ var (
// always print out progress. This avoids the user wondering what's going on.
const statsReportLimit = 8 * time.Second

func exportPreimages(ctx *cli.Context) error {
if len(ctx.Args()) < 1 {
utils.Fatalf("This command requires an argument.")
}

cfg := makeAllConfigs(ctx)

rawDbs := makeDirectDBsProducer(cfg)
gdb := makeGossipStore(rawDbs, cfg)
defer gdb.Close()

fn := ctx.Args().First()

return utils.ExportPreimages(gdb.EvmStore().EvmDb, fn)
}

func exportEvents(ctx *cli.Context) error {
if len(ctx.Args()) < 1 {
utils.Fatalf("This command requires an argument.")
Expand Down