mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
Fixed a few more init beacon node bugs (#3297)
This commit is contained in:
@@ -14,6 +14,7 @@ go_library(
|
||||
deps = [
|
||||
"//beacon-chain/blockchain/forkchoice:go_default_library",
|
||||
"//beacon-chain/cache/depositcache:go_default_library",
|
||||
"//beacon-chain/core/blocks:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/state:go_default_library",
|
||||
"//beacon-chain/core/validators:go_default_library",
|
||||
|
||||
@@ -39,7 +39,7 @@ func (c *ChainService) ReceiveBlock(ctx context.Context, block *ethpb.BeaconBloc
|
||||
return errors.Wrap(err, "could not broadcast block")
|
||||
}
|
||||
log.WithFields(logrus.Fields{
|
||||
"attDataRoot": hex.EncodeToString(root[:]),
|
||||
"blockRoot": hex.EncodeToString(root[:]),
|
||||
}).Info("Broadcasting block")
|
||||
|
||||
if err := c.ReceiveBlockNoPubsub(ctx, block); err != nil {
|
||||
|
||||
@@ -13,8 +13,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/go-ssz"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain/forkchoice"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/cache/depositcache"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
|
||||
@@ -146,6 +148,11 @@ func (c *ChainService) initializeBeaconChain(
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not initialize genesis state")
|
||||
}
|
||||
stateRoot, err := ssz.HashTreeRoot(genesisState)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not tree hash genesis state")
|
||||
}
|
||||
genesisBlk := blocks.NewGenesisBlock(stateRoot[:])
|
||||
|
||||
if err := c.saveGenesisValidators(ctx, genesisState); err != nil {
|
||||
return errors.Wrap(err, "could not save genesis validators")
|
||||
@@ -155,6 +162,9 @@ func (c *ChainService) initializeBeaconChain(
|
||||
return errors.Wrap(err, "could not start genesis store for fork choice")
|
||||
}
|
||||
|
||||
c.headBlock = genesisBlk
|
||||
c.headState = genesisState
|
||||
c.canonicalRoots[genesisState.Slot] = c.FinalizedCheckpt().Root
|
||||
c.canonicalRoots[genesisState.Slot] = c.FinalizedCheckpt().Root
|
||||
|
||||
return nil
|
||||
|
||||
@@ -314,4 +314,14 @@ func TestChainService_initializeBeaconChain(t *testing.T) {
|
||||
t.Errorf("Validator %s missing from db", hex.EncodeToString(v.PublicKey))
|
||||
}
|
||||
}
|
||||
|
||||
if bc.HeadState() == nil {
|
||||
t.Error("Head state can't be nil after initialize beacon chain")
|
||||
}
|
||||
if bc.HeadBlock() == nil {
|
||||
t.Error("Head state can't be nil after initialize beacon chain")
|
||||
}
|
||||
if bc.CanonicalRoot(0) == nil {
|
||||
t.Error("Canonical root for slot 0 can't be nil after initialize beacon chain")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user