-
Notifications
You must be signed in to change notification settings - Fork 371
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
feat: replace DIFFICULTY with PREVRANDAO after Merge/EIP-4399 #162
Conversation
a3712ca
to
5068df6
Compare
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 PR currently reverted #161, which I don't think is a good thing to do.
The reason we moved config
out of runtime because it's actually just not really used. There are huge amount of parameters, yet we just need two of them.
I would appreciate one of the following alternative way:
- Just don't set the
has_prevrandao
config. Instead, ifHandler::block_randomness
isSome
, userandao
behavior. Otherwise, usedifficulty
behavior`. I would prefer this. - Create a separate
RuntimeConfig
struct that just has the three parameters neededstack_limit
,memory_limit
, andhas_randao
.
07d297d
to
d19423b
Compare
@sorpaas I've addressed your comment. Can you take another look please? |
src/backend/memory.rs
Outdated
@@ -110,6 +115,9 @@ impl<'vicinity> Backend for MemoryBackend<'vicinity> { | |||
fn block_difficulty(&self) -> U256 { | |||
self.vicinity.block_difficulty | |||
} | |||
fn block_randomness(&self) -> Option<U256> { |
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.
fn block_randomness(&self) -> Option<U256> { | |
fn block_randomness(&self) -> Option<H256> { |
And you can avoid the conversion.
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've changed it but this means EVM hosts (including evm-test) will have to take care of the endianness conversion. Isn't that error-prone?
LGTM. Please update the test PR. |
Tests PR has been updated to convert endianness: https://github.com/rust-blockchain/evm-tests/pull/19/files#diff-bf42ab7deb71f94483835a445200880b13b91fc19cf43ad526262e4ea4d7b7d3R74-R84 |
I think we actually need to merge this first, then I'll be able to update the evm git submodule in the tests PR to the latest master here, and then that can be merged too. |
In the We don't have any CIs in the test repo, only the main one. |
Yes, that's how I've been developing.
I resolved the conflict on that PR. Let me know what to do next. |
@sorpaas ping |
@sorpaas jsontests won't run I believe, I still need to send one more PR for the two repos to build together. Can we merge this as is and I'll send the follow up PR soon that should fix everything? |
That PR has been sent btw: #163 |
* update PrecompileHandle ref: rust-ethereum/evm#122 * update fee calculation ref: rust-ethereum/evm#132 * add code_size/code_hash fn in StackState trait ref: rust-ethereum/evm#140 * update evm call stack ref: rust-ethereum/evm#136 * update evm call stack ref: rust-ethereum/evm#155 * add shanghai eips 3651, 3855, 3860 ref: rust-ethereum/evm#152 * update is_precompile ref: rust-ethereum/evm#157 * fix eip-3860 ref: rust-ethereum/evm#160 * update runtime config ref: rust-ethereum/evm#161 * add eip-4399 ref: rust-ethereum/evm#162 * fix eip-2618 ref: rust-ethereum/evm#163 * fix nonce back to U256 ref: rust-ethereum/evm#166 * remove exit_substate in create functions ref: rust-ethereum/evm#168 * record external cost ref: rust-ethereum/evm#170 * add record_external_operation ref: rust-ethereum/evm#171 * add storage_growth ref: rust-ethereum/evm#173 * update evm * switch to shanghai hardfork * update ecrecover ref: polkadot-evm/frontier#964 (#2696)
EIP-4399 that has been introduced in the Merge hasn't yet been implemented in sputnik, so this PR does it.
The EIP changed the DIFFICULTY opcode to PREVRANDAO, that returns random data from a consensus node post Merge, rather than the block difficulty, which after the Merge is always 0.
Changes:
has_prevrandao
specifies whether this EIP is enabled.block_randomness
has been added toMemoryVicinity
, so EVM hosts can specify the randomness they wish to use for the current execution of the EVM. Ifhas_prevrandao
is enabled then this value is returned by opcode0x44
.Config
fromRuntime
was reverted as this config is actually needed in this implementation.Note: depends on rust-blockchain/evm-tests#19 to be merged first because CI here is failing as evm-tests is out-of-date.