Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Constantinople SSTORE refund fix #5316

Merged
merged 2 commits into from
Oct 15, 2018
Merged

Constantinople SSTORE refund fix #5316

merged 2 commits into from
Oct 15, 2018

Conversation

chfast
Copy link
Member

@chfast chfast commented Oct 15, 2018

cc @sorpaas.

There are 2 commits: the first one cleans up some code to make the fix in the second commit more obvious.

@chfast chfast requested review from gumb0, holiman and winsvega October 15, 2018 12:22
@codecov-io
Copy link

Codecov Report

Merging #5316 into master will decrease coverage by 0.41%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5316      +/-   ##
==========================================
- Coverage   61.87%   61.45%   -0.42%     
==========================================
  Files         342      342              
  Lines       28063    28062       -1     
  Branches     3238     3238              
==========================================
- Hits        17363    17245     -118     
- Misses       9561     9670     +109     
- Partials     1139     1147       +8

@@ -90,7 +90,7 @@ struct SubState
{
std::set<Address> suicides; ///< Any accounts that have suicided.
LogEntries logs; ///< Any logs.
u256 refunds; ///< Refund counter for storage changes.
int64_t refunds = 0; ///< Refund counter for storage changes.
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be safer to use signed bigint?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but if 63 bits are not enough I'd like to constructs a test for this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, you would need 3*10^13 millions gas in a transaction.

Copy link

Choose a reason for hiding this comment

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

Yeah. For this counter, geth uses u64, and parity uses i128 (which is basically signed u64). If we make every opcode give maximum amount of refund as we currently have, it would still take decades of execution for that to ever overflow.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for clarification @sorpaas.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants