-
Notifications
You must be signed in to change notification settings - Fork 6k
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 support for EXTCODEHASH #4676
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4676 +/- ##
===========================================
- Coverage 87.92% 87.91% -0.01%
===========================================
Files 314 314
Lines 31766 31779 +13
Branches 3748 3749 +1
===========================================
+ Hits 27930 27940 +10
- Misses 2572 2575 +3
Partials 1264 1264
|
libevmasm/Instruction.h
Outdated
@@ -82,6 +82,7 @@ enum class Instruction: uint8_t | |||
EXTCODECOPY, ///< copy external code (from another contract) | |||
RETURNDATASIZE = 0x3d, ///< get size of return data buffer | |||
RETURNDATACOPY = 0x3e, ///< copy return data in current environment to memory | |||
EXTCODEHASH = 0x3f, |
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.
Needs description.
libevmasm/Instruction.cpp
Outdated
@@ -215,6 +216,7 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo = | |||
{ Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true, Tier::ExtCode } }, | |||
{ Instruction::RETURNDATASIZE, {"RETURNDATASIZE", 0, 0, 1, false, Tier::Base } }, | |||
{ Instruction::RETURNDATACOPY, {"RETURNDATACOPY", 0, 3, 0, true, Tier::VeryLow } }, | |||
{ Instruction::EXTCODESIZE, { "EXTCODEHASH", 0, 1, 1, false, Tier::ExtCode } }, |
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 seems to be wrong?
@@ -112,6 +112,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ | |||
gas += wordGas(GasCosts::copyGas, m_state->relativeStackElement(-2)); | |||
break; | |||
case Instruction::EXTCODESIZE: | |||
case Instruction::EXTCODEHASH: | |||
gas = GasCosts::extCodeGas(m_evmVersion); |
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.
Is this really charged the same?
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.
Most likely.
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.
Ah I'm sorry, - it seems to be the same as Instruction::BALANCE
.
Needs a changelog entry and tests too (see tests for create2). |
Will take this over. |
Is it accepted for constantinople in the same way as shift instructions are? |
@chriseth rebase and fixed this. |
155e783
to
054932b
Compare
@chriseth I think this is fine to merge. (Also needed for creating tests in github.com/ethereum/tests) |
@chriseth added documentation |
| | | | keccak256(<address> . n . keccak256(mem[p...(p+s))) and send v | | ||
| | | | wei and return the new address | | ||
| | | | keccak256(0xff . <address> . n . keccak256(mem[p...(p+s))) | | ||
| | | | and send v wei and return the new address | |
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 was missed in #5013.
| create(v, p, s) | | F | create new contract with code mem[p...(p+s)) and send v wei | | ||
| | | | and return the new address | | ||
+-------------------------+-----+---+-----------------------------------------------------------------+ | ||
| create2(v, n, p, s) | | C | create new contract with code mem[p...(p+s)) at address | | ||
| | | | keccak256(<address> . n . keccak256(mem[p...(p+s))) and send v | | ||
| | | | wei and return the new address | | ||
| | | | keccak256(0xff . <address> . n . keccak256(mem[p...(p+s))) | |
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 use u256(n)
to clarify padding?
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.
Started doing that but ran into a lot more to explain. Will prepare a separate PR.
Implementation for
EXTCODEHASH
opcode support in Solidity. For now, this seems to work with LLL assembly, which is what I am using to write someEXTCODEHASH
state tests.Implements https://eips.ethereum.org/EIPS/eip-1052