EVM/node: state override that specifies with an empty storage
What
Follows !14921 (merged)
Part of #7476 (closed)
Implements state part of the state override of eth_call even with an empty state.
see go-ethereum doc for spec.
An example in the doc seems to imply the RPC can accept a state override parameter with an empty state for an address :
{
"0xebe8efa441b9302a0d7eaecc277c09d20d684540": {
"code": "0x...",
"state": {
""
}
}
}
This particular JSON is not a valid JSON, but the following is:
{
"0xebe8efa441b9302a0d7eaecc277c09d20d684540": {
"code": "0x...",
"state": {}
}
}
So we make it work.
Why
Because maybe someone need it ? And it's a convenient way to reset the storage of an account ? And it's in the spec, sorta.
How
So now state_override.state is of type hex StorageMap.t option.
We tweak the encoding to map:
- state is not specified ->
None - state is specified but empty ->
Some StorageMap.empty - state is specified and not empty -> same as before
We can't do the obvious encoding Data_encoding.option <map encoding> (or use opt) because both would be nullable, and Data_encoding crashes at run time. ( see Data_encoding doc)
Manually testing the MR
We add a test:
dune exec etherlink/tezt/tests/main.exe -- alpha state_empty
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR