Skip to content

remove exported output file on error#119

Merged
louisliu2048 merged 1 commit intomainfrom
dumi/fix-580
Jan 26, 2026
Merged

remove exported output file on error#119
louisliu2048 merged 1 commit intomainfrom
dumi/fix-580

Conversation

@dloghin
Copy link
Contributor

@dloghin dloghin commented Jan 26, 2026

Description

Issue

The export command creates the output file before executing any export work, then returns early on errors, e.g., failed block reads, interrupts, or invalid ranges, without removing or rolling back the newly created file. When the export loop is skipped or aborted, it leaves behind an empty or partial file. At the same time, the command still appears to have produced an artifact, increasing the likelihood that operators will treat incomplete exports as valid backups.Consider ensuring that any early-return path removes the partially created file so that failed exports do not leave behind misleading artifacts.

Fix

We modified the execute() function to remove the output file if an error occurs. We wrap the main logic in a closure block and add cleanup logic on error (file bin/toolsexport.rs).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Code Guidelines

Before submitting your PR, please review the relevant code guidelines in the docs/ folder:

Specific Guidelines by Component:

Checklist

  • I have reviewed the relevant code guidelines in the docs/ folder
  • My code follows the coding standards of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Testing

Previously:

  • create a local devnet using xlayer-toolkit
  • run:
xlayer-reth-tools export --datadir /home/ubuntu/git/XLayer/xlayer-toolkit/devnet/data/op-reth-seq --exported-data 
exported.rlp
...
2026-01-26T02:26:03.885564Z ERROR Error: Other(
    FileSystem(
        Open {
            source: Os {
                code: 2,
                kind: NotFound,
                message: "No such file or directory",
            },
            path: "xlayer-toolkit/devnet/data/op-reth-seq/static_files/static_file_headers_0_499999.conf",
        },
    ),
)
  • but the output file is still created:
    exported.rlp 0 bytes

After fix:

  • we get the same error but no file is created

@dloghin dloghin requested a review from JimmyShi22 January 26, 2026 02:33
Copy link
Contributor

@JimmyShi22 JimmyShi22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this code will delete the file when error or ctr-c

@louisliu2048 louisliu2048 merged commit 8a92328 into main Jan 26, 2026
Vui-Chee added a commit that referenced this pull request Jan 30, 2026
* dev:
  fix: upgrade reth v1.10.2 version with bug fixes (#134)
  Update dependencies, use reth v1.10.2 and builder v0.3.0 (#133)
  chore: fix rust formatter (#132)
  chore: better rename, fix unused variable warning (#99) (#131)
  Fix comments (#127)
  Add trace log on tx cache hits (#126)
  replace magic error code number to INTERNAL_ERROR_CODE (#125)
  feat(legacy): remove eth_transactionPreExec (#124)
  fix tools readme (#123)
  fix(rpc): improve parameter validation in get_logs and service methods (#121)
  remove output file on error (#119)
  feat(legacy): support legacy routing for batch requests (#117)
  fix(legacy): avoid possible panic on malformed block params (#111)
  fallback to legacy if res is empty (#118)
  refactor(rpc): remove transaction_pre_exec API (#120)
  use XLayerPayloadServiceBuilder to simplify main() codes, merge to main branch (#112)
  fix(tools): check end block >= start block (#116)
  forward req to legacy on err (#110)
  fix: resolve audit issues related to flashblocks subscription (#113)
  fix(rpc): add trace_address for delegatecall and fix address format c… (#104)
@dloghin dloghin deleted the dumi/fix-580 branch February 11, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants