Skip to content

Commit

Permalink
Genesis is always canonical
Browse files Browse the repository at this point in the history
  • Loading branch information
pinglamb committed Jan 21, 2021
1 parent f7a8903 commit f3dada5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
6 changes: 1 addition & 5 deletions beacon-chain/rpc/beacon/blocks.go
Expand Up @@ -164,15 +164,11 @@ func (bs *Server) ListBlocks(
if err != nil {
return nil, err
}
canonical, err := bs.CanonicalFetcher.IsCanonical(ctx, root)
if err != nil {
return nil, err
}
containers := []*ethpb.BeaconBlockContainer{
{
Block: genBlk,
BlockRoot: root[:],
Canonical: canonical,
Canonical: true,
},
}

Expand Down
14 changes: 2 additions & 12 deletions beacon-chain/rpc/beacon/blocks_test.go
Expand Up @@ -71,14 +71,10 @@ func TestServer_ListBlocks_NoResults(t *testing.T) {

func TestServer_ListBlocks_Genesis(t *testing.T) {
db := dbTest.SetupDB(t)
chain := &chainMock.ChainService{
CanonicalRoots: map[[32]byte]bool{},
}
ctx := context.Background()

bs := &Server{
BeaconDB: db,
CanonicalFetcher: chain,
BeaconDB: db,
}

// Should throw an error if no genesis block is found.
Expand All @@ -97,7 +93,6 @@ func TestServer_ListBlocks_Genesis(t *testing.T) {
require.NoError(t, err)
require.NoError(t, db.SaveBlock(ctx, blk))
require.NoError(t, db.SaveGenesisBlockRoot(ctx, root))
chain.CanonicalRoots[root] = true
wanted := &ethpb.ListBlocksResponse{
BlockContainers: []*ethpb.BeaconBlockContainer{
{
Expand All @@ -122,14 +117,10 @@ func TestServer_ListBlocks_Genesis(t *testing.T) {

func TestServer_ListBlocks_Genesis_MultiBlocks(t *testing.T) {
db := dbTest.SetupDB(t)
chain := &chainMock.ChainService{
CanonicalRoots: map[[32]byte]bool{},
}
ctx := context.Background()

bs := &Server{
BeaconDB: db,
CanonicalFetcher: chain,
BeaconDB: db,
}
// Should return the proper genesis block if it exists.
parentRoot := [32]byte{1, 2, 3}
Expand All @@ -139,7 +130,6 @@ func TestServer_ListBlocks_Genesis_MultiBlocks(t *testing.T) {
require.NoError(t, err)
require.NoError(t, db.SaveBlock(ctx, blk))
require.NoError(t, db.SaveGenesisBlockRoot(ctx, root))
chain.CanonicalRoots[root] = true

count := uint64(100)
blks := make([]*ethpb.SignedBeaconBlock, count)
Expand Down

0 comments on commit f3dada5

Please sign in to comment.