diff --git a/beacon-chain/blockchain/core.go b/beacon-chain/blockchain/core.go index ffba4e048a02..815632e11bd5 100644 --- a/beacon-chain/blockchain/core.go +++ b/beacon-chain/blockchain/core.go @@ -32,10 +32,20 @@ type BeaconChain struct { } type beaconState struct { - ActiveState *types.ActiveState + // ActiveState captures the beacon state at block processing level, + // it focuses on verifying aggregated signatures and pending attestations. + ActiveState *types.ActiveState + // CrystallizedState captures the beacon state at epoch transition level, + // it focuses on changes to the validator set, processing cross links and + // setting up FFG checkpoints. CrystallizedState *types.CrystallizedState } +type beaconCommittee struct { + shardID int + committee []int +} + // NewBeaconChain initializes a beacon chain using genesis state parameters if // none provided. func NewBeaconChain(db ethdb.Database) (*BeaconChain, error) { @@ -168,17 +178,14 @@ func (b *BeaconChain) PersistCrystallizedState() error { return b.db.Put([]byte(crystallizedStateLookupKey), encodedState) } -// IsEpochTransition checks if the current slotNumber divided -// by the epoch length (64 slots) is greater than the current epoch. +// IsEpochTransition checks if it's epoch transition time. func (b *BeaconChain) IsEpochTransition(slotNumber uint64) bool { - currentEpoch := b.state.CrystallizedState.CurrentEpoch() - isTransition := (slotNumber / params.EpochLength) > currentEpoch - return isTransition + return slotNumber >= b.CrystallizedState().LastStateRecalc()+params.CycleLength } // CanProcessBlock decides if an incoming p2p block can be processed into the chain's block trie. func (b *BeaconChain) CanProcessBlock(fetcher types.POWBlockFetcher, block *types.Block) (bool, error) { - if _, err := fetcher.BlockByHash(context.Background(), block.MainChainRef()); err != nil { + if _, err := fetcher.BlockByHash(context.Background(), block.PowChainRef()); err != nil { return false, fmt.Errorf("fetching PoW block corresponding to mainchain reference failed: %v", err) } @@ -249,99 +256,106 @@ func (b *BeaconChain) computeNewActiveState(seed common.Hash) (*types.ActiveStat // TODO: Verify randao reveal from validator's hash pre image. return types.NewActiveState(&pb.ActiveState{ - TotalAttesterDeposits: 0, - AttesterBitfield: []byte{}, + PendingAttestations: []*pb.AttestationRecord{}, + RecentBlockHashes: [][]byte{}, }), nil } -// rotateValidatorSet is called every dynasty transition. It's primary function is -// to go through queued validators and induct them to be active, and remove bad -// active validator whose balance is below threshold to the exit set. It also cross checks -// every validator's switch dynasty before induct or remove. -func (b *BeaconChain) rotateValidatorSet() ([]*pb.ValidatorRecord, []*pb.ValidatorRecord, []*pb.ValidatorRecord) { - - var newExitedValidators = b.CrystallizedState().ExitedValidators() - var newActiveValidators []*pb.ValidatorRecord - upperbound := b.CrystallizedState().ActiveValidatorsLength()/30 + 1 - exitCount := 0 - - // Loop through active validator set, remove validator whose balance is below 50% and switch dynasty > current dynasty. - for _, validator := range b.CrystallizedState().ActiveValidators() { - if validator.Balance < params.DefaultBalance/2 { - newExitedValidators = append(newExitedValidators, validator) - } else if validator.SwitchDynasty == b.CrystallizedState().CurrentDynasty()+1 && exitCount < upperbound { - newExitedValidators = append(newExitedValidators, validator) - exitCount++ - } else { - newActiveValidators = append(newActiveValidators, validator) +// rotateValidatorSet is called every dynasty transition. The primary functions are: +// 1.) Go through queued validator indices and induct them to be active by setting start +// dynasty to current epoch. +// 2.) Remove bad active validator whose balance is below threshold to the exit set by +// setting end dynasty to current epoch. +func (b *BeaconChain) rotateValidatorSet() { + + validators := b.CrystallizedState().Validators() + upperbound := len(b.activeValidatorIndices())/30 + 1 + + // Loop through active validator set, remove validator whose balance is below 50%. + for _, index := range b.activeValidatorIndices() { + if validators[index].Balance < params.DefaultBalance/2 { + validators[index].EndDynasty = b.CrystallizedState().CurrentDynasty() } } // Get the total number of validator we can induct. inductNum := upperbound - if b.CrystallizedState().QueuedValidatorsLength() < inductNum { - inductNum = b.CrystallizedState().QueuedValidatorsLength() + if len(b.queuedValidatorIndices()) < inductNum { + inductNum = len(b.queuedValidatorIndices()) } // Induct queued validator to active validator set until the switch dynasty is greater than current number. - for i := 0; i < inductNum; i++ { - if b.CrystallizedState().QueuedValidators()[i].SwitchDynasty > b.CrystallizedState().CurrentDynasty()+1 { - inductNum = i + for _, index := range b.queuedValidatorIndices() { + validators[index].StartDynasty = b.CrystallizedState().CurrentDynasty() + inductNum-- + if inductNum == 0 { break } - newActiveValidators = append(newActiveValidators, b.CrystallizedState().QueuedValidators()[i]) } - newQueuedValidators := b.CrystallizedState().QueuedValidators()[inductNum:] - - return newQueuedValidators, newActiveValidators, newExitedValidators } // getAttestersProposer returns lists of random sampled attesters and proposer indices. func (b *BeaconChain) getAttestersProposer(seed common.Hash) ([]int, int, error) { - attesterCount := math.Min(params.AttesterCount, float64(b.CrystallizedState().ActiveValidatorsLength())) + attesterCount := math.Min(params.MinCommiteeSize, float64(b.CrystallizedState().ValidatorsLength())) - indices, err := utils.ShuffleIndices(seed, b.CrystallizedState().ActiveValidatorsLength()) + indices, err := utils.ShuffleIndices(seed, b.activeValidatorIndices()) if err != nil { return nil, -1, err } return indices[:int(attesterCount)], indices[len(indices)-1], nil } +// getAttestersTotalDeposit returns the total deposit combined by attesters. +// TODO: Consider slashing condition. +func (b *BeaconChain) getAttestersTotalDeposit() (uint64, error) { + var numOfBits int + for _, attestation := range b.ActiveState().PendingAttestations() { + for _, byte := range attestation.AttesterBitfield { + numOfBits += int(utils.BitSetCount(byte)) + } + } + // Assume there's no slashing condition, the following logic will change later phase. + return uint64(numOfBits) * params.DefaultBalance, nil +} + // calculateRewardsFFG adjusts validators balances by applying rewards or penalties // based on FFG incentive structure. -func (b *BeaconChain) calculateRewardsFFG() error { +func (b *BeaconChain) calculateRewardsFFG(block *types.Block) error { b.lock.Lock() defer b.lock.Unlock() - activeValidators := b.state.CrystallizedState.ActiveValidators() - attesterDeposits := b.state.ActiveState.TotalAttesterDeposits() + validators := b.CrystallizedState().Validators() + activeValidators := b.activeValidatorIndices() + attesterDeposits, err := b.getAttestersTotalDeposit() + if err != nil { + return err + } totalDeposit := b.state.CrystallizedState.TotalDeposits() attesterFactor := attesterDeposits * 3 totalFactor := uint64(totalDeposit * 2) - + println(attesterFactor) + println(totalFactor) if attesterFactor >= totalFactor { - log.Info("Setting justified epoch to current epoch: %v", b.CrystallizedState().CurrentEpoch()) - b.state.CrystallizedState.UpdateJustifiedEpoch() + log.Info("Setting justified epoch to current slot number: %v", block.SlotNumber()) + b.state.CrystallizedState.UpdateJustifiedSlot(block.SlotNumber()) log.Info("Applying rewards and penalties for the validators from last epoch") - for i := range activeValidators { - voted, err := b.hasAttesterAtIndexVoted(i) + + for i, attesterIndex := range activeValidators { + voted, err := utils.CheckBit(b.state.ActiveState.LatestPendingAttestation().AttesterBitfield, attesterIndex) if err != nil { return fmt.Errorf("exiting calculate rewards FFG due to %v", err) } if voted { - activeValidators[i].Balance += params.AttesterReward + validators[i].Balance += params.AttesterReward } else { - activeValidators[i].Balance -= params.AttesterReward + validators[i].Balance -= params.AttesterReward } } log.Info("Resetting attester bit field to all zeros") - b.resetAttesterBitfield() - - log.Info("Resetting total attester deposit to zero") - b.ActiveState().SetTotalAttesterDeposits(0) + b.ActiveState().ClearPendingAttestations() - b.CrystallizedState().SetActiveValidators(activeValidators) + b.CrystallizedState().SetValidators(validators) err := b.PersistActiveState() if err != nil { return err @@ -354,33 +368,88 @@ func (b *BeaconChain) calculateRewardsFFG() error { return nil } -// hasAttesterAtIndexVoted checks if the attester at the passed index has voted by comparing its bit field. -func (b *BeaconChain) hasAttesterAtIndexVoted(index int) (bool, error) { - bitfield := b.state.ActiveState.AttesterBitfield() - attesterBlock := (index + 1) / 8 - attesterFieldIndex := (index + 1) % 8 - if attesterFieldIndex == 0 { - attesterFieldIndex = 8 - } else { - attesterBlock++ +// activeValidatorIndices filters out active validators based on start and end dynasty +// and returns their indices in a list. +func (b *BeaconChain) activeValidatorIndices() []int { + var indices []int + validators := b.CrystallizedState().Validators() + dynasty := b.CrystallizedState().CurrentDynasty() + for i := 0; i < len(validators); i++ { + if validators[i].StartDynasty <= dynasty && dynasty < validators[i].EndDynasty { + indices = append(indices, i) + } } + return indices +} - if len(bitfield) < attesterBlock { - return false, errors.New("attester index does not exist") +// exitedValidatorIndices filters out exited validators based on start and end dynasty +// and returns their indices in a list. +func (b *BeaconChain) exitedValidatorIndices() []int { + var indices []int + validators := b.CrystallizedState().Validators() + dynasty := b.CrystallizedState().CurrentDynasty() + for i := 0; i < len(validators); i++ { + if validators[i].StartDynasty < dynasty && validators[i].EndDynasty < dynasty { + indices = append(indices, i) + } } + return indices +} - field := bitfield[attesterBlock-1] >> (8 - uint(attesterFieldIndex)) - if field%2 != 0 { - return true, nil +// queuedValidatorIndices filters out queued validators based on start and end dynasty +// and returns their indices in a list. +func (b *BeaconChain) queuedValidatorIndices() []int { + var indices []int + validators := b.CrystallizedState().Validators() + dynasty := b.CrystallizedState().CurrentDynasty() + for i := 0; i < len(validators); i++ { + if validators[i].StartDynasty > dynasty { + indices = append(indices, i) + } } - - return false, nil + return indices } -// resetAttesterBitfield resets the attester bit field of active state to zeros. -func (b *BeaconChain) resetAttesterBitfield() { - newbitfields := make([]byte, b.CrystallizedState().ActiveValidatorsLength()/8) - b.state.ActiveState.SetAttesterBitfield(newbitfields) +// validatorsByHeightShard splits a shuffled validator list by height and by shard, +// it ensures there's enough validators per height and per shard, if not, it'll skip +// some heights and shards. +func (b *BeaconChain) validatorsByHeightShard() ([]*beaconCommittee, error) { + indices := b.activeValidatorIndices() + var committeesPerSlot int + var slotsPerCommittee int + var committees []*beaconCommittee + + if len(indices) >= params.CycleLength*params.MinCommiteeSize { + committeesPerSlot = len(indices)/params.CycleLength/(params.MinCommiteeSize*2) + 1 + slotsPerCommittee = 1 + } else { + committeesPerSlot = 1 + slotsPerCommittee = 1 + for len(indices)*slotsPerCommittee < params.MinCommiteeSize && slotsPerCommittee < params.CycleLength { + slotsPerCommittee *= 2 + } + } + + // split the shuffled list for heights. + shuffledList, err := utils.ShuffleIndices(b.state.CrystallizedState.DynastySeed(), indices) + if err != nil { + return nil, err + } + + heightList := utils.SplitIndices(shuffledList, params.CycleLength) + + // split the shuffled height list for shards + for i, subList := range heightList { + shardList := utils.SplitIndices(subList, params.MinCommiteeSize) + for _, shardIndex := range shardList { + shardID := int(b.CrystallizedState().CrosslinkingStartShard()) + i*committeesPerSlot/slotsPerCommittee + committees = append(committees, &beaconCommittee{ + shardID: shardID, + committee: shardIndex, + }) + } + } + return committees, nil } // saveBlock puts the passed block into the beacon chain db. @@ -396,6 +465,3 @@ func (b *BeaconChain) saveBlock(block *types.Block) error { return b.db.Put(hash[:], encodedState) } - -// Slashing Condtions -// TODO: Implement all the conditions and add in the methods once the spec is updated diff --git a/beacon-chain/blockchain/core_test.go b/beacon-chain/blockchain/core_test.go index 8f8e848f005d..9bbbad123be5 100644 --- a/beacon-chain/blockchain/core_test.go +++ b/beacon-chain/blockchain/core_test.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "errors" + "math" "reflect" "testing" "time" @@ -120,8 +121,12 @@ func TestSetActiveState(t *testing.T) { defer db.Close() data := &pb.ActiveState{ - TotalAttesterDeposits: 4096, - AttesterBitfield: []byte{'A', 'B', 'C'}, + PendingAttestations: []*pb.AttestationRecord{ + {Slot: 0, ShardBlockHash: []byte{1}}, {Slot: 1, ShardBlockHash: []byte{2}}, + }, + RecentBlockHashes: [][]byte{ + {'A'}, {'B'}, {'C'}, {'D'}, + }, } active := types.NewActiveState(data) @@ -138,12 +143,14 @@ func TestSetActiveState(t *testing.T) { t.Fatalf("unable to setup second beacon chain: %v", err) } - // The active state should still be the one we mutated and persited earlier. - if active.TotalAttesterDeposits() != newBeaconChain.state.ActiveState.TotalAttesterDeposits() { - t.Errorf("active state height incorrect. wanted %v, got %v", active.TotalAttesterDeposits(), newBeaconChain.state.ActiveState.TotalAttesterDeposits()) + // The active state should still be the one we mutated and persited earlier + for i, hash := range active.RecentBlockHashes() { + if hash.Hex() != newBeaconChain.ActiveState().RecentBlockHashes()[i].Hex() { + t.Errorf("active state block hash. wanted %v, got %v", hash.Hex(), newBeaconChain.ActiveState().RecentBlockHashes()[i].Hex()) + } } - if !bytes.Equal(active.AttesterBitfield(), newBeaconChain.state.ActiveState.AttesterBitfield()) { - t.Errorf("active state randao incorrect. wanted %v, got %v", active.AttesterBitfield(), newBeaconChain.state.ActiveState.AttesterBitfield()) + if reflect.DeepEqual(active.PendingAttestations(), newBeaconChain.state.ActiveState.RecentBlockHashes()) { + t.Errorf("active state pending attestation incorrect. wanted %v, got %v", active.PendingAttestations(), newBeaconChain.state.ActiveState.RecentBlockHashes()) } } @@ -152,8 +159,8 @@ func TestSetCrystallizedState(t *testing.T) { defer db.Close() data := &pb.CrystallizedState{ - CurrentDynasty: 3, - CurrentCheckPoint: []byte("checkpoint"), + CurrentDynasty: 3, + DynastySeed: []byte{'A'}, } crystallized := types.NewCrystallizedState(data) @@ -174,8 +181,8 @@ func TestSetCrystallizedState(t *testing.T) { if crystallized.CurrentDynasty() != newBeaconChain.state.CrystallizedState.CurrentDynasty() { t.Errorf("crystallized state dynasty incorrect. wanted %v, got %v", crystallized.CurrentDynasty(), newBeaconChain.state.CrystallizedState.CurrentDynasty()) } - if crystallized.CurrentCheckPoint().Hex() != newBeaconChain.state.CrystallizedState.CurrentCheckPoint().Hex() { - t.Errorf("crystallized state current checkpoint incorrect. wanted %v, got %v", crystallized.CurrentCheckPoint().Hex(), newBeaconChain.state.CrystallizedState.CurrentCheckPoint().Hex()) + if crystallized.DynastySeed() != newBeaconChain.state.CrystallizedState.DynastySeed() { + t.Errorf("crystallized state current checkpoint incorrect. wanted %v, got %v", crystallized.DynastySeed(), newBeaconChain.state.CrystallizedState.DynastySeed()) } } @@ -186,12 +193,13 @@ func TestGetAttestersProposer(t *testing.T) { var validators []*pb.ValidatorRecord // Create 1000 validators in ActiveValidators. for i := 0; i < 1000; i++ { - validator := &pb.ValidatorRecord{WithdrawalAddress: []byte{'A'}, PublicKey: 0} + validator := &pb.ValidatorRecord{StartDynasty: 1, EndDynasty: 100} validators = append(validators, validator) } _, crystallized := types.NewGenesisStates() - crystallized.SetActiveValidators(validators) + crystallized.SetValidators(validators) + crystallized.IncrementCurrentDynasty() beaconChain.SetCrystallizedState(crystallized) attesters, proposer, err := beaconChain.getAttestersProposer(common.Hash{'A'}) @@ -199,7 +207,9 @@ func TestGetAttestersProposer(t *testing.T) { t.Errorf("GetAttestersProposer function failed: %v", err) } - validatorList, err := utils.ShuffleIndices(common.Hash{'A'}, len(validators)) + activeValidators := beaconChain.activeValidatorIndices() + + validatorList, err := utils.ShuffleIndices(common.Hash{'A'}, activeValidators) if err != nil { t.Errorf("Shuffle function function failed: %v", err) } @@ -239,14 +249,14 @@ func TestCanProcessBlock(t *testing.T) { } // Initialize initial state - activeState := types.NewActiveState(&pb.ActiveState{TotalAttesterDeposits: 10000}) + activeState := types.NewActiveState(&pb.ActiveState{RecentBlockHashes: [][]byte{{'A'}}}) beaconChain.state.ActiveState = activeState activeHash, err := activeState.Hash() if err != nil { t.Fatalf("Cannot hash active state: %v", err) } - crystallized := types.NewCrystallizedState(&pb.CrystallizedState{CurrentEpoch: 5}) + crystallized := types.NewCrystallizedState(&pb.CrystallizedState{}) beaconChain.state.CrystallizedState = crystallized crystallizedHash, err := crystallized.Hash() if err != nil { @@ -300,12 +310,13 @@ func TestProcessBlockWithBadHashes(t *testing.T) { } // Initialize state - active := types.NewActiveState(&pb.ActiveState{TotalAttesterDeposits: 10000}) + active := types.NewActiveState(&pb.ActiveState{RecentBlockHashes: [][]byte{{'A'}}}) activeStateHash, err := active.Hash() if err != nil { t.Fatalf("Cannot hash active state: %v", err) } - crystallized := types.NewCrystallizedState(&pb.CrystallizedState{CurrentEpoch: 10000}) + + crystallized := types.NewCrystallizedState(&pb.CrystallizedState{LastStateRecalc: 10000}) crystallizedStateHash, err := crystallized.Hash() if err != nil { t.Fatalf("Cannot hash crystallized state: %v", err) @@ -319,7 +330,7 @@ func TestProcessBlockWithBadHashes(t *testing.T) { }) // Test negative scenario where active state hash is different than node's compute - beaconChain.state.ActiveState = types.NewActiveState(&pb.ActiveState{TotalAttesterDeposits: 9999}) + beaconChain.state.ActiveState = types.NewActiveState(&pb.ActiveState{RecentBlockHashes: [][]byte{{'B'}}}) canProcess, err := beaconChain.CanProcessBlock(&mockFetcher{}, block) if err == nil { @@ -330,7 +341,7 @@ func TestProcessBlockWithBadHashes(t *testing.T) { } // Test negative scenario where crystallized state hash is different than node's compute - beaconChain.state.CrystallizedState = types.NewCrystallizedState(&pb.CrystallizedState{CurrentEpoch: 9999}) + beaconChain.state.CrystallizedState = types.NewCrystallizedState(&pb.CrystallizedState{LastStateRecalc: 9999}) canProcess, err = beaconChain.CanProcessBlock(&mockFetcher{}, block) if err == nil { @@ -346,14 +357,14 @@ func TestProcessBlockWithInvalidParent(t *testing.T) { defer db.Close() // If parent hash is non-existent, processing block should fail. - active := types.NewActiveState(&pb.ActiveState{TotalAttesterDeposits: 10000}) + active := types.NewActiveState(&pb.ActiveState{RecentBlockHashes: [][]byte{{'A'}}}) activeStateHash, err := active.Hash() if err != nil { t.Fatalf("Cannot hash active state: %v", err) } beaconChain.state.ActiveState = active - crystallized := types.NewCrystallizedState(&pb.CrystallizedState{CurrentEpoch: 10000}) + crystallized := types.NewCrystallizedState(&pb.CrystallizedState{LastStateRecalc: 10000}) crystallizedStateHash, err := crystallized.Hash() if err != nil { t.Fatalf("Cannot hash crystallized state: %v", err) @@ -418,69 +429,48 @@ func TestRotateValidatorSet(t *testing.T) { beaconChain, db := startInMemoryBeaconChain(t) defer db.Close() - activeValidators := []*pb.ValidatorRecord{ - {Balance: 10000, WithdrawalAddress: []byte{'A'}}, - {Balance: 15000, WithdrawalAddress: []byte{'B'}}, - {Balance: 20000, WithdrawalAddress: []byte{'C'}}, - {Balance: 25000, WithdrawalAddress: []byte{'D'}}, - {Balance: 30000, WithdrawalAddress: []byte{'E'}}, - } - - queuedValidators := []*pb.ValidatorRecord{ - {Balance: params.DefaultBalance, WithdrawalAddress: []byte{'F'}}, - {Balance: params.DefaultBalance, WithdrawalAddress: []byte{'G'}}, - {Balance: params.DefaultBalance, WithdrawalAddress: []byte{'H'}}, - {Balance: params.DefaultBalance, WithdrawalAddress: []byte{'I'}}, - {Balance: params.DefaultBalance, WithdrawalAddress: []byte{'J'}}, + validators := []*pb.ValidatorRecord{ + {Balance: 10, StartDynasty: 0, EndDynasty: params.DefaultEndDynasty}, // half below default balance, should be moved to exit + {Balance: 15, StartDynasty: 1, EndDynasty: params.DefaultEndDynasty}, // half below default balance, should be moved to exit + {Balance: 20, StartDynasty: 2, EndDynasty: params.DefaultEndDynasty}, // stays in active + {Balance: 25, StartDynasty: 3, EndDynasty: params.DefaultEndDynasty}, // stays in active + {Balance: 30, StartDynasty: 4, EndDynasty: params.DefaultEndDynasty}, // stays in active } - exitedValidators := []*pb.ValidatorRecord{ - {Balance: 99999, WithdrawalAddress: []byte{'K'}}, - {Balance: 99999, WithdrawalAddress: []byte{'L'}}, - {Balance: 99999, WithdrawalAddress: []byte{'M'}}, - {Balance: 99999, WithdrawalAddress: []byte{'N'}}, - {Balance: 99999, WithdrawalAddress: []byte{'O'}}, - } - - beaconChain.CrystallizedState().SetActiveValidators(activeValidators) - beaconChain.CrystallizedState().SetQueuedValidators(queuedValidators) - beaconChain.CrystallizedState().SetExitedValidators(exitedValidators) - - if beaconChain.CrystallizedState().ActiveValidatorsLength() != 5 { - t.Errorf("Get active validator count failed, wanted 5, got %v", beaconChain.CrystallizedState().ActiveValidatorsLength()) - } - if beaconChain.CrystallizedState().QueuedValidatorsLength() != 5 { - t.Errorf("Get queued validator count failed, wanted 5, got %v", beaconChain.CrystallizedState().QueuedValidatorsLength()) - } - if beaconChain.CrystallizedState().ExitedValidatorsLength() != 5 { - t.Errorf("Get exited validator count failed, wanted 5, got %v", beaconChain.CrystallizedState().ExitedValidatorsLength()) + data := &pb.CrystallizedState{ + Validators: validators, + CurrentDynasty: 10, } + state := types.NewCrystallizedState(data) + beaconChain.SetCrystallizedState(state) - newQueuedValidators, newActiveValidators, newExitedValidators := beaconChain.rotateValidatorSet() + // rotate validator set and increment dynasty count by 1 + beaconChain.rotateValidatorSet() + beaconChain.CrystallizedState().IncrementCurrentDynasty() - if len(newActiveValidators) != 4 { - t.Errorf("Get active validator count failed, wanted 5, got %v", len(newActiveValidators)) + if !reflect.DeepEqual(beaconChain.activeValidatorIndices(), []int{2, 3, 4}) { + t.Errorf("active validator indices should be [2,3,4], got: %v", beaconChain.activeValidatorIndices()) } - if len(newQueuedValidators) != 4 { - t.Errorf("Get queued validator count failed, wanted 4, got %v", len(newQueuedValidators)) + if len(beaconChain.queuedValidatorIndices()) != 0 { + t.Errorf("queued validator indices should be [], got: %v", beaconChain.queuedValidatorIndices()) } - if len(newExitedValidators) != 7 { - t.Errorf("Get exited validator count failed, wanted 6, got %v", len(newExitedValidators)) + if !reflect.DeepEqual(beaconChain.exitedValidatorIndices(), []int{0, 1}) { + t.Errorf("exited validator indices should be [0,1], got: %v", beaconChain.exitedValidatorIndices()) } } -func TestIsEpochTransition(t *testing.T) { +func TestIsSlotTransition(t *testing.T) { beaconChain, db := startInMemoryBeaconChain(t) defer db.Close() - if err := beaconChain.SetCrystallizedState(types.NewCrystallizedState(&pb.CrystallizedState{CurrentEpoch: 1})); err != nil { + if err := beaconChain.SetCrystallizedState(types.NewCrystallizedState(&pb.CrystallizedState{LastStateRecalc: params.CycleLength})); err != nil { t.Fatalf("unable to mutate crystallizedstate: %v", err) } if !beaconChain.IsEpochTransition(128) { - t.Errorf("there was supposed to be an epoch transition but there isn't one now") + t.Errorf("there was supposed to be an Slot transition but there isn't one now") } if beaconChain.IsEpochTransition(80) { - t.Errorf("there is not supposed to be an epoch transition but there is one now") + t.Errorf("there is not supposed to be an Slot transition but there is one now") } } @@ -489,10 +479,13 @@ func TestHasVoted(t *testing.T) { defer db.Close() // Setting bit field to 11111111 - beaconChain.ActiveState().SetAttesterBitfield([]byte{255}) + pendingAttestation := &pb.AttestationRecord{ + AttesterBitfield: []byte{255}, + } + beaconChain.ActiveState().NewPendingAttestation(pendingAttestation) - for i := 0; i < len(beaconChain.ActiveState().AttesterBitfield()); i++ { - voted, err := beaconChain.hasAttesterAtIndexVoted(i) + for i := 0; i < len(beaconChain.ActiveState().LatestPendingAttestation().AttesterBitfield); i++ { + voted, err := utils.CheckBit(beaconChain.ActiveState().LatestPendingAttestation().AttesterBitfield, i) if err != nil { t.Errorf("checking bitfield for vote failed: %v", err) } @@ -502,10 +495,13 @@ func TestHasVoted(t *testing.T) { } // Setting bit field to 01010101 - beaconChain.ActiveState().SetAttesterBitfield([]byte{85}) + pendingAttestation = &pb.AttestationRecord{ + AttesterBitfield: []byte{85}, + } + beaconChain.ActiveState().NewPendingAttestation(pendingAttestation) - for i := 0; i < len(beaconChain.ActiveState().AttesterBitfield()); i++ { - voted, err := beaconChain.hasAttesterAtIndexVoted(i) + for i := 0; i < len(beaconChain.ActiveState().LatestPendingAttestation().AttesterBitfield); i++ { + voted, err := utils.CheckBit(beaconChain.ActiveState().LatestPendingAttestation().AttesterBitfield, i) if err != nil { t.Errorf("checking bitfield for vote failed: %v", err) } @@ -518,7 +514,7 @@ func TestHasVoted(t *testing.T) { } } -func TestResetAttesterBitfields(t *testing.T) { +func TestClearAttesterBitfields(t *testing.T) { beaconChain, db := startInMemoryBeaconChain(t) defer db.Close() @@ -531,82 +527,73 @@ func TestResetAttesterBitfields(t *testing.T) { validators = append(validators, validator) } - beaconChain.CrystallizedState().SetActiveValidators(validators) - - testAttesterBitfield := []byte{2, 4, 6, 9} - if err := beaconChain.SetActiveState(types.NewActiveState(&pb.ActiveState{AttesterBitfield: testAttesterBitfield})); err != nil { - t.Fatal("unable to mutate active state") - } - - beaconChain.resetAttesterBitfield() + testAttesterBitfield := []byte{1, 2, 3, 4} + beaconChain.CrystallizedState().SetValidators(validators) + beaconChain.ActiveState().NewPendingAttestation(&pb.AttestationRecord{AttesterBitfield: testAttesterBitfield}) + beaconChain.ActiveState().ClearPendingAttestations() - if bytes.Equal(testAttesterBitfield, beaconChain.state.ActiveState.AttesterBitfield()) { + if bytes.Equal(testAttesterBitfield, beaconChain.state.ActiveState.LatestPendingAttestation().AttesterBitfield) { t.Fatalf("attester bitfields have not been able to be reset: %v", testAttesterBitfield) } - bitfieldLength := j / 8 - - if !bytes.Equal(beaconChain.state.ActiveState.AttesterBitfield(), make([]byte, bitfieldLength)) { - t.Fatalf("attester bitfields are not zeroed out: %v", beaconChain.state.ActiveState.AttesterBitfield()) + if !bytes.Equal(beaconChain.state.ActiveState.LatestPendingAttestation().AttesterBitfield, []byte{}) { + t.Fatalf("attester bitfields are not zeroed out: %v", beaconChain.state.ActiveState.LatestPendingAttestation().AttesterBitfield) } } } -func TestResetTotalAttesterDeposit(t *testing.T) { +func TestClearRecentBlockHashes(t *testing.T) { beaconChain, db := startInMemoryBeaconChain(t) defer db.Close() - active := types.NewActiveState(&pb.ActiveState{TotalAttesterDeposits: 10000}) + active := types.NewActiveState(&pb.ActiveState{RecentBlockHashes: [][]byte{{'A'}, {'B'}, {'C'}}}) if err := beaconChain.SetActiveState(active); err != nil { t.Fatalf("unable to Mutate Active state: %v", err) } - if beaconChain.state.ActiveState.TotalAttesterDeposits() != uint64(10000) { - t.Fatalf("attester deposit was not saved: %d", beaconChain.state.ActiveState.TotalAttesterDeposits()) + if reflect.DeepEqual(beaconChain.state.ActiveState.RecentBlockHashes(), [][]byte{{'A'}, {'B'}, {'C'}}) { + t.Fatalf("recent block hash was not saved: %d", beaconChain.state.ActiveState.RecentBlockHashes()) } - beaconChain.ActiveState().SetTotalAttesterDeposits(0) - if beaconChain.state.ActiveState.TotalAttesterDeposits() != uint64(0) { - t.Fatalf("attester deposit was not able to be reset: %d", beaconChain.state.ActiveState.TotalAttesterDeposits()) + beaconChain.ActiveState().ClearRecentBlockHashes() + if reflect.DeepEqual(beaconChain.state.ActiveState.RecentBlockHashes(), [][]byte{}) { + t.Fatalf("attester deposit was not able to be reset: %d", beaconChain.state.ActiveState.RecentBlockHashes()) } } -func TestUpdateJustifiedEpoch(t *testing.T) { +func TestUpdateJustifiedSlot(t *testing.T) { beaconChain, db := startInMemoryBeaconChain(t) defer db.Close() - data := &pb.CrystallizedState{CurrentEpoch: 5, LastJustifiedEpoch: 4, LastFinalizedEpoch: 3} + data := &pb.CrystallizedState{LastStateRecalc: 5 * params.CycleLength, LastJustifiedSlot: 4, LastFinalizedSlot: 3} beaconChain.SetCrystallizedState(types.NewCrystallizedState(data)) - - if beaconChain.state.CrystallizedState.LastFinalizedEpoch() != uint64(3) || - beaconChain.state.CrystallizedState.LastJustifiedEpoch() != uint64(4) || - beaconChain.state.CrystallizedState.CurrentEpoch() != uint64(5) { + if beaconChain.state.CrystallizedState.LastFinalizedSlot() != uint64(3) || + beaconChain.state.CrystallizedState.LastJustifiedSlot() != uint64(4) { t.Fatal("crystallized state unable to be saved") } - beaconChain.state.CrystallizedState.UpdateJustifiedEpoch() + beaconChain.state.CrystallizedState.UpdateJustifiedSlot(5) - if beaconChain.state.CrystallizedState.LastJustifiedEpoch() != uint64(5) { - t.Fatalf("unable to update last justified epoch: %d", beaconChain.state.CrystallizedState.LastJustifiedEpoch()) + if beaconChain.state.CrystallizedState.LastJustifiedSlot() != uint64(5) { + t.Fatalf("unable to update last justified Slot: %d", beaconChain.state.CrystallizedState.LastJustifiedSlot()) } - if beaconChain.state.CrystallizedState.LastFinalizedEpoch() != uint64(4) { - t.Fatalf("unable to update last finalized epoch: %d", beaconChain.state.CrystallizedState.LastFinalizedEpoch()) + if beaconChain.state.CrystallizedState.LastFinalizedSlot() != uint64(4) { + t.Fatalf("unable to update last finalized Slot: %d", beaconChain.state.CrystallizedState.LastFinalizedSlot()) } - data = &pb.CrystallizedState{CurrentEpoch: 8, LastJustifiedEpoch: 4, LastFinalizedEpoch: 3} + data = &pb.CrystallizedState{LastStateRecalc: 8 * params.CycleLength, LastJustifiedSlot: 4, LastFinalizedSlot: 3} beaconChain.SetCrystallizedState(types.NewCrystallizedState(data)) - if beaconChain.state.CrystallizedState.LastFinalizedEpoch() != uint64(3) || - beaconChain.state.CrystallizedState.LastJustifiedEpoch() != uint64(4) || - beaconChain.state.CrystallizedState.CurrentEpoch() != uint64(8) { + if beaconChain.state.CrystallizedState.LastFinalizedSlot() != uint64(3) || + beaconChain.state.CrystallizedState.LastJustifiedSlot() != uint64(4) { t.Fatal("crystallized state unable to be saved") } - beaconChain.state.CrystallizedState.UpdateJustifiedEpoch() + beaconChain.state.CrystallizedState.UpdateJustifiedSlot(8) - if beaconChain.state.CrystallizedState.LastJustifiedEpoch() != uint64(8) { - t.Fatalf("unable to update last justified epoch: %d", beaconChain.state.CrystallizedState.LastJustifiedEpoch()) + if beaconChain.state.CrystallizedState.LastJustifiedSlot() != uint64(8) { + t.Fatalf("unable to update last justified Slot: %d", beaconChain.state.CrystallizedState.LastJustifiedSlot()) } - if beaconChain.state.CrystallizedState.LastFinalizedEpoch() != uint64(3) { - t.Fatalf("unable to update last finalized epoch: %d", beaconChain.state.CrystallizedState.LastFinalizedEpoch()) + if beaconChain.state.CrystallizedState.LastFinalizedSlot() != uint64(3) { + t.Fatalf("unable to update last finalized Slot: %d", beaconChain.state.CrystallizedState.LastFinalizedSlot()) } } @@ -616,17 +603,20 @@ func TestComputeValidatorRewardsAndPenalties(t *testing.T) { var validators []*pb.ValidatorRecord for i := 0; i < 40; i++ { - validator := &pb.ValidatorRecord{Balance: 1000, WithdrawalAddress: []byte{'A'}, PublicKey: 0} + validator := &pb.ValidatorRecord{Balance: 32, StartDynasty: 1, EndDynasty: 10} validators = append(validators, validator) } + block := NewBlock(t, &pb.BeaconBlock{ + SlotNumber: 5, + }) + data := &pb.CrystallizedState{ - ActiveValidators: validators, - CurrentCheckPoint: []byte("checkpoint"), - TotalDeposits: 40000, - CurrentEpoch: 5, - LastJustifiedEpoch: 4, - LastFinalizedEpoch: 3, + Validators: validators, + CurrentDynasty: 1, + TotalDeposits: 100, + LastJustifiedSlot: 4, + LastFinalizedSlot: 3, } if err := beaconChain.SetCrystallizedState(types.NewCrystallizedState(data)); err != nil { t.Fatalf("unable to mutate crystallizedstate: %v", err) @@ -634,34 +624,86 @@ func TestComputeValidatorRewardsAndPenalties(t *testing.T) { //Binary representation of bitfield: 11001000 10010100 10010010 10110011 00110001 testAttesterBitfield := []byte{200, 148, 146, 179, 49} - types.NewActiveState(&pb.ActiveState{AttesterBitfield: testAttesterBitfield}) - ActiveState := types.NewActiveState(&pb.ActiveState{TotalAttesterDeposits: 40000, AttesterBitfield: testAttesterBitfield}) - if err := beaconChain.SetActiveState(ActiveState); err != nil { + state := types.NewActiveState(&pb.ActiveState{PendingAttestations: []*pb.AttestationRecord{{AttesterBitfield: testAttesterBitfield}}}) + if err := beaconChain.SetActiveState(state); err != nil { t.Fatalf("unable to Mutate Active state: %v", err) } - if err := beaconChain.calculateRewardsFFG(); err != nil { + if err := beaconChain.calculateRewardsFFG(block); err != nil { t.Fatalf("could not compute validator rewards and penalties: %v", err) } - if beaconChain.state.CrystallizedState.LastJustifiedEpoch() != uint64(5) { - t.Fatalf("unable to update last justified epoch: %d", beaconChain.state.CrystallizedState.LastJustifiedEpoch()) + if beaconChain.state.CrystallizedState.LastJustifiedSlot() != uint64(5) { + t.Fatalf("unable to update last justified Slot: %d", beaconChain.state.CrystallizedState.LastJustifiedSlot()) + } + if beaconChain.state.CrystallizedState.LastFinalizedSlot() != uint64(4) { + t.Fatalf("unable to update last finalized Slot: %d", beaconChain.state.CrystallizedState.LastFinalizedSlot()) } - if beaconChain.state.CrystallizedState.LastFinalizedEpoch() != uint64(4) { - t.Fatalf("unable to update last finalized epoch: %d", beaconChain.state.CrystallizedState.LastFinalizedEpoch()) + if beaconChain.CrystallizedState().Validators()[0].Balance != uint64(33) { + t.Fatalf("validator balance not updated: %d", beaconChain.CrystallizedState().Validators()[1].Balance) } - if beaconChain.CrystallizedState().ActiveValidators()[0].Balance != uint64(1001) { - t.Fatalf("validator balance not updated: %d", beaconChain.CrystallizedState().ActiveValidators()[1].Balance) + if beaconChain.CrystallizedState().Validators()[7].Balance != uint64(31) { + t.Fatalf("validator balance not updated: %d", beaconChain.CrystallizedState().Validators()[1].Balance) } - if beaconChain.CrystallizedState().ActiveValidators()[7].Balance != uint64(999) { - t.Fatalf("validator balance not updated: %d", beaconChain.CrystallizedState().ActiveValidators()[1].Balance) + if beaconChain.CrystallizedState().Validators()[29].Balance != uint64(31) { + t.Fatalf("validator balance not updated: %d", beaconChain.CrystallizedState().Validators()[1].Balance) } - if beaconChain.CrystallizedState().ActiveValidators()[29].Balance != uint64(999) { - t.Fatalf("validator balance not updated: %d", beaconChain.CrystallizedState().ActiveValidators()[1].Balance) +} + +func TestValidatorIndices(t *testing.T) { + beaconChain, db := startInMemoryBeaconChain(t) + defer db.Close() + + data := &pb.CrystallizedState{ + Validators: []*pb.ValidatorRecord{ + {PublicKey: 0, StartDynasty: 0, EndDynasty: 2}, // active + {PublicKey: 0, StartDynasty: 0, EndDynasty: 2}, // active + {PublicKey: 0, StartDynasty: 1, EndDynasty: 2}, // active + {PublicKey: 0, StartDynasty: 0, EndDynasty: 2}, // active + {PublicKey: 0, StartDynasty: 0, EndDynasty: 3}, // active + {PublicKey: 0, StartDynasty: 2, EndDynasty: uint64(math.Inf(0))}, // queued + }, + CurrentDynasty: 1, + } + + crystallized := types.NewCrystallizedState(data) + if err := beaconChain.SetCrystallizedState(crystallized); err != nil { + t.Fatalf("unable to mutate crystallized state: %v", err) + } + + if !reflect.DeepEqual(beaconChain.activeValidatorIndices(), []int{0, 1, 2, 3, 4}) { + t.Errorf("active validator indices should be [0 1 2 3 4], got: %v", beaconChain.activeValidatorIndices()) + } + if !reflect.DeepEqual(beaconChain.queuedValidatorIndices(), []int{5}) { + t.Errorf("queued validator indices should be [5], got: %v", beaconChain.queuedValidatorIndices()) + } + if len(beaconChain.exitedValidatorIndices()) != 0 { + t.Errorf("exited validator indices to be empty, got: %v", beaconChain.exitedValidatorIndices()) + } + + data = &pb.CrystallizedState{ + Validators: []*pb.ValidatorRecord{ + {PublicKey: 0, StartDynasty: 1, EndDynasty: uint64(math.Inf(0))}, // active + {PublicKey: 0, StartDynasty: 2, EndDynasty: uint64(math.Inf(0))}, // active + {PublicKey: 0, StartDynasty: 6, EndDynasty: uint64(math.Inf(0))}, // queued + {PublicKey: 0, StartDynasty: 7, EndDynasty: uint64(math.Inf(0))}, // queued + {PublicKey: 0, StartDynasty: 1, EndDynasty: 2}, // exited + {PublicKey: 0, StartDynasty: 1, EndDynasty: 3}, // exited + }, + CurrentDynasty: 5, + } + + crystallized = types.NewCrystallizedState(data) + if err := beaconChain.SetCrystallizedState(crystallized); err != nil { + t.Fatalf("unable to mutate crystallized state: %v", err) + } + + if !reflect.DeepEqual(beaconChain.activeValidatorIndices(), []int{0, 1}) { + t.Errorf("active validator indices should be [0 1 2 4 5], got: %v", beaconChain.activeValidatorIndices()) } - if beaconChain.state.ActiveState.TotalAttesterDeposits() != uint64(0) { - t.Fatalf("attester deposit was not able to be reset: %d", beaconChain.state.ActiveState.TotalAttesterDeposits()) + if !reflect.DeepEqual(beaconChain.queuedValidatorIndices(), []int{2, 3}) { + t.Errorf("queued validator indices should be [3], got: %v", beaconChain.queuedValidatorIndices()) } - if !bytes.Equal(beaconChain.state.ActiveState.AttesterBitfield(), make([]byte, 5)) { - t.Fatalf("attester bitfields are not zeroed out: %v", beaconChain.state.ActiveState.AttesterBitfield()) + if !reflect.DeepEqual(beaconChain.exitedValidatorIndices(), []int{4, 5}) { + t.Errorf("exited validator indices should be [3], got: %v", beaconChain.exitedValidatorIndices()) } } diff --git a/beacon-chain/blockchain/service.go b/beacon-chain/blockchain/service.go index d4f897fd5c15..fbb535abcb3a 100644 --- a/beacon-chain/blockchain/service.go +++ b/beacon-chain/blockchain/service.go @@ -163,23 +163,23 @@ func (c *ChainService) ProcessActiveState(state *types.ActiveState) error { } // ContainsBlock checks if a block for the hash exists in the chain. -// This method must be safe to call from a goroutine +// This method must be safe to call from a goroutine. // -// TODO: implement function +// TODO: implement function. func (c *ChainService) ContainsBlock(h [32]byte) bool { return false } // ContainsCrystallizedState checks if a crystallized state for the hash exists in the chain. // -// TODO: implement function +// TODO: implement function. func (c *ChainService) ContainsCrystallizedState(h [32]byte) bool { return false } // ContainsActiveState checks if a active state for the hash exists in the chain. // -// TODO: implement function +// TODO: implement function. func (c *ChainService) ContainsActiveState(h [32]byte) bool { return false } @@ -200,7 +200,7 @@ func (c *ChainService) run(done <-chan struct{}) { for { select { case block := <-c.latestBeaconBlock: - // TODO: Using latest block hash for seed, this will eventually be replaced by randao + // TODO: Using latest block hash for seed, this will eventually be replaced by randao. activeState, err := c.chain.computeNewActiveState(c.web3Service.LatestBlockHash()) if err != nil { log.Errorf("Compute active state failed: %v", err) @@ -211,11 +211,17 @@ func (c *ChainService) run(done <-chan struct{}) { log.Errorf("Write active state to disk failed: %v", err) } - currentSlot := block.SlotNumber() + // TODO: Apply 2.1 fork choice logic using the following. + validatorsByHeight, err := c.chain.validatorsByHeightShard() + if err != nil { + log.Errorf("Unable to get validators by height and by shard: %v", err) + } + log.Debugf("Received the following validators by height: %v", validatorsByHeight) - transition := c.chain.IsEpochTransition(currentSlot) + // Entering epoch transitions. + transition := c.chain.IsEpochTransition(block.SlotNumber()) if transition { - if err := c.chain.calculateRewardsFFG(); err != nil { + if err := c.chain.calculateRewardsFFG(block); err != nil { log.Errorf("Error computing validator rewards and penalties %v", err) } } diff --git a/beacon-chain/params/config.go b/beacon-chain/params/config.go index 160dd92faac6..c9f04c641506 100644 --- a/beacon-chain/params/config.go +++ b/beacon-chain/params/config.go @@ -2,16 +2,14 @@ package params const ( - // AttesterCount is the number of attesters per committee/ - AttesterCount = 32 // AttesterReward determines how much ETH attesters get for performing their duty. AttesterReward = 1 - // EpochLength is the beacon chain epoch length in slots. - EpochLength = 64 + // CycleLength is the beacon chain epoch length in slots. + CycleLength = 64 // ShardCount is a fixed number. ShardCount = 1024 - // DefaultBalance of a validator. - DefaultBalance = 32000 + // DefaultBalance of a validator in ETH. + DefaultBalance = 32 // MaxValidators in the protocol. MaxValidators = 4194304 // SlotDuration in seconds. @@ -20,4 +18,6 @@ const ( Cofactor = 19 // MinCommiteeSize is the minimal number of validator needs to be in a committee. MinCommiteeSize = 128 + // DefaultEndDynasty is the upper bound of dynasty. We use it to track queued and exited validators. + DefaultEndDynasty = 9999999999999999999 ) diff --git a/beacon-chain/simulator/service.go b/beacon-chain/simulator/service.go index a364e8f83849..f53a202666a2 100644 --- a/beacon-chain/simulator/service.go +++ b/beacon-chain/simulator/service.go @@ -105,7 +105,7 @@ func (sim *Simulator) run(delayChan <-chan time.Time, done <-chan struct{}) { validators = append(validators, validator) } - crystallizedState.SetActiveValidators(validators) + crystallizedState.SetValidators(validators) crystallizedStateHash, err := crystallizedState.Hash() if err != nil { @@ -115,7 +115,7 @@ func (sim *Simulator) run(delayChan <-chan time.Time, done <-chan struct{}) { block, err := types.NewBlock(&pb.BeaconBlock{ SlotNumber: sim.slotNum, Timestamp: ptypes.TimestampNow(), - MainChainRef: sim.web3Service.LatestBlockHash().Bytes(), + PowChainRef: sim.web3Service.LatestBlockHash().Bytes(), ActiveStateHash: activeStateHash[:], CrystallizedStateHash: crystallizedStateHash[:], ParentHash: make([]byte, 32), @@ -128,11 +128,11 @@ func (sim *Simulator) run(delayChan <-chan time.Time, done <-chan struct{}) { log.WithField("currentSlot", block.SlotNumber()).Info("Current slot") // Is it epoch transition time? - if block.SlotNumber()/params.EpochLength > crystallizedState.CurrentEpoch() { - crystallizedState.IncrementEpoch() - crystallizedState.UpdateJustifiedEpoch() - log.WithField("lastJustifiedEpoch", crystallizedState.LastJustifiedEpoch()).Info("Last justified epoch") - log.WithField("lastFinalizedEpoch", crystallizedState.LastFinalizedEpoch()).Info("Last finalized epoch") + if block.SlotNumber() >= crystallizedState.LastStateRecalc()+params.CycleLength { + crystallizedState.SetLastJustifiedSlot(block.SlotNumber()) + crystallizedState.UpdateJustifiedSlot(block.SlotNumber()) + log.WithField("lastJustifiedEpoch", crystallizedState.LastJustifiedSlot()).Info("Last justified epoch") + log.WithField("lastFinalizedEpoch", crystallizedState.LastFinalizedSlot()).Info("Last finalized epoch") h, err := crystallizedState.Hash() if err != nil { diff --git a/beacon-chain/simulator/service_test.go b/beacon-chain/simulator/service_test.go index 756104b24ce5..a726ee9d05cc 100644 --- a/beacon-chain/simulator/service_test.go +++ b/beacon-chain/simulator/service_test.go @@ -168,7 +168,7 @@ func TestCrystallizedRequest(t *testing.T) { <-exitRoutine }() - state := types.NewCrystallizedState(&pb.CrystallizedState{CurrentEpoch: 99}) + state := types.NewCrystallizedState(&pb.CrystallizedState{LastStateRecalc: 99}) h, err := state.Hash() if err != nil { diff --git a/beacon-chain/sync/service.go b/beacon-chain/sync/service.go index da0534a99c80..a9037b68bcf6 100644 --- a/beacon-chain/sync/service.go +++ b/beacon-chain/sync/service.go @@ -389,7 +389,7 @@ func (ss *Service) runInitialSync(delaychan <-chan time.Time, done <-chan struct continue } - ss.currentSlotNumber = crystallizedState.LastFinalizedEpoch() + ss.currentSlotNumber = crystallizedState.LastFinalizedSlot() ss.requestNextBlock() crystallizedStateSub.Unsubscribe() } diff --git a/beacon-chain/sync/service_test.go b/beacon-chain/sync/service_test.go index 8078ae2ac979..5c5d9e4e0f0b 100644 --- a/beacon-chain/sync/service_test.go +++ b/beacon-chain/sync/service_test.go @@ -167,8 +167,8 @@ func TestProcessBlock(t *testing.T) { }() data := &pb.BeaconBlock{ - MainChainRef: []byte{1, 2, 3, 4, 5}, - ParentHash: make([]byte, 32), + PowChainRef: []byte{1, 2, 3, 4, 5}, + ParentHash: make([]byte, 32), } responseBlock := &pb.BeaconBlockResponse{ @@ -214,8 +214,8 @@ func TestProcessMultipleBlocks(t *testing.T) { }() data1 := &pb.BeaconBlock{ - MainChainRef: []byte{1, 2, 3, 4, 5}, - ParentHash: make([]byte, 32), + PowChainRef: []byte{1, 2, 3, 4, 5}, + ParentHash: make([]byte, 32), } responseBlock1 := &pb.BeaconBlockResponse{ @@ -228,8 +228,8 @@ func TestProcessMultipleBlocks(t *testing.T) { } data2 := &pb.BeaconBlock{ - MainChainRef: []byte{6, 7, 8, 9, 10}, - ParentHash: make([]byte, 32), + PowChainRef: []byte{6, 7, 8, 9, 10}, + ParentHash: make([]byte, 32), } responseBlock2 := &pb.BeaconBlockResponse{ @@ -290,8 +290,8 @@ func TestProcessSameBlock(t *testing.T) { }() data := &pb.BeaconBlock{ - MainChainRef: []byte{1, 2, 3}, - ParentHash: make([]byte, 32), + PowChainRef: []byte{1, 2, 3}, + ParentHash: make([]byte, 32), } responseBlock := &pb.BeaconBlockResponse{ @@ -476,12 +476,12 @@ func TestProcessCrystallizedStates(t *testing.T) { }() data1 := &pb.CrystallizedState{ - LastJustifiedEpoch: 100, - LastFinalizedEpoch: 99, + LastJustifiedSlot: 100, + LastFinalizedSlot: 99, } data2 := &pb.CrystallizedState{ - LastJustifiedEpoch: 100, - LastFinalizedEpoch: 98, + LastJustifiedSlot: 100, + LastFinalizedSlot: 98, } responseState1 := &pb.CrystallizedStateResponse{ @@ -542,10 +542,10 @@ func TestProcessActiveStates(t *testing.T) { }() state1 := &pb.ActiveState{ - TotalAttesterDeposits: 10000, + RecentBlockHashes: [][]byte{{'A'}, {'B'}, {'C'}}, } state2 := &pb.ActiveState{ - TotalAttesterDeposits: 10001, + RecentBlockHashes: [][]byte{{1}, {2}, {3}}, } responseState1 := &pb.ActiveStateResponse{ @@ -607,8 +607,8 @@ func TestProcessSameCrystallizedState(t *testing.T) { }() data := &pb.CrystallizedState{ - LastJustifiedEpoch: 100, - LastFinalizedEpoch: 99, + LastJustifiedSlot: 100, + LastFinalizedSlot: 99, } responseState := &pb.CrystallizedStateResponse{ @@ -660,7 +660,7 @@ func TestProcessSameActiveState(t *testing.T) { }() data := &pb.ActiveState{ - TotalAttesterDeposits: 100, + RecentBlockHashes: [][]byte{{'A'}, {'B'}, {'C'}}, } responseState1 := &pb.ActiveStateResponse{ @@ -716,7 +716,7 @@ func TestSetBlockForInitialSync(t *testing.T) { generichash[0] = 'a' block := &pb.BeaconBlock{ - MainChainRef: []byte{1, 2, 3}, + PowChainRef: []byte{1, 2, 3}, ParentHash: generichash, SlotNumber: uint64(20), CrystallizedStateHash: generichash, @@ -764,7 +764,7 @@ func TestSavingBlocksInSync(t *testing.T) { generichash[0] = 'a' crystallizedState := &pb.CrystallizedState{ - LastFinalizedEpoch: 99, + LastFinalizedSlot: 99, } stateResponse := &pb.CrystallizedStateResponse{ @@ -772,8 +772,8 @@ func TestSavingBlocksInSync(t *testing.T) { } incorrectState := &pb.CrystallizedState{ - LastFinalizedEpoch: 9, - LastJustifiedEpoch: 20, + LastFinalizedSlot: 9, + LastJustifiedSlot: 20, } incorrectStateResponse := &pb.CrystallizedStateResponse{ @@ -787,7 +787,7 @@ func TestSavingBlocksInSync(t *testing.T) { getBlockResponseMsg := func(slotNumber uint64) p2p.Message { block := &pb.BeaconBlock{ - MainChainRef: []byte{1, 2, 3}, + PowChainRef: []byte{1, 2, 3}, ParentHash: generichash, SlotNumber: slotNumber, CrystallizedStateHash: crystallizedStateHash[:], @@ -813,7 +813,7 @@ func TestSavingBlocksInSync(t *testing.T) { ss.blockBuf <- msg1 ss.crystallizedStateBuf <- msg2 - if ss.currentSlotNumber == incorrectStateResponse.CrystallizedState.LastFinalizedEpoch { + if ss.currentSlotNumber == incorrectStateResponse.CrystallizedState.LastFinalizedSlot { t.Fatalf("Crystallized state updated incorrectly: %x", ss.currentSlotNumber) } @@ -829,8 +829,8 @@ func TestSavingBlocksInSync(t *testing.T) { msg1 = getBlockResponseMsg(30) ss.blockBuf <- msg1 - if stateResponse.CrystallizedState.GetLastFinalizedEpoch() != ss.currentSlotNumber { - t.Fatalf("slotnumber saved when it was not supposed too: %v", stateResponse.CrystallizedState.GetLastFinalizedEpoch()) + if stateResponse.CrystallizedState.GetLastFinalizedSlot() != ss.currentSlotNumber { + t.Fatalf("slotnumber saved when it was not supposed too: %v", stateResponse.CrystallizedState.GetLastFinalizedSlot()) } msg1 = getBlockResponseMsg(100) @@ -866,7 +866,7 @@ func TestDelayChan(t *testing.T) { generichash[0] = 'a' crystallizedstate := &pb.CrystallizedState{ - LastFinalizedEpoch: 99, + LastFinalizedSlot: 99, } stateResponse := &pb.CrystallizedStateResponse{ @@ -879,7 +879,7 @@ func TestDelayChan(t *testing.T) { } block := &pb.BeaconBlock{ - MainChainRef: []byte{1, 2, 3}, + PowChainRef: []byte{1, 2, 3}, ParentHash: generichash, SlotNumber: uint64(20), CrystallizedStateHash: crystallizedStateHash[:], diff --git a/beacon-chain/types/block.go b/beacon-chain/types/block.go index 8c9587b44bdf..5e362b955c30 100644 --- a/beacon-chain/types/block.go +++ b/beacon-chain/types/block.go @@ -18,16 +18,23 @@ type Block struct { data *pb.BeaconBlock } -// AggregateVote contains the fields of aggregate vote in individual shard. -type AggregateVote struct { - ShardID uint32 // Shard ID of the voted shard. - ShardBlockHash []byte // ShardBlockHash is the shard block hash of the voted shard. - SignerBitmask []byte // SignerBitmask is the bit mask of every validator that signed. - AggregateSig []uint // AggregateSig is the aggregated signatures of individual shard. -} - // NewBlock explicitly sets the data field of a block. +// Return block with default fields if data is nil. func NewBlock(data *pb.BeaconBlock) (*Block, error) { + if data == nil { + return &Block{ + data: &pb.BeaconBlock{ + ParentHash: []byte{0}, + SlotNumber: 0, + RandaoReveal: []byte{0}, + Attestations: []*pb.AttestationRecord{}, + PowChainRef: []byte{0}, + ActiveStateHash: []byte{0}, + CrystallizedStateHash: []byte{0}, + }, + }, nil + } + if len(data.ParentHash) != 32 { return nil, errors.New("invalid block data, parent hash should be 32 bytes") } @@ -82,32 +89,37 @@ func (b *Block) SlotNumber() uint64 { return b.data.SlotNumber } -// MainChainRef returns a keccak256 hash corresponding to a PoW chain block. -func (b *Block) MainChainRef() common.Hash { - return common.BytesToHash(b.data.MainChainRef) +// PowChainRef returns a keccak256 hash corresponding to a PoW chain block. +func (b *Block) PowChainRef() common.Hash { + return common.BytesToHash(b.data.PowChainRef) } // RandaoReveal returns the blake2b randao hash. func (b *Block) RandaoReveal() [32]byte { var h [32]byte - copy(h[:], b.data.RandaoReveal[:32]) + copy(h[:], b.data.RandaoReveal) return h } // ActiveStateHash returns the active state hash. func (b *Block) ActiveStateHash() [32]byte { var h [32]byte - copy(h[:], b.data.ActiveStateHash[:32]) + copy(h[:], b.data.ActiveStateHash) return h } // CrystallizedStateHash returns the crystallized state hash. func (b *Block) CrystallizedStateHash() [32]byte { var h [32]byte - copy(h[:], b.data.CrystallizedStateHash[:32]) + copy(h[:], b.data.CrystallizedStateHash) return h } +// AttestationCount returns the number of attestations. +func (b *Block) AttestationCount() int { + return len(b.data.Attestations) +} + // Timestamp returns the Go type time.Time from the protobuf type contained in the block. func (b *Block) Timestamp() (time.Time, error) { return ptypes.Timestamp(b.data.Timestamp) diff --git a/beacon-chain/types/state.go b/beacon-chain/types/state.go index d08ee86399af..ab39be065cc5 100644 --- a/beacon-chain/types/state.go +++ b/beacon-chain/types/state.go @@ -13,8 +13,8 @@ type ActiveState struct { data *pb.ActiveState } -// CrystallizedState contains fields of every epoch state, -// it changes every epoch. +// CrystallizedState contains fields of every Slot state, +// it changes every Slot. type CrystallizedState struct { data *pb.CrystallizedState } @@ -33,28 +33,41 @@ func NewActiveState(data *pb.ActiveState) *ActiveState { func NewGenesisStates() (*ActiveState, *CrystallizedState) { active := &ActiveState{ data: &pb.ActiveState{ - TotalAttesterDeposits: 0, - AttesterBitfield: []byte{}, + PendingAttestations: []*pb.AttestationRecord{}, + RecentBlockHashes: [][]byte{}, }, } crystallized := &CrystallizedState{ data: &pb.CrystallizedState{ - ActiveValidators: []*pb.ValidatorRecord{}, - QueuedValidators: []*pb.ValidatorRecord{}, - ExitedValidators: []*pb.ValidatorRecord{}, - CurrentEpochShuffling: []uint64{}, - CurrentEpoch: 0, - LastJustifiedEpoch: 0, - LastFinalizedEpoch: 0, - CurrentDynasty: 0, - TotalDeposits: 0, - DynastySeed: []byte{}, - DynastySeedLastReset: 0, + LastStateRecalc: 0, + JustifiedStreak: 0, + LastJustifiedSlot: 0, + LastFinalizedSlot: 0, + CurrentDynasty: 0, + CrosslinkingStartShard: 0, + TotalDeposits: 0, + DynastySeed: []byte{}, + DynastySeedLastReset: 0, + CrosslinkRecords: []*pb.CrosslinkRecord{}, + Validators: []*pb.ValidatorRecord{}, + IndicesForHeights: []*pb.ShardAndCommitteeArray{}, }, } return active, crystallized } +// NewAttestationRecord initializes an attestation record with default parameters. +func NewAttestationRecord() *pb.AttestationRecord { + return &pb.AttestationRecord{ + Slot: 0, + ShardId: 0, + ObliqueParentHashes: [][]byte{}, + ShardBlockHash: []byte{0}, + AttesterBitfield: nil, + AggregateSig: []uint64{0, 0}, + } +} + // Proto returns the underlying protobuf data within a state primitive. func (a *ActiveState) Proto() *pb.ActiveState { return a.data @@ -75,24 +88,40 @@ func (a *ActiveState) Hash() ([32]byte, error) { return blake2b.Sum256(data), nil } -// TotalAttesterDeposits returns total quantity of wei that attested for the most recent checkpoint. -func (a *ActiveState) TotalAttesterDeposits() uint64 { - return a.data.TotalAttesterDeposits +// PendingAttestations returns attestations that have not yet been processed. +func (a *ActiveState) PendingAttestations() []*pb.AttestationRecord { + return a.data.PendingAttestations +} + +// NewPendingAttestation inserts a new pending attestaton fields. +func (a *ActiveState) NewPendingAttestation(record *pb.AttestationRecord) { + a.data.PendingAttestations = append(a.data.PendingAttestations, record) +} + +// LatestPendingAttestation returns the latest pending attestaton fields. +func (a *ActiveState) LatestPendingAttestation() *pb.AttestationRecord { + return a.data.PendingAttestations[len(a.data.PendingAttestations)-1] } -// SetTotalAttesterDeposits sets total quantity of wei that attested for the most recent checkpoint. -func (a *ActiveState) SetTotalAttesterDeposits(deposit uint64) { - a.data.TotalAttesterDeposits = deposit +// ClearPendingAttestations clears attestations that have not yet been processed. +func (a *ActiveState) ClearPendingAttestations() { + for i := range a.data.PendingAttestations { + a.data.PendingAttestations[i] = &pb.AttestationRecord{} + } } -// AttesterBitfield returns a bitfield for seeing which attester has attested. -func (a *ActiveState) AttesterBitfield() []byte { - return a.data.AttesterBitfield +// RecentBlockHashes returns the most recent 2*EPOCH_LENGTH block hashes. +func (a *ActiveState) RecentBlockHashes() []common.Hash { + var blockhashes []common.Hash + for _, hash := range a.data.RecentBlockHashes { + blockhashes = append(blockhashes, common.BytesToHash(hash)) + } + return blockhashes } -// SetAttesterBitfield sets attester bitfield. -func (a *ActiveState) SetAttesterBitfield(bitfield []byte) { - a.data.AttesterBitfield = bitfield +// ClearRecentBlockHashes resets the most recent 64 block hashes. +func (a *ActiveState) ClearRecentBlockHashes() { + a.data.RecentBlockHashes = [][]byte{} } // Proto returns the underlying protobuf data within a state primitive. @@ -115,123 +144,115 @@ func (c *CrystallizedState) Hash() ([32]byte, error) { return blake2b.Sum256(data), nil } -// ActiveValidators returns the list of active validators. -func (c *CrystallizedState) ActiveValidators() []*pb.ValidatorRecord { - return c.data.ActiveValidators -} - -// ActiveValidatorsLength returns the number of total active validators. -func (c *CrystallizedState) ActiveValidatorsLength() int { - return len(c.data.ActiveValidators) +// LastStateRecalc returns when the last time crystallized state recalculated. +func (c *CrystallizedState) LastStateRecalc() uint64 { + return c.data.LastStateRecalc } -// SetActiveValidators sets the active validator set. -func (c *CrystallizedState) SetActiveValidators(validators []*pb.ValidatorRecord) { - c.data.ActiveValidators = validators +// JustifiedStreak returns number of consecutive justified slots ending at head. +func (c *CrystallizedState) JustifiedStreak() uint64 { + return c.data.JustifiedStreak } -// QueuedValidators returns the list of validators that are queued. -func (c *CrystallizedState) QueuedValidators() []*pb.ValidatorRecord { - return c.data.QueuedValidators +// ClearJustifiedStreak clears the number of consecutive justified slots. +func (c *CrystallizedState) ClearJustifiedStreak() { + c.data.JustifiedStreak = 0 } -// QueuedValidatorsLength returns the number of total queued validators. -func (c *CrystallizedState) QueuedValidatorsLength() int { - return len(c.data.QueuedValidators) +// CrosslinkingStartShard returns next shard that crosslinking assignment will start from. +func (c *CrystallizedState) CrosslinkingStartShard() uint64 { + return c.data.CrosslinkingStartShard } -// SetQueuedValidators sets the queued validator set. -func (c *CrystallizedState) SetQueuedValidators(validators []*pb.ValidatorRecord) { - c.data.QueuedValidators = validators +// LastJustifiedSlot return the last justified slot of the beacon chain. +func (c *CrystallizedState) LastJustifiedSlot() uint64 { + return c.data.LastJustifiedSlot } -// ExitedValidators returns the list of validators that have exited. -func (c *CrystallizedState) ExitedValidators() []*pb.ValidatorRecord { - return c.data.ExitedValidators +// SetLastJustifiedSlot sets the last justified Slot of the beacon chain. +func (c *CrystallizedState) SetLastJustifiedSlot(Slot uint64) { + c.data.LastJustifiedSlot = Slot } -// ExitedValidatorsLength returns the number of total exited validators. -func (c *CrystallizedState) ExitedValidatorsLength() int { - return len(c.data.ExitedValidators) +// LastFinalizedSlot returns the last finalized Slot of the beacon chain. +func (c *CrystallizedState) LastFinalizedSlot() uint64 { + return c.data.LastFinalizedSlot } -// SetExitedValidators sets the exited validator set.. -func (c *CrystallizedState) SetExitedValidators(validators []*pb.ValidatorRecord) { - c.data.ExitedValidators = validators +// SetLastFinalizedSlot sets last justified Slot of the beacon chain. +func (c *CrystallizedState) SetLastFinalizedSlot(Slot uint64) { + c.data.LastFinalizedSlot = Slot } -// CurrentEpochShuffling is the permutation of validators that determines -// who participates in what committee and at what height. -func (c *CrystallizedState) CurrentEpochShuffling() []uint64 { - return c.data.CurrentEpochShuffling -} - -// CurrentEpoch returns the current epoch of the beacon chain. -func (c *CrystallizedState) CurrentEpoch() uint64 { - return c.data.CurrentEpoch +// CurrentDynasty returns the current dynasty of the beacon chain. +func (c *CrystallizedState) CurrentDynasty() uint64 { + return c.data.CurrentDynasty } -// IncrementEpoch increments the epoch by one. -func (c *CrystallizedState) IncrementEpoch() { - c.data.CurrentEpoch++ +// IncrementCurrentDynasty increments current dynasty by one. +func (c *CrystallizedState) IncrementCurrentDynasty() { + c.data.CurrentDynasty++ } -// LastJustifiedEpoch return the last justified epoch of the beacon chain. -func (c *CrystallizedState) LastJustifiedEpoch() uint64 { - return c.data.LastJustifiedEpoch +// TotalDeposits returns total balance of deposits. +func (c *CrystallizedState) TotalDeposits() uint64 { + return c.data.TotalDeposits } -// SetLastJustifiedEpoch sets the last justified epoch of the beacon chain. -func (c *CrystallizedState) SetLastJustifiedEpoch(epoch uint64) { - c.data.LastJustifiedEpoch = epoch +// SetTotalDeposits sets total balance of deposits. +func (c *CrystallizedState) SetTotalDeposits(total uint64) { + c.data.TotalDeposits = total } -// LastFinalizedEpoch returns the last finalized epoch of the beacon chain. -func (c *CrystallizedState) LastFinalizedEpoch() uint64 { - return c.data.LastFinalizedEpoch +// DynastySeed is used to select the committee for each shard. +func (c *CrystallizedState) DynastySeed() [32]byte { + var h [32]byte + copy(h[:], c.data.DynastySeed) + return h } -// SetLastFinalizedEpoch sets last justified epoch of the beacon chain. -func (c *CrystallizedState) SetLastFinalizedEpoch(epoch uint64) { - c.data.LastFinalizedEpoch = epoch +// DynastySeedLastReset is the last finalized Slot that the crosslink seed was reset. +func (c *CrystallizedState) DynastySeedLastReset() uint64 { + return c.data.DynastySeedLastReset } -// CurrentDynasty returns the current dynasty of the beacon chain. -func (c *CrystallizedState) CurrentDynasty() uint64 { - return c.data.CurrentDynasty +// Validators returns list of validators. +func (c *CrystallizedState) Validators() []*pb.ValidatorRecord { + return c.data.Validators } -// NextShard returns where the crosslink assignment will be coming from. -func (c *CrystallizedState) NextShard() uint64 { - return c.data.NextShard +// ValidatorsLength returns the number of total validators. +func (c *CrystallizedState) ValidatorsLength() int { + return len(c.data.Validators) } -// CurrentCheckPoint returns the current checkpoint for the FFG state. -func (c *CrystallizedState) CurrentCheckPoint() common.Hash { - return common.BytesToHash(c.data.CurrentCheckPoint) +// SetValidators sets the validator set. +func (c *CrystallizedState) SetValidators(validators []*pb.ValidatorRecord) { + c.data.Validators = validators } -// TotalDeposits returns the combined deposits of all the validators. -func (c *CrystallizedState) TotalDeposits() uint64 { - return c.data.TotalDeposits +// IndicesForHeights returns what active validators are part of the attester set +// at what height, and in what shard. +func (c *CrystallizedState) IndicesForHeights() []*pb.ShardAndCommitteeArray { + return c.data.IndicesForHeights } -// DynastySeed returns the seed used to select the committee for each shard. -func (c *CrystallizedState) DynastySeed() common.Hash { - return common.BytesToHash(c.data.DynastySeed) +// ClearIndicesForHeights clears the IndicesForHeights set. +func (c *CrystallizedState) ClearIndicesForHeights() { + c.data.IndicesForHeights = []*pb.ShardAndCommitteeArray{} } -// DynastySeedLastReset is the last finalized epoch that the crosslink seed was reset. -func (c *CrystallizedState) DynastySeedLastReset() uint64 { - return c.data.DynastySeedLastReset +// CrosslinkRecords returns records about the most recent cross link or each shard. +func (c *CrystallizedState) CrosslinkRecords() []*pb.CrosslinkRecord { + return c.data.CrosslinkRecords } -// UpdateJustifiedEpoch updates the justified epoch during an epoch transition. -func (c *CrystallizedState) UpdateJustifiedEpoch() { - epoch := c.LastJustifiedEpoch() - c.SetLastJustifiedEpoch(c.CurrentEpoch()) +// UpdateJustifiedSlot updates the justified and finalized Slot during a dynasty transition. +func (c *CrystallizedState) UpdateJustifiedSlot(currentSlot uint64) { + slot := c.LastJustifiedSlot() + c.SetLastJustifiedSlot(currentSlot) - if c.CurrentEpoch() == (epoch + 1) { - c.SetLastFinalizedEpoch(epoch) + if currentSlot == (slot + 1) { + c.SetLastFinalizedSlot(slot) } } diff --git a/beacon-chain/utils/BUILD.bazel b/beacon-chain/utils/BUILD.bazel index c861fd0c6df2..64b2acb2c644 100644 --- a/beacon-chain/utils/BUILD.bazel +++ b/beacon-chain/utils/BUILD.bazel @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", srcs = [ + "checkbit.go", "clock.go", "flags.go", "shuffle.go", @@ -20,6 +21,7 @@ go_library( go_test( name = "go_default_test", srcs = [ + "checkbit_test.go", "clock_test.go", "shuffle_test.go", ], diff --git a/beacon-chain/utils/checkbit.go b/beacon-chain/utils/checkbit.go new file mode 100644 index 000000000000..ca3ea8d487e6 --- /dev/null +++ b/beacon-chain/utils/checkbit.go @@ -0,0 +1,34 @@ +package utils + +import ( + "errors" +) + +// CheckBit checks if a bit in a bit field is one. +func CheckBit(bitfield []byte, index int) (bool, error) { + chunkLocation := (index + 1) / 8 + indexLocation := (index + 1) % 8 + if indexLocation == 0 { + indexLocation = 8 + } else { + chunkLocation++ + } + + if len(bitfield) < chunkLocation { + return false, errors.New("attester index does not exist") + } + + field := bitfield[chunkLocation-1] >> (8 - uint(indexLocation)) + if field%2 != 0 { + return true, nil + } + return false, nil +} + +// BitSetCount counts the number of 1s in a byte using the following algo: +// https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel +func BitSetCount(v byte) byte { + v = (v & 0x55) + ((v >> 1) & 0x55) + v = (v & 0x33) + ((v >> 2) & 0x33) + return (v + (v >> 4)) & 0xF +} diff --git a/beacon-chain/utils/checkbit_test.go b/beacon-chain/utils/checkbit_test.go new file mode 100644 index 000000000000..888c6605be0f --- /dev/null +++ b/beacon-chain/utils/checkbit_test.go @@ -0,0 +1,23 @@ +package utils + +import ( + "testing" +) + +func TestBitSetCount(t *testing.T) { + tests := []struct { + a byte + b int + }{ + {a: 200, b: 3}, //11001000 + {a: 148, b: 3}, //10010100 + {a: 146, b: 3}, //10010010 + {a: 179, b: 5}, //10110011 + {a: 49, b: 3}, //00110001 + } + for _, tt := range tests { + if int(BitSetCount(tt.a)) != tt.b { + t.Errorf("Expected %v, Got %v", tt.b, int(BitSetCount(tt.a))) + } + } +} diff --git a/beacon-chain/utils/shuffle.go b/beacon-chain/utils/shuffle.go index 8d7d656f82e2..739917c14fe6 100644 --- a/beacon-chain/utils/shuffle.go +++ b/beacon-chain/utils/shuffle.go @@ -3,7 +3,6 @@ package utils import ( "errors" - "math" "github.com/ethereum/go-ethereum/common" "github.com/prysmaticlabs/prysm/beacon-chain/params" @@ -12,18 +11,13 @@ import ( // ShuffleIndices returns a list of pseudorandomly sampled // indices. This is used to use to select attesters and proposers. -func ShuffleIndices(seed common.Hash, validatorCount int) ([]int, error) { - if validatorCount > params.MaxValidators { +func ShuffleIndices(seed common.Hash, validatorList []int) ([]int, error) { + if len(validatorList) > params.MaxValidators { return nil, errors.New("Validator count has exceeded MaxValidator Count") } - // construct a list of indices up to MaxValidators. - validatorList := make([]int, validatorCount) - for i := range validatorList { - validatorList[i] = i - } - hashSeed := blake2b.Sum256(seed[:]) + validatorCount := len(validatorList) // shuffle stops at the second to last index. for i := 0; i < validatorCount-1; i++ { @@ -38,48 +32,13 @@ func ShuffleIndices(seed common.Hash, validatorCount int) ([]int, error) { return validatorList, nil } -// GetCutoffs is used to split up validators into groups at the start -// of every epoch. It determines at what height validators can make -// attestations and crosslinks. It returns lists of cutoff indices and heights. -func GetCutoffs(validatorCount int) ([]int, []int) { - var heightCutoff = []int{0} - var heights []int - var heightCount float64 - - // Skip heights if there's not enough validators to fill in a min sized committee. - if validatorCount < params.EpochLength*params.MinCommiteeSize { - heightCount = math.Floor(float64(validatorCount) / params.MinCommiteeSize) - for i := 0; i < int(heightCount); i++ { - heights = append(heights, (i*params.Cofactor)%params.EpochLength) - } - // Enough validators, fill in all the heights. - } else { - heightCount = params.EpochLength - for i := 0; i < int(heightCount); i++ { - heights = append(heights, i) - } - } - - filled := 0 - appendHeight := false - for i := 0; i < params.EpochLength-1; i++ { - appendHeight = false - for _, height := range heights { - if i == height { - appendHeight = true - } - } - if appendHeight { - filled++ - heightCutoff = append(heightCutoff, filled*validatorCount/int(heightCount)) - } else { - heightCutoff = append(heightCutoff, heightCutoff[len(heightCutoff)-1]) - } +// SplitIndices splits a list into n pieces. +func SplitIndices(l []int, n int) [][]int { + var divided [][]int + for i := 0; i < n; i++ { + start := len(l) * i / n + end := len(l) * (i + 1) / n + divided = append(divided, l[start:end]) } - heightCutoff = append(heightCutoff, validatorCount) - - // TODO: For the validators assigned to each height, split them up into - // committees for different shards. Do not assign the last END_EPOCH_GRACE_PERIOD - // heights in a epoch to any shards. - return heightCutoff, heights + return divided } diff --git a/beacon-chain/utils/shuffle_test.go b/beacon-chain/utils/shuffle_test.go index a2b411082179..d48f5665571a 100644 --- a/beacon-chain/utils/shuffle_test.go +++ b/beacon-chain/utils/shuffle_test.go @@ -1,7 +1,6 @@ package utils import ( - "math" "reflect" "testing" @@ -10,7 +9,13 @@ import ( ) func TestFaultyShuffleIndices(t *testing.T) { - if _, err := ShuffleIndices(common.Hash{'a'}, params.MaxValidators+1); err == nil { + var list []int + + for i := 0; i < params.MaxValidators+1; i++ { + list = append(list, i) + } + + if _, err := ShuffleIndices(common.Hash{'a'}, list); err == nil { t.Error("Shuffle should have failed when validator count exceeds MaxValidators") } } @@ -18,75 +23,44 @@ func TestFaultyShuffleIndices(t *testing.T) { func TestShuffleIndices(t *testing.T) { hash1 := common.BytesToHash([]byte{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g'}) hash2 := common.BytesToHash([]byte{'1', '2', '3', '4', '5', '6', '7', '1', '2', '3', '4', '5', '6', '7', '1', '2', '3', '4', '5', '6', '7', '1', '2', '3', '4', '5', '6', '7', '1', '2', '3', '4', '5', '6', '7'}) + var list1 []int + + for i := 0; i < 100; i++ { + list1 = append(list1, i) + } - list1, err := ShuffleIndices(hash1, 100) + list2 := make([]int, len(list1)) + copy(list2, list1) + + list1, err := ShuffleIndices(hash1, list1) if err != nil { t.Errorf("Shuffle failed with: %v", err) } - list2, err := ShuffleIndices(hash2, 100) + list2, err = ShuffleIndices(hash2, list2) if err != nil { t.Errorf("Shuffle failed with: %v", err) } + if reflect.DeepEqual(list1, list2) { t.Errorf("2 shuffled lists shouldn't be equal") } } -func TestCutOffValidatorSet(t *testing.T) { - // Test scenario #1: Assume there's enough validators to fill in all the heights. - validatorCount := params.EpochLength * params.MinCommiteeSize - cutoffsValidators, _ := GetCutoffs(validatorCount) - - // The length of cutoff list should be 65. Since there is 64 heights per epoch, - // it means during every height, a new set of 128 validators will form a committee. - expectedCount := int(math.Ceil(float64(validatorCount)/params.MinCommiteeSize)) + 1 - if len(cutoffsValidators) != expectedCount { - t.Errorf("Incorrect count for cutoffs validator. Wanted: %v, Got: %v", expectedCount, len(cutoffsValidators)) +func TestSplitIndices(t *testing.T) { + var l []int + validators := 64000 + for i := 0; i < validators; i++ { + l = append(l, i) } - - // Verify each cutoff is an increment of MinCommiteeSize, it means 128 validators forms a - // a committee and get to attest per height. - count := 0 - for _, cutoff := range cutoffsValidators { - if cutoff != count { - t.Errorf("cutoffsValidators did not get 128 increment. Wanted: count, Got: %v", cutoff) - } - count += params.MinCommiteeSize - } - - // Test scenario #2: Assume there's not enough validators to fill in all the heights. - validatorCount = 1000 - cutoffs2, _ := GetCutoffs(validatorCount) - cutoffsValidators = unique(cutoffs2) - // With 1000 validators, we can't attest every height. Given min committee size is 128, - // we can only attest 7 heights. round down 1000 / 128 equals to 7, means the length is 8. - expectedCount = int(math.Ceil(float64(validatorCount) / params.MinCommiteeSize)) - if len(unique(cutoffsValidators)) != expectedCount { - t.Errorf("Incorrect count for cutoffs validator. Wanted: %v, Got: %v", expectedCount, validatorCount/params.MinCommiteeSize) - } - - // Verify each cutoff is an increment of 142~143 (1000 / 7). - count = 0 - for _, cutoff := range cutoffsValidators { - num := count * validatorCount / (len(cutoffsValidators) - 1) - if cutoff != num { - t.Errorf("cutoffsValidators did not get correct increment. Wanted: %v, Got: %v", num, cutoff) - } - count++ + split := SplitIndices(l, params.CycleLength) + if len(split) != params.CycleLength { + t.Errorf("Split list failed due to incorrect length, wanted:%v, got:%v", params.CycleLength, len(split)) } -} -// helper function to remove duplicates in a int slice. -func unique(ints []int) []int { - keys := make(map[int]bool) - list := []int{} - for _, int := range ints { - if _, value := keys[int]; !value { - keys[int] = true - list = append(list, int) + for _, s := range split { + if len(s) != validators/params.CycleLength { + t.Errorf("Split list failed due to incorrect length, wanted:%v, got:%v", validators/params.CycleLength, len(s)) } } - return list - } diff --git a/client/attester/service_test.go b/client/attester/service_test.go index 75944adf6d83..dbca70f10498 100644 --- a/client/attester/service_test.go +++ b/client/attester/service_test.go @@ -47,6 +47,7 @@ func TestAttesterLoop(t *testing.T) { hook := logTest.NewGlobal() ctrl := gomock.NewController(t) defer ctrl.Finish() + b := &mockBeaconService{ attesterChan: make(chan bool), } diff --git a/client/beacon/service.go b/client/beacon/service.go index 86c5d3e0aa1f..a61613672691 100644 --- a/client/beacon/service.go +++ b/client/beacon/service.go @@ -111,6 +111,7 @@ func (s *Service) fetchBeaconBlocks(client pb.BeaconServiceClient) { } func (s *Service) fetchCrystallizedState(client pb.BeaconServiceClient) { + var activeValidatorIndices []int stream, err := client.LatestCrystallizedState(s.ctx, &empty.Empty{}) if err != nil { log.Errorf("Could not setup crystallized beacon state streaming client: %v", err) @@ -135,16 +136,19 @@ func (s *Service) fetchCrystallizedState(client pb.BeaconServiceClient) { continue } crystallizedStateHash := blake2b.Sum256(stateData) + dynasty := crystallizedState.GetCurrentDynasty() - activeValidators := crystallizedState.GetActiveValidators() - + for i, validator := range crystallizedState.GetValidators() { + if validator.StartDynasty <= dynasty && dynasty < validator.EndDynasty { + activeValidatorIndices = append(activeValidatorIndices, i) + } + } isValidatorIndexSet := false - for i, val := range activeValidators { - // TODO: Check the public key instead of withdrawal address. This will - // use BLS. - if isZeroAddress(val.GetWithdrawalAddress()) { - s.validatorIndex = i + for _, val := range activeValidatorIndices { + // TODO: Check the public key instead of withdrawal address. This will use BLS. + if isZeroAddress(crystallizedState.Validators[val].WithdrawalAddress) { + s.validatorIndex = val isValidatorIndexSet = true break } diff --git a/client/beacon/service_test.go b/client/beacon/service_test.go index 539175c5716e..056e9d237906 100644 --- a/client/beacon/service_test.go +++ b/client/beacon/service_test.go @@ -208,9 +208,9 @@ func TestFetchCrystallizedState(t *testing.T) { testutil.AssertLogsContain(t, hook, "Could not marshal crystallized state proto") // If the current validator is not found within the active validators list, log a debug message. - validator := &pbp2p.ValidatorRecord{WithdrawalAddress: []byte("0x01")} + validator := &pbp2p.ValidatorRecord{WithdrawalAddress: []byte("0x01"), StartDynasty: 1, EndDynasty: 10} stream = internal.NewMockBeaconService_LatestCrystallizedStateClient(ctrl) - stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{ActiveValidators: []*pbp2p.ValidatorRecord{validator}}, nil) + stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{Validators: []*pbp2p.ValidatorRecord{validator}, CurrentDynasty: 5}, nil) stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{}, io.EOF) mockServiceClient = internal.NewMockBeaconServiceClient(ctrl) @@ -224,9 +224,9 @@ func TestFetchCrystallizedState(t *testing.T) { testutil.AssertLogsContain(t, hook, "Validator index not found in latest crystallized state's active validator list") // A faulty client.ShuffleValidators should log error. - validator = &pbp2p.ValidatorRecord{WithdrawalAddress: []byte{}} + validator = &pbp2p.ValidatorRecord{WithdrawalAddress: []byte{}, StartDynasty: 1, EndDynasty: 10} stream = internal.NewMockBeaconService_LatestCrystallizedStateClient(ctrl) - stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{ActiveValidators: []*pbp2p.ValidatorRecord{validator}}, nil) + stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{Validators: []*pbp2p.ValidatorRecord{validator}, CurrentDynasty: 5}, nil) stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{}, io.EOF) mockServiceClient = internal.NewMockBeaconServiceClient(ctrl) @@ -244,11 +244,11 @@ func TestFetchCrystallizedState(t *testing.T) { testutil.AssertLogsContain(t, hook, "Could not fetch shuffled validator indices: something went wrong") // Height should be assigned based on the result of ShuffleValidators. - validator1 := &pbp2p.ValidatorRecord{WithdrawalAddress: []byte("0x0")} - validator2 := &pbp2p.ValidatorRecord{WithdrawalAddress: []byte("0x1")} - validator3 := &pbp2p.ValidatorRecord{WithdrawalAddress: []byte{}} + validator1 := &pbp2p.ValidatorRecord{WithdrawalAddress: []byte("0x0"), StartDynasty: 1, EndDynasty: 10} + validator2 := &pbp2p.ValidatorRecord{WithdrawalAddress: []byte("0x1"), StartDynasty: 1, EndDynasty: 10} + validator3 := &pbp2p.ValidatorRecord{WithdrawalAddress: []byte{}, StartDynasty: 1, EndDynasty: 10} stream = internal.NewMockBeaconService_LatestCrystallizedStateClient(ctrl) - stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{ActiveValidators: []*pbp2p.ValidatorRecord{validator1, validator2, validator3}}, nil) + stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{Validators: []*pbp2p.ValidatorRecord{validator1, validator2, validator3}, CurrentDynasty: 5}, nil) stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{}, io.EOF) mockServiceClient = internal.NewMockBeaconServiceClient(ctrl) @@ -271,11 +271,11 @@ func TestFetchCrystallizedState(t *testing.T) { // If the validator is the last index in the shuffled validator indices, it should be assigned // to be a proposer. - validator1 = &pbp2p.ValidatorRecord{WithdrawalAddress: []byte("0x0")} - validator2 = &pbp2p.ValidatorRecord{WithdrawalAddress: []byte("0x1")} - validator3 = &pbp2p.ValidatorRecord{WithdrawalAddress: []byte{}} + validator1 = &pbp2p.ValidatorRecord{WithdrawalAddress: []byte("0x0"), StartDynasty: 1, EndDynasty: 10} + validator2 = &pbp2p.ValidatorRecord{WithdrawalAddress: []byte("0x1"), StartDynasty: 1, EndDynasty: 10} + validator3 = &pbp2p.ValidatorRecord{WithdrawalAddress: []byte{}, StartDynasty: 1, EndDynasty: 10} stream = internal.NewMockBeaconService_LatestCrystallizedStateClient(ctrl) - stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{ActiveValidators: []*pbp2p.ValidatorRecord{validator1, validator2, validator3}}, nil) + stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{Validators: []*pbp2p.ValidatorRecord{validator1, validator2, validator3}, CurrentDynasty: 5}, nil) stream.EXPECT().Recv().Return(&pbp2p.CrystallizedState{}, io.EOF) mockServiceClient = internal.NewMockBeaconServiceClient(ctrl) diff --git a/proto/beacon/p2p/v1/messages.pb.go b/proto/beacon/p2p/v1/messages.pb.go index fc1daec73d91..4dbf4fffe005 100644 --- a/proto/beacon/p2p/v1/messages.pb.go +++ b/proto/beacon/p2p/v1/messages.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: proto/beacon/p2p/v1/messages.proto +// source: messages.proto package ethereum_beacon_p2p_v1 @@ -30,7 +30,7 @@ func (m *BeaconBlockHashAnnounce) Reset() { *m = BeaconBlockHashAnnounce func (m *BeaconBlockHashAnnounce) String() string { return proto.CompactTextString(m) } func (*BeaconBlockHashAnnounce) ProtoMessage() {} func (*BeaconBlockHashAnnounce) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{0} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{0} } func (m *BeaconBlockHashAnnounce) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_BeaconBlockHashAnnounce.Unmarshal(m, b) @@ -68,7 +68,7 @@ func (m *BeaconBlockRequest) Reset() { *m = BeaconBlockRequest{} } func (m *BeaconBlockRequest) String() string { return proto.CompactTextString(m) } func (*BeaconBlockRequest) ProtoMessage() {} func (*BeaconBlockRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{1} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{1} } func (m *BeaconBlockRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_BeaconBlockRequest.Unmarshal(m, b) @@ -106,7 +106,7 @@ func (m *BeaconBlockRequestBySlotNumber) Reset() { *m = BeaconBlockReque func (m *BeaconBlockRequestBySlotNumber) String() string { return proto.CompactTextString(m) } func (*BeaconBlockRequestBySlotNumber) ProtoMessage() {} func (*BeaconBlockRequestBySlotNumber) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{2} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{2} } func (m *BeaconBlockRequestBySlotNumber) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_BeaconBlockRequestBySlotNumber.Unmarshal(m, b) @@ -144,7 +144,7 @@ func (m *BeaconBlockResponse) Reset() { *m = BeaconBlockResponse{} } func (m *BeaconBlockResponse) String() string { return proto.CompactTextString(m) } func (*BeaconBlockResponse) ProtoMessage() {} func (*BeaconBlockResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{3} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{3} } func (m *BeaconBlockResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_BeaconBlockResponse.Unmarshal(m, b) @@ -172,26 +172,24 @@ func (m *BeaconBlockResponse) GetBlock() *BeaconBlock { } type BeaconBlock struct { - ParentHash []byte `protobuf:"bytes,1,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty"` - SlotNumber uint64 `protobuf:"varint,2,opt,name=slot_number,json=slotNumber,proto3" json:"slot_number,omitempty"` - RandaoReveal []byte `protobuf:"bytes,3,opt,name=randao_reveal,json=randaoReveal,proto3" json:"randao_reveal,omitempty"` - AttestationBitmask []byte `protobuf:"bytes,4,opt,name=attestation_bitmask,json=attestationBitmask,proto3" json:"attestation_bitmask,omitempty"` - AttestationAggregateSig []uint32 `protobuf:"varint,5,rep,packed,name=attestation_aggregate_sig,json=attestationAggregateSig,proto3" json:"attestation_aggregate_sig,omitempty"` - ShardAggregateVotes []*AggregateVote `protobuf:"bytes,6,rep,name=shard_aggregate_votes,json=shardAggregateVotes,proto3" json:"shard_aggregate_votes,omitempty"` - MainChainRef []byte `protobuf:"bytes,7,opt,name=main_chain_ref,json=mainChainRef,proto3" json:"main_chain_ref,omitempty"` - ActiveStateHash []byte `protobuf:"bytes,8,opt,name=active_state_hash,json=activeStateHash,proto3" json:"active_state_hash,omitempty"` - CrystallizedStateHash []byte `protobuf:"bytes,9,opt,name=crystallized_state_hash,json=crystallizedStateHash,proto3" json:"crystallized_state_hash,omitempty"` - Timestamp *timestamp.Timestamp `protobuf:"bytes,10,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ParentHash []byte `protobuf:"bytes,1,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty"` + SlotNumber uint64 `protobuf:"varint,2,opt,name=slot_number,json=slotNumber,proto3" json:"slot_number,omitempty"` + RandaoReveal []byte `protobuf:"bytes,3,opt,name=randao_reveal,json=randaoReveal,proto3" json:"randao_reveal,omitempty"` + PowChainRef []byte `protobuf:"bytes,4,opt,name=pow_chain_ref,json=powChainRef,proto3" json:"pow_chain_ref,omitempty"` + ActiveStateHash []byte `protobuf:"bytes,5,opt,name=active_state_hash,json=activeStateHash,proto3" json:"active_state_hash,omitempty"` + CrystallizedStateHash []byte `protobuf:"bytes,6,opt,name=crystallized_state_hash,json=crystallizedStateHash,proto3" json:"crystallized_state_hash,omitempty"` + Timestamp *timestamp.Timestamp `protobuf:"bytes,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Attestations []*AttestationRecord `protobuf:"bytes,8,rep,name=attestations,proto3" json:"attestations,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *BeaconBlock) Reset() { *m = BeaconBlock{} } func (m *BeaconBlock) String() string { return proto.CompactTextString(m) } func (*BeaconBlock) ProtoMessage() {} func (*BeaconBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{4} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{4} } func (m *BeaconBlock) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_BeaconBlock.Unmarshal(m, b) @@ -232,30 +230,9 @@ func (m *BeaconBlock) GetRandaoReveal() []byte { return nil } -func (m *BeaconBlock) GetAttestationBitmask() []byte { +func (m *BeaconBlock) GetPowChainRef() []byte { if m != nil { - return m.AttestationBitmask - } - return nil -} - -func (m *BeaconBlock) GetAttestationAggregateSig() []uint32 { - if m != nil { - return m.AttestationAggregateSig - } - return nil -} - -func (m *BeaconBlock) GetShardAggregateVotes() []*AggregateVote { - if m != nil { - return m.ShardAggregateVotes - } - return nil -} - -func (m *BeaconBlock) GetMainChainRef() []byte { - if m != nil { - return m.MainChainRef + return m.PowChainRef } return nil } @@ -281,6 +258,13 @@ func (m *BeaconBlock) GetTimestamp() *timestamp.Timestamp { return nil } +func (m *BeaconBlock) GetAttestations() []*AttestationRecord { + if m != nil { + return m.Attestations + } + return nil +} + type CrystallizedStateHashAnnounce struct { Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -292,7 +276,7 @@ func (m *CrystallizedStateHashAnnounce) Reset() { *m = CrystallizedState func (m *CrystallizedStateHashAnnounce) String() string { return proto.CompactTextString(m) } func (*CrystallizedStateHashAnnounce) ProtoMessage() {} func (*CrystallizedStateHashAnnounce) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{5} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{5} } func (m *CrystallizedStateHashAnnounce) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CrystallizedStateHashAnnounce.Unmarshal(m, b) @@ -330,7 +314,7 @@ func (m *CrystallizedStateRequest) Reset() { *m = CrystallizedStateReque func (m *CrystallizedStateRequest) String() string { return proto.CompactTextString(m) } func (*CrystallizedStateRequest) ProtoMessage() {} func (*CrystallizedStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{6} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{6} } func (m *CrystallizedStateRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CrystallizedStateRequest.Unmarshal(m, b) @@ -368,7 +352,7 @@ func (m *CrystallizedStateResponse) Reset() { *m = CrystallizedStateResp func (m *CrystallizedStateResponse) String() string { return proto.CompactTextString(m) } func (*CrystallizedStateResponse) ProtoMessage() {} func (*CrystallizedStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{7} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{7} } func (m *CrystallizedStateResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CrystallizedStateResponse.Unmarshal(m, b) @@ -396,29 +380,28 @@ func (m *CrystallizedStateResponse) GetCrystallizedState() *CrystallizedState { } type CrystallizedState struct { - ActiveValidators []*ValidatorRecord `protobuf:"bytes,1,rep,name=active_validators,json=activeValidators,proto3" json:"active_validators,omitempty"` - QueuedValidators []*ValidatorRecord `protobuf:"bytes,2,rep,name=queued_validators,json=queuedValidators,proto3" json:"queued_validators,omitempty"` - ExitedValidators []*ValidatorRecord `protobuf:"bytes,3,rep,name=exited_validators,json=exitedValidators,proto3" json:"exited_validators,omitempty"` - CurrentEpochShuffling []uint64 `protobuf:"varint,4,rep,packed,name=current_epoch_shuffling,json=currentEpochShuffling,proto3" json:"current_epoch_shuffling,omitempty"` - CurrentEpoch uint64 `protobuf:"varint,5,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"` - LastJustifiedEpoch uint64 `protobuf:"varint,6,opt,name=last_justified_epoch,json=lastJustifiedEpoch,proto3" json:"last_justified_epoch,omitempty"` - LastFinalizedEpoch uint64 `protobuf:"varint,7,opt,name=last_finalized_epoch,json=lastFinalizedEpoch,proto3" json:"last_finalized_epoch,omitempty"` - CurrentDynasty uint64 `protobuf:"varint,8,opt,name=current_dynasty,json=currentDynasty,proto3" json:"current_dynasty,omitempty"` - NextShard uint64 `protobuf:"varint,9,opt,name=next_shard,json=nextShard,proto3" json:"next_shard,omitempty"` - CurrentCheckPoint []byte `protobuf:"bytes,10,opt,name=current_check_point,json=currentCheckPoint,proto3" json:"current_check_point,omitempty"` - TotalDeposits uint64 `protobuf:"varint,11,opt,name=total_deposits,json=totalDeposits,proto3" json:"total_deposits,omitempty"` - DynastySeed []byte `protobuf:"bytes,12,opt,name=dynasty_seed,json=dynastySeed,proto3" json:"dynasty_seed,omitempty"` - DynastySeedLastReset uint64 `protobuf:"varint,13,opt,name=dynasty_seed_last_reset,json=dynastySeedLastReset,proto3" json:"dynasty_seed_last_reset,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + LastStateRecalc uint64 `protobuf:"varint,1,opt,name=last_state_recalc,json=lastStateRecalc,proto3" json:"last_state_recalc,omitempty"` + JustifiedStreak uint64 `protobuf:"varint,2,opt,name=justified_streak,json=justifiedStreak,proto3" json:"justified_streak,omitempty"` + LastJustifiedSlot uint64 `protobuf:"varint,3,opt,name=last_justified_slot,json=lastJustifiedSlot,proto3" json:"last_justified_slot,omitempty"` + LastFinalizedSlot uint64 `protobuf:"varint,4,opt,name=last_finalized_slot,json=lastFinalizedSlot,proto3" json:"last_finalized_slot,omitempty"` + CurrentDynasty uint64 `protobuf:"varint,5,opt,name=current_dynasty,json=currentDynasty,proto3" json:"current_dynasty,omitempty"` + CrosslinkingStartShard uint64 `protobuf:"varint,6,opt,name=crosslinking_start_shard,json=crosslinkingStartShard,proto3" json:"crosslinking_start_shard,omitempty"` + TotalDeposits uint64 `protobuf:"varint,7,opt,name=total_deposits,json=totalDeposits,proto3" json:"total_deposits,omitempty"` + DynastySeed []byte `protobuf:"bytes,8,opt,name=dynasty_seed,json=dynastySeed,proto3" json:"dynasty_seed,omitempty"` + DynastySeedLastReset uint64 `protobuf:"varint,9,opt,name=dynasty_seed_last_reset,json=dynastySeedLastReset,proto3" json:"dynasty_seed_last_reset,omitempty"` + CrosslinkRecords []*CrosslinkRecord `protobuf:"bytes,10,rep,name=crosslink_records,json=crosslinkRecords,proto3" json:"crosslink_records,omitempty"` + Validators []*ValidatorRecord `protobuf:"bytes,11,rep,name=validators,proto3" json:"validators,omitempty"` + IndicesForHeights []*ShardAndCommitteeArray `protobuf:"bytes,12,rep,name=indices_for_heights,json=indicesForHeights,proto3" json:"indices_for_heights,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *CrystallizedState) Reset() { *m = CrystallizedState{} } func (m *CrystallizedState) String() string { return proto.CompactTextString(m) } func (*CrystallizedState) ProtoMessage() {} func (*CrystallizedState) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{8} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{8} } func (m *CrystallizedState) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CrystallizedState.Unmarshal(m, b) @@ -438,95 +421,126 @@ func (m *CrystallizedState) XXX_DiscardUnknown() { var xxx_messageInfo_CrystallizedState proto.InternalMessageInfo -func (m *CrystallizedState) GetActiveValidators() []*ValidatorRecord { +func (m *CrystallizedState) GetLastStateRecalc() uint64 { if m != nil { - return m.ActiveValidators + return m.LastStateRecalc } - return nil + return 0 } -func (m *CrystallizedState) GetQueuedValidators() []*ValidatorRecord { +func (m *CrystallizedState) GetJustifiedStreak() uint64 { if m != nil { - return m.QueuedValidators + return m.JustifiedStreak } - return nil + return 0 } -func (m *CrystallizedState) GetExitedValidators() []*ValidatorRecord { +func (m *CrystallizedState) GetLastJustifiedSlot() uint64 { if m != nil { - return m.ExitedValidators + return m.LastJustifiedSlot } - return nil + return 0 } -func (m *CrystallizedState) GetCurrentEpochShuffling() []uint64 { +func (m *CrystallizedState) GetLastFinalizedSlot() uint64 { if m != nil { - return m.CurrentEpochShuffling + return m.LastFinalizedSlot } - return nil + return 0 } -func (m *CrystallizedState) GetCurrentEpoch() uint64 { +func (m *CrystallizedState) GetCurrentDynasty() uint64 { if m != nil { - return m.CurrentEpoch + return m.CurrentDynasty } return 0 } -func (m *CrystallizedState) GetLastJustifiedEpoch() uint64 { +func (m *CrystallizedState) GetCrosslinkingStartShard() uint64 { if m != nil { - return m.LastJustifiedEpoch + return m.CrosslinkingStartShard } return 0 } -func (m *CrystallizedState) GetLastFinalizedEpoch() uint64 { +func (m *CrystallizedState) GetTotalDeposits() uint64 { if m != nil { - return m.LastFinalizedEpoch + return m.TotalDeposits } return 0 } -func (m *CrystallizedState) GetCurrentDynasty() uint64 { +func (m *CrystallizedState) GetDynastySeed() []byte { if m != nil { - return m.CurrentDynasty + return m.DynastySeed } - return 0 + return nil } -func (m *CrystallizedState) GetNextShard() uint64 { +func (m *CrystallizedState) GetDynastySeedLastReset() uint64 { if m != nil { - return m.NextShard + return m.DynastySeedLastReset } return 0 } -func (m *CrystallizedState) GetCurrentCheckPoint() []byte { +func (m *CrystallizedState) GetCrosslinkRecords() []*CrosslinkRecord { if m != nil { - return m.CurrentCheckPoint + return m.CrosslinkRecords } return nil } -func (m *CrystallizedState) GetTotalDeposits() uint64 { +func (m *CrystallizedState) GetValidators() []*ValidatorRecord { if m != nil { - return m.TotalDeposits + return m.Validators } - return 0 + return nil } -func (m *CrystallizedState) GetDynastySeed() []byte { +func (m *CrystallizedState) GetIndicesForHeights() []*ShardAndCommitteeArray { if m != nil { - return m.DynastySeed + return m.IndicesForHeights } return nil } -func (m *CrystallizedState) GetDynastySeedLastReset() uint64 { +type ShardAndCommitteeArray struct { + ArrayShardAndCommittee []*ShardAndCommittee `protobuf:"bytes,1,rep,name=array_shard_and_committee,json=arrayShardAndCommittee,proto3" json:"array_shard_and_committee,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ShardAndCommitteeArray) Reset() { *m = ShardAndCommitteeArray{} } +func (m *ShardAndCommitteeArray) String() string { return proto.CompactTextString(m) } +func (*ShardAndCommitteeArray) ProtoMessage() {} +func (*ShardAndCommitteeArray) Descriptor() ([]byte, []int) { + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{9} +} +func (m *ShardAndCommitteeArray) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ShardAndCommitteeArray.Unmarshal(m, b) +} +func (m *ShardAndCommitteeArray) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ShardAndCommitteeArray.Marshal(b, m, deterministic) +} +func (dst *ShardAndCommitteeArray) XXX_Merge(src proto.Message) { + xxx_messageInfo_ShardAndCommitteeArray.Merge(dst, src) +} +func (m *ShardAndCommitteeArray) XXX_Size() int { + return xxx_messageInfo_ShardAndCommitteeArray.Size(m) +} +func (m *ShardAndCommitteeArray) XXX_DiscardUnknown() { + xxx_messageInfo_ShardAndCommitteeArray.DiscardUnknown(m) +} + +var xxx_messageInfo_ShardAndCommitteeArray proto.InternalMessageInfo + +func (m *ShardAndCommitteeArray) GetArrayShardAndCommittee() []*ShardAndCommittee { if m != nil { - return m.DynastySeedLastReset + return m.ArrayShardAndCommittee } - return 0 + return nil } type ActiveStateHashAnnounce struct { @@ -540,7 +554,7 @@ func (m *ActiveStateHashAnnounce) Reset() { *m = ActiveStateHashAnnounce func (m *ActiveStateHashAnnounce) String() string { return proto.CompactTextString(m) } func (*ActiveStateHashAnnounce) ProtoMessage() {} func (*ActiveStateHashAnnounce) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{9} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{10} } func (m *ActiveStateHashAnnounce) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ActiveStateHashAnnounce.Unmarshal(m, b) @@ -578,7 +592,7 @@ func (m *ActiveStateRequest) Reset() { *m = ActiveStateRequest{} } func (m *ActiveStateRequest) String() string { return proto.CompactTextString(m) } func (*ActiveStateRequest) ProtoMessage() {} func (*ActiveStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{10} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{11} } func (m *ActiveStateRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ActiveStateRequest.Unmarshal(m, b) @@ -605,6 +619,52 @@ func (m *ActiveStateRequest) GetHash() []byte { return nil } +type ShardAndCommittee struct { + ShardId uint64 `protobuf:"varint,1,opt,name=shard_id,json=shardId,proto3" json:"shard_id,omitempty"` + Committee []uint32 `protobuf:"varint,2,rep,packed,name=committee,proto3" json:"committee,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ShardAndCommittee) Reset() { *m = ShardAndCommittee{} } +func (m *ShardAndCommittee) String() string { return proto.CompactTextString(m) } +func (*ShardAndCommittee) ProtoMessage() {} +func (*ShardAndCommittee) Descriptor() ([]byte, []int) { + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{12} +} +func (m *ShardAndCommittee) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ShardAndCommittee.Unmarshal(m, b) +} +func (m *ShardAndCommittee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ShardAndCommittee.Marshal(b, m, deterministic) +} +func (dst *ShardAndCommittee) XXX_Merge(src proto.Message) { + xxx_messageInfo_ShardAndCommittee.Merge(dst, src) +} +func (m *ShardAndCommittee) XXX_Size() int { + return xxx_messageInfo_ShardAndCommittee.Size(m) +} +func (m *ShardAndCommittee) XXX_DiscardUnknown() { + xxx_messageInfo_ShardAndCommittee.DiscardUnknown(m) +} + +var xxx_messageInfo_ShardAndCommittee proto.InternalMessageInfo + +func (m *ShardAndCommittee) GetShardId() uint64 { + if m != nil { + return m.ShardId + } + return 0 +} + +func (m *ShardAndCommittee) GetCommittee() []uint32 { + if m != nil { + return m.Committee + } + return nil +} + type ActiveStateResponse struct { ActiveState *ActiveState `protobuf:"bytes,1,opt,name=active_state,json=activeState,proto3" json:"active_state,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -616,7 +676,7 @@ func (m *ActiveStateResponse) Reset() { *m = ActiveStateResponse{} } func (m *ActiveStateResponse) String() string { return proto.CompactTextString(m) } func (*ActiveStateResponse) ProtoMessage() {} func (*ActiveStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{11} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{13} } func (m *ActiveStateResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ActiveStateResponse.Unmarshal(m, b) @@ -644,18 +704,18 @@ func (m *ActiveStateResponse) GetActiveState() *ActiveState { } type ActiveState struct { - TotalAttesterDeposits uint64 `protobuf:"varint,1,opt,name=total_attester_deposits,json=totalAttesterDeposits,proto3" json:"total_attester_deposits,omitempty"` - AttesterBitfield []byte `protobuf:"bytes,2,opt,name=attester_bitfield,json=attesterBitfield,proto3" json:"attester_bitfield,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + PendingAttestations []*AttestationRecord `protobuf:"bytes,1,rep,name=pending_attestations,json=pendingAttestations,proto3" json:"pending_attestations,omitempty"` + RecentBlockHashes [][]byte `protobuf:"bytes,2,rep,name=recent_block_hashes,json=recentBlockHashes,proto3" json:"recent_block_hashes,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *ActiveState) Reset() { *m = ActiveState{} } func (m *ActiveState) String() string { return proto.CompactTextString(m) } func (*ActiveState) ProtoMessage() {} func (*ActiveState) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{12} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{14} } func (m *ActiveState) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ActiveState.Unmarshal(m, b) @@ -675,78 +735,16 @@ func (m *ActiveState) XXX_DiscardUnknown() { var xxx_messageInfo_ActiveState proto.InternalMessageInfo -func (m *ActiveState) GetTotalAttesterDeposits() uint64 { +func (m *ActiveState) GetPendingAttestations() []*AttestationRecord { if m != nil { - return m.TotalAttesterDeposits - } - return 0 -} - -func (m *ActiveState) GetAttesterBitfield() []byte { - if m != nil { - return m.AttesterBitfield + return m.PendingAttestations } return nil } -type AggregateVote struct { - ShardId uint32 `protobuf:"varint,1,opt,name=shard_id,json=shardId,proto3" json:"shard_id,omitempty"` - ShardBlockHash []byte `protobuf:"bytes,2,opt,name=shard_block_hash,json=shardBlockHash,proto3" json:"shard_block_hash,omitempty"` - SignerBitmask []byte `protobuf:"bytes,3,opt,name=signer_bitmask,json=signerBitmask,proto3" json:"signer_bitmask,omitempty"` - AggregateSig []uint32 `protobuf:"varint,4,rep,packed,name=aggregate_sig,json=aggregateSig,proto3" json:"aggregate_sig,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *AggregateVote) Reset() { *m = AggregateVote{} } -func (m *AggregateVote) String() string { return proto.CompactTextString(m) } -func (*AggregateVote) ProtoMessage() {} -func (*AggregateVote) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{13} -} -func (m *AggregateVote) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AggregateVote.Unmarshal(m, b) -} -func (m *AggregateVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AggregateVote.Marshal(b, m, deterministic) -} -func (dst *AggregateVote) XXX_Merge(src proto.Message) { - xxx_messageInfo_AggregateVote.Merge(dst, src) -} -func (m *AggregateVote) XXX_Size() int { - return xxx_messageInfo_AggregateVote.Size(m) -} -func (m *AggregateVote) XXX_DiscardUnknown() { - xxx_messageInfo_AggregateVote.DiscardUnknown(m) -} - -var xxx_messageInfo_AggregateVote proto.InternalMessageInfo - -func (m *AggregateVote) GetShardId() uint32 { +func (m *ActiveState) GetRecentBlockHashes() [][]byte { if m != nil { - return m.ShardId - } - return 0 -} - -func (m *AggregateVote) GetShardBlockHash() []byte { - if m != nil { - return m.ShardBlockHash - } - return nil -} - -func (m *AggregateVote) GetSignerBitmask() []byte { - if m != nil { - return m.SignerBitmask - } - return nil -} - -func (m *AggregateVote) GetAggregateSig() []uint32 { - if m != nil { - return m.AggregateSig + return m.RecentBlockHashes } return nil } @@ -757,7 +755,8 @@ type ValidatorRecord struct { WithdrawalAddress []byte `protobuf:"bytes,3,opt,name=withdrawal_address,json=withdrawalAddress,proto3" json:"withdrawal_address,omitempty"` RandaoCommitment []byte `protobuf:"bytes,4,opt,name=randao_commitment,json=randaoCommitment,proto3" json:"randao_commitment,omitempty"` Balance uint64 `protobuf:"varint,5,opt,name=balance,proto3" json:"balance,omitempty"` - SwitchDynasty uint64 `protobuf:"varint,6,opt,name=switch_dynasty,json=switchDynasty,proto3" json:"switch_dynasty,omitempty"` + StartDynasty uint64 `protobuf:"varint,6,opt,name=start_dynasty,json=startDynasty,proto3" json:"start_dynasty,omitempty"` + EndDynasty uint64 `protobuf:"varint,7,opt,name=end_dynasty,json=endDynasty,proto3" json:"end_dynasty,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -767,7 +766,7 @@ func (m *ValidatorRecord) Reset() { *m = ValidatorRecord{} } func (m *ValidatorRecord) String() string { return proto.CompactTextString(m) } func (*ValidatorRecord) ProtoMessage() {} func (*ValidatorRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_messages_bc6e7d0a50c57853, []int{14} + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{15} } func (m *ValidatorRecord) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ValidatorRecord.Unmarshal(m, b) @@ -822,13 +821,144 @@ func (m *ValidatorRecord) GetBalance() uint64 { return 0 } -func (m *ValidatorRecord) GetSwitchDynasty() uint64 { +func (m *ValidatorRecord) GetStartDynasty() uint64 { + if m != nil { + return m.StartDynasty + } + return 0 +} + +func (m *ValidatorRecord) GetEndDynasty() uint64 { if m != nil { - return m.SwitchDynasty + return m.EndDynasty + } + return 0 +} + +type AttestationRecord struct { + Slot uint64 `protobuf:"varint,1,opt,name=slot,proto3" json:"slot,omitempty"` + ShardId uint64 `protobuf:"varint,2,opt,name=shard_id,json=shardId,proto3" json:"shard_id,omitempty"` + ShardBlockHash []byte `protobuf:"bytes,3,opt,name=shard_block_hash,json=shardBlockHash,proto3" json:"shard_block_hash,omitempty"` + AttesterBitfield []byte `protobuf:"bytes,4,opt,name=attester_bitfield,json=attesterBitfield,proto3" json:"attester_bitfield,omitempty"` + ObliqueParentHashes [][]byte `protobuf:"bytes,5,rep,name=oblique_parent_hashes,json=obliqueParentHashes,proto3" json:"oblique_parent_hashes,omitempty"` + AggregateSig []uint64 `protobuf:"varint,6,rep,packed,name=aggregate_sig,json=aggregateSig,proto3" json:"aggregate_sig,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AttestationRecord) Reset() { *m = AttestationRecord{} } +func (m *AttestationRecord) String() string { return proto.CompactTextString(m) } +func (*AttestationRecord) ProtoMessage() {} +func (*AttestationRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{16} +} +func (m *AttestationRecord) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_AttestationRecord.Unmarshal(m, b) +} +func (m *AttestationRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_AttestationRecord.Marshal(b, m, deterministic) +} +func (dst *AttestationRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_AttestationRecord.Merge(dst, src) +} +func (m *AttestationRecord) XXX_Size() int { + return xxx_messageInfo_AttestationRecord.Size(m) +} +func (m *AttestationRecord) XXX_DiscardUnknown() { + xxx_messageInfo_AttestationRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_AttestationRecord proto.InternalMessageInfo + +func (m *AttestationRecord) GetSlot() uint64 { + if m != nil { + return m.Slot + } + return 0 +} + +func (m *AttestationRecord) GetShardId() uint64 { + if m != nil { + return m.ShardId } return 0 } +func (m *AttestationRecord) GetShardBlockHash() []byte { + if m != nil { + return m.ShardBlockHash + } + return nil +} + +func (m *AttestationRecord) GetAttesterBitfield() []byte { + if m != nil { + return m.AttesterBitfield + } + return nil +} + +func (m *AttestationRecord) GetObliqueParentHashes() [][]byte { + if m != nil { + return m.ObliqueParentHashes + } + return nil +} + +func (m *AttestationRecord) GetAggregateSig() []uint64 { + if m != nil { + return m.AggregateSig + } + return nil +} + +type CrosslinkRecord struct { + Dynasty uint64 `protobuf:"varint,1,opt,name=dynasty,proto3" json:"dynasty,omitempty"` + Blockhash []byte `protobuf:"bytes,2,opt,name=blockhash,proto3" json:"blockhash,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CrosslinkRecord) Reset() { *m = CrosslinkRecord{} } +func (m *CrosslinkRecord) String() string { return proto.CompactTextString(m) } +func (*CrosslinkRecord) ProtoMessage() {} +func (*CrosslinkRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_messages_fd49ec7a0f54a90f, []int{17} +} +func (m *CrosslinkRecord) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CrosslinkRecord.Unmarshal(m, b) +} +func (m *CrosslinkRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CrosslinkRecord.Marshal(b, m, deterministic) +} +func (dst *CrosslinkRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_CrosslinkRecord.Merge(dst, src) +} +func (m *CrosslinkRecord) XXX_Size() int { + return xxx_messageInfo_CrosslinkRecord.Size(m) +} +func (m *CrosslinkRecord) XXX_DiscardUnknown() { + xxx_messageInfo_CrosslinkRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_CrosslinkRecord proto.InternalMessageInfo + +func (m *CrosslinkRecord) GetDynasty() uint64 { + if m != nil { + return m.Dynasty + } + return 0 +} + +func (m *CrosslinkRecord) GetBlockhash() []byte { + if m != nil { + return m.Blockhash + } + return nil +} + func init() { proto.RegisterType((*BeaconBlockHashAnnounce)(nil), "ethereum.beacon.p2p.v1.BeaconBlockHashAnnounce") proto.RegisterType((*BeaconBlockRequest)(nil), "ethereum.beacon.p2p.v1.BeaconBlockRequest") @@ -839,82 +969,89 @@ func init() { proto.RegisterType((*CrystallizedStateRequest)(nil), "ethereum.beacon.p2p.v1.CrystallizedStateRequest") proto.RegisterType((*CrystallizedStateResponse)(nil), "ethereum.beacon.p2p.v1.CrystallizedStateResponse") proto.RegisterType((*CrystallizedState)(nil), "ethereum.beacon.p2p.v1.CrystallizedState") + proto.RegisterType((*ShardAndCommitteeArray)(nil), "ethereum.beacon.p2p.v1.ShardAndCommitteeArray") proto.RegisterType((*ActiveStateHashAnnounce)(nil), "ethereum.beacon.p2p.v1.ActiveStateHashAnnounce") proto.RegisterType((*ActiveStateRequest)(nil), "ethereum.beacon.p2p.v1.ActiveStateRequest") + proto.RegisterType((*ShardAndCommittee)(nil), "ethereum.beacon.p2p.v1.ShardAndCommittee") proto.RegisterType((*ActiveStateResponse)(nil), "ethereum.beacon.p2p.v1.ActiveStateResponse") proto.RegisterType((*ActiveState)(nil), "ethereum.beacon.p2p.v1.ActiveState") - proto.RegisterType((*AggregateVote)(nil), "ethereum.beacon.p2p.v1.AggregateVote") proto.RegisterType((*ValidatorRecord)(nil), "ethereum.beacon.p2p.v1.ValidatorRecord") -} - -func init() { - proto.RegisterFile("proto/beacon/p2p/v1/messages.proto", fileDescriptor_messages_bc6e7d0a50c57853) -} - -var fileDescriptor_messages_bc6e7d0a50c57853 = []byte{ - // 1023 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x5f, 0x6f, 0xdb, 0x36, - 0x10, 0x47, 0x1a, 0x27, 0x69, 0xce, 0x76, 0x12, 0x33, 0xcd, 0xa2, 0x14, 0xe8, 0x9a, 0x39, 0x2b, - 0xea, 0x6e, 0xa8, 0xbc, 0xa6, 0xd8, 0xb0, 0xed, 0xcd, 0x49, 0x57, 0xec, 0x1f, 0x86, 0x42, 0x2e, - 0x8a, 0xed, 0x61, 0x10, 0x68, 0xe9, 0x6c, 0x71, 0x91, 0x44, 0x55,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, 0x09, 0x93, 0x09, 0xa6, 0xb2, 0xdc, 0xc9, 0x7b, 0x86, 0x38, 0xaf, - 0x71, 0xe2, 0xc0, 0xd6, 0x84, 0xc6, 0x34, 0x0d, 0xb0, 0xbc, 0x04, 0xaa, 0x47, 0x5d, 0x9f, 0x4b, - 0x26, 0x83, 0xa8, 0x1e, 0x4d, 0x33, 0xf9, 0x5d, 0x83, 0x96, 0x93, 0x39, 0xd9, 0xd4, 0x6b, 0xe9, - 0xf9, 0xfb, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x02, 0xbd, 0x37, 0xce, 0x09, 0x00, 0x00, + proto.RegisterType((*AttestationRecord)(nil), "ethereum.beacon.p2p.v1.AttestationRecord") + proto.RegisterType((*CrosslinkRecord)(nil), "ethereum.beacon.p2p.v1.CrosslinkRecord") +} + +func init() { proto.RegisterFile("messages.proto", fileDescriptor_messages_fd49ec7a0f54a90f) } + +var fileDescriptor_messages_fd49ec7a0f54a90f = []byte{ + // 1113 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x5f, 0x6f, 0x1b, 0x45, + 0x10, 0x97, 0x13, 0xe7, 0xdf, 0xd8, 0x89, 0xe3, 0x75, 0x9b, 0x5c, 0x2a, 0x4a, 0xc2, 0x55, 0xa8, + 0x29, 0xa8, 0x57, 0x91, 0x0a, 0x54, 0x1e, 0x9d, 0x54, 0xa1, 0x85, 0x82, 0xaa, 0x73, 0x85, 0x78, + 0x00, 0x4e, 0xeb, 0xdb, 0xb1, 0xbd, 0xe4, 0x7c, 0xeb, 0xee, 0xae, 0x13, 0x99, 0x07, 0xde, 0xf8, + 0x0c, 0x3c, 0xf0, 0x19, 0xf8, 0x72, 0x7c, 0x02, 0xb4, 0x7f, 0xee, 0x7c, 0x8e, 0x93, 0x54, 0xbc, + 0xdd, 0xfd, 0xe6, 0x37, 0x73, 0x33, 0xb3, 0xb3, 0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, 0xcb, 0xdf, 0xb1, 0x78, 0x79, 0x14, 0xa6, + 0x76, 0x37, 0x0e, 0x28, 0x93, 0x3e, 0xd7, 0x03, 0x8e, 0x19, 0x2b, 0x6a, 0x2f, 0x0c, 0xa7, 0x1e, + 0x27, 0x27, 0x70, 0x5f, 0xf4, 0x33, 0xfe, 0x7e, 0x8a, 0x49, 0xe5, 0x2f, 0x07, 0x55, 0xb0, 0x66, + 0xcf, 0xb9, 0xe3, 0x8d, 0x6f, 0xcb, 0xdf, 0x1d, 0x54, 0xa6, 0x2b, 0x74, 0x38, 0x94, 0x38, 0x34, + 0x6b, 0x4a, 0xf1, 0x61, 0xb0, 0x7e, 0xb4, 0x6a, 0xba, 0x52, 0x82, 0x3d, 0x3e, 0x0c, 0x5f, 0x43, + 0xeb, 0x9a, 0x00, 0x9a, 0x3e, 0x17, 0x4d, 0xf2, 0xd7, 0xca, 0xbf, 0x9a, 0x6b, 0x65, 0xcb, 0xb2, + 0x55, 0xad, 0xd8, 0x54, 0xe7, 0x40, 0x7f, 0xdd, 0xfe, 0x77, 0x3c, 0xff, 0x2f, 0x00, 0x00, 0xff, + 0xff, 0x78, 0xcf, 0x39, 0xe2, 0xd1, 0x0a, 0x00, 0x00, } diff --git a/proto/beacon/p2p/v1/messages.proto b/proto/beacon/p2p/v1/messages.proto index c34309d22118..6877b9e0cbbc 100644 --- a/proto/beacon/p2p/v1/messages.proto +++ b/proto/beacon/p2p/v1/messages.proto @@ -24,13 +24,11 @@ message BeaconBlock { bytes parent_hash = 1; uint64 slot_number = 2; bytes randao_reveal = 3; - bytes attestation_bitmask = 4; - repeated uint32 attestation_aggregate_sig = 5; - repeated AggregateVote shard_aggregate_votes = 6; - bytes main_chain_ref = 7; - bytes active_state_hash = 8; - bytes crystallized_state_hash = 9; - google.protobuf.Timestamp timestamp = 10; + bytes pow_chain_ref = 4; + bytes active_state_hash = 5; + bytes crystallized_state_hash = 6; + google.protobuf.Timestamp timestamp = 7; + repeated AttestationRecord attestations = 8; } message CrystallizedStateHashAnnounce { @@ -46,19 +44,22 @@ message CrystallizedStateResponse { } message CrystallizedState { - repeated ValidatorRecord active_validators = 1; - repeated ValidatorRecord queued_validators = 2; - repeated ValidatorRecord exited_validators = 3; - repeated uint64 current_epoch_shuffling = 4; - uint64 current_epoch = 5; - uint64 last_justified_epoch = 6; - uint64 last_finalized_epoch = 7; - uint64 current_dynasty = 8; - uint64 next_shard = 9; - bytes current_check_point = 10; - uint64 total_deposits = 11; - bytes dynasty_seed = 12; - uint64 dynasty_seed_last_reset = 13; + uint64 last_state_recalc = 1; + uint64 justified_streak = 2; + uint64 last_justified_slot = 3; + uint64 last_finalized_slot = 4; + uint64 current_dynasty = 5; + uint64 crosslinking_start_shard = 6; + uint64 total_deposits = 7; + bytes dynasty_seed = 8; + uint64 dynasty_seed_last_reset = 9; + repeated CrosslinkRecord crosslink_records = 10; + repeated ValidatorRecord validators = 11; + repeated ShardAndCommitteeArray indices_for_heights = 12; +} + +message ShardAndCommitteeArray { + repeated ShardAndCommittee array_shard_and_committee = 1; } message ActiveStateHashAnnounce { @@ -69,20 +70,18 @@ message ActiveStateRequest { bytes hash = 1; } +message ShardAndCommittee { + uint64 shard_id = 1; + repeated uint32 committee = 2; +} + message ActiveStateResponse { ActiveState active_state = 1; } message ActiveState { - uint64 total_attester_deposits = 1; - bytes attester_bitfield = 2; -} - -message AggregateVote { - uint32 shard_id = 1; - bytes shard_block_hash = 2; - bytes signer_bitmask = 3; - repeated uint32 aggregate_sig = 4; + repeated AttestationRecord pending_attestations = 1; + repeated bytes recent_block_hashes = 2; } message ValidatorRecord { @@ -91,5 +90,20 @@ message ValidatorRecord { bytes withdrawal_address = 3; bytes randao_commitment = 4; uint64 balance = 5; - uint64 switch_dynasty = 6; + uint64 start_dynasty = 6; + uint64 end_dynasty = 7; +} + +message AttestationRecord { + uint64 slot = 1; + uint64 shard_id = 2; + bytes shard_block_hash = 3; + bytes attester_bitfield = 4; + repeated bytes oblique_parent_hashes = 5; + repeated uint64 aggregate_sig = 6; } + +message CrosslinkRecord { + uint64 dynasty = 1; + bytes blockhash = 2; +} \ No newline at end of file diff --git a/proto/beacon/rpc/v1/services.pb.go b/proto/beacon/rpc/v1/services.pb.go index 54f2dd7c67ca..234a1b2aaaad 100644 --- a/proto/beacon/rpc/v1/services.pb.go +++ b/proto/beacon/rpc/v1/services.pb.go @@ -7,8 +7,8 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import empty "github.com/golang/protobuf/ptypes/empty" -import v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" -import v11 "github.com/prysmaticlabs/prysm/proto/sharding/p2p/v1" +import v11 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" +import v1 "github.com/prysmaticlabs/prysm/proto/sharding/p2p/v1" import ( context "golang.org/x/net/context" @@ -37,7 +37,7 @@ func (m *ShuffleRequest) Reset() { *m = ShuffleRequest{} } func (m *ShuffleRequest) String() string { return proto.CompactTextString(m) } func (*ShuffleRequest) ProtoMessage() {} func (*ShuffleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_services_dd4dfbcfce50f511, []int{0} + return fileDescriptor_services_8cc913424e1d367a, []int{0} } func (m *ShuffleRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ShuffleRequest.Unmarshal(m, b) @@ -77,7 +77,7 @@ func (m *ShuffleResponse) Reset() { *m = ShuffleResponse{} } func (m *ShuffleResponse) String() string { return proto.CompactTextString(m) } func (*ShuffleResponse) ProtoMessage() {} func (*ShuffleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_services_dd4dfbcfce50f511, []int{1} + return fileDescriptor_services_8cc913424e1d367a, []int{1} } func (m *ShuffleResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ShuffleResponse.Unmarshal(m, b) @@ -119,20 +119,19 @@ func (m *ShuffleResponse) GetAssignedAttestationHeights() []uint64 { } type ProposeRequest struct { - RandaoReveal []byte `protobuf:"bytes,1,opt,name=randao_reveal,json=randaoReveal,proto3" json:"randao_reveal,omitempty"` - AttestationBitmask []byte `protobuf:"bytes,2,opt,name=attestation_bitmask,json=attestationBitmask,proto3" json:"attestation_bitmask,omitempty"` - AttestationAggregateSig []uint32 `protobuf:"varint,3,rep,packed,name=attestation_aggregate_sig,json=attestationAggregateSig,proto3" json:"attestation_aggregate_sig,omitempty"` - ShardAggregateVotes []*v1.AggregateVote `protobuf:"bytes,5,rep,name=shard_aggregate_votes,json=shardAggregateVotes,proto3" json:"shard_aggregate_votes,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + RandaoReveal []byte `protobuf:"bytes,1,opt,name=randao_reveal,json=randaoReveal,proto3" json:"randao_reveal,omitempty"` + AttestationBitmask []byte `protobuf:"bytes,2,opt,name=attestation_bitmask,json=attestationBitmask,proto3" json:"attestation_bitmask,omitempty"` + AttestationAggregateSig []uint32 `protobuf:"varint,3,rep,packed,name=attestation_aggregate_sig,json=attestationAggregateSig,proto3" json:"attestation_aggregate_sig,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *ProposeRequest) Reset() { *m = ProposeRequest{} } func (m *ProposeRequest) String() string { return proto.CompactTextString(m) } func (*ProposeRequest) ProtoMessage() {} func (*ProposeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_services_dd4dfbcfce50f511, []int{2} + return fileDescriptor_services_8cc913424e1d367a, []int{2} } func (m *ProposeRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ProposeRequest.Unmarshal(m, b) @@ -173,13 +172,6 @@ func (m *ProposeRequest) GetAttestationAggregateSig() []uint32 { return nil } -func (m *ProposeRequest) GetShardAggregateVotes() []*v1.AggregateVote { - if m != nil { - return m.ShardAggregateVotes - } - return nil -} - type ProposeResponse struct { BlockHash []byte `protobuf:"bytes,1,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -191,7 +183,7 @@ func (m *ProposeResponse) Reset() { *m = ProposeResponse{} } func (m *ProposeResponse) String() string { return proto.CompactTextString(m) } func (*ProposeResponse) ProtoMessage() {} func (*ProposeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_services_dd4dfbcfce50f511, []int{3} + return fileDescriptor_services_8cc913424e1d367a, []int{3} } func (m *ProposeResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ProposeResponse.Unmarshal(m, b) @@ -219,18 +211,18 @@ func (m *ProposeResponse) GetBlockHash() []byte { } type SignRequest struct { - BlockHash []byte `protobuf:"bytes,1,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` - Signature *v11.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + BlockHash []byte `protobuf:"bytes,1,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` + Signature *v1.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *SignRequest) Reset() { *m = SignRequest{} } func (m *SignRequest) String() string { return proto.CompactTextString(m) } func (*SignRequest) ProtoMessage() {} func (*SignRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_services_dd4dfbcfce50f511, []int{4} + return fileDescriptor_services_8cc913424e1d367a, []int{4} } func (m *SignRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignRequest.Unmarshal(m, b) @@ -257,7 +249,7 @@ func (m *SignRequest) GetBlockHash() []byte { return nil } -func (m *SignRequest) GetSignature() *v11.Signature { +func (m *SignRequest) GetSignature() *v1.Signature { if m != nil { return m.Signature } @@ -275,7 +267,7 @@ func (m *SignResponse) Reset() { *m = SignResponse{} } func (m *SignResponse) String() string { return proto.CompactTextString(m) } func (*SignResponse) ProtoMessage() {} func (*SignResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_services_dd4dfbcfce50f511, []int{5} + return fileDescriptor_services_8cc913424e1d367a, []int{5} } func (m *SignResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignResponse.Unmarshal(m, b) @@ -352,7 +344,7 @@ func (c *beaconServiceClient) LatestBeaconBlock(ctx context.Context, in *empty.E } type BeaconService_LatestBeaconBlockClient interface { - Recv() (*v1.BeaconBlock, error) + Recv() (*v11.BeaconBlock, error) grpc.ClientStream } @@ -360,8 +352,8 @@ type beaconServiceLatestBeaconBlockClient struct { grpc.ClientStream } -func (x *beaconServiceLatestBeaconBlockClient) Recv() (*v1.BeaconBlock, error) { - m := new(v1.BeaconBlock) +func (x *beaconServiceLatestBeaconBlockClient) Recv() (*v11.BeaconBlock, error) { + m := new(v11.BeaconBlock) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } @@ -384,7 +376,7 @@ func (c *beaconServiceClient) LatestCrystallizedState(ctx context.Context, in *e } type BeaconService_LatestCrystallizedStateClient interface { - Recv() (*v1.CrystallizedState, error) + Recv() (*v11.CrystallizedState, error) grpc.ClientStream } @@ -392,8 +384,8 @@ type beaconServiceLatestCrystallizedStateClient struct { grpc.ClientStream } -func (x *beaconServiceLatestCrystallizedStateClient) Recv() (*v1.CrystallizedState, error) { - m := new(v1.CrystallizedState) +func (x *beaconServiceLatestCrystallizedStateClient) Recv() (*v11.CrystallizedState, error) { + m := new(v11.CrystallizedState) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } @@ -429,7 +421,7 @@ func _BeaconService_LatestBeaconBlock_Handler(srv interface{}, stream grpc.Serve } type BeaconService_LatestBeaconBlockServer interface { - Send(*v1.BeaconBlock) error + Send(*v11.BeaconBlock) error grpc.ServerStream } @@ -437,7 +429,7 @@ type beaconServiceLatestBeaconBlockServer struct { grpc.ServerStream } -func (x *beaconServiceLatestBeaconBlockServer) Send(m *v1.BeaconBlock) error { +func (x *beaconServiceLatestBeaconBlockServer) Send(m *v11.BeaconBlock) error { return x.ServerStream.SendMsg(m) } @@ -450,7 +442,7 @@ func _BeaconService_LatestCrystallizedState_Handler(srv interface{}, stream grpc } type BeaconService_LatestCrystallizedStateServer interface { - Send(*v1.CrystallizedState) error + Send(*v11.CrystallizedState) error grpc.ServerStream } @@ -458,7 +450,7 @@ type beaconServiceLatestCrystallizedStateServer struct { grpc.ServerStream } -func (x *beaconServiceLatestCrystallizedStateServer) Send(m *v1.CrystallizedState) error { +func (x *beaconServiceLatestCrystallizedStateServer) Send(m *v11.CrystallizedState) error { return x.ServerStream.SendMsg(m) } @@ -633,48 +625,46 @@ var _ProposerService_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("proto/beacon/rpc/v1/services.proto", fileDescriptor_services_dd4dfbcfce50f511) -} - -var fileDescriptor_services_dd4dfbcfce50f511 = []byte{ - // 618 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x51, 0x6b, 0xd4, 0x40, - 0x10, 0x26, 0xad, 0x16, 0x3b, 0xbd, 0x6b, 0x71, 0x4b, 0xdb, 0x33, 0x5a, 0x28, 0x77, 0x6d, 0xad, - 0x2f, 0x49, 0x7b, 0x82, 0x0f, 0xe2, 0x83, 0xad, 0x28, 0x15, 0x7c, 0x90, 0x04, 0x0a, 0xbe, 0x18, - 0xf6, 0x92, 0xb9, 0x64, 0x69, 0x2e, 0x1b, 0x77, 0xf7, 0x02, 0xf5, 0x7f, 0x09, 0xfe, 0x39, 0x41, - 0xb2, 0x9b, 0xe4, 0x72, 0x67, 0x53, 0x1f, 0x33, 0xf3, 0x7d, 0x33, 0xb3, 0xdf, 0xcc, 0x17, 0x18, - 0xe6, 0x82, 0x2b, 0xee, 0x4e, 0x90, 0x86, 0x3c, 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7a, 0x0b, 0xd6, 0xf0, 0x14, 0x7a, 0xa6, 0x61, 0x35, 0xdf, 0x3e, 0x6c, - 0x98, 0x75, 0xea, 0x6e, 0x4f, 0xbc, 0xea, 0x6b, 0xfc, 0x6b, 0x0d, 0xfa, 0x57, 0xfa, 0xfd, 0xbe, - 0xf1, 0x19, 0xf1, 0xe0, 0xe9, 0x17, 0x5a, 0x4a, 0x6a, 0xc2, 0x57, 0xe5, 0x54, 0x64, 0xdf, 0x31, - 0xa6, 0x70, 0x6a, 0x53, 0x38, 0x1f, 0x4b, 0x53, 0xd8, 0xa3, 0x2e, 0x15, 0x5b, 0xe4, 0x73, 0x8b, - 0x7c, 0x87, 0x03, 0x53, 0xf3, 0xc3, 0xaa, 0x15, 0x3a, 0x2b, 0xbf, 0xea, 0xaa, 0xfc, 0x4f, 0x89, - 0x73, 0x8b, 0xe4, 0x70, 0xf8, 0x09, 0x55, 0x98, 0xf8, 0x5d, 0xd6, 0x38, 0x75, 0xee, 0xff, 0x6d, - 0x38, 0xcb, 0x66, 0xb6, 0x5f, 0xfe, 0x17, 0x67, 0xf4, 0x1c, 0x33, 0xd8, 0x31, 0xc6, 0x40, 0x51, - 0x0b, 0x77, 0x03, 0x9b, 0xa5, 0xe4, 0x46, 0xb0, 0x51, 0x67, 0xa1, 0xc5, 0x19, 0xd8, 0xc7, 0x0f, - 0x83, 0xaa, 0x56, 0xa2, 0xb9, 0xb6, 0xa6, 0x55, 0x00, 0xbd, 0x2a, 0x64, 0xba, 0x75, 0x3e, 0x6f, - 0xd9, 0xa5, 0xdd, 0xcf, 0x5b, 0x39, 0xe7, 0xc9, 0x86, 0xde, 0xc6, 0xeb, 0xbf, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x0d, 0xf4, 0x6b, 0xb7, 0x92, 0x05, 0x00, 0x00, + proto.RegisterFile("proto/beacon/rpc/v1/services.proto", fileDescriptor_services_8cc913424e1d367a) +} + +var fileDescriptor_services_8cc913424e1d367a = []byte{ + // 587 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x5f, 0x4f, 0xd4, 0x4e, + 0x14, 0x4d, 0xe1, 0x17, 0xf2, 0xe3, 0xb2, 0x0b, 0x71, 0x8c, 0xb0, 0x56, 0x49, 0xc8, 0x82, 0x88, + 0x2f, 0x53, 0x58, 0x13, 0x1f, 0x8c, 0x0f, 0x82, 0xd1, 0x60, 0xe2, 0x83, 0x69, 0x13, 0x1e, 0x6d, + 0x66, 0xdb, 0xbb, 0xd3, 0x09, 0xdd, 0x4e, 0x9d, 0x99, 0xdd, 0x04, 0x3f, 0x8e, 0xdf, 0xc1, 0xc4, + 0x8f, 0x67, 0x3a, 0xd3, 0x96, 0x2e, 0x52, 0x7c, 0x9c, 0x7b, 0xcf, 0xb9, 0x7f, 0xce, 0x9c, 0x0b, + 0xe3, 0x52, 0x49, 0x23, 0x83, 0x29, 0xb2, 0x44, 0x16, 0x81, 0x2a, 0x93, 0x60, 0x79, 0x16, 0x68, + 0x54, 0x4b, 0x91, 0xa0, 0xa6, 0x36, 0x49, 0x76, 0xd1, 0x64, 0xa8, 0x70, 0x31, 0xa7, 0x0e, 0x46, + 0x55, 0x99, 0xd0, 0xe5, 0x99, 0x7f, 0xe4, 0xb8, 0x3a, 0x63, 0x2a, 0x15, 0x05, 0x0f, 0xca, 0x49, + 0x59, 0xb1, 0xe7, 0xa8, 0x35, 0xe3, 0x0d, 0xdb, 0x5f, 0xed, 0x70, 0x3f, 0xe6, 0x19, 0x97, 0x92, + 0xe7, 0x18, 0xd8, 0xd7, 0x74, 0x31, 0x0b, 0x70, 0x5e, 0x9a, 0x1b, 0x97, 0x1c, 0x5f, 0xc2, 0x76, + 0x94, 0x2d, 0x66, 0xb3, 0x1c, 0x43, 0xfc, 0xbe, 0x40, 0x6d, 0xc8, 0x1b, 0xd8, 0x4b, 0xd4, 0x8d, + 0x36, 0x2c, 0xcf, 0x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ff, + 0xe8, 0x61, 0x50, 0xdd, 0x4a, 0xb5, 0x6e, 0x6b, 0x5b, 0xc5, 0x30, 0xa8, 0x43, 0xae, 0x5b, 0xef, + 0x7a, 0xab, 0xa7, 0xd4, 0xbf, 0xde, 0x1d, 0x3b, 0x4f, 0x37, 0xec, 0x6f, 0xbc, 0xfe, 0x13, 0x00, + 0x00, 0xff, 0xff, 0x0a, 0x10, 0x58, 0x49, 0x37, 0x05, 0x00, 0x00, } diff --git a/proto/beacon/rpc/v1/services.proto b/proto/beacon/rpc/v1/services.proto index 606897d62177..cc3f9946d430 100644 --- a/proto/beacon/rpc/v1/services.proto +++ b/proto/beacon/rpc/v1/services.proto @@ -34,7 +34,6 @@ message ProposeRequest { bytes randao_reveal = 1; bytes attestation_bitmask = 2; repeated uint32 attestation_aggregate_sig = 3; - repeated ethereum.beacon.p2p.v1.AggregateVote shard_aggregate_votes = 5; } message ProposeResponse { @@ -48,4 +47,4 @@ message SignRequest { message SignResponse { bool signed = 1; -} +} \ No newline at end of file