From 39c6f9c7cf6bf9f34b1931416b436089555f0bb2 Mon Sep 17 00:00:00 2001 From: Egor Lysenko Date: Fri, 10 Jun 2022 00:55:11 +0400 Subject: [PATCH] add 'export preimages' command --- cmd/opera/launcher/chaincmd.go | 14 ++++++++++++++ cmd/opera/launcher/export.go | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) 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.")