Skip to content

Commit 24c11e7

Browse files
authored
Merge branch 'develop' into batch-deposit-verification-cleanup
2 parents 3633b77 + 6c22ede commit 24c11e7

19 files changed

+544
-1263
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
5959
### Deprecated
6060
- `--disable-grpc-gateway` flag is deprecated due to grpc gateway removal.
6161
- `--enable-experimental-state` flag is deprecated. This feature is now on by default. Opt-out with `--disable-experimental-state`.
62+
- `/eth/v1alpha1/validator/activation/stream` grpc wait for activation stream is deprecated. [pr](https://github.com/prysmaticlabs/prysm/pull/14514)
6263

6364
### Removed
6465

beacon-chain/rpc/prysm/v1alpha1/validator/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type Server struct {
8383
// WaitForActivation checks if a validator public key exists in the active validator registry of the current
8484
// beacon state, if not, then it creates a stream which listens for canonical states which contain
8585
// the validator with the public key as an active validator record.
86+
// Deprecated: do not use, just poll validator status every epoch.
8687
func (vs *Server) WaitForActivation(req *ethpb.ValidatorActivationRequest, stream ethpb.BeaconNodeValidator_WaitForActivationServer) error {
8788
activeValidatorExists, validatorStatuses, err := vs.activationStatus(stream.Context(), req.PublicKeys)
8889
if err != nil {

proto/prysm/v1alpha1/validator.pb.go

Lines changed: 285 additions & 282 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/prysm/v1alpha1/validator.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ service BeaconNodeValidator {
8787
option (google.api.http) = {
8888
get: "/eth/v1alpha1/validator/activation/stream"
8989
};
90+
option deprecated = true;
9091
}
9192

9293
// ValidatorIndex retrieves a validator's index location in the beacon state's

testing/mock/beacon_validator_client_mock.go

Lines changed: 0 additions & 123 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

time/slots/slottime.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
1111
mathutil "github.com/prysmaticlabs/prysm/v5/math"
1212
prysmTime "github.com/prysmaticlabs/prysm/v5/time"
13+
"github.com/sirupsen/logrus"
1314
)
1415

1516
// MaxSlotBuffer specifies the max buffer given to slots from
@@ -286,3 +287,25 @@ func WithinVotingWindow(genesisTime uint64, slot primitives.Slot) bool {
286287
func MaxSafeEpoch() primitives.Epoch {
287288
return primitives.Epoch(math.MaxUint64 / uint64(params.BeaconConfig().SlotsPerEpoch))
288289
}
290+
291+
// SecondsUntilNextEpochStart returns how many seconds until the next Epoch start from the current time and slot
292+
func SecondsUntilNextEpochStart(genesisTimeSec uint64) (uint64, error) {
293+
currentSlot := CurrentSlot(genesisTimeSec)
294+
firstSlotOfNextEpoch, err := EpochStart(ToEpoch(currentSlot) + 1)
295+
if err != nil {
296+
return 0, err
297+
}
298+
nextEpochStartTime, err := ToTime(genesisTimeSec, firstSlotOfNextEpoch)
299+
if err != nil {
300+
return 0, err
301+
}
302+
es := nextEpochStartTime.Unix()
303+
n := time.Now().Unix()
304+
waitTime := uint64(es - n)
305+
log.WithFields(logrus.Fields{
306+
"current_slot": currentSlot,
307+
"next_epoch_start_slot": firstSlotOfNextEpoch,
308+
"is_epoch_start": IsEpochStart(currentSlot),
309+
}).Debugf("%d seconds until next epoch", waitTime)
310+
return waitTime, nil
311+
}

time/slots/slottime_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,3 +607,28 @@ func TestWithinVotingWindow(t *testing.T) {
607607
genesisTime = uint64(time.Now().Add(-40 * time.Second).Unix())
608608
require.Equal(t, false, WithinVotingWindow(genesisTime, 3))
609609
}
610+
611+
func TestSecondsUntilNextEpochStart(t *testing.T) {
612+
secondsInEpoch := uint64(params.BeaconConfig().SlotsPerEpoch) * params.BeaconConfig().SecondsPerSlot
613+
// try slot 3
614+
genesisTime := uint64(time.Now().Add(-39 * time.Second).Unix())
615+
waitTime, err := SecondsUntilNextEpochStart(genesisTime)
616+
require.NoError(t, err)
617+
require.Equal(t, secondsInEpoch-(params.BeaconConfig().SecondsPerSlot*3)-3, waitTime)
618+
// try slot 34
619+
genesisTime = uint64(time.Now().Add(time.Duration(-1*int(secondsInEpoch)-int(params.BeaconConfig().SecondsPerSlot*2)-5) * time.Second).Unix())
620+
waitTime, err = SecondsUntilNextEpochStart(genesisTime)
621+
require.NoError(t, err)
622+
require.Equal(t, secondsInEpoch-(params.BeaconConfig().SecondsPerSlot*2)-5, waitTime)
623+
624+
// check if waitTime is correctly EpochStart
625+
n := time.Now().Add(-39 * time.Second)
626+
genesisTime = uint64(n.Unix())
627+
waitTime, err = SecondsUntilNextEpochStart(genesisTime)
628+
require.NoError(t, err)
629+
require.Equal(t, secondsInEpoch-39, waitTime)
630+
newGenesisTime := uint64(n.Add(time.Duration(-1*int(waitTime)) * time.Second).Unix())
631+
currentSlot := CurrentSlot(newGenesisTime)
632+
require.Equal(t, true, IsEpochStart(currentSlot))
633+
634+
}

validator/client/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ go_test(
144144
"//runtime:go_default_library",
145145
"//runtime/version:go_default_library",
146146
"//testing/assert:go_default_library",
147-
"//testing/mock:go_default_library",
148147
"//testing/require:go_default_library",
149148
"//testing/util:go_default_library",
150149
"//testing/validator-mock:go_default_library",
@@ -169,7 +168,6 @@ go_test(
169168
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
170169
"@com_github_sirupsen_logrus//:go_default_library",
171170
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
172-
"@com_github_stretchr_testify//mock:go_default_library",
173171
"@com_github_tyler_smith_go_bip39//:go_default_library",
174172
"@com_github_urfave_cli_v2//:go_default_library",
175173
"@com_github_wealdtech_go_eth2_util//:go_default_library",

validator/client/beacon-api/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test")
33
go_library(
44
name = "go_default_library",
55
srcs = [
6-
"activation.go",
76
"attestation_data.go",
87
"beacon_api_beacon_chain_client.go",
98
"beacon_api_helpers.go",
@@ -75,7 +74,6 @@ go_test(
7574
name = "go_default_test",
7675
size = "small",
7776
srcs = [
78-
"activation_test.go",
7977
"attestation_data_test.go",
8078
"beacon_api_beacon_chain_client_test.go",
8179
"beacon_api_helpers_test.go",

validator/client/beacon-api/activation.go

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)