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

Enable eth_call state override #2219

Merged
merged 4 commits into from
Apr 12, 2023
Merged

Enable eth_call state override #2219

merged 4 commits into from
Apr 12, 2023

Conversation

nbaztec
Copy link
Contributor

@nbaztec nbaztec commented Apr 11, 2023

What does it do?

enabled eth_call state override as supported by geth

Fixes #1860

✔️ eth_call now supports an optional third parameter that can be used to set state overrides for specific addresses (useful for mocking purposes). The object is a key-value structure where each key identifies the address to override, while the value is a mapping of different override-able parameters.

provider.send("eth_call", "latest", {
    "0x123...": {
        balance: "0xff",
        nonce: "0x01",
        code: "0x.......",
        state: {
            "0xabc...": "0x...",
        },
        stateDiff: {
            "0xdef...": "0x...",
        },
    }   
});

The fields are:

  • balance - sets the balance for the address.
  • nonce - sets the nonce for the address.
  • code - sets the EVM bytecode for the address.
  • state - fully sets the storage for the address as provided by the key-value pairs.
  • stateDiff - selectively sets the storage for the address as provided by the key-value pairs.

See tests for examples.

What important points reviewers should know?

Is there something left for follow-up PRs?

What alternative implementations were considered?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

What value does it bring to the blockchain users?

@nbaztec nbaztec added B5-clientnoteworthy Changes should be mentioned in any downstream projects' release notes D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. not-breaking Does not need to be mentioned in breaking changes labels Apr 11, 2023
Copy link
Contributor

@tgmichel tgmichel left a comment

Choose a reason for hiding this comment

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

Added a typo comment otherwise looks good, great work!!

tests/tests/test-eth-call/test-eth-call-state-override.ts Outdated Show resolved Hide resolved
@nbaztec nbaztec merged commit 7776790 into master Apr 12, 2023
@nbaztec nbaztec deleted the nish-eth-call-override branch April 12, 2023 13:45
imstar15 pushed a commit to AvaProtocol/moonbeam that referenced this pull request May 16, 2023
@notlesh notlesh added D1-audited👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. labels May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B5-clientnoteworthy Changes should be mentioned in any downstream projects' release notes D1-audited👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited not-breaking Does not need to be mentioned in breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eth_call stateDiff override set not working
3 participants