diff --git a/beacon-chain/blockchain/BUILD.bazel b/beacon-chain/blockchain/BUILD.bazel index 2e1183765..25f78dd4d 100644 --- a/beacon-chain/blockchain/BUILD.bazel +++ b/beacon-chain/blockchain/BUILD.bazel @@ -27,6 +27,7 @@ go_library( "//shared/hashutil:go_default_library", "//shared/p2p:go_default_library", "//shared/params:go_default_library", + "@com_github_gogo_protobuf//proto:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", diff --git a/beacon-chain/blockchain/fork_choice.go b/beacon-chain/blockchain/fork_choice.go index 5267cfc66..3812398d2 100644 --- a/beacon-chain/blockchain/fork_choice.go +++ b/beacon-chain/blockchain/fork_choice.go @@ -5,6 +5,7 @@ import ( "context" "fmt" + "github.com/gogo/protobuf/proto" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prysmaticlabs/prysm/beacon-chain/cache" @@ -176,7 +177,7 @@ func (c *ChainService) ApplyForkChoiceRule( } newState := postState - if !isDescendant { + if !isDescendant && !proto.Equal(currentHead, newHead) { log.WithFields(logrus.Fields{ "currentSlot": currentHead.Slot - params.BeaconConfig().GenesisSlot, "currentRoot": fmt.Sprintf("%#x", bytesutil.Trunc(currentHeadRoot[:])), @@ -195,6 +196,13 @@ func (c *ChainService) ApplyForkChoiceRule( reorgCount.Inc() } + if proto.Equal(currentHead, newHead) { + log.WithFields(logrus.Fields{ + "currentSlot": currentHead.Slot - params.BeaconConfig().GenesisSlot, + "currentRoot": fmt.Sprintf("%#x", bytesutil.Trunc(currentHeadRoot[:])), + }).Warn("Head did not change after fork choice, current head has the most votes") + } + // If we receive forked blocks. if newHead.Slot != newState.Slot { newState, err = c.beaconDB.HistoricalStateFromSlot(ctx, newHead.Slot, newHeadRoot)