diff --git a/cmd/opera/launcher/chaincmd.go b/cmd/opera/launcher/chaincmd.go index 00070b7e1..e47c397f8 100644 --- a/cmd/opera/launcher/chaincmd.go +++ b/cmd/opera/launcher/chaincmd.go @@ -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: "", + Action: utils.MigrateFlags(exportPreimages), + Flags: []cli.Flag{ + DataDirFlag, + }, + Description: ` + opera export preimages + +Requires a first argument of the file to write to. `, }, { diff --git a/cmd/opera/launcher/export.go b/cmd/opera/launcher/export.go index 30b7bd48c..1c2d75a06 100644 --- a/cmd/opera/launcher/export.go +++ b/cmd/opera/launcher/export.go @@ -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.")