-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Charge for hashing init code in CREATE2 #5295
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5295 +/- ##
=========================================
+ Coverage 61.09% 61.1% +0.01%
=========================================
Files 340 340
Lines 27764 27784 +20
Branches 3208 3209 +1
=========================================
+ Hits 16962 16977 +15
- Misses 9668 9673 +5
Partials 1134 1134 |
@chfast Any idea what happened to macOS build here? |
It cannot find sha3WordGas symbol :/ |
Linker can't find the symbol, but it's |
libaleth-interpreter/VMCalls.cpp
Outdated
salt = m_SP[3]; | ||
// charge for hashing initCode = GSHA3WORD * ceil(len(init_code) / 32) | ||
m_runGas += toInt63((static_cast<u512>(initSize) + 31) / 32 * uint64_t(VMSchedule::sha3WordGas)); |
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.
Write it as u512(initSize)
because there is not data loss here.
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.
I prefer to avoid C-style casts altogether, than to have a rule when they're safe
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-casts-named
But here u512{initSize}
can be used, I'll change it.
@chfast Looks like it's obscure C++11 & 14 rules about |
So Another option is to add definitions of
https://en.cppreference.com/w/cpp/language/static#Constant_static_members |
I don't care which workaround is used, but I've found this for
|
I see, this is third kind of workaround. So as I understand |
I don't know why it work and I don't want to know. I think it was me who add this but I have not investigated the reasons. |
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.
Also maybe squash commits?
libevm/LegacyVMCalls.cpp
Outdated
salt = m_SP[3]; | ||
// charge for hashing initCode = GSHA3WORD * ceil(len(init_code) / 32) | ||
m_runGas += toInt63((static_cast<u512>(initSize) + 31) / 32 * m_schedule->sha3WordGas); |
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.
Same static_cast
-> u512{}
change here.
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.
done
Changing the gas cost of CREATE2 according to the latest changes in spec ethereum/EIPs#1375
cc @winsvega