Skip to content
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/evm: Random opcode (EIP-4399) #24068

Conversation

MariusVanDerWijden
Copy link
Member

@MariusVanDerWijden MariusVanDerWijden commented Dec 6, 2021

This PR implements EIP-4399, the RANDOM opcode post-merge.
Since we don't know the merge block number beforehand, we need to somehow signal to the EVM that the Random opcode should be used now. For that I've implemented the SetVMConfig method. Since the transition can happen both during block insertion over the API and during the sync, I needed to add a lock for the vmConf. Might not be the greatest way to do it (suggestions very welcome). I also pass the vmConf by value now, not by reference as it is dereferenced in all callers anyway.

Additionally I extended the StateTestUtil to be able to create state tests with the RANDOM opcode. An example for that later.

replaces #23985

{"FuzzyVM-37426906-1385711810":
{"env":{"currentCoinbase":"b94f5374fce5edbc8e2a8697c15331677e6ebf0b","currentRandom":"0x1000000000000000000000000000000000000000000000000000000000000001","currentGasLimit":"0x26e1f476fe1e22","currentNumber":"0x1",
"currentTimestamp":"0x3e8","currentBaseFee":"0x3B","previousHash":"0x000000000000000000000000000000000000000000000000000000000000000"},
"pre":{
	"0x00000000000000000000000000000000b0b0face": {"code":"0x40600052","storage":{},"balance":"0x0","nonce":"0x0"},
	"0x000000000000000000000000000000ca1100f022": {"code":"0x444455","storage":{},"balance":"0x0","nonce":"0x0"},
	"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b":{"code":"0x","storage":{},"balance":"0x3fffffffffffffff","nonce":"0x0"}
	},
"transaction":{"gasPrice":"0x80","nonce":"0x0","to":"0x000000000000000000000000000000ca1100f022","data":[""],"gasLimit":["0x1312d00"],"value":["0xec43921b"],"secretKey":"0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"}
,"out":"0x","post":{
	"London":[{"hash":"63f729142596e783fee36c8db6d47db30783290dc33073d242108baf0281ca71","logs":"1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
	"indexes":{"data":0,"gas":0,"value":0}}]
	}}}

@MariusVanDerWijden MariusVanDerWijden force-pushed the eip-4399-ontopof-v3 branch 2 times, most recently from 1bf9700 to 2f50205 Compare December 8, 2021 13:07
@MariusVanDerWijden MariusVanDerWijden marked this pull request as ready for review December 20, 2021 10:28
@MariusVanDerWijden MariusVanDerWijden changed the title Draft implementation of EIP-4399 core/evm: Random opcode (EIP-4399) Dec 20, 2021
@MariusVanDerWijden
Copy link
Member Author

superseeded by #24141

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

Successfully merging this pull request may close these issues.

None yet

1 participant