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

Add Support for Specifying Access Lists #19

Merged
merged 2 commits into from
Sep 25, 2023
Merged

Add Support for Specifying Access Lists #19

merged 2 commits into from
Sep 25, 2023

Conversation

nlordell
Copy link
Contributor

This PR adds support for specifying access lists to simulations. It is mostly straight forward, we overwrite the foundry::Evm's TxEnv to additionally include a simulation's access list (just requires some type conversions as the revm crate uses slightly different types to ethers).

call_raw_* Functions now take a single CallRawRequest as the number of arguments were growing and hit Clippy's "too many arguments" lint.

Manual Testing:

Run simulations with and without access lists and see different gas used amounts:
% curl -s http://localhost:8080/api/v1/simulate -H 'Content-Type: application/json' --data '@-' <<JSON | jq .gasUsed
{
  "chainId": 1,
  "from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  "to": "0xDEf1CA1fb7FBcDC777520aa7f396b4E015F497aB",
  "data": "0x70a08231000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045",
  "gasLimit": 50000,
  "value": "0",
  "blockNumber": 18175734,
  "accessList": [{ "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "storageKeys": [] }]
}
JSON
26394

% curl -s http://localhost:8080/api/v1/simulate -H 'Content-Type: application/json' --data '@-' <<JSON | jq .gasUsed
{
  "chainId": 1,
  "from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  "to": "0xDEf1CA1fb7FBcDC777520aa7f396b4E015F497aB",
  "data": "0x70a08231000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045",
  "gasLimit": 50000,
  "value": "0",
  "blockNumber": 18175734 
}                                                                                                
JSON
23994

@fleupold
Copy link
Contributor

Awesome!

@devanoneth
Copy link
Contributor

Thanks again @nlordell, this looks great!

Do you mind resolving conflicts here too and adding an integration test to tests/api.rs? It should be relatively straight forward to turn your manual test into an integration test but please ping me if you have any questions on that.

@nlordell
Copy link
Contributor Author

Do you mind resolving conflicts here too

I'll do #18 first and this one afterwards, as there will be more merge conflicts from that PR as well.

@nlordell
Copy link
Contributor Author

Updated the PR to:

  • Document the API changes in the README
  • Add an E2E test using access lists

@devanoneth devanoneth merged commit bbbe4aa into EnsoFinance:main Sep 25, 2023
3 checks passed
@devanoneth
Copy link
Contributor

Thanks for the contribution again @nlordell!

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.

3 participants