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

Anvil does not fund accounts when forking Arbitrum One #6795

Closed
2 tasks done
wuya666 opened this issue Jan 14, 2024 · 2 comments
Closed
2 tasks done

Anvil does not fund accounts when forking Arbitrum One #6795

wuya666 opened this issue Jan 14, 2024 · 2 comments
Labels
T-bug Type: bug

Comments

@wuya666
Copy link

wuya666 commented Jan 14, 2024

Component

Anvil

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (293fad7 2024-01-14T00:19:14.283768427Z)

What command(s) is the bug in?

anvil --chain-id 42161 --fork-url

Operating System

Linux

Describe the bug

As we want to test our project with real blockchain data, we try to fork Arbitrum One by running

anvil --chain-id 42161 --fork-url https://arb-mainnet.g.alchemy.com/v2/<Alchemy API Key>

it starts up seemingly ok

0.2.0 (293fad7 2024-01-14T00:19:14.280402885Z)                                                                           
    https://github.com/foundry-rs/foundry                                                                                    
                                                                                                                             
Available Accounts                                                                                                           
==================                                                                                                           
                                                                                                                             
(0) 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 (10000.000000000000000000 ETH)                                                
(1) 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 (10000.000000000000000000 ETH)                                                
(2) 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC (10000.000000000000000000 ETH)                                                
(3) 0x90F79bf6EB2c4f870365E785982E1f101E93b906 (10000.000000000000000000 ETH)                                                
(4) 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 (10000.000000000000000000 ETH)                                                
(5) 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc (10000.000000000000000000 ETH)                                                
(6) 0x976EA74026E726554dB657fA54763abd0C3a0aa9 (10000.000000000000000000 ETH)                                                
(7) 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 (10000.000000000000000000 ETH)                                                
(8) 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f (10000.000000000000000000 ETH)                                                
(9) 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 (10000.000000000000000000 ETH)                                                
                                                                                                                             
Private Keys                                                                                                                 
==================                                                                                                           
                                                                                                                             
(0) 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80                                                       
(1) 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d                                                       
(2) 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a                                                       
(3) 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6                                                       
(4) 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a                                                       
(5) 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba                                                       
(6) 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e                                                       
(7) 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356                                                       
(8) 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97                                                       
(9) 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6                                                       
                                                                                                                             
Wallet                                                                                                                       
==================                                                                                                           
Mnemonic:          test test test test test test test test test test test junk                                               
Derivation path:   m/44'/60'/0'/0/                                                                                           
                                                                                                                             
                                                                                                                             
Fork                                                                                                                         
==================                                                                                                           
Endpoint:       https://arb-mainnet.g.alchemy.com/v2/<Alchemy API Key>                                        
Block number:   170497454                                                                                                    
Block hash:     0xab0a891e5bac12a87258c365f5eb4e306a30436d71492a90af413cfe52622c62                                           
Chain ID:       42161                                                                                                        
                                                                                                                             
Base Fee                                                                                                                     
==================                                                                                                           
                                                                                                                             
100000000                                                                                                                    
                                                                                                                             
Gas Limit                                                                                                                    
==================                                                                                                           
                                                                                                                             
30000000                                                                                                                     
                                                                                                                             
Genesis Timestamp                                                                                                            
==================                                                                                                           
                                                                                                                             
1705270167                                                                                                                   
                                                                                                                             
Listening on 127.0.0.1:8545

But when I try to get the balance of the prefunded address, it shows 0

$ curl -X POST -H 'Content-Type: application/json' http://127.0.0.1:8545 -d '{"jsonrp
c":"2.0","method":"eth_getBalance","params":["0x90F79bf6EB2c4f870365E785982E1f101E93b906", "latest"],"id":1}

{"jsonrpc":"2.0","id":1,"result":"0x0"}

This bug can be somewhat remediated by setting the chainId of the forked network to any number other than 42161, for example to 42162

anvil --chain-id 42162 --fork-url https://arb-mainnet.g.alchemy.com/v2/<Alchemy API Key>

Then the getBalance call will return the correct result

$ curl -X POST -H 'Content-Type: application/json' http://127.0.0.1:8545 -d '{"jsonrp
c":"2.0","method":"eth_getBalance","params":["0x90F79bf6EB2c4f870365E785982E1f101E93b906", "latest"],"id":1}'

{"jsonrpc":"2.0","id":1,"result":"0x21e19e0c9bab2400000"}

However as our system requires the correct chainId to function on each chain, it is not a good solution for our testing purposes. Right now we had to resort to using Hardhat to fork the chain for tests.

@wuya666 wuya666 added the T-bug Type: bug label Jan 14, 2024
@gakonst gakonst added this to Foundry Jan 14, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Jan 14, 2024
@mattsse
Copy link
Member

mattsse commented Jan 15, 2024

this is the same issue as #6749

for Arbitrum forks we need to track the block number differently

@zerosnacks
Copy link
Member

anvil --chain-id 42161 --fork-url https://arb-mainnet.g.alchemy.com/v2/<API_KEY>

curl -X POST -H 'Content-Type: application/json' http://127.0.0.1:8545 -d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x90F79bf6EB2c4f870365E785982E1f101E93b906", "latest"],"id":1}'

Now correctly returns

{"jsonrpc":"2.0","id":1,"result":"0x21e19e0c9bab2400000"}

Marking as resolved

@jenpaff jenpaff moved this from Todo to Completed in Foundry Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

3 participants