-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement gas refund #493
Implement gas refund #493
Conversation
bb7d211
to
a6121d0
Compare
Codecov Report
@@ Coverage Diff @@
## master #493 +/- ##
==========================================
+ Coverage 99.39% 99.40% +0.01%
==========================================
Files 53 53
Lines 5145 5249 +104
==========================================
+ Hits 5114 5218 +104
Misses 31 31
Flags with carried forward coverage won't be shown. Click here to find out more.
|
7e25e13
to
5350ed2
Compare
test/unittests/evm_storage_test.cpp
Outdated
int64_t expected_gas_refund) { | ||
auto& storage = host.accounts[msg.recipient].storage; | ||
storage[key] = {current, original}; | ||
execute(sstore(0xef, calldataload(0)), value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe could be simpler
execute(sstore(0xef, calldataload(0)), value); | |
execute(sstore(0xef, value), {}); |
test/unittests/evm_storage_test.cpp
Outdated
int64_t clear = -1; | ||
}; | ||
|
||
auto test = [this](const evmc::bytes32& original, const evmc::bytes32& current, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this helper be reused between two tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is rather difficult because it accesses this
.
EXPECT_GAS_USED(EVMC_SUCCESS, 7603); // Cold access to 0xbe. | ||
EXPECT_EQ(result.gas_refund, 24000); | ||
|
||
// Second selfdestruct of the same account. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add a test for another selfdestruct of different account
|
||
const auto a = 0xaa_address; | ||
const auto code = | ||
call(a) + callcode(a) + delegatecall(a) + staticcall(a) + create() + create2(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be redundant, but I thought of having two calls of each type to check that it's also aggregated for same type calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, some minor suggestions only in tests.
Calculate, aggregate and report the gas refund. This requires changes to
SSTORE
,SELFDESTRUCT
and calls (propagate gas refund).