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

eth_call base on specific block & specific index #23018

Open
huahuayu opened this issue Jun 8, 2021 · 3 comments
Open

eth_call base on specific block & specific index #23018

huahuayu opened this issue Jun 8, 2021 · 3 comments

Comments

@huahuayu
Copy link
Contributor

huahuayu commented Jun 8, 2021

hi, eth_call can be executed query/tx in a specific block as this method shows

func (ec *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {

is it possible to execute eth_call in a specific block AND a specific index?

I happened to see this service, it can fork chain at a specific block and index, which is really cool!

image

and then I can do simulation

image

how can I implement it in the native go-ethereum current codebase?

@nebojsa94
Copy link
Contributor

Hey @huahuayu,

We have a custom EVM that is more flexible than standard JSON-RPC interface, but you can definitely accomplish this with go-ethereum.

Basically, instead of just opening StateDB at a certain block number you also need to apply all transactions with an index lower than provided index.

Keep in mind that this requires an archive node if you want to perform eth_call on old blocks (more than 128 blocks in the past) and that applying transactions can take a bit more time (up to 300-400ms) depending on the index.

@huahuayu
Copy link
Contributor Author

huahuayu commented Jun 8, 2021

@nebojsa94 thanks for the reply, your tools are great!

Exactly the same thought in my mind :) It can be realized by archive node + ganache-cli fork + execute lower index tx in sequence.

@huahuayu
Copy link
Contributor Author

could this be native support in geth, it should be useful @karalabe

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

No branches or pull requests

2 participants