mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
Update EthereumAPIs (#4186)
* include new patch targeting latest ethapis master * ensure project builds * Merge branch 'master' into update-all-api * fix up committees * Merge branch 'update-all-api' of github.com:prysmaticlabs/prysm into update-all-api * include latest eth apis * Merge branch 'master' into update-all-api * update block tests * Merge branch 'update-all-api' of github.com:prysmaticlabs/prysm into update-all-api * Merge branch 'master' into update-all-api * add todos
This commit is contained in:
committed by
prylabs-bulldozer[bot]
parent
83781d0b74
commit
c31f46d973
@@ -1233,7 +1233,7 @@ go_repository(
|
||||
|
||||
go_repository(
|
||||
name = "com_github_prysmaticlabs_ethereumapis",
|
||||
commit = "23585b69a8b4113742948e3e266ceece844518a6",
|
||||
commit = "5f21afe48ab14bd0d5311cf5d33853a3e23d2fda",
|
||||
importpath = "github.com/prysmaticlabs/ethereumapis",
|
||||
patch_args = ["-p1"],
|
||||
patches = [
|
||||
|
||||
@@ -113,6 +113,14 @@ func (bs *Server) ListAttestations(
|
||||
}, nil
|
||||
}
|
||||
|
||||
// StreamAttestations to clients every single time a new attestation is received.
|
||||
// TODO(#4184): Implement.
|
||||
func (bs *Server) StreamAttestations(
|
||||
_ *ethpb.ListAttestationsRequest, _ ethpb.BeaconChain_StreamAttestationsServer,
|
||||
) error {
|
||||
return status.Error(codes.Unimplemented, "Not yet implemented")
|
||||
}
|
||||
|
||||
// AttestationPool retrieves pending attestations.
|
||||
//
|
||||
// The server returns a list of attestations that have been seen but not
|
||||
|
||||
@@ -32,48 +32,6 @@ func (bs *Server) ListBlocks(
|
||||
}
|
||||
|
||||
switch q := req.QueryFilter.(type) {
|
||||
case *ethpb.ListBlocksRequest_Epoch:
|
||||
startSlot := q.Epoch * params.BeaconConfig().SlotsPerEpoch
|
||||
endSlot := startSlot + params.BeaconConfig().SlotsPerEpoch - 1
|
||||
|
||||
blks, err := bs.BeaconDB.Blocks(ctx, filters.NewFilter().SetStartSlot(startSlot).SetEndSlot(endSlot))
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Failed to get blocks: %v", err)
|
||||
}
|
||||
|
||||
numBlks := len(blks)
|
||||
if numBlks == 0 {
|
||||
return ðpb.ListBlocksResponse{
|
||||
BlockContainers: make([]*ethpb.BeaconBlockContainer, 0),
|
||||
TotalSize: 0,
|
||||
NextPageToken: strconv.Itoa(0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), numBlks)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not paginate blocks: %v", err)
|
||||
}
|
||||
|
||||
returnedBlks := blks[start:end]
|
||||
containers := make([]*ethpb.BeaconBlockContainer, len(returnedBlks))
|
||||
for i, b := range returnedBlks {
|
||||
root, err := ssz.SigningRoot(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
containers[i] = ðpb.BeaconBlockContainer{
|
||||
Block: b,
|
||||
BlockRoot: root[:],
|
||||
}
|
||||
}
|
||||
|
||||
return ðpb.ListBlocksResponse{
|
||||
BlockContainers: containers,
|
||||
TotalSize: int32(numBlks),
|
||||
NextPageToken: nextPageToken,
|
||||
}, nil
|
||||
|
||||
case *ethpb.ListBlocksRequest_Root:
|
||||
blk, err := bs.BeaconDB.Block(ctx, bytesutil.ToBytes32(q.Root))
|
||||
if err != nil {
|
||||
|
||||
@@ -36,8 +36,8 @@ func TestServer_ListBlocks_NoResults(t *testing.T) {
|
||||
NextPageToken: strconv.Itoa(0),
|
||||
}
|
||||
res, err := bs.ListBlocks(ctx, ðpb.ListBlocksRequest{
|
||||
QueryFilter: ðpb.ListBlocksRequest_Epoch{
|
||||
Epoch: 0,
|
||||
QueryFilter: ðpb.ListBlocksRequest_Slot{
|
||||
Slot: 0,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -142,7 +142,7 @@ func TestServer_ListBlocks_Pagination(t *testing.T) {
|
||||
defer dbTest.TeardownDB(t, db)
|
||||
ctx := context.Background()
|
||||
|
||||
count := uint64(100)
|
||||
count := uint64(6)
|
||||
blks := make([]*ethpb.BeaconBlock, count)
|
||||
blkContainers := make([]*ethpb.BeaconBlockContainer, count)
|
||||
for i := uint64(0); i < count; i++ {
|
||||
@@ -160,80 +160,29 @@ func TestServer_ListBlocks_Pagination(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
root6, err := ssz.SigningRoot(ðpb.BeaconBlock{Slot: 6})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
bs := &Server{
|
||||
BeaconDB: db,
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
req *ethpb.ListBlocksRequest
|
||||
res *ethpb.ListBlocksResponse
|
||||
}{
|
||||
{req: ðpb.ListBlocksRequest{
|
||||
PageToken: strconv.Itoa(0),
|
||||
QueryFilter: ðpb.ListBlocksRequest_Slot{Slot: 5},
|
||||
PageSize: 3},
|
||||
res: ðpb.ListBlocksResponse{
|
||||
BlockContainers: []*ethpb.BeaconBlockContainer{{Block: ðpb.BeaconBlock{Slot: 5}, BlockRoot: blkContainers[5].BlockRoot}},
|
||||
NextPageToken: "",
|
||||
TotalSize: 1}},
|
||||
{req: ðpb.ListBlocksRequest{
|
||||
PageToken: strconv.Itoa(0),
|
||||
QueryFilter: ðpb.ListBlocksRequest_Root{Root: root6[:]},
|
||||
PageSize: 3},
|
||||
res: ðpb.ListBlocksResponse{
|
||||
BlockContainers: []*ethpb.BeaconBlockContainer{{Block: ðpb.BeaconBlock{Slot: 6}, BlockRoot: blkContainers[6].BlockRoot}},
|
||||
TotalSize: 1}},
|
||||
{req: ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Root{Root: root6[:]}},
|
||||
res: ðpb.ListBlocksResponse{
|
||||
BlockContainers: []*ethpb.BeaconBlockContainer{{Block: ðpb.BeaconBlock{Slot: 6}, BlockRoot: blkContainers[6].BlockRoot}},
|
||||
TotalSize: 1}},
|
||||
{req: ðpb.ListBlocksRequest{
|
||||
PageToken: strconv.Itoa(0),
|
||||
QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 0},
|
||||
PageSize: 100},
|
||||
res: ðpb.ListBlocksResponse{
|
||||
BlockContainers: blkContainers[0:params.BeaconConfig().SlotsPerEpoch],
|
||||
NextPageToken: "",
|
||||
TotalSize: int32(params.BeaconConfig().SlotsPerEpoch)}},
|
||||
{req: ðpb.ListBlocksRequest{
|
||||
PageToken: strconv.Itoa(1),
|
||||
QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 5},
|
||||
PageSize: 3},
|
||||
res: ðpb.ListBlocksResponse{
|
||||
BlockContainers: blkContainers[43:46],
|
||||
NextPageToken: "2",
|
||||
TotalSize: int32(params.BeaconConfig().SlotsPerEpoch)}},
|
||||
{req: ðpb.ListBlocksRequest{
|
||||
PageToken: strconv.Itoa(1),
|
||||
QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 11},
|
||||
PageSize: 7},
|
||||
res: ðpb.ListBlocksResponse{
|
||||
BlockContainers: blkContainers[95:96],
|
||||
NextPageToken: "",
|
||||
TotalSize: int32(params.BeaconConfig().SlotsPerEpoch)}},
|
||||
{req: ðpb.ListBlocksRequest{
|
||||
PageToken: strconv.Itoa(0),
|
||||
QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 12},
|
||||
PageSize: 4},
|
||||
res: ðpb.ListBlocksResponse{
|
||||
BlockContainers: blkContainers[96:100],
|
||||
NextPageToken: "1",
|
||||
TotalSize: int32(params.BeaconConfig().SlotsPerEpoch / 2)}},
|
||||
req := ðpb.ListBlocksRequest{
|
||||
PageToken: strconv.Itoa(0),
|
||||
QueryFilter: ðpb.ListBlocksRequest_Slot{Slot: 5},
|
||||
PageSize: 3,
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
res, err := bs.ListBlocks(ctx, test.req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !proto.Equal(res, test.res) {
|
||||
t.Errorf("Incorrect blocks response, wanted %v, received %v", test.res, res)
|
||||
}
|
||||
want := ðpb.ListBlocksResponse{
|
||||
BlockContainers: []*ethpb.BeaconBlockContainer{{
|
||||
Block: ðpb.BeaconBlock{Slot: 5},
|
||||
BlockRoot: blkContainers[5].BlockRoot,
|
||||
}},
|
||||
NextPageToken: "",
|
||||
TotalSize: 1,
|
||||
}
|
||||
res, err := bs.ListBlocks(ctx, req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !proto.Equal(res, want) {
|
||||
t.Errorf("Incorrect blocks response, wanted %v, received %v", want, res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +206,7 @@ func TestServer_ListBlocks_Errors(t *testing.T) {
|
||||
t.Errorf("Expected error %v, received %v", wanted, err)
|
||||
}
|
||||
|
||||
req = ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Epoch{}}
|
||||
req = ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Slot{Slot: 0}}
|
||||
res, err := bs.ListBlocks(ctx, req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -2,12 +2,10 @@ package beacon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/pagination"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -21,15 +19,6 @@ func (bs *Server) ListBeaconCommittees(
|
||||
ctx context.Context,
|
||||
req *ethpb.ListCommitteesRequest,
|
||||
) (*ethpb.BeaconCommittees, error) {
|
||||
if int(req.PageSize) > params.BeaconConfig().MaxPageSize {
|
||||
return nil, status.Errorf(
|
||||
codes.InvalidArgument,
|
||||
"Requested page size %d can not be greater than max size %d",
|
||||
req.PageSize,
|
||||
params.BeaconConfig().MaxPageSize,
|
||||
)
|
||||
}
|
||||
|
||||
headState, err := bs.HeadFetcher.HeadState(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, "Could not get head state")
|
||||
@@ -108,7 +97,7 @@ func (bs *Server) ListBeaconCommittees(
|
||||
)
|
||||
}
|
||||
|
||||
committees := make([]*ethpb.BeaconCommittees_CommitteeItem, 0)
|
||||
committeesList := make(map[uint64]*ethpb.BeaconCommittees_CommitteesList)
|
||||
for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ {
|
||||
var countAtSlot = uint64(len(activeIndices)) / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize
|
||||
if countAtSlot > params.BeaconConfig().MaxCommitteesPerSlot {
|
||||
@@ -117,6 +106,7 @@ func (bs *Server) ListBeaconCommittees(
|
||||
if countAtSlot == 0 {
|
||||
countAtSlot = 1
|
||||
}
|
||||
committeeItems := make([]*ethpb.BeaconCommittees_CommitteeItem, countAtSlot)
|
||||
for i := uint64(0); i < countAtSlot; i++ {
|
||||
epochOffset := i + (slot%params.BeaconConfig().SlotsPerEpoch)*countAtSlot
|
||||
totalCount := countAtSlot * params.BeaconConfig().SlotsPerEpoch
|
||||
@@ -129,39 +119,18 @@ func (bs *Server) ListBeaconCommittees(
|
||||
err,
|
||||
)
|
||||
}
|
||||
committees = append(committees, ðpb.BeaconCommittees_CommitteeItem{
|
||||
Committee: committee,
|
||||
Slot: slot,
|
||||
})
|
||||
committeeItems[i] = ðpb.BeaconCommittees_CommitteeItem{
|
||||
ValidatorIndices: committee,
|
||||
}
|
||||
}
|
||||
committeesList[slot] = ðpb.BeaconCommittees_CommitteesList{
|
||||
Committees: committeeItems,
|
||||
}
|
||||
}
|
||||
|
||||
numCommittees := len(committees)
|
||||
// If there are no committees, we simply return a response specifying this.
|
||||
// Otherwise, attempting to paginate 0 committees below would result in an error.
|
||||
if numCommittees == 0 {
|
||||
return ðpb.BeaconCommittees{
|
||||
Epoch: helpers.SlotToEpoch(startSlot),
|
||||
ActiveValidatorCount: uint64(len(activeIndices)),
|
||||
Committees: make([]*ethpb.BeaconCommittees_CommitteeItem, 0),
|
||||
TotalSize: int32(0),
|
||||
NextPageToken: strconv.Itoa(0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), numCommittees)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(
|
||||
codes.Internal,
|
||||
"Could not paginate results: %v",
|
||||
err,
|
||||
)
|
||||
}
|
||||
return ðpb.BeaconCommittees{
|
||||
Epoch: helpers.SlotToEpoch(startSlot),
|
||||
Committees: committeesList,
|
||||
ActiveValidatorCount: uint64(len(activeIndices)),
|
||||
Committees: committees[start:end],
|
||||
TotalSize: int32(numCommittees),
|
||||
NextPageToken: nextPageToken,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -2,10 +2,7 @@ package beacon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
@@ -18,58 +15,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
func TestServer_ListBeaconCommittees_Pagination_OutOfRange(t *testing.T) {
|
||||
db := dbTest.SetupDB(t)
|
||||
defer dbTest.TeardownDB(t, db)
|
||||
|
||||
numValidators := 1
|
||||
headState := setupActiveValidators(t, db, numValidators)
|
||||
headState.RandaoMixes = make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)
|
||||
for i := 0; i < len(headState.RandaoMixes); i++ {
|
||||
headState.RandaoMixes[i] = make([]byte, 32)
|
||||
}
|
||||
|
||||
bs := &Server{
|
||||
HeadFetcher: &mock.ChainService{
|
||||
State: headState,
|
||||
},
|
||||
}
|
||||
|
||||
numCommittees := uint64(0)
|
||||
for slot := uint64(0); slot < params.BeaconConfig().SlotsPerEpoch; slot++ {
|
||||
var countAtSlot = uint64(numValidators) / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize
|
||||
if countAtSlot > params.BeaconConfig().MaxCommitteesPerSlot {
|
||||
countAtSlot = params.BeaconConfig().MaxCommitteesPerSlot
|
||||
}
|
||||
if countAtSlot == 0 {
|
||||
countAtSlot = 1
|
||||
}
|
||||
numCommittees += countAtSlot
|
||||
}
|
||||
|
||||
req := ðpb.ListCommitteesRequest{PageToken: strconv.Itoa(1), PageSize: 100}
|
||||
wanted := fmt.Sprintf("page start %d >= list %d", req.PageSize, numCommittees)
|
||||
if _, err := bs.ListBeaconCommittees(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) {
|
||||
t.Errorf("Expected error %v, received %v", wanted, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServer_ListBeaconCommittees_Pagination_ExceedsMaxPageSize(t *testing.T) {
|
||||
bs := &Server{}
|
||||
exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1)
|
||||
|
||||
wanted := fmt.Sprintf(
|
||||
"Requested page size %d can not be greater than max size %d",
|
||||
exceedsMax,
|
||||
params.BeaconConfig().MaxPageSize,
|
||||
)
|
||||
req := ðpb.ListCommitteesRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax}
|
||||
if _, err := bs.ListBeaconCommittees(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) {
|
||||
t.Errorf("Expected error %v, received %v", wanted, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) {
|
||||
func TestServer_ListBeaconCommittees(t *testing.T) {
|
||||
db := dbTest.SetupDB(t)
|
||||
defer dbTest.TeardownDB(t, db)
|
||||
|
||||
@@ -95,7 +41,7 @@ func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wanted := make([]*ethpb.BeaconCommittees_CommitteeItem, 0)
|
||||
wanted := make(map[uint64]*ethpb.BeaconCommittees_CommitteesList)
|
||||
for slot := uint64(0); slot < params.BeaconConfig().SlotsPerEpoch; slot++ {
|
||||
var countAtSlot = uint64(numValidators) / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize
|
||||
if countAtSlot > params.BeaconConfig().MaxCommitteesPerSlot {
|
||||
@@ -104,6 +50,7 @@ func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) {
|
||||
if countAtSlot == 0 {
|
||||
countAtSlot = 1
|
||||
}
|
||||
committeeItems := make([]*ethpb.BeaconCommittees_CommitteeItem, countAtSlot)
|
||||
for i := uint64(0); i < countAtSlot; i++ {
|
||||
epochOffset := i + (slot%params.BeaconConfig().SlotsPerEpoch)*countAtSlot
|
||||
totalCount := countAtSlot * params.BeaconConfig().SlotsPerEpoch
|
||||
@@ -111,10 +58,12 @@ func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wanted = append(wanted, ðpb.BeaconCommittees_CommitteeItem{
|
||||
Committee: committee,
|
||||
Slot: slot,
|
||||
})
|
||||
committeeItems[i] = ðpb.BeaconCommittees_CommitteeItem{
|
||||
ValidatorIndices: committee,
|
||||
}
|
||||
}
|
||||
wanted[slot] = ðpb.BeaconCommittees_CommitteesList{
|
||||
Committees: committeeItems,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,39 +72,11 @@ func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) {
|
||||
res *ethpb.BeaconCommittees
|
||||
}{
|
||||
{
|
||||
req: ðpb.ListCommitteesRequest{
|
||||
PageSize: 2,
|
||||
},
|
||||
req: ðpb.ListCommitteesRequest{},
|
||||
res: ðpb.BeaconCommittees{
|
||||
Epoch: 0,
|
||||
Committees: wanted[0:2],
|
||||
Committees: wanted,
|
||||
ActiveValidatorCount: uint64(numValidators),
|
||||
NextPageToken: strconv.Itoa(1),
|
||||
TotalSize: int32(len(wanted)),
|
||||
},
|
||||
},
|
||||
{
|
||||
req: ðpb.ListCommitteesRequest{
|
||||
PageToken: strconv.Itoa(1), PageSize: 3,
|
||||
},
|
||||
res: ðpb.BeaconCommittees{
|
||||
Epoch: 0,
|
||||
Committees: wanted[3:6],
|
||||
ActiveValidatorCount: uint64(numValidators),
|
||||
NextPageToken: strconv.Itoa(2),
|
||||
TotalSize: int32(len(wanted)),
|
||||
},
|
||||
},
|
||||
{
|
||||
req: ðpb.ListCommitteesRequest{
|
||||
PageToken: strconv.Itoa(3), PageSize: 5,
|
||||
},
|
||||
res: ðpb.BeaconCommittees{
|
||||
Epoch: 0,
|
||||
Committees: wanted[15:20],
|
||||
ActiveValidatorCount: uint64(numValidators),
|
||||
NextPageToken: strconv.Itoa(4),
|
||||
TotalSize: int32(len(wanted)),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -207,7 +128,7 @@ func TestServer_ListBeaconCommittees_FromArchive(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wanted := make([]*ethpb.BeaconCommittees_CommitteeItem, 0)
|
||||
wanted := make(map[uint64]*ethpb.BeaconCommittees_CommitteesList)
|
||||
for slot := uint64(0); slot < params.BeaconConfig().SlotsPerEpoch; slot++ {
|
||||
var countAtSlot = uint64(numValidators) / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize
|
||||
if countAtSlot > params.BeaconConfig().MaxCommitteesPerSlot {
|
||||
@@ -216,6 +137,7 @@ func TestServer_ListBeaconCommittees_FromArchive(t *testing.T) {
|
||||
if countAtSlot == 0 {
|
||||
countAtSlot = 1
|
||||
}
|
||||
committeeItems := make([]*ethpb.BeaconCommittees_CommitteeItem, countAtSlot)
|
||||
for i := uint64(0); i < countAtSlot; i++ {
|
||||
epochOffset := i + (slot%params.BeaconConfig().SlotsPerEpoch)*countAtSlot
|
||||
totalCount := countAtSlot * params.BeaconConfig().SlotsPerEpoch
|
||||
@@ -223,10 +145,12 @@ func TestServer_ListBeaconCommittees_FromArchive(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wanted = append(wanted, ðpb.BeaconCommittees_CommitteeItem{
|
||||
Committee: committee,
|
||||
Slot: slot,
|
||||
})
|
||||
committeeItems[i] = ðpb.BeaconCommittees_CommitteeItem{
|
||||
ValidatorIndices: committee,
|
||||
}
|
||||
}
|
||||
wanted[slot] = ðpb.BeaconCommittees_CommitteesList{
|
||||
Committees: committeeItems,
|
||||
}
|
||||
}
|
||||
res1, err := bs.ListBeaconCommittees(context.Background(), ðpb.ListCommitteesRequest{
|
||||
@@ -252,8 +176,6 @@ func TestServer_ListBeaconCommittees_FromArchive(t *testing.T) {
|
||||
Epoch: 0,
|
||||
Committees: wanted,
|
||||
ActiveValidatorCount: uint64(numValidators),
|
||||
NextPageToken: "",
|
||||
TotalSize: int32(len(wanted)),
|
||||
}
|
||||
if !reflect.DeepEqual(wantedRes, res1) {
|
||||
t.Errorf("Wanted %v, received %v", wantedRes, res1)
|
||||
|
||||
@@ -247,6 +247,14 @@ func (bs *Server) ListValidators(
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetValidator information from any validator in the registry by index or public key.
|
||||
// TODO(#4177): Implement.
|
||||
func (bs *Server) GetValidator(
|
||||
_ context.Context, _ *ethpb.GetValidatorRequest,
|
||||
) (*ethpb.Validator, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "Not yet implemented")
|
||||
}
|
||||
|
||||
// GetValidatorActiveSetChanges retrieves the active set changes for a given epoch.
|
||||
//
|
||||
// This data includes any activations, voluntary exits, and involuntary
|
||||
|
||||
@@ -5,10 +5,6 @@ import (
|
||||
"time"
|
||||
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/cache/depositcache"
|
||||
@@ -21,6 +17,9 @@ import (
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
var log logrus.FieldLogger
|
||||
|
||||
@@ -255,7 +255,7 @@ index 69a148a..1b6ac18 100644
|
||||
+ bytes signature = 4 [(gogoproto.moretags) = "ssz-size:\"96\""];
|
||||
}
|
||||
diff --git a/eth/v1alpha1/beacon_chain.proto b/eth/v1alpha1/beacon_chain.proto
|
||||
index c31fe0f..ee2e2ec 100644
|
||||
index 5389a4e..2029f0e 100644
|
||||
--- a/eth/v1alpha1/beacon_chain.proto
|
||||
+++ b/eth/v1alpha1/beacon_chain.proto
|
||||
@@ -15,6 +15,7 @@ syntax = "proto3";
|
||||
@@ -266,7 +266,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
|
||||
@@ -76,9 +77,9 @@ service BeaconChain {
|
||||
@@ -84,9 +85,9 @@ service BeaconChain {
|
||||
};
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
// This includes the head block slot and root as well as information about
|
||||
// the most recent finalized and justified slots.
|
||||
rpc StreamChainHead(google.protobuf.Empty) returns (stream ChainHead) {
|
||||
@@ -278,7 +279,7 @@ message ChainHead {
|
||||
@@ -290,7 +291,7 @@ message ChainHead {
|
||||
uint64 head_epoch = 2;
|
||||
|
||||
// 32 byte merkle tree root of the canonical head block in the beacon node.
|
||||
@@ -288,7 +288,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
|
||||
// Most recent slot that contains the finalized block.
|
||||
uint64 finalized_slot = 4;
|
||||
@@ -287,7 +288,7 @@ message ChainHead {
|
||||
@@ -299,7 +300,7 @@ message ChainHead {
|
||||
uint64 finalized_epoch = 5;
|
||||
|
||||
// Most recent 32 byte finalized block root.
|
||||
@@ -297,7 +297,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
|
||||
// Most recent slot that contains the justified block.
|
||||
uint64 justified_slot = 7;
|
||||
@@ -296,7 +297,7 @@ message ChainHead {
|
||||
@@ -308,7 +309,7 @@ message ChainHead {
|
||||
uint64 justified_epoch = 8;
|
||||
|
||||
// Most recent 32 byte justified block root.
|
||||
@@ -306,7 +306,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
|
||||
// Most recent slot that contains the previous justified block.
|
||||
uint64 previous_justified_slot = 10;
|
||||
@@ -305,7 +306,7 @@ message ChainHead {
|
||||
@@ -317,7 +318,7 @@ message ChainHead {
|
||||
uint64 previous_justified_epoch = 11;
|
||||
|
||||
// Previous 32 byte justified block root.
|
||||
@@ -315,7 +315,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
}
|
||||
|
||||
message ListCommitteesRequest {
|
||||
@@ -363,7 +364,7 @@ message ListValidatorBalancesRequest {
|
||||
@@ -362,7 +363,7 @@ message ListValidatorBalancesRequest {
|
||||
|
||||
// Validator 48 byte BLS public keys to filter validators for the given
|
||||
// epoch.
|
||||
@@ -324,7 +324,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
|
||||
// Validator indices to filter validators for the given epoch.
|
||||
repeated uint64 indices = 4;
|
||||
@@ -384,7 +385,7 @@ message ValidatorBalances {
|
||||
@@ -383,7 +384,7 @@ message ValidatorBalances {
|
||||
|
||||
message Balance {
|
||||
// Validator's 48 byte BLS public key.
|
||||
@@ -333,7 +333,16 @@ index c31fe0f..ee2e2ec 100644
|
||||
|
||||
// Validator's index in the validator set.
|
||||
uint64 index = 2;
|
||||
@@ -460,17 +461,17 @@ message ActiveSetChanges {
|
||||
@@ -432,7 +433,7 @@ message GetValidatorRequest {
|
||||
uint64 index = 1;
|
||||
|
||||
// 48 byte validator public key.
|
||||
- bytes public_key = 2;
|
||||
+ bytes public_key = 2 [(gogoproto.moretags) = "ssz-size:\"48\""];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,17 +470,17 @@ message ActiveSetChanges {
|
||||
uint64 epoch = 1;
|
||||
|
||||
// 48 byte validator public keys that have been activated in this epoch.
|
||||
@@ -355,7 +364,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
}
|
||||
|
||||
message ValidatorQueue {
|
||||
@@ -480,11 +481,11 @@ message ValidatorQueue {
|
||||
@@ -489,11 +490,11 @@ message ValidatorQueue {
|
||||
|
||||
// Ordered list of 48 byte public keys awaiting activation. 0th index is the
|
||||
// next key to be processed.
|
||||
@@ -369,7 +378,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
}
|
||||
|
||||
message ListValidatorAssignmentsRequest {
|
||||
@@ -496,7 +497,7 @@ message ListValidatorAssignmentsRequest {
|
||||
@@ -505,7 +506,7 @@ message ListValidatorAssignmentsRequest {
|
||||
bool genesis = 2;
|
||||
}
|
||||
// 48 byte validator public keys to filter assignments for the given epoch.
|
||||
@@ -378,7 +387,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
|
||||
// Validator indicies to filter assignments for the given epoch.
|
||||
repeated uint64 indices = 4;
|
||||
@@ -531,7 +532,7 @@ message ValidatorAssignments {
|
||||
@@ -540,7 +541,7 @@ message ValidatorAssignments {
|
||||
uint64 proposer_slot = 4;
|
||||
|
||||
// 48 byte BLS public key.
|
||||
@@ -388,7 +397,7 @@ index c31fe0f..ee2e2ec 100644
|
||||
|
||||
// The epoch for which this set of validator assignments is valid.
|
||||
diff --git a/eth/v1alpha1/validator.proto b/eth/v1alpha1/validator.proto
|
||||
index a8c18fb..ca67c10 100644
|
||||
index 9f07458..e30cd3f 100644
|
||||
--- a/eth/v1alpha1/validator.proto
|
||||
+++ b/eth/v1alpha1/validator.proto
|
||||
@@ -15,6 +15,7 @@ syntax = "proto3";
|
||||
@@ -399,7 +408,7 @@ index a8c18fb..ca67c10 100644
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "eth/v1alpha1/beacon_block.proto";
|
||||
@@ -96,14 +97,14 @@ message DutiesRequest {
|
||||
@@ -106,14 +107,14 @@ message DutiesRequest {
|
||||
// Epoch at which validators should perform their duties.
|
||||
uint64 epoch = 1;
|
||||
// Array of byte encoded BLS public keys.
|
||||
@@ -416,7 +425,7 @@ index a8c18fb..ca67c10 100644
|
||||
// Slot at which a validator must attest.
|
||||
uint64 attestation_slot = 2;
|
||||
// Shard at which a validator must attest.
|
||||
@@ -120,7 +121,7 @@ message BlockRequest {
|
||||
@@ -130,7 +131,7 @@ message BlockRequest {
|
||||
// Slot for which the block should be proposed.
|
||||
uint64 slot = 1;
|
||||
// Validator's 32 byte randao reveal secret of the current epoch.
|
||||
@@ -425,7 +434,7 @@ index a8c18fb..ca67c10 100644
|
||||
}
|
||||
|
||||
message AttestationDataRequest {
|
||||
@@ -137,10 +138,10 @@ message AttestationDataRequest {
|
||||
@@ -147,10 +148,10 @@ message AttestationDataRequest {
|
||||
// An Ethereum 2.0 validator.
|
||||
message Validator {
|
||||
// 48 byte BLS public key used for the validator's activities.
|
||||
|
||||
Reference in New Issue
Block a user