eth_simulateV1
S1na, OlegJakuskin, Micah, Lukasz Rozmej, Epheph, Killari
Oleg, Killari
https://github.com/ethereum/execution-apis/pull/484
EP484
https://github.com/ethereum/execution-apis/pull/484
What is eth_simulateV1?
�
eth_simulateV1 Core Features
2) Replace account state
3) ECRecover precompile override
3) Precompile override - ECRecover
Mapping
Move ecrecover
Replace code
ECRecover
Use Case: Swap USDC -> ETH Permit message faking
Get The Interceptor: https://www.dark.florist/
3) Precompile override - The query itself
{
"jsonrpc": "2.0",
"id": 4993,
"method": "eth_simulateV1",
"params": [
{
"blockStateCalls": [
{
"calls": [
{ ... approve(address,uint256) ...},
{ ... Uniswap swap transaction ... },
],
"stateOverrides": {
"0x0000000000000000000000000000000000000001": {
"state": {
"0x259bff9b47742e0b81631440ff18b8f1b584a8bc37ef684764aeb20b8bca6068": "0x000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045"
},
"code": "ECRECOVER OVERRIDE BYTECODE",
"movePrecompileToAddress": "0x0000000000000000000000000000000000123456"
}
},
}
],
"traceTransfers": true,
"validation": false
},
"0x11b1ebd"
]
}
2) Permit message
3) Swap Transaction
The outcome of the whole query:
4) Event Logs + ETH transfer logs
4) ETH transfer logs
"logs": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000b57ab8767cae33be61ff15167134861865f7d22c",
"0x000000000000000000000000ced10840f87a2320fdca1dbe17d4f8e4211840a8"
],
"data": "0x0000000000000000000000000000000000000000000000000f43fc2c04ee0000",
"blockNumber": "0x11b1f65",
"transactionHash": "0xdc7f600bef3a06b0864572f85634a4ffa00b8c4318949168727d89b4560b24b0",
"transactionIndex": "0x0",
"blockHash": "0x673fb12c793b9b118d6effdd74e9491a04e1666551f19bdb49fa95b9e134acaf",
"logIndex": "0x0",
"removed": false
}
]
Example: Governor Bravo execution simulation
{
"jsonrpc": "2.0",
"id": 204,
"method": "eth_simulateV1",
"params": [
{
"blockStateCalls": [
{
"calls": [
{
"type": "0x2",
"from": "0xdbd38f7e739709fe5bfae6cc8ef67c3820830e0c",
"nonce": "0x0",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"to": "0xb57ab8767cae33be61ff15167134861865f7d22c",
"value": "0x0",
"input": "execute timelock",
"chainId": "0x1",
"accessList": []
}
],
"stateOverrides": {
"0xb57ab8767cae33be61ff15167134861865f7d22c": {
"stateDiff": {},
"code": "Timelock contract replacement bytecode"
}
}
}
],
"traceTransfers": true,
"validation": false
},
"0x11b1f64"
]
}
{
"jsonrpc": "2.0",
"id": 204,
"result": [
{
"number": "0x11b1f65",
"hash": "0x673fb12c793b9b118d6effdd74e9491a04e1666551f19bdb49fa95b9e134acaf",
"timestamp": "0x65509098",
"gasLimit": "0x1c9c380",
"gasUsed": "0xbe97",
"feeRecipient": "0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97",
"baseFeePerGas": "0x429978e78",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"calls": [
{
"returnData": "0x",
"logs": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000b57ab8767cae33be61ff15167134861865f7d22c",
"0x000000000000000000000000ced10840f87a2320fdca1dbe17d4f8e4211840a8"
],
"data": "0x0000000000000000000000000000000000000000000000000f43fc2c04ee0000",
"blockNumber": "0x11b1f65",
"transactionHash": "0xdc7f600bef3a06b0864572f85634a4ffa00b8c4318949168727d89b4560b24b0",
"transactionIndex": "0x0",
"blockHash": "0x673fb12c793b9b118d6effdd74e9491a04e1666551f19bdb49fa95b9e134acaf",
"logIndex": "0x0",
"removed": false
},
{
"address": "0xb57ab8767cae33be61ff15167134861865f7d22c",
"topics": [
"0xa560e3198060a2f10670c1ec5b403077ea6ae93ca8de1c32b451dc1a943cd6e7",
"0x3e6eeeeced3a3b85bb1f37bb260f823dca5e1013558c4d93984762be0154ff21",
"0x000000000000000000000000ced10840f87a2320fdca1dbe17d4f8e4211840a8"
],
"data": "0x0000000000000000000000000000000000000000000000000f43fc2c04ee0000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockNumber": "0x11b1f65",
"transactionHash": "0xdc7f600bef3a06b0864572f85634a4ffa00b8c4318949168727d89b4560b24b0",
"transactionIndex": "0x0",
"blockHash": "0x673fb12c793b9b118d6effdd74e9491a04e1666551f19bdb49fa95b9e134acaf",
"logIndex": "0x1",
"removed": false
}
],
"gasUsed": "0xbe97",
"status": "0x1"
}
]
}
]
}
Existing implementations of eth_simulateV1 EP484
Nethermind: https://github.com/NethermindEth/nethermind/ (95% of features merged into master)
Geth: https://github.com/s1na/go-ethereum/tree/multicall
�More implementations needed! Join us: https://github.com/ethereum/execution-apis/pull/484
Implementation details
Simplified
* This is basically in part turning the Ethereum chain client into a multitenant app for many users to try on many chain versions
System changes
State updates
We allow to set:
What eth_call second argument does, yet on per processed block level.
Overlay Updating DBs is hard, updating caching in-memory only ones combined with on disk is harder.
DB + Caches
EVM updates
Users can override Precompiles:
*Some implementations may allow general smart contract redirects
Users get special logs…
Extra Logs!
RPC updates
Object data structures
Parsing of nested dictionaries/maps
Configuration Limits on max blocks, gas, request size
Validation Mode
Skipped stuff
Q: What do we do when user asks for block 1, 100, 1000?
A:
Development support
Eth_simulate overall
Discussion
We want users to explore tree of possibilities over time and blockspace!