mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
Prevent Reorg Infinite Loops in Initial Sync (#2109)
* refactor initial sync to prevent reorg infinite loops * lint * fixed build * passing tests * tests passing * terence suggestion
This commit is contained in:
@@ -48,7 +48,6 @@ type Config struct {
|
||||
BeaconDB *db.BeaconDB
|
||||
P2P p2pAPI
|
||||
SyncService syncService
|
||||
ChainService chainService
|
||||
PowChain powChainService
|
||||
}
|
||||
|
||||
@@ -72,11 +71,6 @@ type p2pAPI interface {
|
||||
Subscribe(msg proto.Message, channel chan p2p.Message) event.Subscription
|
||||
}
|
||||
|
||||
type chainService interface {
|
||||
ReceiveBlock(ctx context.Context, block *pb.BeaconBlock) (*pb.BeaconState, error)
|
||||
ApplyForkChoiceRule(ctx context.Context, block *pb.BeaconBlock, computedState *pb.BeaconState) error
|
||||
}
|
||||
|
||||
type powChainService interface {
|
||||
BlockExists(ctx context.Context, hash common.Hash) (bool, *big.Int, error)
|
||||
}
|
||||
@@ -95,7 +89,6 @@ type InitialSync struct {
|
||||
cancel context.CancelFunc
|
||||
p2p p2pAPI
|
||||
syncService syncService
|
||||
chainService chainService
|
||||
db *db.BeaconDB
|
||||
powchain powChainService
|
||||
blockAnnounceBuf chan p2p.Message
|
||||
@@ -110,6 +103,7 @@ type InitialSync struct {
|
||||
syncedFeed *event.Feed
|
||||
reqState bool
|
||||
stateRootOfHighestObservedSlot [32]byte
|
||||
highestObservedCanonicalState *pb.BeaconState
|
||||
mutex *sync.Mutex
|
||||
}
|
||||
|
||||
@@ -130,7 +124,6 @@ func NewInitialSyncService(ctx context.Context,
|
||||
cancel: cancel,
|
||||
p2p: cfg.P2P,
|
||||
syncService: cfg.SyncService,
|
||||
chainService: cfg.ChainService,
|
||||
db: cfg.BeaconDB,
|
||||
powchain: cfg.PowChain,
|
||||
currentSlot: params.BeaconConfig().GenesisSlot,
|
||||
@@ -157,13 +150,6 @@ func (s *InitialSync) Start() {
|
||||
}
|
||||
s.currentSlot = cHead.Slot
|
||||
|
||||
var reqState bool
|
||||
// setting genesis bool
|
||||
if cHead.Slot == params.BeaconConfig().GenesisSlot || s.isSlotDiffLarge() {
|
||||
reqState = true
|
||||
}
|
||||
s.reqState = reqState
|
||||
|
||||
go func() {
|
||||
ticker := time.NewTicker(s.syncPollingInterval)
|
||||
s.run(ticker.C)
|
||||
@@ -198,7 +184,6 @@ func (s *InitialSync) SyncedFeed() *event.Feed {
|
||||
// delayChan is explicitly passed into this function to facilitate tests that don't require a timeout.
|
||||
// It is assumed that the goroutine `run` is only called once per instance.
|
||||
func (s *InitialSync) run(delayChan <-chan time.Time) {
|
||||
|
||||
blockSub := s.p2p.Subscribe(&pb.BeaconBlockResponse{}, s.blockBuf)
|
||||
batchedBlocksub := s.p2p.Subscribe(&pb.BatchedBeaconBlockResponse{}, s.batchedBlockBuf)
|
||||
blockAnnounceSub := s.p2p.Subscribe(&pb.BeaconBlockAnnounce{}, s.blockAnnounceBuf)
|
||||
@@ -213,14 +198,11 @@ func (s *InitialSync) run(delayChan <-chan time.Time) {
|
||||
close(s.stateBuf)
|
||||
}()
|
||||
|
||||
if s.reqState {
|
||||
if err := s.requestStateFromPeer(s.ctx, s.stateRootOfHighestObservedSlot[:], p2p.AnyPeer); err != nil {
|
||||
log.Errorf("Could not request state from peer %v", err)
|
||||
}
|
||||
} else {
|
||||
// Send out a batch request
|
||||
s.requestBatchedBlocks(s.currentSlot+1, s.highestObservedSlot)
|
||||
if err := s.requestStateFromPeer(s.ctx, s.stateRootOfHighestObservedSlot[:], p2p.AnyPeer); err != nil {
|
||||
log.Errorf("Could not request state from peer %v", err)
|
||||
}
|
||||
// Send out a batch request
|
||||
s.requestBatchedBlocks(s.currentSlot+1, s.highestObservedSlot)
|
||||
|
||||
for {
|
||||
select {
|
||||
@@ -337,7 +319,10 @@ func (s *InitialSync) processBlockAnnounce(msg p2p.Message) {
|
||||
}
|
||||
|
||||
s.requestBatchedBlocks(s.currentSlot+1, s.highestObservedSlot)
|
||||
log.Debugf("Successfully requested the next block with slot: %d", data.SlotNumber-params.BeaconConfig().GenesisSlot)
|
||||
log.Debugf(
|
||||
"Successfully requested the next block with slot: %d",
|
||||
data.SlotNumber-params.BeaconConfig().GenesisSlot,
|
||||
)
|
||||
}
|
||||
|
||||
// processBlock is the main method that validates each block which is received
|
||||
@@ -420,50 +405,42 @@ func (s *InitialSync) processState(msg p2p.Message) {
|
||||
ctx, span := trace.StartSpan(msg.Ctx, "beacon-chain.sync.initial-sync.processState")
|
||||
defer span.End()
|
||||
data := msg.Data.(*pb.BeaconStateResponse)
|
||||
beaconState := data.BeaconState
|
||||
finalizedState := data.FinalizedState
|
||||
justifiedState := data.JustifiedState
|
||||
canonicalState := data.CanonicalState
|
||||
recState.Inc()
|
||||
|
||||
if s.currentSlot > beaconState.FinalizedEpoch*params.BeaconConfig().SlotsPerEpoch {
|
||||
if s.currentSlot > finalizedState.Slot {
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.db.SaveCurrentAndFinalizedState(beaconState); err != nil {
|
||||
log.Errorf("Unable to set beacon state for initial sync %v", err)
|
||||
if err := s.db.SaveFinalizedState(finalizedState); err != nil {
|
||||
log.Errorf("Unable to set received last finalized state in db: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.db.SaveFinalizedBlock(beaconState.LatestBlock); err != nil {
|
||||
if err := s.db.SaveFinalizedBlock(finalizedState.LatestBlock); err != nil {
|
||||
log.Errorf("Could not save finalized block %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.db.SaveBlock(beaconState.LatestBlock); err != nil {
|
||||
log.Errorf("Could not save block %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.db.UpdateChainHead(beaconState.LatestBlock, beaconState); err != nil {
|
||||
log.Errorf("Could not update chainhead %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.db.SaveJustifiedState(beaconState); err != nil {
|
||||
if err := s.db.SaveJustifiedState(justifiedState); err != nil {
|
||||
log.Errorf("Could not set beacon state for initial sync %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.db.SaveJustifiedBlock(beaconState.LatestBlock); err != nil {
|
||||
if err := s.db.SaveJustifiedBlock(justifiedState.LatestBlock); err != nil {
|
||||
log.Errorf("Could not save finalized block %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
h, err := hashutil.HashProto(beaconState)
|
||||
h, err := hashutil.HashProto(canonicalState)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
exists, blkNum, err := s.powchain.BlockExists(ctx, bytesutil.ToBytes32(beaconState.LatestEth1Data.BlockHash32))
|
||||
exists, blkNum, err := s.powchain.BlockExists(ctx, bytesutil.ToBytes32(finalizedState.LatestEth1Data.BlockHash32))
|
||||
if err != nil {
|
||||
log.Errorf("Unable to get powchain block %v", err)
|
||||
}
|
||||
@@ -479,21 +456,34 @@ func (s *InitialSync) processState(msg p2p.Message) {
|
||||
s.reqState = false
|
||||
}
|
||||
|
||||
if err := s.db.SaveBlock(canonicalState.LatestBlock); err != nil {
|
||||
log.Errorf("Could not save block %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.db.UpdateChainHead(canonicalState.LatestBlock, canonicalState); err != nil {
|
||||
log.Errorf("Could not update chain head %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// sets the current slot to the last finalized slot of the
|
||||
// beacon state to begin our sync from.
|
||||
s.currentSlot = beaconState.FinalizedEpoch * params.BeaconConfig().SlotsPerEpoch
|
||||
s.beaconStateSlot = beaconState.Slot
|
||||
log.Debugf("Successfully saved beacon state with the last finalized slot: %d", beaconState.FinalizedEpoch*params.BeaconConfig().SlotsPerEpoch-params.BeaconConfig().GenesisSlot)
|
||||
lastFinalizedSlot := finalizedState.Slot
|
||||
s.currentSlot = lastFinalizedSlot
|
||||
s.highestObservedCanonicalState = canonicalState
|
||||
log.Debugf(
|
||||
"Successfully saved beacon state with the last finalized slot: %d",
|
||||
lastFinalizedSlot-params.BeaconConfig().GenesisSlot,
|
||||
)
|
||||
|
||||
s.requestBatchedBlocks(s.currentSlot+1, s.highestObservedSlot)
|
||||
}
|
||||
|
||||
// requestStateFromPeer always requests for the last finalized slot from a peer.
|
||||
// requestStateFromPeer always requests for the last finalized state from a peer.
|
||||
func (s *InitialSync) requestStateFromPeer(ctx context.Context, stateRoot []byte, peerID peer.ID) error {
|
||||
ctx, span := trace.StartSpan(ctx, "beacon-chain.sync.initial-sync.requestStateFromPeer")
|
||||
defer span.End()
|
||||
stateReq.Inc()
|
||||
log.Debugf("Successfully processed incoming block with state hash: %#x", stateRoot)
|
||||
return s.p2p.Send(ctx, &pb.BeaconStateRequest{FinalizedStateRootHash32S: stateRoot}, peerID)
|
||||
}
|
||||
|
||||
@@ -519,14 +509,20 @@ func (s *InitialSync) requestBatchedBlocks(startSlot uint64, endSlot uint64) {
|
||||
defer span.End()
|
||||
sentBatchedBlockReq.Inc()
|
||||
if startSlot > endSlot {
|
||||
log.Debugf("Invalid batched request from slot %d to %d", startSlot-params.BeaconConfig().GenesisSlot, endSlot-params.BeaconConfig().GenesisSlot)
|
||||
log.Debugf(
|
||||
"Invalid batched request from slot %d to %d",
|
||||
startSlot-params.BeaconConfig().GenesisSlot, endSlot-params.BeaconConfig().GenesisSlot,
|
||||
)
|
||||
return
|
||||
}
|
||||
blockLimit := params.BeaconConfig().BatchBlockLimit
|
||||
if startSlot+blockLimit < endSlot {
|
||||
endSlot = startSlot + blockLimit
|
||||
}
|
||||
log.Debugf("Requesting batched blocks from slot %d to %d", startSlot-params.BeaconConfig().GenesisSlot, endSlot-params.BeaconConfig().GenesisSlot)
|
||||
log.Debugf(
|
||||
"Requesting batched blocks from slot %d to %d",
|
||||
startSlot-params.BeaconConfig().GenesisSlot, endSlot-params.BeaconConfig().GenesisSlot,
|
||||
)
|
||||
s.p2p.Broadcast(ctx, &pb.BatchedBeaconBlockRequest{
|
||||
StartSlot: startSlot,
|
||||
EndSlot: endSlot,
|
||||
@@ -556,22 +552,7 @@ func (s *InitialSync) validateAndSaveNextBlock(ctx context.Context, block *pb.Be
|
||||
}
|
||||
// since the block will not be processed by chainservice we save
|
||||
// the block and do not send it to chainservice.
|
||||
if s.beaconStateSlot >= block.Slot {
|
||||
if err := s.db.SaveBlock(block); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Send block to main chain service to be processed.
|
||||
beaconState, err := s.chainService.ReceiveBlock(ctx, block)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not process beacon block: %v", err)
|
||||
}
|
||||
if err := s.chainService.ApplyForkChoiceRule(ctx, block, beaconState); err != nil {
|
||||
return fmt.Errorf("could not apply fork choice rule: %v", err)
|
||||
}
|
||||
return nil
|
||||
return s.db.SaveBlock(block)
|
||||
}
|
||||
|
||||
func (s *InitialSync) checkBlockValidity(ctx context.Context, block *pb.BeaconBlock) error {
|
||||
@@ -599,14 +580,6 @@ func (s *InitialSync) checkBlockValidity(ctx context.Context, block *pb.BeaconBl
|
||||
return nil
|
||||
}
|
||||
|
||||
// isSlotDiff large checks if the difference between the current slot and highest observed
|
||||
// slot isnt too large.
|
||||
func (s *InitialSync) isSlotDiffLarge() bool {
|
||||
slotsPerEpoch := params.BeaconConfig().SlotsPerEpoch
|
||||
epochLimit := params.BeaconConfig().SyncEpochLimit
|
||||
return s.currentSlot+slotsPerEpoch*epochLimit < s.highestObservedSlot
|
||||
}
|
||||
|
||||
func (s *InitialSync) doesParentExist(block *pb.BeaconBlock) bool {
|
||||
parentHash := bytesutil.ToBytes32(block.ParentRootHash32)
|
||||
return s.db.HasBlock(parentHash)
|
||||
|
||||
@@ -51,16 +51,6 @@ func (ms *mockSyncService) ResumeSync() {
|
||||
|
||||
}
|
||||
|
||||
type mockChainService struct{}
|
||||
|
||||
func (m *mockChainService) ReceiveBlock(ctx context.Context, block *pb.BeaconBlock) (*pb.BeaconState, error) {
|
||||
return &pb.BeaconState{}, nil
|
||||
}
|
||||
|
||||
func (m *mockChainService) ApplyForkChoiceRule(ctx context.Context, block *pb.BeaconBlock, computedState *pb.BeaconState) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func setUpGenesisStateAndBlock(beaconDB *db.BeaconDB, t *testing.T) {
|
||||
ctx := context.Background()
|
||||
genesisTime := time.Now()
|
||||
@@ -93,10 +83,9 @@ func TestSavingBlock_InSync(t *testing.T) {
|
||||
setUpGenesisStateAndBlock(db, t)
|
||||
|
||||
cfg := &Config{
|
||||
P2P: &mockP2P{},
|
||||
SyncService: &mockSyncService{},
|
||||
BeaconDB: db,
|
||||
ChainService: &mockChainService{},
|
||||
P2P: &mockP2P{},
|
||||
SyncService: &mockSyncService{},
|
||||
BeaconDB: db,
|
||||
}
|
||||
ss := NewInitialSyncService(context.Background(), cfg)
|
||||
ss.reqState = false
|
||||
@@ -117,12 +106,17 @@ func TestSavingBlock_InSync(t *testing.T) {
|
||||
genericHash := make([]byte, 32)
|
||||
genericHash[0] = 'a'
|
||||
|
||||
beaconState := &pb.BeaconState{
|
||||
fState := &pb.BeaconState{
|
||||
FinalizedEpoch: params.BeaconConfig().GenesisSlot + 1,
|
||||
}
|
||||
jState := &pb.BeaconState{
|
||||
JustifiedEpoch: params.BeaconConfig().GenesisSlot + 2,
|
||||
}
|
||||
|
||||
stateResponse := &pb.BeaconStateResponse{
|
||||
BeaconState: beaconState,
|
||||
FinalizedState: fState,
|
||||
JustifiedState: jState,
|
||||
CanonicalState: jState,
|
||||
}
|
||||
|
||||
incorrectState := &pb.BeaconState{
|
||||
@@ -131,10 +125,12 @@ func TestSavingBlock_InSync(t *testing.T) {
|
||||
}
|
||||
|
||||
incorrectStateResponse := &pb.BeaconStateResponse{
|
||||
BeaconState: incorrectState,
|
||||
FinalizedState: incorrectState,
|
||||
JustifiedState: incorrectState,
|
||||
CanonicalState: incorrectState,
|
||||
}
|
||||
|
||||
stateRoot, err := hashutil.HashProto(beaconState)
|
||||
stateRoot, err := hashutil.HashProto(fState)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to tree hash state: %v", err)
|
||||
}
|
||||
@@ -179,7 +175,7 @@ func TestSavingBlock_InSync(t *testing.T) {
|
||||
|
||||
ss.stateBuf <- msg2
|
||||
|
||||
if ss.currentSlot == incorrectStateResponse.BeaconState.FinalizedEpoch*params.BeaconConfig().SlotsPerEpoch {
|
||||
if ss.currentSlot == incorrectStateResponse.CanonicalState.FinalizedEpoch*params.BeaconConfig().SlotsPerEpoch {
|
||||
t.Fatalf("Beacon state updated incorrectly: %d", ss.currentSlot)
|
||||
}
|
||||
|
||||
@@ -190,7 +186,10 @@ func TestSavingBlock_InSync(t *testing.T) {
|
||||
msg1 = getBlockResponseMsg(params.BeaconConfig().GenesisSlot + 1)
|
||||
ss.blockBuf <- msg1
|
||||
if params.BeaconConfig().GenesisSlot+1 != ss.currentSlot {
|
||||
t.Fatalf("Slot saved when it was not supposed too: %v", stateResponse.BeaconState.FinalizedEpoch*params.BeaconConfig().SlotsPerEpoch)
|
||||
t.Fatalf(
|
||||
"Slot saved when it was not supposed too: %v",
|
||||
stateResponse.CanonicalState.FinalizedEpoch*params.BeaconConfig().SlotsPerEpoch,
|
||||
)
|
||||
}
|
||||
|
||||
msg1 = getBlockResponseMsg(params.BeaconConfig().GenesisSlot + 2)
|
||||
@@ -214,10 +213,9 @@ func TestProcessingBatchedBlocks_OK(t *testing.T) {
|
||||
setUpGenesisStateAndBlock(db, t)
|
||||
|
||||
cfg := &Config{
|
||||
P2P: &mockP2P{},
|
||||
SyncService: &mockSyncService{},
|
||||
BeaconDB: db,
|
||||
ChainService: &mockChainService{},
|
||||
P2P: &mockP2P{},
|
||||
SyncService: &mockSyncService{},
|
||||
BeaconDB: db,
|
||||
}
|
||||
ss := NewInitialSyncService(context.Background(), cfg)
|
||||
ss.reqState = false
|
||||
@@ -256,10 +254,9 @@ func TestProcessingBlocks_SkippedSlots(t *testing.T) {
|
||||
setUpGenesisStateAndBlock(db, t)
|
||||
|
||||
cfg := &Config{
|
||||
P2P: &mockP2P{},
|
||||
SyncService: &mockSyncService{},
|
||||
BeaconDB: db,
|
||||
ChainService: &mockChainService{},
|
||||
P2P: &mockP2P{},
|
||||
SyncService: &mockSyncService{},
|
||||
BeaconDB: db,
|
||||
}
|
||||
ss := NewInitialSyncService(context.Background(), cfg)
|
||||
ss.reqState = false
|
||||
@@ -317,10 +314,9 @@ func TestDelayChan_OK(t *testing.T) {
|
||||
setUpGenesisStateAndBlock(db, t)
|
||||
|
||||
cfg := &Config{
|
||||
P2P: &mockP2P{},
|
||||
SyncService: &mockSyncService{},
|
||||
BeaconDB: db,
|
||||
ChainService: &mockChainService{},
|
||||
P2P: &mockP2P{},
|
||||
SyncService: &mockSyncService{},
|
||||
BeaconDB: db,
|
||||
}
|
||||
ss := NewInitialSyncService(context.Background(), cfg)
|
||||
ss.reqState = false
|
||||
@@ -341,15 +337,20 @@ func TestDelayChan_OK(t *testing.T) {
|
||||
genericHash := make([]byte, 32)
|
||||
genericHash[0] = 'a'
|
||||
|
||||
beaconState := &pb.BeaconState{
|
||||
FinalizedEpoch: params.BeaconConfig().GenesisSlot + 1,
|
||||
fState := &pb.BeaconState{
|
||||
FinalizedEpoch: params.BeaconConfig().GenesisEpoch + 1,
|
||||
}
|
||||
jState := &pb.BeaconState{
|
||||
FinalizedEpoch: params.BeaconConfig().GenesisEpoch + 1,
|
||||
JustifiedEpoch: params.BeaconConfig().GenesisEpoch + 2,
|
||||
}
|
||||
|
||||
stateResponse := &pb.BeaconStateResponse{
|
||||
BeaconState: beaconState,
|
||||
FinalizedState: fState,
|
||||
JustifiedState: jState,
|
||||
}
|
||||
|
||||
stateRoot, err := hashutil.HashProto(beaconState)
|
||||
stateRoot, err := hashutil.HashProto(fState)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to tree hash state: %v", err)
|
||||
}
|
||||
@@ -409,7 +410,6 @@ func TestRequestBlocksBySlot_OK(t *testing.T) {
|
||||
cfg := &Config{
|
||||
P2P: &mockP2P{},
|
||||
SyncService: &mockSyncService{},
|
||||
ChainService: &mockChainService{},
|
||||
BeaconDB: db,
|
||||
BlockBufferSize: 100,
|
||||
}
|
||||
|
||||
@@ -120,7 +120,6 @@ func (q *Querier) Stop() error {
|
||||
}
|
||||
|
||||
func (q *Querier) listenForStateInitialization() {
|
||||
|
||||
sub := q.chainService.StateInitializedFeed().Subscribe(q.chainStartBuf)
|
||||
defer sub.Unsubscribe()
|
||||
for {
|
||||
@@ -140,9 +139,7 @@ func (q *Querier) listenForStateInitialization() {
|
||||
}
|
||||
|
||||
func (q *Querier) run() {
|
||||
|
||||
responseSub := q.p2p.Subscribe(&pb.ChainHeadResponse{}, q.responseBuf)
|
||||
|
||||
// Ticker so that service will keep on requesting for chain head
|
||||
// until they get a response.
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
@@ -183,7 +180,7 @@ func (q *Querier) RequestLatestHead() {
|
||||
q.p2p.Broadcast(context.Background(), request)
|
||||
}
|
||||
|
||||
// IsSynced checks if the node is cuurently synced with the
|
||||
// IsSynced checks if the node is currently synced with the
|
||||
// rest of the network.
|
||||
func (q *Querier) IsSynced() (bool, error) {
|
||||
if q.chainStarted && q.atGenesis {
|
||||
|
||||
@@ -340,9 +340,26 @@ func (rs *RegularSync) handleStateRequest(msg p2p.Message) error {
|
||||
log.Debugf("Requested state root is different from locally stored state root %#x", req.FinalizedStateRootHash32S)
|
||||
return err
|
||||
}
|
||||
log.WithField("beaconState", fmt.Sprintf("%#x", root)).Debug("Sending beacon state to peer")
|
||||
log.WithField(
|
||||
"beaconState", fmt.Sprintf("%#x", root),
|
||||
).Debug("Sending finalized, justified, and canonical states to peer")
|
||||
defer sentState.Inc()
|
||||
if err := rs.p2p.Send(ctx, &pb.BeaconStateResponse{BeaconState: fState}, msg.Peer); err != nil {
|
||||
jState, err := rs.db.JustifiedState()
|
||||
if err != nil {
|
||||
log.Errorf("Unable to retrieve justified state, %v", err)
|
||||
return err
|
||||
}
|
||||
canonicalState, err := rs.db.State(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("Unable to retrieve canonical beacon state, %v", err)
|
||||
return err
|
||||
}
|
||||
resp := &pb.BeaconStateResponse{
|
||||
FinalizedState: fState,
|
||||
JustifiedState: jState,
|
||||
CanonicalState: canonicalState,
|
||||
}
|
||||
if err := rs.p2p.Send(ctx, resp, msg.Peer); err != nil {
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -677,6 +677,12 @@ func TestHandleStateReq_OK(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("could not attempt fetch beacon state: %v", err)
|
||||
}
|
||||
if err := db.SaveJustifiedState(beaconState); err != nil {
|
||||
t.Fatalf("could not save justified state: %v", err)
|
||||
}
|
||||
if err := db.SaveFinalizedState(beaconState); err != nil {
|
||||
t.Fatalf("could not save justified state: %v", err)
|
||||
}
|
||||
stateRoot, err := hashutil.HashProto(beaconState)
|
||||
if err != nil {
|
||||
t.Fatalf("could not hash beacon state: %v", err)
|
||||
@@ -697,5 +703,5 @@ func TestHandleStateReq_OK(t *testing.T) {
|
||||
if err := ss.handleStateRequest(msg1); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
testutil.AssertLogsContain(t, hook, "Sending beacon state to peer")
|
||||
testutil.AssertLogsContain(t, hook, "Sending finalized, justified, and canonical states to peer")
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ func NewSyncService(ctx context.Context, cfg *Config) *Service {
|
||||
isCfg := initialsync.DefaultConfig()
|
||||
isCfg.BeaconDB = cfg.BeaconDB
|
||||
isCfg.P2P = cfg.P2P
|
||||
isCfg.ChainService = cfg.ChainService
|
||||
isCfg.PowChain = cfg.PowChainService
|
||||
|
||||
rsCfg := DefaultRegularSyncConfig()
|
||||
|
||||
@@ -88,11 +88,23 @@ func setupSimBackendAndDB(t *testing.T) (*backend.SimulatedBackend, *db.BeaconDB
|
||||
if err := beacondb.SaveState(bd.State()); err != nil {
|
||||
t.Fatalf("Could not save state %v", err)
|
||||
}
|
||||
if err := beacondb.SaveJustifiedState(bd.State()); err != nil {
|
||||
t.Fatalf("Could not save state %v", err)
|
||||
}
|
||||
if err := beacondb.SaveFinalizedState(bd.State()); err != nil {
|
||||
t.Fatalf("Could not save state %v", err)
|
||||
}
|
||||
|
||||
memBlocks := bd.InMemoryBlocks()
|
||||
if err := beacondb.SaveBlock(memBlocks[0]); err != nil {
|
||||
t.Fatalf("Could not save block %v", err)
|
||||
}
|
||||
if err := beacondb.SaveJustifiedBlock(memBlocks[0]); err != nil {
|
||||
t.Fatalf("Could not save block %v", err)
|
||||
}
|
||||
if err := beacondb.SaveFinalizedBlock(memBlocks[0]); err != nil {
|
||||
t.Fatalf("Could not save block %v", err)
|
||||
}
|
||||
|
||||
if err := beacondb.UpdateChainHead(memBlocks[0], bd.State()); err != nil {
|
||||
t.Fatalf("Could not update chain head %v", err)
|
||||
|
||||
272
proto/beacon/p2p/v1/messages.pb.go
generated
272
proto/beacon/p2p/v1/messages.pb.go
generated
@@ -644,7 +644,9 @@ func (m *BeaconStateRequest) GetFinalizedStateRootHash32S() []byte {
|
||||
}
|
||||
|
||||
type BeaconStateResponse struct {
|
||||
BeaconState *BeaconState `protobuf:"bytes,1,opt,name=beacon_state,json=beaconState,proto3" json:"beacon_state,omitempty"`
|
||||
FinalizedState *BeaconState `protobuf:"bytes,1,opt,name=finalized_state,json=finalizedState,proto3" json:"finalized_state,omitempty"`
|
||||
JustifiedState *BeaconState `protobuf:"bytes,2,opt,name=justified_state,json=justifiedState,proto3" json:"justified_state,omitempty"`
|
||||
CanonicalState *BeaconState `protobuf:"bytes,3,opt,name=canonical_state,json=canonicalState,proto3" json:"canonical_state,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
@@ -683,9 +685,23 @@ func (m *BeaconStateResponse) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_BeaconStateResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *BeaconStateResponse) GetBeaconState() *BeaconState {
|
||||
func (m *BeaconStateResponse) GetFinalizedState() *BeaconState {
|
||||
if m != nil {
|
||||
return m.BeaconState
|
||||
return m.FinalizedState
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BeaconStateResponse) GetJustifiedState() *BeaconState {
|
||||
if m != nil {
|
||||
return m.JustifiedState
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BeaconStateResponse) GetCanonicalState() *BeaconState {
|
||||
if m != nil {
|
||||
return m.CanonicalState
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1469,61 +1485,63 @@ func init() {
|
||||
func init() { proto.RegisterFile("proto/beacon/p2p/v1/messages.proto", fileDescriptor_a1d590cda035b632) }
|
||||
|
||||
var fileDescriptor_a1d590cda035b632 = []byte{
|
||||
// 863 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x51, 0x73, 0xdb, 0x44,
|
||||
0x10, 0xc7, 0x51, 0x93, 0xd4, 0xe9, 0xda, 0x09, 0xee, 0x05, 0x1a, 0x27, 0xd3, 0x3a, 0x89, 0x4a,
|
||||
0x87, 0xc0, 0x4c, 0x9d, 0x69, 0xfa, 0xd4, 0x27, 0x46, 0x72, 0x04, 0x6e, 0x1b, 0xe4, 0x22, 0xc9,
|
||||
0x30, 0x3c, 0x30, 0x87, 0x6c, 0x1f, 0xb5, 0x07, 0xe7, 0xee, 0xd0, 0x9d, 0x3d, 0x09, 0xc3, 0x2b,
|
||||
0x9f, 0x81, 0x4f, 0xc0, 0x77, 0xe1, 0x91, 0x8f, 0xc0, 0xe4, 0x93, 0x30, 0xba, 0x3b, 0x39, 0x8a,
|
||||
0xad, 0x28, 0x79, 0xe8, 0x9b, 0x6f, 0xf7, 0xbf, 0xff, 0xdd, 0xdf, 0x66, 0x35, 0x13, 0xb0, 0x79,
|
||||
0xc2, 0x24, 0x3b, 0xea, 0x93, 0x78, 0xc0, 0xe8, 0x11, 0x3f, 0xe6, 0x47, 0xb3, 0x17, 0x47, 0x67,
|
||||
0x44, 0x88, 0xf8, 0x3d, 0x11, 0x2d, 0x95, 0x44, 0x8f, 0x88, 0x1c, 0x91, 0x84, 0x4c, 0xcf, 0x5a,
|
||||
0x5a, 0xd6, 0xe2, 0xc7, 0xbc, 0x35, 0x7b, 0xb1, 0xbb, 0x57, 0x54, 0x2b, 0x2f, 0x78, 0x56, 0x68,
|
||||
0x7f, 0x03, 0xeb, 0x1e, 0x9d, 0x91, 0x09, 0xe3, 0x04, 0x1d, 0x40, 0x4d, 0xf0, 0x98, 0xe2, 0x01,
|
||||
0xa3, 0x92, 0x9c, 0xcb, 0x86, 0xb5, 0x6f, 0x1d, 0xd6, 0x82, 0x6a, 0x1a, 0x6b, 0xeb, 0x10, 0x6a,
|
||||
0x40, 0x85, 0xc7, 0x17, 0x13, 0x16, 0x0f, 0x1b, 0xf7, 0x54, 0x36, 0x7b, 0xda, 0x6f, 0x60, 0xcb,
|
||||
0x55, 0x5d, 0xdc, 0x09, 0x1b, 0xfc, 0xea, 0x50, 0xca, 0xa6, 0x74, 0x40, 0x10, 0x82, 0xd5, 0x51,
|
||||
0x2c, 0x46, 0xc6, 0x4b, 0xfd, 0x46, 0x7b, 0x50, 0x15, 0x13, 0x26, 0x31, 0x9d, 0x9e, 0xf5, 0x49,
|
||||
0xa2, 0x8c, 0x56, 0x03, 0x48, 0x43, 0xbe, 0x8a, 0xd8, 0x87, 0x80, 0x72, 0x5e, 0x01, 0xf9, 0x6d,
|
||||
0x4a, 0x84, 0x2c, 0xb2, 0xb2, 0x1d, 0x68, 0x2e, 0x2b, 0xdd, 0x8b, 0x70, 0xee, 0xb5, 0xd8, 0xcc,
|
||||
0x5a, 0x6a, 0xf6, 0x97, 0x75, 0x6d, 0xf2, 0x80, 0x08, 0xce, 0xa8, 0x20, 0xe8, 0x15, 0xac, 0xf5,
|
||||
0xd3, 0x80, 0x2a, 0xa9, 0x1e, 0x3f, 0x6d, 0x15, 0xaf, 0xb8, 0x95, 0xaf, 0xd5, 0x15, 0xc8, 0x83,
|
||||
0x6a, 0x2c, 0x25, 0x11, 0x32, 0x96, 0x63, 0x46, 0x15, 0x60, 0x89, 0x81, 0x73, 0x25, 0x0d, 0xf2,
|
||||
0x75, 0x76, 0x0f, 0x76, 0xdc, 0x58, 0x0e, 0x46, 0x64, 0x58, 0xb0, 0x8d, 0x27, 0x00, 0x42, 0xc6,
|
||||
0x89, 0xc4, 0x29, 0x8a, 0xc1, 0x7a, 0xa0, 0x22, 0x29, 0x3c, 0xda, 0x81, 0x75, 0x42, 0x87, 0x3a,
|
||||
0xa9, 0x17, 0x5c, 0x21, 0x74, 0x98, 0xa6, 0xec, 0x11, 0xec, 0x16, 0xd9, 0x1a, 0xec, 0x37, 0xb0,
|
||||
0xd9, 0xd7, 0x59, 0xac, 0x60, 0x44, 0xc3, 0xda, 0x5f, 0xb9, 0x2b, 0xff, 0x86, 0x29, 0x55, 0x2f,
|
||||
0x61, 0x23, 0xa8, 0xb7, 0x47, 0xf1, 0x98, 0x76, 0x48, 0x3c, 0x34, 0x73, 0xdb, 0x7f, 0xc0, 0xc3,
|
||||
0x5c, 0xcc, 0x34, 0x2d, 0xba, 0x12, 0x04, 0xab, 0xb9, 0xe9, 0xd5, 0x6f, 0xf4, 0x15, 0x3c, 0xfe,
|
||||
0x65, 0x4c, 0xe3, 0xc9, 0xf8, 0x77, 0x32, 0xc4, 0xe9, 0x9a, 0x08, 0x4e, 0x18, 0x93, 0x38, 0x2d,
|
||||
0x78, 0x79, 0x2c, 0x1a, 0x2b, 0xaa, 0x7e, 0x67, 0xae, 0x09, 0x53, 0x49, 0xc0, 0x98, 0xec, 0x68,
|
||||
0x81, 0xfd, 0x1c, 0xb6, 0xf5, 0xbc, 0x2a, 0x93, 0x46, 0xcb, 0x2e, 0xd5, 0xee, 0x65, 0x87, 0xa8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c, 0x20, 0xc7, 0xac, 0xf3, 0x99, 0x25,
|
||||
0xe4, 0x50, 0xb2, 0x8c, 0x31, 0xad, 0xa6, 0x45, 0x4e, 0x14, 0x79, 0x69, 0xfc, 0x75, 0xd7, 0xbf,
|
||||
0xb2, 0xab, 0xa5, 0x73, 0xe4, 0x33, 0x99, 0xdb, 0xc6, 0x62, 0xc9, 0xdc, 0x6c, 0xd3, 0xad, 0xfd,
|
||||
0x73, 0xd9, 0xb4, 0xfe, 0xbd, 0x6c, 0x5a, 0xff, 0x5d, 0x36, 0xad, 0xfe, 0x7d, 0xf5, 0xdf, 0xd8,
|
||||
0xcb, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x7c, 0xb5, 0x2a, 0x92, 0xec, 0x09, 0x00, 0x00,
|
||||
// 893 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xdf, 0x72, 0xdb, 0x44,
|
||||
0x14, 0xc6, 0x51, 0x9c, 0xd4, 0xe9, 0xb1, 0xe3, 0xba, 0x1b, 0x68, 0x9c, 0x4c, 0xeb, 0x24, 0x2a,
|
||||
0x1d, 0x02, 0x33, 0x75, 0xa6, 0xe9, 0x55, 0xaf, 0x18, 0xc9, 0xd1, 0xe0, 0xb6, 0x41, 0x2e, 0x92,
|
||||
0x0d, 0xc3, 0xd5, 0xb2, 0xb6, 0xb7, 0xb5, 0xc0, 0xd9, 0x15, 0xde, 0xb5, 0x27, 0x61, 0xb8, 0xe5,
|
||||
0x19, 0x78, 0x02, 0xde, 0x85, 0x4b, 0x1e, 0x81, 0xc9, 0x8b, 0xc0, 0x68, 0xb5, 0x52, 0xe4, 0x3f,
|
||||
0x51, 0x9c, 0x99, 0xde, 0x49, 0xe7, 0x7c, 0xdf, 0xef, 0x9c, 0x6f, 0xb3, 0xca, 0x18, 0xcc, 0x70,
|
||||
0xcc, 0x25, 0x3f, 0xee, 0x51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0x41, 0x59, 0x4a, 0x27, 0x4f, 0x1b, 0xcb, 0x8f, 0xb8, 0x91, 0xf5, 0xc6, 0x0e, 0xe4, 0x40,
|
||||
0x89, 0x48, 0x49, 0x85, 0x24, 0x32, 0xe0, 0x4c, 0x05, 0xcc, 0x01, 0x58, 0xd7, 0x52, 0x2f, 0xeb,
|
||||
0x33, 0xbb, 0xb0, 0x6b, 0x13, 0xd9, 0x1f, 0xd2, 0xc1, 0x92, 0xd3, 0x78, 0x02, 0x20, 0x24, 0x19,
|
||||
0x4b, 0x1c, 0x45, 0xd1, 0xb1, 0xee, 0xab, 0x4a, 0x14, 0x1e, 0xed, 0xc2, 0x26, 0x65, 0x83, 0xb8,
|
||||
0x19, 0x1f, 0x70, 0x91, 0xb2, 0x41, 0xd4, 0x32, 0x87, 0xb0, 0xb7, 0x0c, 0xab, 0x63, 0xbf, 0x81,
|
||||
0x4a, 0x2f, 0xee, 0x62, 0x15, 0x46, 0xd4, 0x8c, 0x83, 0xc2, 0xaa, 0xf9, 0xb7, 0xb4, 0x55, 0xbd,
|
||||
0x09, 0x13, 0x41, 0xb5, 0x39, 0x24, 0x01, 0x6b, 0x51, 0x32, 0xd0, 0x7b, 0x9b, 0xbf, 0xc3, 0xc3,
|
||||
0x4c, 0x4d, 0x0f, 0x5d, 0x76, 0x4b, 0x10, 0xac, 0x67, 0xb6, 0x57, 0xcf, 0xe8, 0x6b, 0x78, 0xfc,
|
||||
0x3e, 0x60, 0x64, 0x14, 0xfc, 0x46, 0x07, 0x38, 0x3a, 0x26, 0x8a, 0xc7, 0x9c, 0x4b, 0x1c, 0x19,
|
||||
0x5e, 0x9e, 0x88, 0x5a, 0x41, 0xf9, 0x77, 0x53, 0x8d, 0x1f, 0x49, 0x3c, 0xce, 0x65, 0x2b, 0x16,
|
||||
0x98, 0xcf, 0x61, 0x27, 0xde, 0x57, 0x75, 0xa2, 0x6a, 0xde, 0x4d, 0x35, 0xbb, 0xc9, 0x45, 0x8c,
|
||||
0x41,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x8b, 0x5b, 0x8e, 0x75, 0x9a,
|
||||
0x5a, 0x8b, 0x68, 0x07, 0xb6, 0x67, 0xea, 0xda, 0xb0, 0x89, 0xea, 0xb0, 0xa7, 0x59, 0x7e, 0xc7,
|
||||
0xea, 0x38, 0xb8, 0x65, 0xf9, 0xad, 0xeb, 0xcc, 0xf7, 0x33, 0x99, 0xe3, 0x7e, 0x82, 0x84, 0x4c,
|
||||
0x94, 0xa4, 0xa3, 0xa1, 0xa5, 0xc8, 0x64, 0x75, 0x3a, 0x4e, 0x54, 0x7f, 0xdd, 0x76, 0xaf, 0x71,
|
||||
0xe5, 0x68, 0x8f, 0x6c, 0x27, 0xa1, 0x6d, 0xcd, 0x5b, 0x52, 0x58, 0xc5, 0x2e, 0xff, 0x7d, 0x55,
|
||||
0x37, 0xfe, 0xb9, 0xaa, 0x1b, 0xff, 0x5e, 0xd5, 0x8d, 0xde, 0x3d, 0xf5, 0x83, 0xf1, 0xe5, 0xff,
|
||||
0x01, 0x00, 0x00, 0xff, 0xff, 0x1d, 0x87, 0xb8, 0xa8, 0x8f, 0x0a, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Envelope) Marshal() (dAtA []byte, err error) {
|
||||
@@ -1877,16 +1895,36 @@ func (m *BeaconStateResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.BeaconState != nil {
|
||||
if m.FinalizedState != nil {
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
i = encodeVarintMessages(dAtA, i, uint64(m.BeaconState.Size()))
|
||||
n3, err := m.BeaconState.MarshalTo(dAtA[i:])
|
||||
i = encodeVarintMessages(dAtA, i, uint64(m.FinalizedState.Size()))
|
||||
n3, err := m.FinalizedState.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n3
|
||||
}
|
||||
if m.JustifiedState != nil {
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintMessages(dAtA, i, uint64(m.JustifiedState.Size()))
|
||||
n4, err := m.JustifiedState.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n4
|
||||
}
|
||||
if m.CanonicalState != nil {
|
||||
dAtA[i] = 0x1a
|
||||
i++
|
||||
i = encodeVarintMessages(dAtA, i, uint64(m.CanonicalState.Size()))
|
||||
n5, err := m.CanonicalState.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n5
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
i += copy(dAtA[i:], m.XXX_unrecognized)
|
||||
}
|
||||
@@ -1972,11 +2010,11 @@ func (m *AttestationResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintMessages(dAtA, i, uint64(m.Attestation.Size()))
|
||||
n4, err := m.Attestation.MarshalTo(dAtA[i:])
|
||||
n6, err := m.Attestation.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n4
|
||||
i += n6
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
i += copy(dAtA[i:], m.XXX_unrecognized)
|
||||
@@ -2063,11 +2101,11 @@ func (m *ProposerSlashingResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintMessages(dAtA, i, uint64(m.ProposerSlashing.Size()))
|
||||
n5, err := m.ProposerSlashing.MarshalTo(dAtA[i:])
|
||||
n7, err := m.ProposerSlashing.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n5
|
||||
i += n7
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
i += copy(dAtA[i:], m.XXX_unrecognized)
|
||||
@@ -2154,11 +2192,11 @@ func (m *AttesterSlashingResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintMessages(dAtA, i, uint64(m.AttesterSlashing.Size()))
|
||||
n6, err := m.AttesterSlashing.MarshalTo(dAtA[i:])
|
||||
n8, err := m.AttesterSlashing.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n6
|
||||
i += n8
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
i += copy(dAtA[i:], m.XXX_unrecognized)
|
||||
@@ -2245,11 +2283,11 @@ func (m *DepositResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintMessages(dAtA, i, uint64(m.Deposit.Size()))
|
||||
n7, err := m.Deposit.MarshalTo(dAtA[i:])
|
||||
n9, err := m.Deposit.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n7
|
||||
i += n9
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
i += copy(dAtA[i:], m.XXX_unrecognized)
|
||||
@@ -2336,11 +2374,11 @@ func (m *ExitResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintMessages(dAtA, i, uint64(m.VoluntaryExit.Size()))
|
||||
n8, err := m.VoluntaryExit.MarshalTo(dAtA[i:])
|
||||
n10, err := m.VoluntaryExit.MarshalTo(dAtA[i:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i += n8
|
||||
i += n10
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
i += copy(dAtA[i:], m.XXX_unrecognized)
|
||||
@@ -2556,8 +2594,16 @@ func (m *BeaconStateResponse) Size() (n int) {
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.BeaconState != nil {
|
||||
l = m.BeaconState.Size()
|
||||
if m.FinalizedState != nil {
|
||||
l = m.FinalizedState.Size()
|
||||
n += 1 + l + sovMessages(uint64(l))
|
||||
}
|
||||
if m.JustifiedState != nil {
|
||||
l = m.JustifiedState.Size()
|
||||
n += 1 + l + sovMessages(uint64(l))
|
||||
}
|
||||
if m.CanonicalState != nil {
|
||||
l = m.CanonicalState.Size()
|
||||
n += 1 + l + sovMessages(uint64(l))
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
@@ -3937,7 +3983,7 @@ func (m *BeaconStateResponse) Unmarshal(dAtA []byte) error {
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field BeaconState", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field FinalizedState", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
@@ -3964,10 +4010,82 @@ func (m *BeaconStateResponse) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.BeaconState == nil {
|
||||
m.BeaconState = &BeaconState{}
|
||||
if m.FinalizedState == nil {
|
||||
m.FinalizedState = &BeaconState{}
|
||||
}
|
||||
if err := m.BeaconState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
if err := m.FinalizedState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field JustifiedState", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowMessages
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthMessages
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthMessages
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.JustifiedState == nil {
|
||||
m.JustifiedState = &BeaconState{}
|
||||
}
|
||||
if err := m.JustifiedState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field CanonicalState", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowMessages
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthMessages
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthMessages
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.CanonicalState == nil {
|
||||
m.CanonicalState = &BeaconState{}
|
||||
}
|
||||
if err := m.CanonicalState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
|
||||
@@ -71,7 +71,9 @@ message BeaconStateRequest {
|
||||
}
|
||||
|
||||
message BeaconStateResponse {
|
||||
BeaconState beacon_state = 1;
|
||||
BeaconState finalized_state = 1;
|
||||
BeaconState justified_state = 2;
|
||||
BeaconState canonical_state = 3;
|
||||
}
|
||||
|
||||
message AttestationAnnounce {
|
||||
|
||||
Reference in New Issue
Block a user