Skip to content

fix(evm): restore gas refund on JIT revert#321

Merged
zoowii merged 2 commits intoDTVMStack:mainfrom
abmcar:fix/sstore-refund
Feb 5, 2026
Merged

fix(evm): restore gas refund on JIT revert#321
zoowii merged 2 commits intoDTVMStack:mainfrom
abmcar:fix/sstore-refund

Conversation

@abmcar
Copy link
Contributor

@abmcar abmcar commented Feb 3, 2026

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

2. What is the scope of this PR (e.g. component or file name):

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  • Affects user behaviors
  • Contains CI/CD configuration changes
  • Contains documentation changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

6. Release note

None

Copilot AI review requested due to automatic review settings February 3, 2026 07:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes gas refund handling during JIT execution errors and reverts by implementing a stack-based snapshot/restore mechanism for gas refunds.

Changes:

  • Added GasRefundStack to track gas refund snapshots across call hierarchy
  • Implemented automatic gas refund restoration in setExecutionError() for all error conditions except normal exits
  • Added explicit gas refund restoration in revert/invalid/undefined instruction handlers
  • Removed conditional checks for positive gas refund values when adding refunds from subcall results

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/runtime/evm_instance.h Added GasRefundStack member and restoreGasRefundSnapshot() method to support gas refund snapshot/restore mechanism
src/runtime/evm_instance.cpp Integrated gas refund stack management into pushMessage()/popMessage() for call hierarchy tracking, and added restoration logic in setExecutionError()
src/compiler/evm_frontend/evm_imported.cpp Added explicit gas refund restoration in error handlers (invalid, undefined, revert) and removed conditional checks when adding gas refunds from subcall results

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zoowii zoowii merged commit c9a15ed into DTVMStack:main Feb 5, 2026
10 checks passed
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.

2 participants