-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
core/vm, params: implement EXTCODEHASH opcode #17202
Conversation
From eip:
I don't see the check for existence, as implemented it will set zero for both non-existent and no-code ( I may be wrong...?) |
core/vm/instructions.go
Outdated
slot.SetUint64(0) | ||
} else { | ||
slot.SetBytes(hash.Bytes()) | ||
} |
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.
Martin is right here, if the code does have a hash, you can return it. If there is no code however, 3 scenarios can happen:
- The account is a plain account: the returned code hash should be Keccak256("") (ie.
c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
) - The account is a precompile, this is an interesting case, but I think Keccak256("") would be the correct one.
- The account does not exist:
00...0
Please see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1052.md#test-cases for details
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 think you could simplify this code via:
slot := stack.peek()
slot.SetBytes(evm.StateDB.GetCodeHash(common.BigToAddress(slot)))
I.e. Your optimization of slot.SetUint64(0)
is not worth it, because it entails the hash == (common.Hash{})
comparison, which in theory should be equivalent runtime wise to slot.SetBytes(hash.Bytes())
.
@holiman @karalabe This PR relays everything to
All things will keep continuous with statedb. |
params/gas_table.go
Outdated
@@ -63,7 +64,7 @@ var ( | |||
CreateBySuicide: 25000, | |||
} | |||
// GasTableEIP158 contain the gas re-prices for | |||
// the EIP15* phase. | |||
// the EIP158 phase. |
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.
Nitpick, this was correct, because this is EIP155 and EIP158 combo :)
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.
But maybe we can correct it to EIP155/EIP158
@rjl493456442 You are right with regard to the behavior. I stand corrected, code LGTM, just please fix the two issues I've raised just now. |
@karalabe Updated |
Ah, sorry for a followup nitpick. Could you add your comment (#17202 (comment)) into that method's description just so any reviewer will know why it works correctly? |
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.
LGTM
Lgtm |
* core/vm, params: implement EXTCODEHASH opcode * core, params: tiny fixes and polish * core: add function description
Implements EIP1052.