Skip to content

Commit

Permalink
Reset gas refund counter in ExecutionState
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 authored and chfast committed Sep 7, 2022
1 parent f4c04ee commit 447864e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Documentation of all notable changes to the **evmone** project.
The format is based on [Keep a Changelog],
and this project adheres to [Semantic Versioning].

## [0.9.1] — unreleased

### Fixed

- Resetting gas refund counter when execution state is reused.
[#504](https://github.com/ethereum/evmone/pull/504)

## [0.9.0] — 2022-08-30

Expand Down Expand Up @@ -347,6 +353,7 @@ It delivers fully-compatible and high-speed EVM implementation.
- The [intx 0.2.0](https://github.com/chfast/intx/releases/tag/v0.2.0) library is used for 256-bit precision arithmetic.


[0.9.1]: https://github.com/ethereum/evmone/compare/v0.9.0..release/0.9
[0.9.0]: https://github.com/ethereum/evmone/releases/tag/v0.9.0
[0.8.2]: https://github.com/ethereum/evmone/releases/tag/v0.8.2
[0.8.1]: https://github.com/ethereum/evmone/releases/tag/v0.8.1
Expand Down
1 change: 1 addition & 0 deletions lib/evmone/execution_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class ExecutionState
bytes_view _code) noexcept
{
gas_left = message.gas;
gas_refund = 0;
memory.clear();
msg = &message;
host = {host_interface, host_ctx};
Expand Down
3 changes: 3 additions & 0 deletions test/unittests/execution_state_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ TEST(execution_state, reset_advanced)

evmone::advanced::AdvancedExecutionState st;
st.gas_left = 1;
st.gas_refund = 2;
st.stack.push({});
st.memory.grow(64);
st.msg = &msg;
Expand All @@ -97,6 +98,7 @@ TEST(execution_state, reset_advanced)
st.analysis.advanced = &analysis;

EXPECT_EQ(st.gas_left, 1);
EXPECT_EQ(st.gas_refund, 2);
EXPECT_EQ(st.stack.size(), 1);
EXPECT_EQ(st.memory.size(), 64);
EXPECT_EQ(st.msg, &msg);
Expand All @@ -121,6 +123,7 @@ TEST(execution_state, reset_advanced)
// TODO: We are not able to test HostContext with current API. It may require an execution
// test.
EXPECT_EQ(st.gas_left, 13);
EXPECT_EQ(st.gas_refund, 0);
EXPECT_EQ(st.stack.size(), 0);
EXPECT_EQ(st.memory.size(), 0);
EXPECT_EQ(st.msg, &msg2);
Expand Down

0 comments on commit 447864e

Please sign in to comment.