From 3998494fad3d6390f64b7ef8b9e1fbbe491cb8a4 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Fri, 2 Aug 2024 18:02:41 +0300 Subject: [PATCH 1/8] add GetCurrentValidators to state --- snow/validators/state.go | 24 ++++++++++++++++++++++++ snow/validators/validator.go | 9 +++++++++ vms/platformvm/state/state.go | 18 ++++++++++++++++++ vms/platformvm/validators/manager.go | 14 ++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/snow/validators/state.go b/snow/validators/state.go index 3f92df35231..5c2a32d1417 100644 --- a/snow/validators/state.go +++ b/snow/validators/state.go @@ -32,6 +32,15 @@ type State interface { height uint64, subnetID ids.ID, ) (map[ids.NodeID]*GetValidatorOutput, error) + + // GetCurrentValidatorSet returns the current validators of the provided subnet + // and the current P-Chain height. + // Map is keyed by ValidationID. + // The returned map should not be modified. + GetCurrentValidatorSet( + ctx context.Context, + subnetID ids.ID, + ) (map[ids.ID]*GetCurrentValidatorOutput, uint64, error) } type lockedState struct { @@ -78,6 +87,16 @@ func (s *lockedState) GetValidatorSet( return s.s.GetValidatorSet(ctx, height, subnetID) } +func (s *lockedState) GetCurrentValidatorSet( + ctx context.Context, + subnetID ids.ID, +) (map[ids.ID]*GetCurrentValidatorOutput, uint64, error) { + s.lock.Lock() + defer s.lock.Unlock() + + return s.s.GetCurrentValidatorSet(ctx, subnetID) +} + type noValidators struct { State } @@ -91,3 +110,8 @@ func NewNoValidatorsState(state State) State { func (*noValidators) GetValidatorSet(context.Context, uint64, ids.ID) (map[ids.NodeID]*GetValidatorOutput, error) { return nil, nil } + +func (*noValidators) GetCurrentValidatorSet(context.Context, ids.ID) (map[ids.ID]*GetCurrentValidatorOutput, uint64, error) { + // TODO: should we return the actual height? + return nil, 0, nil +} diff --git a/snow/validators/validator.go b/snow/validators/validator.go index 499b5189e42..5f28ac33230 100644 --- a/snow/validators/validator.go +++ b/snow/validators/validator.go @@ -29,3 +29,12 @@ type GetValidatorOutput struct { PublicKey *bls.PublicKey Weight uint64 } + +type GetCurrentValidatorOutput struct { + NodeID ids.NodeID + PublicKey *bls.PublicKey + Weight uint64 + StartTime uint64 + SetWeightNonce uint64 + IsActive bool +} diff --git a/vms/platformvm/state/state.go b/vms/platformvm/state/state.go index a6266a48085..0e43e6720f1 100644 --- a/vms/platformvm/state/state.go +++ b/vms/platformvm/state/state.go @@ -661,6 +661,24 @@ func newState( }, nil } +func (s *state) GetCurrentValidators(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, error) { + result := make(map[ids.ID]*validators.GetCurrentValidatorOutput) + for _, staker := range s.currentStakers.validators[subnetID] { + validator := staker.validator + result[validator.TxID] = &validators.GetCurrentValidatorOutput{ + NodeID: validator.NodeID, + PublicKey: validator.PublicKey, + Weight: validator.Weight, + StartTime: uint64(validator.StartTime.Unix()), + // TODO: not implemented yet + SetWeightNonce: 0, + // TODO: not implemented yet + IsActive: true, + } + } + return result, nil +} + func (s *state) GetCurrentValidator(subnetID ids.ID, nodeID ids.NodeID) (*Staker, error) { return s.currentStakers.GetValidator(subnetID, nodeID) } diff --git a/vms/platformvm/validators/manager.go b/vms/platformvm/validators/manager.go index 781d119e226..2270a8931d5 100644 --- a/vms/platformvm/validators/manager.go +++ b/vms/platformvm/validators/manager.go @@ -86,6 +86,8 @@ type State interface { startHeight uint64, endHeight uint64, ) error + + GetCurrentValidators(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, error) } func NewManager( @@ -385,3 +387,15 @@ func (m *manager) GetSubnetID(_ context.Context, chainID ids.ID) (ids.ID, error) func (m *manager) OnAcceptedBlockID(blkID ids.ID) { m.recentlyAccepted.Add(blkID) } + +func (m *manager) GetCurrentValidatorSet(ctx context.Context, subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { + currentHeight, err := m.getCurrentHeight(ctx) + if err != nil { + return nil, 0, err + } + vdrs, err := m.state.GetCurrentValidators(subnetID) + if err != nil { + return nil, 0, err + } + return vdrs, currentHeight, nil +} From 75250decfe6ca1d400d305ca35211eecaaa35da2 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Thu, 29 Aug 2024 16:23:00 +0300 Subject: [PATCH 2/8] small refactor --- snow/uptime/manager.go | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/snow/uptime/manager.go b/snow/uptime/manager.go index 413a660ec17..04c810340df 100644 --- a/snow/uptime/manager.go +++ b/snow/uptime/manager.go @@ -4,6 +4,7 @@ package uptime import ( + "errors" "time" "github.com/ava-labs/avalanchego/database" @@ -13,6 +14,11 @@ import ( var _ Manager = (*manager)(nil) +var ( + errAlreadyStartedTracking = errors.New("already started tracking") + errNotStartedTracking = errors.New("not started tracking") +) + type Manager interface { Tracker Calculator @@ -54,9 +60,12 @@ func NewManager(state State, clk *mockable.Clock) Manager { } func (m *manager) StartTracking(nodeIDs []ids.NodeID) error { + if m.startedTracking { + return errAlreadyStartedTracking + } now := m.clock.UnixTime() for _, nodeID := range nodeIDs { - upDuration, lastUpdated, err := m.state.GetUptime(nodeID) + upDuration, lastUpdated, err := m.CalculateUptime(nodeID) if err != nil { return err } @@ -67,9 +76,7 @@ func (m *manager) StartTracking(nodeIDs []ids.NodeID) error { continue } - durationOffline := now.Sub(lastUpdated) - newUpDuration := upDuration + durationOffline - if err := m.state.SetUptime(nodeID, newUpDuration, now); err != nil { + if err := m.state.SetUptime(nodeID, upDuration, lastUpdated); err != nil { return err } } @@ -78,9 +85,8 @@ func (m *manager) StartTracking(nodeIDs []ids.NodeID) error { } func (m *manager) StopTracking(nodeIDs []ids.NodeID) error { - // TODO: this was not here before, should we add it? if !m.startedTracking { - return nil + return errNotStartedTracking } defer func() { m.startedTracking = false @@ -89,8 +95,8 @@ func (m *manager) StopTracking(nodeIDs []ids.NodeID) error { for _, nodeID := range nodeIDs { // If the node is already connected, then we can just // update the uptime in the state and remove the connection - if _, isConnected := m.connections[nodeID]; isConnected { - if err := m.disconnect(nodeID); err != nil { + if m.IsConnected(nodeID) { + if err := m.Disconnect(nodeID); err != nil { return err } continue @@ -127,15 +133,11 @@ func (m *manager) IsConnected(nodeID ids.NodeID) bool { } func (m *manager) Disconnect(nodeID ids.NodeID) error { - return m.disconnect(nodeID) -} - -func (m *manager) disconnect(nodeID ids.NodeID) error { + defer delete(m.connections, nodeID) if err := m.updateUptime(nodeID); err != nil { return err } - // TODO: shall we delete the connection regardless of the error? - delete(m.connections, nodeID) + return nil } From fb2128507c5d92b6be5148d3e01bbd84c768e68e Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Mon, 9 Sep 2024 16:51:01 +0300 Subject: [PATCH 3/8] add started tracking --- snow/uptime/manager.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/snow/uptime/manager.go b/snow/uptime/manager.go index 04c810340df..999ac8937a4 100644 --- a/snow/uptime/manager.go +++ b/snow/uptime/manager.go @@ -27,6 +27,7 @@ type Manager interface { type Tracker interface { StartTracking(nodeIDs []ids.NodeID) error StopTracking(nodeIDs []ids.NodeID) error + StartedTracking() bool Connect(nodeID ids.NodeID) error IsConnected(nodeID ids.NodeID) bool @@ -122,6 +123,10 @@ func (m *manager) StopTracking(nodeIDs []ids.NodeID) error { return nil } +func (m *manager) StartedTracking() bool { + return m.startedTracking +} + func (m *manager) Connect(nodeID ids.NodeID) error { m.connections[nodeID] = m.clock.UnixTime() return nil From 477c3ebbdafc64e6cb130ebc37a58dfff1c6dc8f Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Mon, 9 Sep 2024 17:07:41 +0300 Subject: [PATCH 4/8] do not return err --- snow/uptime/manager.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/snow/uptime/manager.go b/snow/uptime/manager.go index 999ac8937a4..70f576060aa 100644 --- a/snow/uptime/manager.go +++ b/snow/uptime/manager.go @@ -4,7 +4,6 @@ package uptime import ( - "errors" "time" "github.com/ava-labs/avalanchego/database" @@ -14,11 +13,6 @@ import ( var _ Manager = (*manager)(nil) -var ( - errAlreadyStartedTracking = errors.New("already started tracking") - errNotStartedTracking = errors.New("not started tracking") -) - type Manager interface { Tracker Calculator @@ -62,7 +56,7 @@ func NewManager(state State, clk *mockable.Clock) Manager { func (m *manager) StartTracking(nodeIDs []ids.NodeID) error { if m.startedTracking { - return errAlreadyStartedTracking + return nil } now := m.clock.UnixTime() for _, nodeID := range nodeIDs { @@ -87,7 +81,7 @@ func (m *manager) StartTracking(nodeIDs []ids.NodeID) error { func (m *manager) StopTracking(nodeIDs []ids.NodeID) error { if !m.startedTracking { - return errNotStartedTracking + return nil } defer func() { m.startedTracking = false From 9c2c211e8299ab3597c0ecf3bc2f79f45db0fce0 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Thu, 19 Sep 2024 14:35:31 -0400 Subject: [PATCH 5/8] add current validators api --- proto/pb/validatorstate/validator_state.pb.go | 411 +++++++++++++++--- .../validatorstate/validator_state_grpc.pb.go | 49 ++- proto/validatorstate/validator_state.proto | 22 + .../gvalidators/validator_state_client.go | 46 ++ .../gvalidators/validator_state_server.go | 37 ++ snow/validators/mock_state.go | 16 + snow/validators/test_state.go | 23 +- snow/validators/traced_state.go | 12 + snow/validators/validator.go | 1 + vms/platformvm/state/mock_state.go | 16 + vms/platformvm/state/state.go | 6 +- vms/platformvm/validators/manager.go | 8 +- vms/platformvm/validators/test_manager.go | 4 + 13 files changed, 567 insertions(+), 84 deletions(-) diff --git a/proto/pb/validatorstate/validator_state.pb.go b/proto/pb/validatorstate/validator_state.pb.go index 591087a0834..5273cb53fcd 100644 --- a/proto/pb/validatorstate/validator_state.pb.go +++ b/proto/pb/validatorstate/validator_state.pb.go @@ -264,6 +264,53 @@ func (x *GetValidatorSetRequest) GetSubnetId() []byte { return nil } +type GetCurrentValidatorSetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SubnetId []byte `protobuf:"bytes,1,opt,name=subnet_id,json=subnetId,proto3" json:"subnet_id,omitempty"` +} + +func (x *GetCurrentValidatorSetRequest) Reset() { + *x = GetCurrentValidatorSetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_validatorstate_validator_state_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetCurrentValidatorSetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCurrentValidatorSetRequest) ProtoMessage() {} + +func (x *GetCurrentValidatorSetRequest) ProtoReflect() protoreflect.Message { + mi := &file_validatorstate_validator_state_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetCurrentValidatorSetRequest.ProtoReflect.Descriptor instead. +func (*GetCurrentValidatorSetRequest) Descriptor() ([]byte, []int) { + return file_validatorstate_validator_state_proto_rawDescGZIP(), []int{5} +} + +func (x *GetCurrentValidatorSetRequest) GetSubnetId() []byte { + if x != nil { + return x.SubnetId + } + return nil +} + type Validator struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -277,7 +324,7 @@ type Validator struct { func (x *Validator) Reset() { *x = Validator{} if protoimpl.UnsafeEnabled { - mi := &file_validatorstate_validator_state_proto_msgTypes[5] + mi := &file_validatorstate_validator_state_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -290,7 +337,7 @@ func (x *Validator) String() string { func (*Validator) ProtoMessage() {} func (x *Validator) ProtoReflect() protoreflect.Message { - mi := &file_validatorstate_validator_state_proto_msgTypes[5] + mi := &file_validatorstate_validator_state_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -303,7 +350,7 @@ func (x *Validator) ProtoReflect() protoreflect.Message { // Deprecated: Use Validator.ProtoReflect.Descriptor instead. func (*Validator) Descriptor() ([]byte, []int) { - return file_validatorstate_validator_state_proto_rawDescGZIP(), []int{5} + return file_validatorstate_validator_state_proto_rawDescGZIP(), []int{6} } func (x *Validator) GetNodeId() []byte { @@ -327,6 +374,101 @@ func (x *Validator) GetPublicKey() []byte { return nil } +type CurrentValidator struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId []byte `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Weight uint64 `protobuf:"varint,2,opt,name=weight,proto3" json:"weight,omitempty"` + PublicKey []byte `protobuf:"bytes,3,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + StartTime uint64 `protobuf:"varint,4,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` + SetWeightNonce uint64 `protobuf:"varint,5,opt,name=set_weight_nonce,json=setWeightNonce,proto3" json:"set_weight_nonce,omitempty"` + IsActive bool `protobuf:"varint,6,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` + ValidationId []byte `protobuf:"bytes,7,opt,name=validation_id,json=validationId,proto3" json:"validation_id,omitempty"` +} + +func (x *CurrentValidator) Reset() { + *x = CurrentValidator{} + if protoimpl.UnsafeEnabled { + mi := &file_validatorstate_validator_state_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CurrentValidator) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CurrentValidator) ProtoMessage() {} + +func (x *CurrentValidator) ProtoReflect() protoreflect.Message { + mi := &file_validatorstate_validator_state_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CurrentValidator.ProtoReflect.Descriptor instead. +func (*CurrentValidator) Descriptor() ([]byte, []int) { + return file_validatorstate_validator_state_proto_rawDescGZIP(), []int{7} +} + +func (x *CurrentValidator) GetNodeId() []byte { + if x != nil { + return x.NodeId + } + return nil +} + +func (x *CurrentValidator) GetWeight() uint64 { + if x != nil { + return x.Weight + } + return 0 +} + +func (x *CurrentValidator) GetPublicKey() []byte { + if x != nil { + return x.PublicKey + } + return nil +} + +func (x *CurrentValidator) GetStartTime() uint64 { + if x != nil { + return x.StartTime + } + return 0 +} + +func (x *CurrentValidator) GetSetWeightNonce() uint64 { + if x != nil { + return x.SetWeightNonce + } + return 0 +} + +func (x *CurrentValidator) GetIsActive() bool { + if x != nil { + return x.IsActive + } + return false +} + +func (x *CurrentValidator) GetValidationId() []byte { + if x != nil { + return x.ValidationId + } + return nil +} + type GetValidatorSetResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -338,7 +480,7 @@ type GetValidatorSetResponse struct { func (x *GetValidatorSetResponse) Reset() { *x = GetValidatorSetResponse{} if protoimpl.UnsafeEnabled { - mi := &file_validatorstate_validator_state_proto_msgTypes[6] + mi := &file_validatorstate_validator_state_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -351,7 +493,7 @@ func (x *GetValidatorSetResponse) String() string { func (*GetValidatorSetResponse) ProtoMessage() {} func (x *GetValidatorSetResponse) ProtoReflect() protoreflect.Message { - mi := &file_validatorstate_validator_state_proto_msgTypes[6] + mi := &file_validatorstate_validator_state_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -364,7 +506,7 @@ func (x *GetValidatorSetResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetValidatorSetResponse.ProtoReflect.Descriptor instead. func (*GetValidatorSetResponse) Descriptor() ([]byte, []int) { - return file_validatorstate_validator_state_proto_rawDescGZIP(), []int{6} + return file_validatorstate_validator_state_proto_rawDescGZIP(), []int{8} } func (x *GetValidatorSetResponse) GetValidators() []*Validator { @@ -374,6 +516,61 @@ func (x *GetValidatorSetResponse) GetValidators() []*Validator { return nil } +type GetCurrentValidatorSetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Validators []*CurrentValidator `protobuf:"bytes,1,rep,name=validators,proto3" json:"validators,omitempty"` + CurrentHeight uint64 `protobuf:"varint,2,opt,name=current_height,json=currentHeight,proto3" json:"current_height,omitempty"` +} + +func (x *GetCurrentValidatorSetResponse) Reset() { + *x = GetCurrentValidatorSetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_validatorstate_validator_state_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetCurrentValidatorSetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCurrentValidatorSetResponse) ProtoMessage() {} + +func (x *GetCurrentValidatorSetResponse) ProtoReflect() protoreflect.Message { + mi := &file_validatorstate_validator_state_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetCurrentValidatorSetResponse.ProtoReflect.Descriptor instead. +func (*GetCurrentValidatorSetResponse) Descriptor() ([]byte, []int) { + return file_validatorstate_validator_state_proto_rawDescGZIP(), []int{9} +} + +func (x *GetCurrentValidatorSetResponse) GetValidators() []*CurrentValidator { + if x != nil { + return x.Validators + } + return nil +} + +func (x *GetCurrentValidatorSetResponse) GetCurrentHeight() uint64 { + if x != nil { + return x.CurrentHeight + } + return 0 +} + var File_validatorstate_validator_state_proto protoreflect.FileDescriptor var file_validatorstate_validator_state_proto_rawDesc = []byte{ @@ -400,45 +597,81 @@ var file_validatorstate_validator_state_proto_rawDesc = []byte{ 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, 0x64, 0x22, - 0x5b, 0x0a, 0x09, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x17, 0x0a, 0x07, - 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6e, - 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1d, 0x0a, - 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x22, 0x54, 0x0a, 0x17, - 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, - 0x72, 0x73, 0x32, 0xf8, 0x02, 0x0a, 0x0e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x54, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x6e, 0x69, - 0x6d, 0x75, 0x6d, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x3c, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x08, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, 0x64, 0x22, 0x5b, 0x0a, + 0x09, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, + 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6e, 0x6f, 0x64, + 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x22, 0xed, 0x01, 0x0a, 0x10, 0x43, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, + 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x77, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, + 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x28, + 0x0a, 0x10, 0x73, 0x65, 0x74, 0x5f, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x6e, 0x6f, 0x6e, + 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x73, 0x65, 0x74, 0x57, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x61, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x54, 0x0a, 0x17, 0x47, 0x65, + 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, + 0x22, 0x89, 0x01, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x32, 0xf1, 0x03, 0x0a, + 0x0e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, + 0x54, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x48, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x28, 0x2e, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x47, 0x65, 0x74, + 0x4d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x28, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, - 0x74, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x48, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, 0x10, 0x47, - 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, - 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x28, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x56, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, 0x44, - 0x12, 0x22, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, 0x44, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, - 0x44, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x62, 0x0a, 0x0f, 0x47, 0x65, 0x74, - 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x12, 0x26, 0x2e, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x47, 0x65, - 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x39, 0x5a, - 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x76, 0x61, 0x2d, - 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x61, 0x76, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x67, 0x6f, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x56, 0x0a, 0x0b, 0x47, + 0x65, 0x74, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, 0x44, 0x12, 0x22, 0x2e, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x53, + 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, 0x44, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, + 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, + 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, 0x44, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x62, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x12, 0x26, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, + 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, + 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x77, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x43, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, + 0x74, 0x12, 0x2d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x2e, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x42, 0x39, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, + 0x76, 0x61, 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x61, 0x76, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x68, + 0x65, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x2f, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x74, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -453,32 +686,38 @@ func file_validatorstate_validator_state_proto_rawDescGZIP() []byte { return file_validatorstate_validator_state_proto_rawDescData } -var file_validatorstate_validator_state_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_validatorstate_validator_state_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_validatorstate_validator_state_proto_goTypes = []interface{}{ - (*GetMinimumHeightResponse)(nil), // 0: validatorstate.GetMinimumHeightResponse - (*GetCurrentHeightResponse)(nil), // 1: validatorstate.GetCurrentHeightResponse - (*GetSubnetIDRequest)(nil), // 2: validatorstate.GetSubnetIDRequest - (*GetSubnetIDResponse)(nil), // 3: validatorstate.GetSubnetIDResponse - (*GetValidatorSetRequest)(nil), // 4: validatorstate.GetValidatorSetRequest - (*Validator)(nil), // 5: validatorstate.Validator - (*GetValidatorSetResponse)(nil), // 6: validatorstate.GetValidatorSetResponse - (*emptypb.Empty)(nil), // 7: google.protobuf.Empty + (*GetMinimumHeightResponse)(nil), // 0: validatorstate.GetMinimumHeightResponse + (*GetCurrentHeightResponse)(nil), // 1: validatorstate.GetCurrentHeightResponse + (*GetSubnetIDRequest)(nil), // 2: validatorstate.GetSubnetIDRequest + (*GetSubnetIDResponse)(nil), // 3: validatorstate.GetSubnetIDResponse + (*GetValidatorSetRequest)(nil), // 4: validatorstate.GetValidatorSetRequest + (*GetCurrentValidatorSetRequest)(nil), // 5: validatorstate.GetCurrentValidatorSetRequest + (*Validator)(nil), // 6: validatorstate.Validator + (*CurrentValidator)(nil), // 7: validatorstate.CurrentValidator + (*GetValidatorSetResponse)(nil), // 8: validatorstate.GetValidatorSetResponse + (*GetCurrentValidatorSetResponse)(nil), // 9: validatorstate.GetCurrentValidatorSetResponse + (*emptypb.Empty)(nil), // 10: google.protobuf.Empty } var file_validatorstate_validator_state_proto_depIdxs = []int32{ - 5, // 0: validatorstate.GetValidatorSetResponse.validators:type_name -> validatorstate.Validator - 7, // 1: validatorstate.ValidatorState.GetMinimumHeight:input_type -> google.protobuf.Empty - 7, // 2: validatorstate.ValidatorState.GetCurrentHeight:input_type -> google.protobuf.Empty - 2, // 3: validatorstate.ValidatorState.GetSubnetID:input_type -> validatorstate.GetSubnetIDRequest - 4, // 4: validatorstate.ValidatorState.GetValidatorSet:input_type -> validatorstate.GetValidatorSetRequest - 0, // 5: validatorstate.ValidatorState.GetMinimumHeight:output_type -> validatorstate.GetMinimumHeightResponse - 1, // 6: validatorstate.ValidatorState.GetCurrentHeight:output_type -> validatorstate.GetCurrentHeightResponse - 3, // 7: validatorstate.ValidatorState.GetSubnetID:output_type -> validatorstate.GetSubnetIDResponse - 6, // 8: validatorstate.ValidatorState.GetValidatorSet:output_type -> validatorstate.GetValidatorSetResponse - 5, // [5:9] is the sub-list for method output_type - 1, // [1:5] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 6, // 0: validatorstate.GetValidatorSetResponse.validators:type_name -> validatorstate.Validator + 7, // 1: validatorstate.GetCurrentValidatorSetResponse.validators:type_name -> validatorstate.CurrentValidator + 10, // 2: validatorstate.ValidatorState.GetMinimumHeight:input_type -> google.protobuf.Empty + 10, // 3: validatorstate.ValidatorState.GetCurrentHeight:input_type -> google.protobuf.Empty + 2, // 4: validatorstate.ValidatorState.GetSubnetID:input_type -> validatorstate.GetSubnetIDRequest + 4, // 5: validatorstate.ValidatorState.GetValidatorSet:input_type -> validatorstate.GetValidatorSetRequest + 5, // 6: validatorstate.ValidatorState.GetCurrentValidatorSet:input_type -> validatorstate.GetCurrentValidatorSetRequest + 0, // 7: validatorstate.ValidatorState.GetMinimumHeight:output_type -> validatorstate.GetMinimumHeightResponse + 1, // 8: validatorstate.ValidatorState.GetCurrentHeight:output_type -> validatorstate.GetCurrentHeightResponse + 3, // 9: validatorstate.ValidatorState.GetSubnetID:output_type -> validatorstate.GetSubnetIDResponse + 8, // 10: validatorstate.ValidatorState.GetValidatorSet:output_type -> validatorstate.GetValidatorSetResponse + 9, // 11: validatorstate.ValidatorState.GetCurrentValidatorSet:output_type -> validatorstate.GetCurrentValidatorSetResponse + 7, // [7:12] is the sub-list for method output_type + 2, // [2:7] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_validatorstate_validator_state_proto_init() } @@ -548,7 +787,7 @@ func file_validatorstate_validator_state_proto_init() { } } file_validatorstate_validator_state_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Validator); i { + switch v := v.(*GetCurrentValidatorSetRequest); i { case 0: return &v.state case 1: @@ -560,6 +799,30 @@ func file_validatorstate_validator_state_proto_init() { } } file_validatorstate_validator_state_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Validator); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_validatorstate_validator_state_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CurrentValidator); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_validatorstate_validator_state_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetValidatorSetResponse); i { case 0: return &v.state @@ -571,6 +834,18 @@ func file_validatorstate_validator_state_proto_init() { return nil } } + file_validatorstate_validator_state_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetCurrentValidatorSetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -578,7 +853,7 @@ func file_validatorstate_validator_state_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_validatorstate_validator_state_proto_rawDesc, NumEnums: 0, - NumMessages: 7, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/pb/validatorstate/validator_state_grpc.pb.go b/proto/pb/validatorstate/validator_state_grpc.pb.go index 8dc2137aad9..510e8aba88a 100644 --- a/proto/pb/validatorstate/validator_state_grpc.pb.go +++ b/proto/pb/validatorstate/validator_state_grpc.pb.go @@ -20,10 +20,11 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - ValidatorState_GetMinimumHeight_FullMethodName = "/validatorstate.ValidatorState/GetMinimumHeight" - ValidatorState_GetCurrentHeight_FullMethodName = "/validatorstate.ValidatorState/GetCurrentHeight" - ValidatorState_GetSubnetID_FullMethodName = "/validatorstate.ValidatorState/GetSubnetID" - ValidatorState_GetValidatorSet_FullMethodName = "/validatorstate.ValidatorState/GetValidatorSet" + ValidatorState_GetMinimumHeight_FullMethodName = "/validatorstate.ValidatorState/GetMinimumHeight" + ValidatorState_GetCurrentHeight_FullMethodName = "/validatorstate.ValidatorState/GetCurrentHeight" + ValidatorState_GetSubnetID_FullMethodName = "/validatorstate.ValidatorState/GetSubnetID" + ValidatorState_GetValidatorSet_FullMethodName = "/validatorstate.ValidatorState/GetValidatorSet" + ValidatorState_GetCurrentValidatorSet_FullMethodName = "/validatorstate.ValidatorState/GetCurrentValidatorSet" ) // ValidatorStateClient is the client API for ValidatorState service. @@ -40,6 +41,9 @@ type ValidatorStateClient interface { // GetValidatorSet returns the weights of the nodeIDs for the provided // subnet at the requested P-chain height. GetValidatorSet(ctx context.Context, in *GetValidatorSetRequest, opts ...grpc.CallOption) (*GetValidatorSetResponse, error) + // GetCurrentValidatorSet returns the weights of the nodeIDs for the provided + // subnet at the current P-chain height. + GetCurrentValidatorSet(ctx context.Context, in *GetCurrentValidatorSetRequest, opts ...grpc.CallOption) (*GetCurrentValidatorSetResponse, error) } type validatorStateClient struct { @@ -86,6 +90,15 @@ func (c *validatorStateClient) GetValidatorSet(ctx context.Context, in *GetValid return out, nil } +func (c *validatorStateClient) GetCurrentValidatorSet(ctx context.Context, in *GetCurrentValidatorSetRequest, opts ...grpc.CallOption) (*GetCurrentValidatorSetResponse, error) { + out := new(GetCurrentValidatorSetResponse) + err := c.cc.Invoke(ctx, ValidatorState_GetCurrentValidatorSet_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ValidatorStateServer is the server API for ValidatorState service. // All implementations must embed UnimplementedValidatorStateServer // for forward compatibility @@ -100,6 +113,9 @@ type ValidatorStateServer interface { // GetValidatorSet returns the weights of the nodeIDs for the provided // subnet at the requested P-chain height. GetValidatorSet(context.Context, *GetValidatorSetRequest) (*GetValidatorSetResponse, error) + // GetCurrentValidatorSet returns the weights of the nodeIDs for the provided + // subnet at the current P-chain height. + GetCurrentValidatorSet(context.Context, *GetCurrentValidatorSetRequest) (*GetCurrentValidatorSetResponse, error) mustEmbedUnimplementedValidatorStateServer() } @@ -119,6 +135,9 @@ func (UnimplementedValidatorStateServer) GetSubnetID(context.Context, *GetSubnet func (UnimplementedValidatorStateServer) GetValidatorSet(context.Context, *GetValidatorSetRequest) (*GetValidatorSetResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetValidatorSet not implemented") } +func (UnimplementedValidatorStateServer) GetCurrentValidatorSet(context.Context, *GetCurrentValidatorSetRequest) (*GetCurrentValidatorSetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCurrentValidatorSet not implemented") +} func (UnimplementedValidatorStateServer) mustEmbedUnimplementedValidatorStateServer() {} // UnsafeValidatorStateServer may be embedded to opt out of forward compatibility for this service. @@ -204,6 +223,24 @@ func _ValidatorState_GetValidatorSet_Handler(srv interface{}, ctx context.Contex return interceptor(ctx, in, info, handler) } +func _ValidatorState_GetCurrentValidatorSet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCurrentValidatorSetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ValidatorStateServer).GetCurrentValidatorSet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ValidatorState_GetCurrentValidatorSet_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ValidatorStateServer).GetCurrentValidatorSet(ctx, req.(*GetCurrentValidatorSetRequest)) + } + return interceptor(ctx, in, info, handler) +} + // ValidatorState_ServiceDesc is the grpc.ServiceDesc for ValidatorState service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -227,6 +264,10 @@ var ValidatorState_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetValidatorSet", Handler: _ValidatorState_GetValidatorSet_Handler, }, + { + MethodName: "GetCurrentValidatorSet", + Handler: _ValidatorState_GetCurrentValidatorSet_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "validatorstate/validator_state.proto", diff --git a/proto/validatorstate/validator_state.proto b/proto/validatorstate/validator_state.proto index 6d2900f08a0..af4850ddda3 100644 --- a/proto/validatorstate/validator_state.proto +++ b/proto/validatorstate/validator_state.proto @@ -17,6 +17,9 @@ service ValidatorState { // GetValidatorSet returns the weights of the nodeIDs for the provided // subnet at the requested P-chain height. rpc GetValidatorSet(GetValidatorSetRequest) returns (GetValidatorSetResponse); + // GetCurrentValidatorSet returns the weights of the nodeIDs for the provided + // subnet at the current P-chain height. + rpc GetCurrentValidatorSet(GetCurrentValidatorSetRequest) returns (GetCurrentValidatorSetResponse); } message GetMinimumHeightResponse { @@ -40,12 +43,31 @@ message GetValidatorSetRequest { bytes subnet_id = 2; } +message GetCurrentValidatorSetRequest { + bytes subnet_id = 1; +} + message Validator { bytes node_id = 1; uint64 weight = 2; bytes public_key = 3; } +message CurrentValidator { + bytes node_id = 1; + uint64 weight = 2; + bytes public_key = 3; + uint64 start_time = 4; + uint64 set_weight_nonce = 5; + bool is_active = 6; + bytes validation_id = 7; +} + message GetValidatorSetResponse { repeated Validator validators = 1; } + +message GetCurrentValidatorSetResponse { + repeated CurrentValidator validators = 1; + uint64 current_height = 2; +} diff --git a/snow/validators/gvalidators/validator_state_client.go b/snow/validators/gvalidators/validator_state_client.go index ae09b749d3c..b9e6af073a3 100644 --- a/snow/validators/gvalidators/validator_state_client.go +++ b/snow/validators/gvalidators/validator_state_client.go @@ -94,3 +94,49 @@ func (c *Client) GetValidatorSet( } return vdrs, nil } + +func (c *Client) GetCurrentValidatorSet( + ctx context.Context, + subnetID ids.ID, +) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { + resp, err := c.client.GetCurrentValidatorSet(ctx, &pb.GetCurrentValidatorSetRequest{ + SubnetId: subnetID[:], + }) + if err != nil { + return nil, 0, err + } + + vdrs := make(map[ids.ID]*validators.GetCurrentValidatorOutput, len(resp.Validators)) + for _, validator := range resp.Validators { + nodeID, err := ids.ToNodeID(validator.NodeId) + if err != nil { + return nil, 0, err + } + var publicKey *bls.PublicKey + if len(validator.PublicKey) > 0 { + // This is a performance optimization to avoid the cost of + // compression and key re-verification with + // PublicKeyFromCompressedBytes. We can safely assume that the BLS + // Public Keys are verified before being added to the P-Chain and + // served by the gRPC server. + publicKey = bls.PublicKeyFromValidUncompressedBytes(validator.PublicKey) + if publicKey == nil { + return nil, 0, errFailedPublicKeyDeserialize + } + } + validationID, err := ids.ToID(validator.ValidationId) + if err != nil { + return nil, 0, err + } + + vdrs[validationID] = &validators.GetCurrentValidatorOutput{ + NodeID: nodeID, + PublicKey: publicKey, + Weight: validator.Weight, + StartTime: validator.StartTime, + SetWeightNonce: validator.SetWeightNonce, + IsActive: validator.IsActive, + } + } + return vdrs, resp.GetCurrentHeight(), nil +} diff --git a/snow/validators/gvalidators/validator_state_server.go b/snow/validators/gvalidators/validator_state_server.go index 0550eba0b9b..6ed40426ec4 100644 --- a/snow/validators/gvalidators/validator_state_server.go +++ b/snow/validators/gvalidators/validator_state_server.go @@ -79,3 +79,40 @@ func (s *Server) GetValidatorSet(ctx context.Context, req *pb.GetValidatorSetReq } return resp, nil } + +func (s *Server) GetCurrentValidatorSet(ctx context.Context, req *pb.GetCurrentValidatorSetRequest) (*pb.GetCurrentValidatorSetResponse, error) { + subnetID, err := ids.ToID(req.SubnetId) + if err != nil { + return nil, err + } + + vdrs, currentHeight, err := s.state.GetCurrentValidatorSet(ctx, subnetID) + if err != nil { + return nil, err + } + + resp := &pb.GetCurrentValidatorSetResponse{ + Validators: make([]*pb.CurrentValidator, len(vdrs)), + CurrentHeight: currentHeight, + } + + i := 0 + for _, vdr := range vdrs { + vdrPB := &pb.CurrentValidator{ + NodeId: vdr.NodeID.Bytes(), + StartTime: vdr.StartTime, + IsActive: vdr.IsActive, + ValidationId: vdr.ValidationID[:], + Weight: vdr.Weight, + SetWeightNonce: vdr.SetWeightNonce, + } + if vdr.PublicKey != nil { + // This is a performance optimization to avoid the cost of compression + // from PublicKeyToCompressedBytes. + vdrPB.PublicKey = bls.PublicKeyToUncompressedBytes(vdr.PublicKey) + } + resp.Validators[i] = vdrPB + i++ + } + return resp, nil +} diff --git a/snow/validators/mock_state.go b/snow/validators/mock_state.go index 6bed638becd..b7757890871 100644 --- a/snow/validators/mock_state.go +++ b/snow/validators/mock_state.go @@ -55,6 +55,22 @@ func (mr *MockStateMockRecorder) GetCurrentHeight(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentHeight", reflect.TypeOf((*MockState)(nil).GetCurrentHeight), arg0) } +// GetCurrentValidatorSet mocks base method. +func (m *MockState) GetCurrentValidatorSet(arg0 context.Context, arg1 ids.ID) (map[ids.ID]*GetCurrentValidatorOutput, uint64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCurrentValidatorSet", arg0, arg1) + ret0, _ := ret[0].(map[ids.ID]*GetCurrentValidatorOutput) + ret1, _ := ret[1].(uint64) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetCurrentValidatorSet indicates an expected call of GetCurrentValidatorSet. +func (mr *MockStateMockRecorder) GetCurrentValidatorSet(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorSet", reflect.TypeOf((*MockState)(nil).GetCurrentValidatorSet), arg0, arg1) +} + // GetMinimumHeight mocks base method. func (m *MockState) GetMinimumHeight(arg0 context.Context) (uint64, error) { m.ctrl.T.Helper() diff --git a/snow/validators/test_state.go b/snow/validators/test_state.go index 378f3e8a878..496edb2578d 100644 --- a/snow/validators/test_state.go +++ b/snow/validators/test_state.go @@ -32,11 +32,13 @@ type TestState struct { CantGetCurrentHeight, CantGetSubnetID, CantGetValidatorSet bool + CantGetCurrentValidatorSet bool - GetMinimumHeightF func(ctx context.Context) (uint64, error) - GetCurrentHeightF func(ctx context.Context) (uint64, error) - GetSubnetIDF func(ctx context.Context, chainID ids.ID) (ids.ID, error) - GetValidatorSetF func(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*GetValidatorOutput, error) + GetMinimumHeightF func(ctx context.Context) (uint64, error) + GetCurrentHeightF func(ctx context.Context) (uint64, error) + GetSubnetIDF func(ctx context.Context, chainID ids.ID) (ids.ID, error) + GetValidatorSetF func(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*GetValidatorOutput, error) + GetCurrentValidatorSetF func(ctx context.Context, subnetID ids.ID) (map[ids.ID]*GetCurrentValidatorOutput, uint64, error) } func (vm *TestState) GetMinimumHeight(ctx context.Context) (uint64, error) { @@ -82,3 +84,16 @@ func (vm *TestState) GetValidatorSet( } return nil, errGetValidatorSet } + +func (vm *TestState) GetCurrentValidatorSet( + ctx context.Context, + subnetID ids.ID, +) (map[ids.ID]*GetCurrentValidatorOutput, uint64, error) { + if vm.GetCurrentValidatorSetF != nil { + return vm.GetCurrentValidatorSetF(ctx, subnetID) + } + if vm.CantGetCurrentValidatorSet && vm.T != nil { + require.FailNow(vm.T, "unexpectedly called GetCurrentValidatorSet") + } + return nil, 0, nil +} diff --git a/snow/validators/traced_state.go b/snow/validators/traced_state.go index 1116ab9d7e7..5f1cd8de686 100644 --- a/snow/validators/traced_state.go +++ b/snow/validators/traced_state.go @@ -72,3 +72,15 @@ func (s *tracedState) GetValidatorSet( return s.s.GetValidatorSet(ctx, height, subnetID) } + +func (s *tracedState) GetCurrentValidatorSet( + ctx context.Context, + subnetID ids.ID, +) (map[ids.ID]*GetCurrentValidatorOutput, uint64, error) { + ctx, span := s.tracer.Start(ctx, s.getValidatorSetTag, oteltrace.WithAttributes( + attribute.Stringer("subnetID", subnetID), + )) + defer span.End() + + return s.s.GetCurrentValidatorSet(ctx, subnetID) +} diff --git a/snow/validators/validator.go b/snow/validators/validator.go index 5f28ac33230..eff95b8266e 100644 --- a/snow/validators/validator.go +++ b/snow/validators/validator.go @@ -31,6 +31,7 @@ type GetValidatorOutput struct { } type GetCurrentValidatorOutput struct { + ValidationID ids.ID NodeID ids.NodeID PublicKey *bls.PublicKey Weight uint64 diff --git a/vms/platformvm/state/mock_state.go b/vms/platformvm/state/mock_state.go index c1321567e6a..f61851af8c6 100644 --- a/vms/platformvm/state/mock_state.go +++ b/vms/platformvm/state/mock_state.go @@ -1291,6 +1291,22 @@ func (mr *MockStateMockRecorder) GetCurrentValidator(arg0, arg1 any) *gomock.Cal return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidator", reflect.TypeOf((*MockState)(nil).GetCurrentValidator), arg0, arg1) } +// GetCurrentValidatorSet mocks base method. +func (m *MockState) GetCurrentValidatorSet(arg0 ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCurrentValidatorSet", arg0) + ret0, _ := ret[0].(map[ids.ID]*validators.GetCurrentValidatorOutput) + ret1, _ := ret[1].(uint64) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetCurrentValidatorSet indicates an expected call of GetCurrentValidatorSet. +func (mr *MockStateMockRecorder) GetCurrentValidatorSet(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorSet", reflect.TypeOf((*MockState)(nil).GetCurrentValidatorSet), arg0) +} + // GetDelegateeReward mocks base method. func (m *MockState) GetDelegateeReward(arg0 ids.ID, arg1 ids.NodeID) (uint64, error) { m.ctrl.T.Helper() diff --git a/vms/platformvm/state/state.go b/vms/platformvm/state/state.go index 0e43e6720f1..4337a299209 100644 --- a/vms/platformvm/state/state.go +++ b/vms/platformvm/state/state.go @@ -175,6 +175,8 @@ type State interface { SetHeight(height uint64) + GetCurrentValidatorSet(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) + // Discard uncommitted changes to the database. Abort() @@ -661,7 +663,7 @@ func newState( }, nil } -func (s *state) GetCurrentValidators(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, error) { +func (s *state) GetCurrentValidatorSet(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { result := make(map[ids.ID]*validators.GetCurrentValidatorOutput) for _, staker := range s.currentStakers.validators[subnetID] { validator := staker.validator @@ -676,7 +678,7 @@ func (s *state) GetCurrentValidators(subnetID ids.ID) (map[ids.ID]*validators.Ge IsActive: true, } } - return result, nil + return result, s.currentHeight, nil } func (s *state) GetCurrentValidator(subnetID ids.ID, nodeID ids.NodeID) (*Staker, error) { diff --git a/vms/platformvm/validators/manager.go b/vms/platformvm/validators/manager.go index 2270a8931d5..2bf370b3187 100644 --- a/vms/platformvm/validators/manager.go +++ b/vms/platformvm/validators/manager.go @@ -87,7 +87,7 @@ type State interface { endHeight uint64, ) error - GetCurrentValidators(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, error) + GetCurrentValidatorSet(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) } func NewManager( @@ -389,11 +389,7 @@ func (m *manager) OnAcceptedBlockID(blkID ids.ID) { } func (m *manager) GetCurrentValidatorSet(ctx context.Context, subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { - currentHeight, err := m.getCurrentHeight(ctx) - if err != nil { - return nil, 0, err - } - vdrs, err := m.state.GetCurrentValidators(subnetID) + vdrs, currentHeight, err := m.state.GetCurrentValidatorSet(subnetID) if err != nil { return nil, 0, err } diff --git a/vms/platformvm/validators/test_manager.go b/vms/platformvm/validators/test_manager.go index e04742f265c..94f3d6e0fe5 100644 --- a/vms/platformvm/validators/test_manager.go +++ b/vms/platformvm/validators/test_manager.go @@ -30,4 +30,8 @@ func (testManager) GetValidatorSet(context.Context, uint64, ids.ID) (map[ids.Nod return nil, nil } +func (testManager) GetCurrentValidatorSet(context.Context, ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { + return nil, 0, nil +} + func (testManager) OnAcceptedBlockID(ids.ID) {} From 29e7797adb63019e140ea97b9e6459e86a969e66 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Thu, 19 Sep 2024 16:36:57 -0400 Subject: [PATCH 6/8] regen mock --- snow/validators/validatorsmock/state.go | 8 ++++---- vms/platformvm/state/mock_state.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/snow/validators/validatorsmock/state.go b/snow/validators/validatorsmock/state.go index 8cc19b2c0d1..feb6cdbb57a 100644 --- a/snow/validators/validatorsmock/state.go +++ b/snow/validators/validatorsmock/state.go @@ -57,19 +57,19 @@ func (mr *StateMockRecorder) GetCurrentHeight(arg0 any) *gomock.Call { } // GetCurrentValidatorSet mocks base method. -func (m *MockState) GetCurrentValidatorSet(arg0 context.Context, arg1 ids.ID) (map[ids.ID]*GetCurrentValidatorOutput, uint64, error) { +func (m *State) GetCurrentValidatorSet(arg0 context.Context, arg1 ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetCurrentValidatorSet", arg0, arg1) - ret0, _ := ret[0].(map[ids.ID]*GetCurrentValidatorOutput) + ret0, _ := ret[0].(map[ids.ID]*validators.GetCurrentValidatorOutput) ret1, _ := ret[1].(uint64) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } // GetCurrentValidatorSet indicates an expected call of GetCurrentValidatorSet. -func (mr *MockStateMockRecorder) GetCurrentValidatorSet(arg0, arg1 any) *gomock.Call { +func (mr *StateMockRecorder) GetCurrentValidatorSet(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorSet", reflect.TypeOf((*MockState)(nil).GetCurrentValidatorSet), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorSet", reflect.TypeOf((*State)(nil).GetCurrentValidatorSet), arg0, arg1) } // GetMinimumHeight mocks base method. diff --git a/vms/platformvm/state/mock_state.go b/vms/platformvm/state/mock_state.go index 5a6f1ad6c51..1dfbd0a004a 100644 --- a/vms/platformvm/state/mock_state.go +++ b/vms/platformvm/state/mock_state.go @@ -410,9 +410,9 @@ func (mr *MockStateMockRecorder) GetCurrentValidator(subnetID, nodeID any) *gomo } // GetCurrentValidatorSet mocks base method. -func (m *MockState) GetCurrentValidatorSet(arg0 ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { +func (m *MockState) GetCurrentValidatorSet(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetCurrentValidatorSet", arg0) + ret := m.ctrl.Call(m, "GetCurrentValidatorSet", subnetID) ret0, _ := ret[0].(map[ids.ID]*validators.GetCurrentValidatorOutput) ret1, _ := ret[1].(uint64) ret2, _ := ret[2].(error) @@ -420,9 +420,9 @@ func (m *MockState) GetCurrentValidatorSet(arg0 ids.ID) (map[ids.ID]*validators. } // GetCurrentValidatorSet indicates an expected call of GetCurrentValidatorSet. -func (mr *MockStateMockRecorder) GetCurrentValidatorSet(arg0 any) *gomock.Call { +func (mr *MockStateMockRecorder) GetCurrentValidatorSet(subnetID any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorSet", reflect.TypeOf((*MockState)(nil).GetCurrentValidatorSet), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorSet", reflect.TypeOf((*MockState)(nil).GetCurrentValidatorSet), subnetID) } // GetDelegateeReward mocks base method. From 09d63ce2672104a2af70f6a9dac1c7ff7acbebc1 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Fri, 20 Sep 2024 10:44:57 -0400 Subject: [PATCH 7/8] populate validationID --- vms/platformvm/state/state.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vms/platformvm/state/state.go b/vms/platformvm/state/state.go index 4ca8db4dd45..78aecdf3423 100644 --- a/vms/platformvm/state/state.go +++ b/vms/platformvm/state/state.go @@ -724,10 +724,11 @@ func (s *state) GetCurrentValidatorSet(subnetID ids.ID) (map[ids.ID]*validators. for _, staker := range s.currentStakers.validators[subnetID] { validator := staker.validator result[validator.TxID] = &validators.GetCurrentValidatorOutput{ - NodeID: validator.NodeID, - PublicKey: validator.PublicKey, - Weight: validator.Weight, - StartTime: uint64(validator.StartTime.Unix()), + ValidationID: validator.TxID, + NodeID: validator.NodeID, + PublicKey: validator.PublicKey, + Weight: validator.Weight, + StartTime: uint64(validator.StartTime.Unix()), // TODO: not implemented yet SetWeightNonce: 0, // TODO: not implemented yet From 07af6b2fbe170c2b3ee4c7b7b011e5e42988d02a Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Fri, 20 Sep 2024 11:02:11 -0400 Subject: [PATCH 8/8] add ctx --- vms/platformvm/state/mock_state.go | 8 ++++---- vms/platformvm/state/state.go | 7 +++++-- vms/platformvm/validators/manager.go | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/vms/platformvm/state/mock_state.go b/vms/platformvm/state/mock_state.go index de9dd04c55c..26f993a7095 100644 --- a/vms/platformvm/state/mock_state.go +++ b/vms/platformvm/state/mock_state.go @@ -410,9 +410,9 @@ func (mr *MockStateMockRecorder) GetCurrentValidator(subnetID, nodeID any) *gomo } // GetCurrentValidatorSet mocks base method. -func (m *MockState) GetCurrentValidatorSet(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { +func (m *MockState) GetCurrentValidatorSet(ctx context.Context, subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetCurrentValidatorSet", subnetID) + ret := m.ctrl.Call(m, "GetCurrentValidatorSet", ctx, subnetID) ret0, _ := ret[0].(map[ids.ID]*validators.GetCurrentValidatorOutput) ret1, _ := ret[1].(uint64) ret2, _ := ret[2].(error) @@ -420,9 +420,9 @@ func (m *MockState) GetCurrentValidatorSet(subnetID ids.ID) (map[ids.ID]*validat } // GetCurrentValidatorSet indicates an expected call of GetCurrentValidatorSet. -func (mr *MockStateMockRecorder) GetCurrentValidatorSet(subnetID any) *gomock.Call { +func (mr *MockStateMockRecorder) GetCurrentValidatorSet(ctx, subnetID any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorSet", reflect.TypeOf((*MockState)(nil).GetCurrentValidatorSet), subnetID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorSet", reflect.TypeOf((*MockState)(nil).GetCurrentValidatorSet), ctx, subnetID) } // GetDelegateeReward mocks base method. diff --git a/vms/platformvm/state/state.go b/vms/platformvm/state/state.go index 78aecdf3423..ac6753ee9ce 100644 --- a/vms/platformvm/state/state.go +++ b/vms/platformvm/state/state.go @@ -193,7 +193,7 @@ type State interface { SetHeight(height uint64) - GetCurrentValidatorSet(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) + GetCurrentValidatorSet(ctx context.Context, subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) // Discard uncommitted changes to the database. Abort() @@ -719,9 +719,12 @@ func (s *state) DeleteExpiry(entry ExpiryEntry) { s.expiryDiff.DeleteExpiry(entry) } -func (s *state) GetCurrentValidatorSet(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { +func (s *state) GetCurrentValidatorSet(ctx context.Context, subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { result := make(map[ids.ID]*validators.GetCurrentValidatorOutput) for _, staker := range s.currentStakers.validators[subnetID] { + if err := ctx.Err(); err != nil { + return nil, 0, err + } validator := staker.validator result[validator.TxID] = &validators.GetCurrentValidatorOutput{ ValidationID: validator.TxID, diff --git a/vms/platformvm/validators/manager.go b/vms/platformvm/validators/manager.go index 2bf370b3187..038553dabb1 100644 --- a/vms/platformvm/validators/manager.go +++ b/vms/platformvm/validators/manager.go @@ -87,7 +87,7 @@ type State interface { endHeight uint64, ) error - GetCurrentValidatorSet(subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) + GetCurrentValidatorSet(ctx context.Context, subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) } func NewManager( @@ -389,7 +389,7 @@ func (m *manager) OnAcceptedBlockID(blkID ids.ID) { } func (m *manager) GetCurrentValidatorSet(ctx context.Context, subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { - vdrs, currentHeight, err := m.state.GetCurrentValidatorSet(subnetID) + vdrs, currentHeight, err := m.state.GetCurrentValidatorSet(ctx, subnetID) if err != nil { return nil, 0, err }