diff --git a/CHANGELOG.md b/CHANGELOG.md index 53d797c92b..f821c59f18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/lib/evmone/execution_state.hpp b/lib/evmone/execution_state.hpp index 3734539171..1ab0528867 100644 --- a/lib/evmone/execution_state.hpp +++ b/lib/evmone/execution_state.hpp @@ -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}; diff --git a/test/unittests/execution_state_test.cpp b/test/unittests/execution_state_test.cpp index 4c37ba9930..832021e488 100644 --- a/test/unittests/execution_state_test.cpp +++ b/test/unittests/execution_state_test.cpp @@ -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; @@ -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); @@ -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);