-
Notifications
You must be signed in to change notification settings - Fork 285
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
state: Clean up state finalization #609
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #609 +/- ##
=======================================
Coverage 97.29% 97.29%
=======================================
Files 78 78
Lines 7640 7648 +8
=======================================
+ Hits 7433 7441 +8
Misses 207 207
Flags with carried forward coverage won't be shown. Click here to find out more.
|
test/state/state.cpp
Outdated
@@ -117,19 +117,22 @@ evmc_message build_message(const Transaction& tx, int64_t execution_gas_limit) n | |||
} | |||
} // namespace | |||
|
|||
void clear_empty_or_destructed_accounts(State& state, evmc_revision rev) |
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.
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.
Good idea :)
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 YP part is actually wrong: ethereum/yellowpaper#885.
346d056
to
a0b39d8
Compare
a0b39d8
to
99695ed
Compare
79f997b
to
60e30e5
Compare
- Separate selfdestruct handling from empty account clearing. - Apply block reward to coinbase consistently. Co-authored-by: Paweł Bylica <[email protected]>
60e30e5
to
9f5c406
Compare
@@ -28,6 +28,10 @@ void run_state_test(const StateTransitionTest& test, evmc::VM& vm) | |||
validate_deployed_code(state, rev); | |||
|
|||
const auto res = state::transition(state, test.block, tx, rev, vm); | |||
|
|||
// Finalize block with reward 0. |
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.
In state tests it's not 0 on pre-merge revisions.
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.
For state tests this is always 0. This effectively only touches/creates the coinbase 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.
True, apparently it's non-zero only in blockchain 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.
FYI, this is configurable in t8n via --state.reward
.
std::variant<TransactionReceipt, std::error_code> transition( | ||
State& state, const BlockInfo& block, const Transaction& tx, evmc_revision rev, evmc::VM& vm) | ||
{ | ||
auto& sender_acc = state.get(tx.sender); | ||
const auto validation_result = validate_transaction(sender_acc, block, tx, rev); | ||
|
||
if (holds_alternative<std::error_code>(validation_result)) | ||
{ | ||
// Pre EIP-158 coinbase has to be touched also for invalid tx. |
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.
Why is this not needed now?
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 emulates applying block reward of 0. Previously, I wasn't exactly sure why this is needed. Now the block reward is "properly" applied in the end.
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.
Coinbase wallet
t8n
andstate-test-runner
.