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

internal/ethapi: eth_simulateV1 #27720

Merged
merged 131 commits into from
Sep 6, 2024
Merged

internal/ethapi: eth_simulateV1 #27720

merged 131 commits into from
Sep 6, 2024

Conversation

s1na
Copy link
Contributor

@s1na s1na commented Jul 13, 2023

This is a successor PR to #25743. This PR is based on a new iteration of the spec: ethereum/execution-apis#484.

eth_multicall takes in a list of blocks, each optionally overriding fields like number, timestamp, etc. of a base block. Each block can include calls. At each block users can override the state. There are extra features, such as:

  • Include ether transfers as part of the logs
  • Overriding precompile codes with evm bytecode
  • Redirecting accounts to another address

Breaking changes

This PR includes the following breaking changes:

  • Block override fields of eth_call and debug_traceCall have had the following fields renamed
    • coinbase -> feeRecipient
    • random -> prevRandao
    • baseFee -> baseFeePerGas

@wjmelements
Copy link
Contributor

There's no reason to have a multicall interface. Either you can have one call do the multicalls or you can use batch jsonrpc.

Please reject this PR.

@s1na
Copy link
Contributor Author

s1na commented Jul 14, 2023

you can use batch jsonrpc.

No.

Either you can have one call do the multicalls

I believe you're referring to https://github.com/mds1/multicall. You're not able to set msg.sender to an arbitrary address there. eth_multicall simply provides much more flexibility for different simulation scenarios, allowing users to customize various EVM context fields.

s1na and others added 3 commits August 19, 2024 13:09
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
@s1na
Copy link
Contributor Author

s1na commented Aug 20, 2024

I've seen this test fail locally and on CI. But only every once in a while. Which is confusing for me because there is no concurrent element here. I expected any failure to be persistent.

--- FAIL: TestSimulateV1 (0.16s)
    --- FAIL: TestSimulateV1/transfer-logs (0.00s)
        api_test.go:2194: test transfer-logs, result mismatch, have
            [{0xb 0x47e7c4 0xd978 0x000000000000000000000000000000000000ffff 0x0 [{0x { 0} [{0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE [0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef 0x00000000000000000000000003812438bebd2b531fb8be4c0a0b0d500318ee31 0x00000000000000000000000016a7ae22a8f1429e4a7126fadae1c6e5806d95d9] 0x0000000000000000000000000000000000000000000000000000000000000032 0xb 0x0 0x0} {0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE [0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef 0x00000000000000000000000016a7ae22a8f1429e4a7126fadae1c6e5806d95d9 0x0000000000000000000000005d412c285f9900d954dcc4751a3026782d97a492] 0x0000000000000000000000000000000000000000000000000000000000000064 0xb 0x0 0x1}] 0xd978 0x1}]}]
            , want
            [{0xb 0x47e7c4 0xd984 0x000000000000000000000000000000000000ffff 0x0 [{0x { 0} [{0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE [0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef 0x00000000000000000000000003812438bebd2b531fb8be4c0a0b0d500318ee31 0x00000000000000000000000016a7ae22a8f1429e4a7126fadae1c6e5806d95d9] 0x0000000000000000000000000000000000000000000000000000000000000032 0xb 0x0 0x0} {0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE [0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef 0x00000000000000000000000016a7ae22a8f1429e4a7126fadae1c6e5806d95d9 0x0000000000000000000000005d412c285f9900d954dcc4751a3026782d97a492] 0x0000000000000000000000000000000000000000000000000000000000000064 0xb 0x0 0x1}] 0xd984 0x1}]}]
FAIL

The difference is 12 used gas.

@s1na
Copy link
Contributor Author

s1na commented Sep 4, 2024

I have updated the flaky test to use a fixed address instead of random. My hunch is that it was sometimes reporting a different gas used because the random address could have had a 0 in the beginning resulting in a different txdata cost.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@holiman holiman added this to the 1.14.9 milestone Sep 4, 2024
@s1na
Copy link
Contributor Author

s1na commented Sep 4, 2024

Merged in master. It was a clean merge 👍

@holiman
Copy link
Contributor

holiman commented Sep 5, 2024

# github.com/ethereum/go-ethereum/internal/ethapi [github.com/ethereum/go-ethereum/internal/ethapi.test]
Error: internal/ethapi/api_test.go:3294:26: not enough arguments in call to state.NewDatabase
	have (ethdb.Database)
	want (*triedb.Database, *snapshot.Tree)
Error: internal/ethapi/api_test.go:3295:47: too many arguments in call to state.New
	have ("github.com/ethereum/go-ethereum/common".Hash, *state.CachingDB, nil)

This PR needs to be re-merged with master, following the state reader merge. I could've rebased it for you, but I know you prefer merging... :)

@holiman holiman merged commit 8f4fac7 into ethereum:master Sep 6, 2024
3 checks passed
@s1na s1na changed the title internal/ethapi: eth_multicall internal/ethapi: eth_simulateV1 Sep 6, 2024
@s1na s1na mentioned this pull request Sep 6, 2024
holiman pushed a commit that referenced this pull request Sep 23, 2024
… global gascap is 0 (#30474)

In #27720, we introduced RPC global gas cap. A value of `0` means an unlimited gas cap. However, this was not the case for simulated calls. This PR fixes the behaviour.
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.

4 participants