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

Genesis stateRoot incorrect for Goerli testnet due to account balances #586

Closed
whalelephant opened this issue Aug 31, 2019 · 2 comments · Fixed by #589
Closed

Genesis stateRoot incorrect for Goerli testnet due to account balances #586

whalelephant opened this issue Aug 31, 2019 · 2 comments · Fixed by #589

Comments

@whalelephant
Copy link

I have found that when using vm.stateManager.generateCanonicalGenesis, where the stateManager is specified for the Goerli testnet, the genesis block stateRoot generated is incorrect.

The account balance from str -> Buffer in stateManager needs some formatting:

 account.balance = new BN(initState[address].slice(2), 16).toArrayLike(Buffer)

The initState account balances from ethereumjs-common is prefixed with '0x' Goerli (not sure if this is a decision for other purposes as they are not for mainnet.

@s1na
Copy link
Contributor

s1na commented Sep 2, 2019

Thanks for tracking down the problem. As a temporary fix we could strip the 0x prefix if one exists. I noticed that the genesis files are inconsistent on this. It's not only Goerli that has the 0x prefix. Also found https://github.com/ethereumjs/ethereumjs-common/issues/30, ethereumjs/ethereumjs-common#35 and ethereum/EIPs#1085. @holgerd77 it seems you were participating in the discussion back then, is there some consensus on the formatting of the genesis state?

@holgerd77
Copy link
Member

Yes, at the time we fixed the address formatting but not yet the balances on the Common library. I think this is one of the many open issues on the libraries which is not unimportant but which we can't prioritize right now (this would need another major release on the Common side).

So I would also suggest to do the temporary fix @s1na suggested and strip the 0x prefix. We should nevertheless also add tests here for the vm.stateManager.generateCanonicalGenesis() function to check against the genesis block state root for all major networks I would say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants