From 50830a700493a357cf367574141c994d61170962 Mon Sep 17 00:00:00 2001 From: "Leo Zhang (zhangchiqing)" Date: Wed, 13 Nov 2024 14:14:50 -0800 Subject: [PATCH] fix export evm state --- cmd/util/cmd/export-evm-state/cmd.go | 6 ------ fvm/evm/emulator/state/exporter.go | 7 ++++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cmd/util/cmd/export-evm-state/cmd.go b/cmd/util/cmd/export-evm-state/cmd.go index 2927b9a313a..007b066183f 100644 --- a/cmd/util/cmd/export-evm-state/cmd.go +++ b/cmd/util/cmd/export-evm-state/cmd.go @@ -95,12 +95,6 @@ func ExportEVMState( } } - fi, err := os.Create(outputPath) - if err != nil { - return err - } - defer fi.Close() - err = exporter.Export(outputPath) if err != nil { return fmt.Errorf("failed to export: %w", err) diff --git a/fvm/evm/emulator/state/exporter.go b/fvm/evm/emulator/state/exporter.go index 49f3a0fdbd8..7b2805321b7 100644 --- a/fvm/evm/emulator/state/exporter.go +++ b/fvm/evm/emulator/state/exporter.go @@ -37,7 +37,8 @@ func NewExporter(ledger atree.Ledger, root flow.Address) (*Exporter, error) { } func (e *Exporter) Export(path string) error { - af, err := os.OpenFile(filepath.Join(path, ExportedAccountsFileName), os.O_RDWR, 0644) + + af, err := os.Create(filepath.Join(path, ExportedAccountsFileName)) if err != nil { return err } @@ -48,7 +49,7 @@ func (e *Exporter) Export(path string) error { return err } - cf, err := os.OpenFile(filepath.Join(path, ExportedCodesFileName), os.O_RDWR, 0644) + cf, err := os.Create(filepath.Join(path, ExportedCodesFileName)) if err != nil { return err } @@ -59,7 +60,7 @@ func (e *Exporter) Export(path string) error { return err } - sf, err := os.OpenFile(filepath.Join(path, ExportedSlotsFileName), os.O_RDWR, 0644) + sf, err := os.Create(filepath.Join(path, ExportedSlotsFileName)) if err != nil { return err }