Skip to content
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

Add state.reward processing #558

Merged
merged 4 commits into from
Feb 10, 2023
Merged

Add state.reward processing #558

merged 4 commits into from
Feb 10, 2023

Conversation

rodiazet
Copy link
Collaborator

@rodiazet rodiazet commented Feb 8, 2023

No description provided.

@rodiazet rodiazet requested review from chfast and axic February 8, 2023 22:00
@codecov
Copy link

codecov bot commented Feb 8, 2023

Codecov Report

Merging #558 (02de26a) into master (886174b) will increase coverage by 0.03%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #558      +/-   ##
==========================================
+ Coverage   97.00%   97.03%   +0.03%     
==========================================
  Files          66       66              
  Lines        6134     6134              
==========================================
+ Hits         5950     5952       +2     
+ Misses        184      182       -2     
Flag Coverage Δ
blockchaintests 76.96% <ø> (ø)
statetests 71.52% <ø> (ø)
unittests 92.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/evmone/instructions.hpp 100.00% <0.00%> (+0.20%) ⬆️
lib/evmone/advanced_analysis.hpp 100.00% <0.00%> (+2.94%) ⬆️

test/t8n/t8n.cpp Outdated Show resolved Hide resolved
test/t8n/t8n.cpp Outdated
state.touch(block.coinbase);
else if (state_reward == std::numeric_limits<intx::uint256>::max())
{
if (state.get_or_insert(block.coinbase).is_empty())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, cleaning up empty accounts is just an EIP-161 rule. Don't we have that implemented?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For <= EIP158 coinbase account is touched even it tx is rejected. retesteth passing -1 as a stare.reward requires zero state to be removed.

test/t8n/t8n.cpp Outdated Show resolved Hide resolved
test/t8n/t8n.cpp Outdated Show resolved Hide resolved
@rodiazet rodiazet requested a review from chfast February 9, 2023 11:15
test/t8n/t8n.cpp Outdated Show resolved Hide resolved
test/t8n/t8n.cpp Outdated Show resolved Hide resolved
test/t8n/t8n.cpp Outdated
else
state.get_or_insert(block.coinbase).balance += *block_reward;
}
else if (rev <= EVMC_TANGERINE_WHISTLE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we do the same in transaction execution?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we are touching there here we are erasing.

@rodiazet rodiazet requested a review from chfast February 9, 2023 14:34
test/t8n/t8n.cpp Outdated Show resolved Hide resolved
@rodiazet rodiazet requested a review from axic February 9, 2023 15:24
test/t8n/t8n.cpp Outdated
if (block_reward.has_value())
state.touch(block.coinbase).balance += *block_reward;
else if (rev <= EVMC_TANGERINE_WHISTLE) // This behaviour is required by retesteth
state.get_accounts().erase(block.coinbase);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this will remove it even when other transactions touched this account. Is that desired?

Copy link
Collaborator Author

@rodiazet rodiazet Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. For some reason I removed also checking if it's empty. Fixed now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not convinced by this quirk. It looks it replicates a bug in some client implementation. Can you provide a list of failing tests?

test/t8n/t8n.cpp Outdated
@@ -54,6 +55,9 @@ int main(int argc, const char* argv[])
output_result_file = argv[i];
else if (arg == "--output.alloc" && ++i < argc)
output_alloc_file = argv[i];
else if (arg == "--state.reward" && ++i < argc)
if (std::string_view(argv[i]) != "-1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to combine all 3 conditions. You can be fancy by doing argv[i] != "-1"sv.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: no matching literal operator for call to 'operator""sv' with arguments of types 'const char *' and 'unsigned long', and no matching literal operator template
else if (arg == "--state.reward" && ++i < argc && argv[i] != "-1"sv)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using namespace std::literals.

test/t8n/t8n.cpp Show resolved Hide resolved
test/t8n/t8n.cpp Outdated
if (block_reward.has_value())
state.touch(block.coinbase).balance += *block_reward;
else if (rev <= EVMC_TANGERINE_WHISTLE) // This behaviour is required by retesteth
state.get_accounts().erase(block.coinbase);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not convinced by this quirk. It looks it replicates a bug in some client implementation. Can you provide a list of failing tests?

test/t8n/t8n.cpp Show resolved Hide resolved
@rodiazet rodiazet merged commit 9a5d8f3 into master Feb 10, 2023
@rodiazet rodiazet deleted the t8n-state-reward branch February 10, 2023 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants