mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
Fix checkForChainStart
pre-genesis state and 0 validator (#6739)
This commit is contained in:
parent
7fff4ec411
commit
905a57cbd7
@ -458,9 +458,12 @@ func (s *Service) checkHeaderRange(start uint64, end uint64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) checkForChainstart(blockHash [32]byte, blockNumber *big.Int, blockTime uint64) {
|
func (s *Service) checkForChainstart(blockHash [32]byte, blockNumber *big.Int, blockTime uint64) {
|
||||||
|
if s.preGenesisState.NumValidators() == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
valCount, err := helpers.ActiveValidatorCount(s.preGenesisState, 0)
|
valCount, err := helpers.ActiveValidatorCount(s.preGenesisState, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("Could not determine active validator count from pref genesis state")
|
log.WithError(err).Error("Could not determine active validator count from pre genesis state")
|
||||||
}
|
}
|
||||||
triggered := state.IsValidGenesisState(valCount, s.createGenesisTime(blockTime))
|
triggered := state.IsValidGenesisState(valCount, s.createGenesisTime(blockTime))
|
||||||
if triggered {
|
if triggered {
|
||||||
|
@ -622,6 +622,16 @@ func TestConsistentGenesisState(t *testing.T) {
|
|||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCheckForChainstart_NoValidator(t *testing.T) {
|
||||||
|
hook := logTest.NewGlobal()
|
||||||
|
testAcc, err := contracts.Setup()
|
||||||
|
require.NoError(t, err, "Unable to set up simulated backend")
|
||||||
|
beaconDB, _ := testDB.SetupDB(t)
|
||||||
|
s := newPowchainService(t, testAcc, beaconDB)
|
||||||
|
s.checkForChainstart([32]byte{}, nil, 0)
|
||||||
|
testutil.AssertLogsDoNotContain(t, hook, "Could not determine active validator count from pre genesis state")
|
||||||
|
}
|
||||||
|
|
||||||
func newPowchainService(t *testing.T, eth1Backend *contracts.TestAccount, beaconDB db.Database) *Service {
|
func newPowchainService(t *testing.T, eth1Backend *contracts.TestAccount, beaconDB db.Database) *Service {
|
||||||
depositCache, err := depositcache.NewDepositCache()
|
depositCache, err := depositcache.NewDepositCache()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user