Skip to content

Commit

Permalink
Merge pull request #504 from ethereum/gas-refund-reset
Browse files Browse the repository at this point in the history
Reset gas refund counter in ExecutionState
  • Loading branch information
chfast authored and gumb0 committed Sep 7, 2022
1 parent 94a6066 commit aa31176
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.9.0-dev
current_version = 0.9.0
tag = True
sign_tags = True
tag_message = evmone {new_version}
Expand Down
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ 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] — 2022-09-07

## [0.9.0] — 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

In this release we have been focused on improving performance of the Baseline interpreter.
The end result is that the Baseline is **26% faster** than in previous version 0.8.0
Expand Down Expand Up @@ -347,7 +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.0]: https://github.com/ethereum/evmone/compare/v0.8.2..master
[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
[0.8.0]: https://github.com/ethereum/evmone/releases/tag/v0.8.0
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cable_set_build_type(DEFAULT Release CONFIGURATION_TYPES Release Debug)
include(Hunter/init)

project(evmone LANGUAGES CXX C)
set(PROJECT_VERSION 0.9.0-dev)
set(PROJECT_VERSION 0.9.0)

string(REGEX MATCH "([0-9]+)\\.([0-9]+)" _ ${PROJECT_VERSION})
set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_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 aa31176

Please sign in to comment.