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
Fix Bug On Startup Using Genesis.json #1258
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this! Just one comment on keeping InitialBeaconState
generic and not pass genesis.json
values as an extra argument. We should use initialValidatorDeposits
instead.
beacon-chain/core/state/state.go
Outdated
@@ -44,6 +45,11 @@ func InitialBeaconState( | |||
latestBlockRoots[i] = params.BeaconConfig().ZeroHash[:] | |||
} | |||
|
|||
latestBalances := make([]uint64, len(genesisValidatorRegistry)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not part of the spec under get_initial_beacon_state
. See https://github.com/ethereum/eth2.0-specs/blob/master/specs/core/0_beacon-chain.md#on-startup. I'd rather keep InitialBeaconState
generic and not work with genesis.json
which will be deprecated super soon, otherwise, it feels kinda hacky. Can we just pass the values of genesis.json
(pub key and balances) inside initialValidatorDeposits
and use that instead? It will still register via v.ProcessDeposit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to deprecate genesis.json super soon, I rather do it in this PR then and have a clean break. Also i guess initialValidators
is not used anywhere so I can start removing that too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. So outside of InitialBeaconState, we should do something like:
If demo config:
Convert Genesis.json to initialValidatorDeposit
Lmk if that doesn't make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reason being genesisValidatorRegistry will always be empty when we don't use Genesis.json
What is the bug exactly? |
Codecov Report
@@ Coverage Diff @@
## master #1258 +/- ##
==========================================
+ Coverage 70.63% 73.52% +2.89%
==========================================
Files 53 84 +31
Lines 4025 5809 +1784
==========================================
+ Hits 2843 4271 +1428
- Misses 959 1195 +236
- Partials 223 343 +120 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good! thanks for the fix. One last thing, there's still a genesis-json reference under VALIDATOR_REGISTRATION.md
, please remove that = )
This fixes a bug, when starting up and running the beacon-chain, by providing the initial validators from
genesis.json
as an argument to initialize state.Due to validators not being initialized from
genesis.json
, it leads to there being no validators stored in the beacon state. After shuffling ,ActiveValidatorIndices
returns an empty slice, which leads there to being no committees so we get a divide by zero error. This PR will be fixing this issue.