From 09a792ded47d9f80ef70663e24a7f26de721ea25 Mon Sep 17 00:00:00 2001 From: pinglamb Date: Sun, 17 Jan 2021 00:14:14 +0800 Subject: [PATCH] isCanonical for slot 0 should return true (#8269) Co-authored-by: terence tsao Co-authored-by: Preston Van Loon --- beacon-chain/rpc/beacon/validators.go | 4 ++++ beacon-chain/rpc/beacon/validators_test.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/beacon-chain/rpc/beacon/validators.go b/beacon-chain/rpc/beacon/validators.go index 11649b8f8c..5470b1cc4b 100644 --- a/beacon-chain/rpc/beacon/validators.go +++ b/beacon-chain/rpc/beacon/validators.go @@ -859,6 +859,10 @@ func (bs *Server) GetIndividualVotes( // if the input slot has a skip block, false is returned, // if the input slot has more than one block, an error is returned. func (bs *Server) isSlotCanonical(ctx context.Context, slot uint64) (bool, error) { + if slot == 0 { + return true, nil + } + hasBlockRoots, roots, err := bs.BeaconDB.BlockRootsBySlot(ctx, slot) if err != nil { return false, err diff --git a/beacon-chain/rpc/beacon/validators_test.go b/beacon-chain/rpc/beacon/validators_test.go index 7ddb162a6d..e208826fdc 100644 --- a/beacon-chain/rpc/beacon/validators_test.go +++ b/beacon-chain/rpc/beacon/validators_test.go @@ -2142,3 +2142,11 @@ func TestServer_isSlotCanonical(t *testing.T) { } } } + +func TestServer_isSlotCanonicalForSlot0(t *testing.T) { + ctx := context.Background() + bs := &Server{} + c, err := bs.isSlotCanonical(ctx, 0) + require.NoError(t, err) + require.Equal(t, true, c) +}