Added roughtime to validator waitToSlotMidpoint (#3344)

* add roughtime to validator waitToSlotMidpoint

* gazelle
This commit is contained in:
skillful-alex 2019-08-28 22:59:30 +03:00 committed by Raul Jordan
parent 5d7c33a8dc
commit 9e5864fc61
3 changed files with 11 additions and 7 deletions

View File

@ -20,6 +20,7 @@ go_library(
"//shared/keystore:go_default_library",
"//shared/mathutil:go_default_library",
"//shared/params:go_default_library",
"//shared/roughtime:go_default_library",
"//shared/slotutil:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_pkg_errors//:go_default_library",
@ -54,6 +55,7 @@ go_test(
"//shared:go_default_library",
"//shared/keystore:go_default_library",
"//shared/params:go_default_library",
"//shared/roughtime:go_default_library",
"//shared/testutil:go_default_library",
"//validator/accounts:go_default_library",
"//validator/internal:go_default_library",

View File

@ -7,14 +7,15 @@ import (
"fmt"
"time"
"github.com/prysmaticlabs/go-bitfield"
"github.com/prysmaticlabs/go-ssz"
bitfield "github.com/prysmaticlabs/go-bitfield"
ssz "github.com/prysmaticlabs/go-ssz"
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/mathutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/roughtime"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
)
@ -150,5 +151,5 @@ func (v *validator) waitToSlotMidpoint(ctx context.Context, slot uint64) {
duration := time.Duration(slot*params.BeaconConfig().SecondsPerSlot+delay) * time.Second
timeToBroadcast := time.Unix(int64(v.genesisTime), 0).Add(duration)
time.Sleep(time.Until(timeToBroadcast))
time.Sleep(roughtime.Until(timeToBroadcast))
}

View File

@ -10,11 +10,12 @@ import (
"github.com/gogo/protobuf/proto"
"github.com/golang/mock/gomock"
"github.com/prysmaticlabs/go-bitfield"
"github.com/prysmaticlabs/go-ssz"
bitfield "github.com/prysmaticlabs/go-bitfield"
ssz "github.com/prysmaticlabs/go-ssz"
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/roughtime"
"github.com/prysmaticlabs/prysm/shared/testutil"
logTest "github.com/sirupsen/logrus/hooks/test"
)
@ -177,7 +178,7 @@ func TestAttestToBlockHead_DoesNotAttestBeforeDelay(t *testing.T) {
validator, m, finish := setup(t)
defer finish()
validator.genesisTime = uint64(time.Now().Unix())
validator.genesisTime = uint64(roughtime.Now().Unix())
m.validatorClient.EXPECT().CommitteeAssignment(
gomock.Any(), // ctx
gomock.AssignableToTypeOf(&pb.AssignmentRequest{}),
@ -213,7 +214,7 @@ func TestAttestToBlockHead_DoesAttestAfterDelay(t *testing.T) {
wg.Add(2)
defer wg.Wait()
validator.genesisTime = uint64(time.Now().Unix())
validator.genesisTime = uint64(roughtime.Now().Unix())
validatorIndex := uint64(5)
committee := []uint64{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10}
validator.assignments = &pb.AssignmentResponse{ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{