Update ChainHead (#4053)

* Can build

* All tests pass

* Update beacon-chain/blockchain/chain_info.go

* Fix context

* Update chainhead

* Tests

* Tests

* e2e

* Update ordering

* Typo

* Use root to get slot

* Division
This commit is contained in:
terence tsao
2019-11-19 11:33:13 -08:00
committed by Raul Jordan
parent 26da7c4114
commit 7a22e98c0f
22 changed files with 519 additions and 289 deletions

View File

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