mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Replace validator wait for activation stream with polling (#14514)
* wip, waitForNextEpoch Broken * fixing wait for activation and timings * updating tests wip * fixing tests * deprecating wait for activation stream * removing duplicate test * Update validator/client/wait_for_activation.go Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update validator/client/wait_for_activation.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * moving seconds until next epoch start to slottime and adding unit test * removing seconds into slot buffer, will need to test * fixing waittime bug * adding pr to changelog * Update validator/client/wait_for_activation.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update validator/client/wait_for_activation.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * fixing incorect log * refactoring based on feedback --------- Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
@@ -33,7 +33,6 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
validatorpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1/validator-client"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
mock2 "github.com/prysmaticlabs/prysm/v5/testing/mock"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/util"
|
||||
validatormock "github.com/prysmaticlabs/prysm/v5/testing/validator-mock"
|
||||
@@ -158,19 +157,6 @@ func (*mockKeymanager) DeleteKeystores(context.Context, [][]byte,
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func generateMockStatusResponse(pubkeys [][]byte) *ethpb.ValidatorActivationResponse {
|
||||
multipleStatus := make([]*ethpb.ValidatorActivationResponse_Status, len(pubkeys))
|
||||
for i, key := range pubkeys {
|
||||
multipleStatus[i] = ðpb.ValidatorActivationResponse_Status{
|
||||
PublicKey: key,
|
||||
Status: ðpb.ValidatorStatusResponse{
|
||||
Status: ethpb.ValidatorStatus_UNKNOWN_STATUS,
|
||||
},
|
||||
}
|
||||
}
|
||||
return ðpb.ValidatorActivationResponse{Statuses: multipleStatus}
|
||||
}
|
||||
|
||||
func TestWaitForChainStart_SetsGenesisInfo(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
@@ -341,46 +327,6 @@ func TestCanonicalHeadSlot_OK(t *testing.T) {
|
||||
assert.Equal(t, primitives.Slot(0), headSlot, "Mismatch slots")
|
||||
}
|
||||
|
||||
func TestWaitMultipleActivation_LogsActivationEpochOK(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
hook := logTest.NewGlobal()
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
chainClient := validatormock.NewMockChainClient(ctrl)
|
||||
prysmChainClient := validatormock.NewMockPrysmChainClient(ctrl)
|
||||
|
||||
kp := randKeypair(t)
|
||||
v := validator{
|
||||
validatorClient: client,
|
||||
km: newMockKeymanager(t, kp),
|
||||
chainClient: chainClient,
|
||||
prysmChainClient: prysmChainClient,
|
||||
pubkeyToStatus: make(map[[48]byte]*validatorStatus),
|
||||
}
|
||||
|
||||
resp := generateMockStatusResponse([][]byte{kp.pub[:]})
|
||||
resp.Statuses[0].Status.Status = ethpb.ValidatorStatus_ACTIVE
|
||||
clientStream := mock2.NewMockBeaconNodeValidator_WaitForActivationClient(ctrl)
|
||||
client.EXPECT().WaitForActivation(
|
||||
gomock.Any(),
|
||||
ðpb.ValidatorActivationRequest{
|
||||
PublicKeys: [][]byte{kp.pub[:]},
|
||||
},
|
||||
).Return(clientStream, nil)
|
||||
clientStream.EXPECT().Recv().Return(
|
||||
resp,
|
||||
nil,
|
||||
)
|
||||
prysmChainClient.EXPECT().ValidatorCount(
|
||||
gomock.Any(),
|
||||
"head",
|
||||
[]validatorType.Status{validatorType.Active},
|
||||
).Return([]iface.ValidatorCount{}, nil)
|
||||
require.NoError(t, v.WaitForActivation(ctx, nil), "Could not wait for activation")
|
||||
require.LogsContain(t, hook, "Validator activated")
|
||||
}
|
||||
|
||||
func TestWaitSync_ContextCanceled(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
Reference in New Issue
Block a user