-
Notifications
You must be signed in to change notification settings - Fork 654
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
Weird balance overrides when forking py-evm
#1960
Comments
I haven't dived deep into what's going on with this code yet. This isn't really an answer to your question, but an alternative would be to follow the model of TheDAO fork: py-evm/eth/vm/forks/homestead/headers.py Lines 85 to 105 in 239c72c
|
@carver this makes sense and thanks so much for highlighting the example, it's quite elegant. Unfortunately, I'm making a dynamic fork to simulate mainnet calls so I'm following an approach similar to |
Did you ever figure this out? |
Unfortunately I didn't, I parked this until I have more observability infrastructure to be able to debug it better but one thing that helped with related issues was being thorough in incorporating all the API functions. For example for nonces, in addition to |
@flux627 are you running into a similar issue? |
I'm still in a research phase for tooling- looking to see if it was possible to fork mainnet with this like Ganache, in hopes that this implementation is faster. But, it seems that this tooling isn't really meant for this. Also looking at hevm, but I don't know Haskell and it doesn't have any bindings. Any suggestions for performant mainnet forking tests are welcome. |
Unfortunately, we aren't currently putting any resources toward new features like this in py-evm (though forking mainnet is definitely a cool one that we've talked about, and would like some day). Though it's fairly straightforward to think of "forking mainnet" (without having the full state) as a kind of variant of Beam Sync. So you can check out how Beam Sync is implemented in trinity, especially the |
pip freeze
):Pip freeze output
What is wrong?
I'm running a notebook shown below (exported in
md
for simplicity).More about how this works:
py-evm
fork that attempts to override the balance for a single address (the coinbase account)getBalance
on the account, it reverts back to 0, any thoughts on why this may be the case? Note the lastget_balance
callupdated get_balance(0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf) = 0
which comes after setting the balance for that addressset_balance(0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf) := 2000000000000000000
.How is the fork itself set up:
get_balance
andset_balance
calls on the_account_db
balances_set
, in addition, it ignores the first run (which is the initial balance set for the coinbase account)Fork testing notebook
Designed to explore why account balances do not preserve correctly when forking
py-evm
.How can it be fixed
This may not be a bug, but I'd love to hear how to ensure that the balances stay consistent between transactions if I do override them.
The text was updated successfully, but these errors were encountered: