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

feat: add basic support for eth_call #1442

Merged
merged 2 commits into from
Sep 13, 2024
Merged

Conversation

morph-dev
Copy link
Collaborator

What was wrong?

Trin doesn't support eth_call requests.

How was it fixed?

  • Refactored the rpc/src/eth_rpc.rs
    • EvmBlockState now takes care of fetching all state related content for a specific block
  • Using async evm execution from trin-execution crate

I tested it locally, with one simple transaction (token balance), and it works.

To-Do in future PRs

  • Add caching to the EvmBlockState
    • this will speed up transaction execution as we wouldn't have to traverse entire trie for every piece of data
  • Add support for fetching block_hash by block number
  • Extract some common logic from trin-execution/src/evm into separate crate: e.g. trin-evm

@morph-dev morph-dev added the state network Issue related to portal state network label Sep 12, 2024
@morph-dev morph-dev added this to the Devcon 2024 milestone Sep 12, 2024
@morph-dev morph-dev requested a review from KolbyML September 12, 2024 13:14
@morph-dev morph-dev self-assigned this Sep 12, 2024
Copy link
Member

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

:shipit:

rpc/src/eth_rpc.rs Show resolved Hide resolved
evm_block_state,
|evm| {
// Allow unlimited gas
evm.cfg_mut().disable_block_gas_limit = true;
Copy link
Member

Choose a reason for hiding this comment

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

                // Allow unlimited gas
                evm.cfg_mut().disable_block_gas_limit = true;

This looks like a very bad idea, why not limit it to the max gas for a block or something

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I check what reth is doing for eth_call, and they do set this flag, and they also set gas_limit if it is not set.

They also configure a lot of other things, that I'm not sure we need (at least for now).

For now, I will remove this flag, and if gas limit is unset, I will set it to block's gas limit.

@morph-dev morph-dev merged commit 56cb29c into ethereum:master Sep 13, 2024
9 checks passed
@morph-dev morph-dev deleted the eth_call branch September 13, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state network Issue related to portal state network
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants