Implement Chain Head Stream & Naming Consistency (#4160)

* include stream chain head mock
* uncomment test
* stream chain head implemented
* remove imports
* chain head stream test
* include stream test with mockgen
* test now passes
* checkin items
* stream tests all passing
* rem learn
* fix up fork checker
* add stream ctx
* gaz, fix test
* fix broken test
* Merge branch 'master' into chain-head-stream
* include context in chain head stream happy path test
* Merge branch 'master' into chain-head-stream
* Merge branch 'master' into chain-head-stream
* Merge refs/heads/master into chain-head-stream
* Merge refs/heads/master into chain-head-stream
This commit is contained in:
Raul Jordan
2019-12-03 11:48:11 -08:00
committed by prylabs-bulldozer[bot]
parent 8bbc589edd
commit 81a83cf100
10 changed files with 325 additions and 42 deletions

View File

@@ -1202,7 +1202,7 @@ go_repository(
go_repository(
name = "com_github_prysmaticlabs_ethereumapis",
commit = "8a69b37df2264eb58b0b0cef5ba25ae9af2d8732",
commit = "23585b69a8b4113742948e3e266ceece844518a6",
importpath = "github.com/prysmaticlabs/ethereumapis",
patch_args = ["-p1"],
patches = [

View File

@@ -50,13 +50,16 @@ go_test(
deps = [
"//beacon-chain/blockchain/testing:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/core/statefeed:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/db/testing:go_default_library",
"//beacon-chain/operations/testing:go_default_library",
"//beacon-chain/rpc/testing:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",
"//shared/params:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",

View File

@@ -8,6 +8,7 @@ import (
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/core/statefeed"
"github.com/prysmaticlabs/prysm/beacon-chain/db/filters"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/pagination"
@@ -175,6 +176,36 @@ func (bs *Server) ListBlocks(
// This includes the head block slot and root as well as information about
// the most recent finalized and justified slots.
func (bs *Server) GetChainHead(ctx context.Context, _ *ptypes.Empty) (*ethpb.ChainHead, error) {
return bs.chainHeadRetrieval(ctx)
}
// StreamChainHead to clients every single time the head block and state of the chain change.
func (bs *Server) StreamChainHead(_ *ptypes.Empty, stream ethpb.BeaconChain_StreamChainHeadServer) error {
stateChannel := make(chan *statefeed.Event, 1)
stateSub := bs.StateNotifier.StateFeed().Subscribe(stateChannel)
defer stateSub.Unsubscribe()
for {
select {
case event := <-stateChannel:
if event.Type == statefeed.BlockProcessed {
res, err := bs.chainHeadRetrieval(bs.Ctx)
if err != nil {
return status.Errorf(codes.Internal, "Could not retrieve chain head: %v", err)
}
return stream.Send(res)
}
case <-stateSub.Err():
return status.Error(codes.Aborted, "Subscriber closed, exiting goroutine")
case <-bs.Ctx.Done():
return status.Error(codes.Canceled, "Context canceled")
case <-stream.Context().Done():
return status.Error(codes.Canceled, "Context canceled")
}
}
}
// Retrieve chain head information from the DB and the current beacon state.
func (bs *Server) chainHeadRetrieval(ctx context.Context) (*ethpb.ChainHead, error) {
headState, err := bs.HeadFetcher.HeadState(ctx)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err)
@@ -191,34 +222,34 @@ func (bs *Server) GetChainHead(ctx context.Context, _ *ptypes.Empty) (*ethpb.Cha
if err != nil || b == nil {
return nil, status.Error(codes.Internal, "Could not get finalized block")
}
finalizedBlockSlot := b.Slot
finalizedSlot := b.Slot
justifiedCheckpoint := headState.CurrentJustifiedCheckpoint
b, err = bs.BeaconDB.Block(ctx, bytesutil.ToBytes32(justifiedCheckpoint.Root))
if err != nil || b == nil {
return nil, status.Error(codes.Internal, "Could not get justified block")
}
justifiedBlockSlot := b.Slot
justifiedSlot := b.Slot
prevJustifiedCheckpoint := headState.PreviousJustifiedCheckpoint
b, err = bs.BeaconDB.Block(ctx, bytesutil.ToBytes32(prevJustifiedCheckpoint.Root))
if err != nil || b == nil {
return nil, status.Error(codes.Internal, "Could not get prev justified block")
}
prevJustifiedBlockSlot := b.Slot
prevJustifiedSlot := b.Slot
return &ethpb.ChainHead{
HeadBlockSlot: headBlock.Slot,
HeadBlockEpoch: helpers.SlotToEpoch(headBlock.Slot),
HeadSlot: headBlock.Slot,
HeadEpoch: helpers.SlotToEpoch(headBlock.Slot),
HeadBlockRoot: headBlockRoot[:],
FinalizedBlockRoot: finalizedCheckpoint.Root,
FinalizedBlockSlot: finalizedBlockSlot,
FinalizedSlot: finalizedSlot,
FinalizedEpoch: finalizedCheckpoint.Epoch,
JustifiedBlockRoot: justifiedCheckpoint.Root,
JustifiedBlockSlot: justifiedBlockSlot,
FinalizedBlockRoot: finalizedCheckpoint.Root,
JustifiedSlot: justifiedSlot,
JustifiedEpoch: justifiedCheckpoint.Epoch,
PreviousJustifiedBlockRoot: prevJustifiedCheckpoint.Root,
PreviousJustifiedSlot: prevJustifiedBlockSlot,
JustifiedBlockRoot: justifiedCheckpoint.Root,
PreviousJustifiedSlot: prevJustifiedSlot,
PreviousJustifiedEpoch: prevJustifiedCheckpoint.Epoch,
PreviousJustifiedBlockRoot: prevJustifiedCheckpoint.Root,
}, nil
}

View File

@@ -9,10 +9,15 @@ import (
"testing"
"github.com/gogo/protobuf/proto"
ptypes "github.com/gogo/protobuf/types"
"github.com/golang/mock/gomock"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/core/statefeed"
dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
mockRPC "github.com/prysmaticlabs/prysm/beacon-chain/rpc/testing"
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/params"
)
@@ -370,13 +375,13 @@ func TestServer_GetChainHead(t *testing.T) {
t.Errorf("Wanted PreviousJustifiedSlot: %d, got: %d",
3, head.PreviousJustifiedSlot)
}
if head.JustifiedBlockSlot != 2 {
if head.JustifiedSlot != 2 {
t.Errorf("Wanted JustifiedSlot: %d, got: %d",
2, head.JustifiedBlockSlot)
2, head.JustifiedSlot)
}
if head.FinalizedBlockSlot != 1 {
if head.FinalizedSlot != 1 {
t.Errorf("Wanted FinalizedSlot: %d, got: %d",
1, head.FinalizedBlockSlot)
1, head.FinalizedSlot)
}
if !bytes.Equal(pjRoot[:], head.PreviousJustifiedBlockRoot) {
t.Errorf("Wanted PreviousJustifiedBlockRoot: %v, got: %v",
@@ -391,3 +396,98 @@ func TestServer_GetChainHead(t *testing.T) {
fRoot[:], head.FinalizedBlockRoot)
}
}
func TestServer_StreamChainHead_ContextCanceled(t *testing.T) {
db := dbTest.SetupDB(t)
defer dbTest.TeardownDB(t, db)
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
chainService := &mock.ChainService{}
server := &Server{
Ctx: ctx,
StateNotifier: chainService.StateNotifier(),
BeaconDB: db,
}
exitRoutine := make(chan bool)
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockStream := mockRPC.NewMockBeaconChain_StreamChainHeadServer(ctrl)
mockStream.EXPECT().Context().Return(ctx)
go func(tt *testing.T) {
if err := server.StreamChainHead(&ptypes.Empty{}, mockStream); !strings.Contains(err.Error(), "Context canceled") {
tt.Errorf("Could not call RPC method: %v", err)
}
<-exitRoutine
}(t)
cancel()
exitRoutine <- true
}
func TestServer_StreamChainHead_OnHeadUpdated(t *testing.T) {
db := dbTest.SetupDB(t)
defer dbTest.TeardownDB(t, db)
finalizedBlock := &ethpb.BeaconBlock{Slot: 1, ParentRoot: []byte{'A'}}
db.SaveBlock(context.Background(), finalizedBlock)
fRoot, _ := ssz.SigningRoot(finalizedBlock)
justifiedBlock := &ethpb.BeaconBlock{Slot: 2, ParentRoot: []byte{'B'}}
db.SaveBlock(context.Background(), justifiedBlock)
jRoot, _ := ssz.SigningRoot(justifiedBlock)
prevJustifiedBlock := &ethpb.BeaconBlock{Slot: 3, ParentRoot: []byte{'C'}}
db.SaveBlock(context.Background(), prevJustifiedBlock)
pjRoot, _ := ssz.SigningRoot(prevJustifiedBlock)
s := &pbp2p.BeaconState{
PreviousJustifiedCheckpoint: &ethpb.Checkpoint{Epoch: 3, Root: pjRoot[:]},
CurrentJustifiedCheckpoint: &ethpb.Checkpoint{Epoch: 2, Root: jRoot[:]},
FinalizedCheckpoint: &ethpb.Checkpoint{Epoch: 1, Root: fRoot[:]},
}
b := &ethpb.BeaconBlock{Slot: s.PreviousJustifiedCheckpoint.Epoch*params.BeaconConfig().SlotsPerEpoch + 1}
hRoot, _ := ssz.SigningRoot(b)
chainService := &mock.ChainService{}
server := &Server{
Ctx: context.Background(),
HeadFetcher: &mock.ChainService{Block: b, State: s},
BeaconDB: db,
StateNotifier: chainService.StateNotifier(),
}
exitRoutine := make(chan bool)
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockStream := mockRPC.NewMockBeaconChain_StreamChainHeadServer(ctrl)
mockStream.EXPECT().Context().Return(context.Background())
mockStream.EXPECT().Send(
&ethpb.ChainHead{
HeadSlot: b.Slot,
HeadEpoch: helpers.SlotToEpoch(b.Slot),
HeadBlockRoot: hRoot[:],
FinalizedSlot: 1,
FinalizedEpoch: 1,
FinalizedBlockRoot: fRoot[:],
JustifiedSlot: 2,
JustifiedEpoch: 2,
JustifiedBlockRoot: jRoot[:],
PreviousJustifiedSlot: 3,
PreviousJustifiedEpoch: 3,
PreviousJustifiedBlockRoot: pjRoot[:],
},
).Return(nil)
go func(tt *testing.T) {
if err := server.StreamChainHead(&ptypes.Empty{}, mockStream); err != nil {
tt.Errorf("Could not call RPC method: %v", err)
}
<-exitRoutine
}(t)
// Send in a loop to ensure it is delivered (busy wait for the service to subscribe to the state feed).
for sent := 0; sent == 0; {
sent = server.StateNotifier.StateFeed().Send(&statefeed.Event{
Type: statefeed.BlockProcessed,
Data: &statefeed.BlockProcessedData{},
})
}
exitRoutine <- true
}

View File

@@ -226,6 +226,7 @@ func (s *Service) Start() {
FinalizationFetcher: s.finalizationFetcher,
ChainStartFetcher: s.chainStartFetcher,
CanonicalStateChan: s.canonicalStateChan,
StateNotifier: s.stateNotifier,
}
aggregatorServer := &aggregator.Server{
BeaconDB: s.beaconDB,

View File

@@ -3,7 +3,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
testonly = True,
srcs = ["validator_service_mock.go"],
srcs = [
"beacon_chain_service_mock.go",
"validator_service_mock.go",
],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/testing",
visibility = ["//beacon-chain:__subpackages__"],
deps = [

View File

@@ -0,0 +1,132 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/prysmaticlabs/ethereumapis/eth/v1alpha1 (interfaces: BeaconChain_StreamChainHeadServer)
// Package testing is a generated GoMock package.
package testing
import (
context "context"
gomock "github.com/golang/mock/gomock"
v1alpha1 "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
metadata "google.golang.org/grpc/metadata"
reflect "reflect"
)
// MockBeaconChain_StreamChainHeadServer is a mock of BeaconChain_StreamChainHeadServer interface
type MockBeaconChain_StreamChainHeadServer struct {
ctrl *gomock.Controller
recorder *MockBeaconChain_StreamChainHeadServerMockRecorder
}
// MockBeaconChain_StreamChainHeadServerMockRecorder is the mock recorder for MockBeaconChain_StreamChainHeadServer
type MockBeaconChain_StreamChainHeadServerMockRecorder struct {
mock *MockBeaconChain_StreamChainHeadServer
}
// NewMockBeaconChain_StreamChainHeadServer creates a new mock instance
func NewMockBeaconChain_StreamChainHeadServer(ctrl *gomock.Controller) *MockBeaconChain_StreamChainHeadServer {
mock := &MockBeaconChain_StreamChainHeadServer{ctrl: ctrl}
mock.recorder = &MockBeaconChain_StreamChainHeadServerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockBeaconChain_StreamChainHeadServer) EXPECT() *MockBeaconChain_StreamChainHeadServerMockRecorder {
return m.recorder
}
// Context mocks base method
func (m *MockBeaconChain_StreamChainHeadServer) Context() context.Context {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Context")
ret0, _ := ret[0].(context.Context)
return ret0
}
// Context indicates an expected call of Context
func (mr *MockBeaconChain_StreamChainHeadServerMockRecorder) Context() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockBeaconChain_StreamChainHeadServer)(nil).Context))
}
// RecvMsg mocks base method
func (m *MockBeaconChain_StreamChainHeadServer) RecvMsg(arg0 interface{}) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RecvMsg", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// RecvMsg indicates an expected call of RecvMsg
func (mr *MockBeaconChain_StreamChainHeadServerMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockBeaconChain_StreamChainHeadServer)(nil).RecvMsg), arg0)
}
// Send mocks base method
func (m *MockBeaconChain_StreamChainHeadServer) Send(arg0 *v1alpha1.ChainHead) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Send", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Send indicates an expected call of Send
func (mr *MockBeaconChain_StreamChainHeadServerMockRecorder) Send(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockBeaconChain_StreamChainHeadServer)(nil).Send), arg0)
}
// SendHeader mocks base method
func (m *MockBeaconChain_StreamChainHeadServer) SendHeader(arg0 metadata.MD) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SendHeader", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// SendHeader indicates an expected call of SendHeader
func (mr *MockBeaconChain_StreamChainHeadServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockBeaconChain_StreamChainHeadServer)(nil).SendHeader), arg0)
}
// SendMsg mocks base method
func (m *MockBeaconChain_StreamChainHeadServer) SendMsg(arg0 interface{}) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SendMsg", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// SendMsg indicates an expected call of SendMsg
func (mr *MockBeaconChain_StreamChainHeadServerMockRecorder) SendMsg(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockBeaconChain_StreamChainHeadServer)(nil).SendMsg), arg0)
}
// SetHeader mocks base method
func (m *MockBeaconChain_StreamChainHeadServer) SetHeader(arg0 metadata.MD) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SetHeader", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// SetHeader indicates an expected call of SetHeader
func (mr *MockBeaconChain_StreamChainHeadServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockBeaconChain_StreamChainHeadServer)(nil).SetHeader), arg0)
}
// SetTrailer mocks base method
func (m *MockBeaconChain_StreamChainHeadServer) SetTrailer(arg0 metadata.MD) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetTrailer", arg0)
}
// SetTrailer indicates an expected call of SetTrailer
func (mr *MockBeaconChain_StreamChainHeadServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockBeaconChain_StreamChainHeadServer)(nil).SetTrailer), arg0)
}

View File

@@ -22,7 +22,7 @@ func finalizationOccurs(client eth.BeaconChainClient) error {
if err != nil {
return errors.Wrap(err, "failed to get chain head")
}
currentEpoch := chainHead.HeadBlockEpoch
currentEpoch := chainHead.HeadEpoch
finalizedEpoch := chainHead.FinalizedEpoch
expectedFinalizedEpoch := currentEpoch - 2

View File

@@ -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 0f490c1..592b169 100644
index c31fe0f..ee2e2ec 100644
--- a/eth/v1alpha1/beacon_chain.proto
+++ b/eth/v1alpha1/beacon_chain.proto
@@ -15,6 +15,7 @@ syntax = "proto3";
@@ -266,16 +266,29 @@ index 0f490c1..592b169 100644
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
@@ -261,7 +262,7 @@ message BeaconBlockContainer {
// Information about the head of the beacon chain.
message ChainHead {
// 32 byte merkle tree root of the canonical head block in the beacon node.
- bytes head_block_root = 1;
+ bytes head_block_root = 1 [(gogoproto.moretags) = "ssz-size:\"32\""];
@@ -76,9 +77,9 @@ service BeaconChain {
};
}
// Slot of the head block.
uint64 head_block_slot = 2;
@@ -276,7 +277,7 @@ message ChainHead {
- // Server-side stream of information about the head of the beacon chain
- // from the view of the beacon chain node.
- //
+ // Server-side stream of information about the head of the beacon chain
+ // from the view of the beacon chain node.
+ //
// 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 {
uint64 head_epoch = 2;
// 32 byte merkle tree root of the canonical head block in the beacon node.
- bytes head_block_root = 3;
+ bytes head_block_root = 3 [(gogoproto.moretags) = "ssz-size:\"32\""];
// Most recent slot that contains the finalized block.
uint64 finalized_slot = 4;
@@ -287,7 +288,7 @@ message ChainHead {
uint64 finalized_epoch = 5;
// Most recent 32 byte finalized block root.
@@ -283,8 +296,8 @@ index 0f490c1..592b169 100644
+ bytes finalized_block_root = 6 [(gogoproto.moretags) = "ssz-size:\"32\""];
// Most recent slot that contains the justified block.
uint64 justified_block_slot = 7;
@@ -285,7 +286,7 @@ message ChainHead {
uint64 justified_slot = 7;
@@ -296,7 +297,7 @@ message ChainHead {
uint64 justified_epoch = 8;
// Most recent 32 byte justified block root.
@@ -293,7 +306,7 @@ index 0f490c1..592b169 100644
// Most recent slot that contains the previous justified block.
uint64 previous_justified_slot = 10;
@@ -294,7 +295,7 @@ message ChainHead {
@@ -305,7 +306,7 @@ message ChainHead {
uint64 previous_justified_epoch = 11;
// Previous 32 byte justified block root.
@@ -302,7 +315,7 @@ index 0f490c1..592b169 100644
}
message ListCommitteesRequest {
@@ -352,7 +353,7 @@ message ListValidatorBalancesRequest {
@@ -363,7 +364,7 @@ message ListValidatorBalancesRequest {
// Validator 48 byte BLS public keys to filter validators for the given
// epoch.
@@ -311,7 +324,7 @@ index 0f490c1..592b169 100644
// Validator indices to filter validators for the given epoch.
repeated uint64 indices = 4;
@@ -373,7 +374,7 @@ message ValidatorBalances {
@@ -384,7 +385,7 @@ message ValidatorBalances {
message Balance {
// Validator's 48 byte BLS public key.
@@ -320,7 +333,7 @@ index 0f490c1..592b169 100644
// Validator's index in the validator set.
uint64 index = 2;
@@ -449,17 +450,17 @@ message ActiveSetChanges {
@@ -460,17 +461,17 @@ message ActiveSetChanges {
uint64 epoch = 1;
// 48 byte validator public keys that have been activated in this epoch.
@@ -342,7 +355,7 @@ index 0f490c1..592b169 100644
}
message ValidatorQueue {
@@ -469,11 +470,11 @@ message ValidatorQueue {
@@ -480,11 +481,11 @@ message ValidatorQueue {
// Ordered list of 48 byte public keys awaiting activation. 0th index is the
// next key to be processed.
@@ -356,7 +369,7 @@ index 0f490c1..592b169 100644
}
message ListValidatorAssignmentsRequest {
@@ -485,7 +486,7 @@ message ListValidatorAssignmentsRequest {
@@ -496,7 +497,7 @@ message ListValidatorAssignmentsRequest {
bool genesis = 2;
}
// 48 byte validator public keys to filter assignments for the given epoch.
@@ -365,7 +378,7 @@ index 0f490c1..592b169 100644
// Validator indicies to filter assignments for the given epoch.
repeated uint64 indices = 4;
@@ -520,7 +521,7 @@ message ValidatorAssignments {
@@ -531,7 +532,7 @@ message ValidatorAssignments {
uint64 proposer_slot = 4;
// 48 byte BLS public key.

View File

@@ -89,8 +89,8 @@ func compareHeads(clients map[string]pb.BeaconChainClient) {
log.Fatal(err)
}
log.Infof("Comparing all heads for head slot :%d", head1.HeadBlockSlot)
if (head1.HeadBlockSlot+1)%params.BeaconConfig().SlotsPerEpoch == 0 {
log.Infof("Comparing all heads for head slot :%d", head1.HeadSlot)
if (head1.HeadSlot+1)%params.BeaconConfig().SlotsPerEpoch == 0 {
p, err := clients[endpt1].GetValidatorParticipation(context.Background(), &pb.GetValidatorParticipationRequest{})
if err != nil {
log.Fatal(err)
@@ -108,10 +108,10 @@ func compareHeads(clients map[string]pb.BeaconChainClient) {
logHead(endpt1, head1)
logHead(endpt2, head2)
if (head1.HeadBlockSlot+1)%params.BeaconConfig().SlotsPerEpoch == 0 {
if (head1.HeadSlot+1)%params.BeaconConfig().SlotsPerEpoch == 0 {
p, err := clients[endpt2].GetValidatorParticipation(context.Background(), &pb.GetValidatorParticipationRequest{
QueryFilter: &pb.GetValidatorParticipationRequest_Epoch{
Epoch: head2.HeadBlockSlot / params.BeaconConfig().SlotsPerEpoch,
Epoch: head2.HeadSlot / params.BeaconConfig().SlotsPerEpoch,
},
})
if err != nil {
@@ -126,7 +126,7 @@ func compareHeads(clients map[string]pb.BeaconChainClient) {
func logHead(endpt string, head *pb.ChainHead) {
log.WithFields(
logrus.Fields{
"HeadSlot": head.HeadBlockSlot,
"HeadSlot": head.HeadSlot,
"HeadRoot": hex.EncodeToString(head.HeadBlockRoot),
"JustifiedEpoch": head.JustifiedEpoch,
"JustifiedRoot": hex.EncodeToString(head.JustifiedBlockRoot),