foundry icon indicating copy to clipboard operation
foundry copied to clipboard

feat(`anvil`): add RPC method similar to the ERC20 `deal` cheatcode

Open anajuliabit opened this issue 1 year ago • 7 comments

Component

Anvil

Describe the feature you would like

I'd like to request the creation of an RPC method similar to the ERC20 deal cheatcode for the following use case:

I need to gather enough votes in a governor to approve a proposal. If a deal equivalent RPC method exists, I could simply deal the quorum amount to any wallet, rather than having to impersonate multiple whale wallets to meet the quorum.

Thank you!

Additional context

No response

anajuliabit avatar Sep 24 '24 21:09 anajuliabit

I think this is a reasonable feature

mattsse avatar Sep 25 '24 12:09 mattsse

+1 on this but would prefer it not be called deal

roninjin10 avatar Oct 05 '24 03:10 roninjin10

This would be very helpful to use anvil as a backend for tests where you need to handle ERC20 tokens

Rubilmax avatar Oct 05 '24 10:10 Rubilmax

@roninjin10 had the idea to request an access list for a call to erc20.balanceOf(account) which would return the storage slot most probably as the last element of the access list returned

That should speed things up right?

Rubilmax avatar Oct 05 '24 10:10 Rubilmax

can I work on this, please?

maxslimb avatar Oct 12 '24 00:10 maxslimb

Assigned @maxslimb

yash-atreya avatar Oct 14 '24 07:10 yash-atreya

@roninjin10 had the idea to request an access list for a call to erc20.balanceOf(account) which would return the storage slot most probably as the last element of the access list returned

That should speed things up right?

For reference, I implemented this using viem in TypeScript here

Results are much much faster, which avoid having to rely on some external cache because only a few RPC queries are made and no brute-force is required anymore

Also, it adds support for non-trivial tokens such as stETH and USD0. I highly recommend doing something similar at anvil's level: request the access list and try each slot of the access list instead of brute-forcing the balanceOf slot

Rubilmax avatar Oct 14 '24 09:10 Rubilmax

@yash-atreya do you have any guidelines to contribute and for creating a pr?

maxslimb avatar Oct 23 '24 03:10 maxslimb

@maxslimb pls see https://github.com/foundry-rs/foundry/blob/master/CONTRIBUTING.md thanks!

grandizzy avatar Nov 07 '24 12:11 grandizzy

There is already this for your use case: https://docs.soliditylabs.io/forge-proposal-simulator/overview/architecture/addresses

sambacha avatar Nov 28 '24 07:11 sambacha

Sorry, what does this issue have in common with FPS addresses @sambacha?

anajuliabit avatar Nov 28 '24 12:11 anajuliabit

hi @maxslimb - are you still working on this issue? Thanks

(If someone changes stuff - please don't assign me - just trying to see which assigned issues are "stale" :) )

Hugoo avatar Mar 21 '25 09:03 Hugoo