mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
One more validator client cleanup (#14048)
* interface names * interface method names * inspection * regenerate pb and mock * Revert beacon node changes * build fix * review * more functions * combine parameters
This commit is contained in:
@@ -37,7 +37,7 @@ func TestExitAccountsCli_OK(t *testing.T) {
|
||||
}
|
||||
|
||||
mockNodeClient.EXPECT().
|
||||
GetGenesis(gomock.Any(), gomock.Any()).
|
||||
Genesis(gomock.Any(), gomock.Any()).
|
||||
Return(ðpb.Genesis{GenesisTime: genesisTime}, nil)
|
||||
|
||||
mockValidatorClient.EXPECT().
|
||||
@@ -133,7 +133,7 @@ func TestExitAccountsCli_OK_AllPublicKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
mockNodeClient.EXPECT().
|
||||
GetGenesis(gomock.Any(), gomock.Any()).
|
||||
Genesis(gomock.Any(), gomock.Any()).
|
||||
Return(ðpb.Genesis{GenesisTime: genesisTime}, nil)
|
||||
|
||||
mockValidatorClient.EXPECT().
|
||||
@@ -235,7 +235,7 @@ func TestExitAccountsCli_OK_ForceExit(t *testing.T) {
|
||||
}
|
||||
|
||||
mockNodeClient.EXPECT().
|
||||
GetGenesis(gomock.Any(), gomock.Any()).
|
||||
Genesis(gomock.Any(), gomock.Any()).
|
||||
Return(ðpb.Genesis{GenesisTime: genesisTime}, nil)
|
||||
|
||||
mockValidatorClient.EXPECT().
|
||||
@@ -324,7 +324,7 @@ func TestExitAccountsCli_WriteJSON_NoBroadcast(t *testing.T) {
|
||||
}
|
||||
|
||||
mockNodeClient.EXPECT().
|
||||
GetGenesis(gomock.Any(), gomock.Any()).
|
||||
Genesis(gomock.Any(), gomock.Any()).
|
||||
Return(ðpb.Genesis{GenesisTime: genesisTime}, nil)
|
||||
|
||||
mockValidatorClient.EXPECT().
|
||||
|
||||
36
testing/validator-mock/chain_client_mock.go
generated
36
testing/validator-mock/chain_client_mock.go
generated
@@ -42,9 +42,9 @@ func (m *MockChainClient) EXPECT() *MockChainClientMockRecorder {
|
||||
}
|
||||
|
||||
// GetChainHead mocks base method.
|
||||
func (m *MockChainClient) GetChainHead(arg0 context.Context, arg1 *emptypb.Empty) (*eth.ChainHead, error) {
|
||||
func (m *MockChainClient) ChainHead(arg0 context.Context, arg1 *emptypb.Empty) (*eth.ChainHead, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetChainHead", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "ChainHead", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.ChainHead)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
@@ -53,13 +53,13 @@ func (m *MockChainClient) GetChainHead(arg0 context.Context, arg1 *emptypb.Empty
|
||||
// GetChainHead indicates an expected call of GetChainHead.
|
||||
func (mr *MockChainClientMockRecorder) GetChainHead(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChainHead", reflect.TypeOf((*MockChainClient)(nil).GetChainHead), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainHead", reflect.TypeOf((*MockChainClient)(nil).ChainHead), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetValidatorParticipation mocks base method.
|
||||
func (m *MockChainClient) GetValidatorParticipation(arg0 context.Context, arg1 *eth.GetValidatorParticipationRequest) (*eth.ValidatorParticipationResponse, error) {
|
||||
func (m *MockChainClient) ValidatorParticipation(arg0 context.Context, arg1 *eth.GetValidatorParticipationRequest) (*eth.ValidatorParticipationResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetValidatorParticipation", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "ValidatorParticipation", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.ValidatorParticipationResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
@@ -68,13 +68,13 @@ func (m *MockChainClient) GetValidatorParticipation(arg0 context.Context, arg1 *
|
||||
// GetValidatorParticipation indicates an expected call of GetValidatorParticipation.
|
||||
func (mr *MockChainClientMockRecorder) GetValidatorParticipation(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorParticipation", reflect.TypeOf((*MockChainClient)(nil).GetValidatorParticipation), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorParticipation", reflect.TypeOf((*MockChainClient)(nil).ValidatorParticipation), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetValidatorPerformance mocks base method.
|
||||
func (m *MockChainClient) GetValidatorPerformance(arg0 context.Context, arg1 *eth.ValidatorPerformanceRequest) (*eth.ValidatorPerformanceResponse, error) {
|
||||
func (m *MockChainClient) ValidatorPerformance(arg0 context.Context, arg1 *eth.ValidatorPerformanceRequest) (*eth.ValidatorPerformanceResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetValidatorPerformance", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "ValidatorPerformance", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.ValidatorPerformanceResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
@@ -83,13 +83,13 @@ func (m *MockChainClient) GetValidatorPerformance(arg0 context.Context, arg1 *et
|
||||
// GetValidatorPerformance indicates an expected call of GetValidatorPerformance.
|
||||
func (mr *MockChainClientMockRecorder) GetValidatorPerformance(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorPerformance", reflect.TypeOf((*MockChainClient)(nil).GetValidatorPerformance), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorPerformance", reflect.TypeOf((*MockChainClient)(nil).ValidatorPerformance), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetValidatorQueue mocks base method.
|
||||
func (m *MockChainClient) GetValidatorQueue(arg0 context.Context, arg1 *emptypb.Empty) (*eth.ValidatorQueue, error) {
|
||||
func (m *MockChainClient) ValidatorQueue(arg0 context.Context, arg1 *emptypb.Empty) (*eth.ValidatorQueue, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetValidatorQueue", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "ValidatorQueue", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.ValidatorQueue)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
@@ -98,13 +98,13 @@ func (m *MockChainClient) GetValidatorQueue(arg0 context.Context, arg1 *emptypb.
|
||||
// GetValidatorQueue indicates an expected call of GetValidatorQueue.
|
||||
func (mr *MockChainClientMockRecorder) GetValidatorQueue(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorQueue", reflect.TypeOf((*MockChainClient)(nil).GetValidatorQueue), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorQueue", reflect.TypeOf((*MockChainClient)(nil).ValidatorQueue), arg0, arg1)
|
||||
}
|
||||
|
||||
// ListValidatorBalances mocks base method.
|
||||
func (m *MockChainClient) ListValidatorBalances(arg0 context.Context, arg1 *eth.ListValidatorBalancesRequest) (*eth.ValidatorBalances, error) {
|
||||
func (m *MockChainClient) ValidatorBalances(arg0 context.Context, arg1 *eth.ListValidatorBalancesRequest) (*eth.ValidatorBalances, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListValidatorBalances", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "ValidatorBalances", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.ValidatorBalances)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
@@ -113,13 +113,13 @@ func (m *MockChainClient) ListValidatorBalances(arg0 context.Context, arg1 *eth.
|
||||
// ListValidatorBalances indicates an expected call of ListValidatorBalances.
|
||||
func (mr *MockChainClientMockRecorder) ListValidatorBalances(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListValidatorBalances", reflect.TypeOf((*MockChainClient)(nil).ListValidatorBalances), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorBalances", reflect.TypeOf((*MockChainClient)(nil).ValidatorBalances), arg0, arg1)
|
||||
}
|
||||
|
||||
// ListValidators mocks base method.
|
||||
func (m *MockChainClient) ListValidators(arg0 context.Context, arg1 *eth.ListValidatorsRequest) (*eth.Validators, error) {
|
||||
func (m *MockChainClient) Validators(arg0 context.Context, arg1 *eth.ListValidatorsRequest) (*eth.Validators, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListValidators", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "Validators", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.Validators)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
@@ -128,5 +128,5 @@ func (m *MockChainClient) ListValidators(arg0 context.Context, arg1 *eth.ListVal
|
||||
// ListValidators indicates an expected call of ListValidators.
|
||||
func (mr *MockChainClientMockRecorder) ListValidators(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListValidators", reflect.TypeOf((*MockChainClient)(nil).ListValidators), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Validators", reflect.TypeOf((*MockChainClient)(nil).Validators), arg0, arg1)
|
||||
}
|
||||
|
||||
84
testing/validator-mock/node_client_mock.go
generated
84
testing/validator-mock/node_client_mock.go
generated
@@ -42,49 +42,19 @@ func (m *MockNodeClient) EXPECT() *MockNodeClientMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// GetGenesis mocks base method.
|
||||
func (m *MockNodeClient) GetGenesis(arg0 context.Context, arg1 *emptypb.Empty) (*eth.Genesis, error) {
|
||||
// Genesis mocks base method.
|
||||
func (m *MockNodeClient) Genesis(arg0 context.Context, arg1 *emptypb.Empty) (*eth.Genesis, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetGenesis", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "Genesis", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.Genesis)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetGenesis indicates an expected call of GetGenesis.
|
||||
func (mr *MockNodeClientMockRecorder) GetGenesis(arg0, arg1 any) *gomock.Call {
|
||||
// Genesis indicates an expected call of Genesis.
|
||||
func (mr *MockNodeClientMockRecorder) Genesis(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGenesis", reflect.TypeOf((*MockNodeClient)(nil).GetGenesis), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetSyncStatus mocks base method.
|
||||
func (m *MockNodeClient) GetSyncStatus(arg0 context.Context, arg1 *emptypb.Empty) (*eth.SyncStatus, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetSyncStatus", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.SyncStatus)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetSyncStatus indicates an expected call of GetSyncStatus.
|
||||
func (mr *MockNodeClientMockRecorder) GetSyncStatus(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncStatus", reflect.TypeOf((*MockNodeClient)(nil).GetSyncStatus), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetVersion mocks base method.
|
||||
func (m *MockNodeClient) GetVersion(arg0 context.Context, arg1 *emptypb.Empty) (*eth.Version, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetVersion", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.Version)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetVersion indicates an expected call of GetVersion.
|
||||
func (mr *MockNodeClientMockRecorder) GetVersion(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVersion", reflect.TypeOf((*MockNodeClient)(nil).GetVersion), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Genesis", reflect.TypeOf((*MockNodeClient)(nil).Genesis), arg0, arg1)
|
||||
}
|
||||
|
||||
// HealthTracker mocks base method.
|
||||
@@ -101,17 +71,47 @@ func (mr *MockNodeClientMockRecorder) HealthTracker() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HealthTracker", reflect.TypeOf((*MockNodeClient)(nil).HealthTracker))
|
||||
}
|
||||
|
||||
// ListPeers mocks base method.
|
||||
func (m *MockNodeClient) ListPeers(arg0 context.Context, arg1 *emptypb.Empty) (*eth.Peers, error) {
|
||||
// Peers mocks base method.
|
||||
func (m *MockNodeClient) Peers(arg0 context.Context, arg1 *emptypb.Empty) (*eth.Peers, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListPeers", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "Peers", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.Peers)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListPeers indicates an expected call of ListPeers.
|
||||
func (mr *MockNodeClientMockRecorder) ListPeers(arg0, arg1 any) *gomock.Call {
|
||||
// Peers indicates an expected call of Peers.
|
||||
func (mr *MockNodeClientMockRecorder) Peers(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPeers", reflect.TypeOf((*MockNodeClient)(nil).ListPeers), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Peers", reflect.TypeOf((*MockNodeClient)(nil).Peers), arg0, arg1)
|
||||
}
|
||||
|
||||
// SyncStatus mocks base method.
|
||||
func (m *MockNodeClient) SyncStatus(arg0 context.Context, arg1 *emptypb.Empty) (*eth.SyncStatus, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SyncStatus", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.SyncStatus)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SyncStatus indicates an expected call of SyncStatus.
|
||||
func (mr *MockNodeClientMockRecorder) SyncStatus(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncStatus", reflect.TypeOf((*MockNodeClient)(nil).SyncStatus), arg0, arg1)
|
||||
}
|
||||
|
||||
// Version mocks base method.
|
||||
func (m *MockNodeClient) Version(arg0 context.Context, arg1 *emptypb.Empty) (*eth.Version, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Version", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.Version)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Version indicates an expected call of Version.
|
||||
func (mr *MockNodeClientMockRecorder) Version(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Version", reflect.TypeOf((*MockNodeClient)(nil).Version), arg0, arg1)
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ func (m *MockPrysmChainClient) EXPECT() *MockPrysmChainClientMockRecorder {
|
||||
}
|
||||
|
||||
// GetValidatorCount mocks base method.
|
||||
func (m *MockPrysmChainClient) GetValidatorCount(arg0 context.Context, arg1 string, arg2 []validator.Status) ([]iface.ValidatorCount, error) {
|
||||
func (m *MockPrysmChainClient) ValidatorCount(arg0 context.Context, arg1 string, arg2 []validator.Status) ([]iface.ValidatorCount, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetValidatorCount", arg0, arg1, arg2)
|
||||
ret := m.ctrl.Call(m, "ValidatorCount", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].([]iface.ValidatorCount)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
@@ -48,5 +48,5 @@ func (m *MockPrysmChainClient) GetValidatorCount(arg0 context.Context, arg1 stri
|
||||
// GetValidatorCount indicates an expected call of GetValidatorCount.
|
||||
func (mr *MockPrysmChainClientMockRecorder) GetValidatorCount(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorCount", reflect.TypeOf((*MockPrysmChainClient)(nil).GetValidatorCount), arg0, arg1, arg2)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorCount", reflect.TypeOf((*MockPrysmChainClient)(nil).ValidatorCount), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
252
testing/validator-mock/validator_client_mock.go
generated
252
testing/validator-mock/validator_client_mock.go
generated
@@ -44,6 +44,66 @@ func (m *MockValidatorClient) EXPECT() *MockValidatorClientMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// AggregatedSelections mocks base method.
|
||||
func (m *MockValidatorClient) AggregatedSelections(arg0 context.Context, arg1 []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AggregatedSelections", arg0, arg1)
|
||||
ret0, _ := ret[0].([]iface.BeaconCommitteeSelection)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// AggregatedSelections indicates an expected call of AggregatedSelections.
|
||||
func (mr *MockValidatorClientMockRecorder) AggregatedSelections(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AggregatedSelections", reflect.TypeOf((*MockValidatorClient)(nil).AggregatedSelections), arg0, arg1)
|
||||
}
|
||||
|
||||
// AggregatedSyncSelections mocks base method.
|
||||
func (m *MockValidatorClient) AggregatedSyncSelections(arg0 context.Context, arg1 []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AggregatedSyncSelections", arg0, arg1)
|
||||
ret0, _ := ret[0].([]iface.SyncCommitteeSelection)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// AggregatedSyncSelections indicates an expected call of AggregatedSyncSelections.
|
||||
func (mr *MockValidatorClientMockRecorder) AggregatedSyncSelections(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AggregatedSyncSelections", reflect.TypeOf((*MockValidatorClient)(nil).AggregatedSyncSelections), arg0, arg1)
|
||||
}
|
||||
|
||||
// AttestationData mocks base method.
|
||||
func (m *MockValidatorClient) AttestationData(arg0 context.Context, arg1 *eth.AttestationDataRequest) (*eth.AttestationData, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AttestationData", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.AttestationData)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// AttestationData indicates an expected call of AttestationData.
|
||||
func (mr *MockValidatorClientMockRecorder) AttestationData(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AttestationData", reflect.TypeOf((*MockValidatorClient)(nil).AttestationData), arg0, arg1)
|
||||
}
|
||||
|
||||
// BeaconBlock mocks base method.
|
||||
func (m *MockValidatorClient) BeaconBlock(arg0 context.Context, arg1 *eth.BlockRequest) (*eth.GenericBeaconBlock, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BeaconBlock", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.GenericBeaconBlock)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// BeaconBlock indicates an expected call of BeaconBlock.
|
||||
func (mr *MockValidatorClientMockRecorder) BeaconBlock(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BeaconBlock", reflect.TypeOf((*MockValidatorClient)(nil).BeaconBlock), arg0, arg1)
|
||||
}
|
||||
|
||||
// CheckDoppelGanger mocks base method.
|
||||
func (m *MockValidatorClient) CheckDoppelGanger(arg0 context.Context, arg1 *eth.DoppelGangerRequest) (*eth.DoppelGangerResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -74,6 +134,21 @@ func (mr *MockValidatorClientMockRecorder) DomainData(arg0, arg1 any) *gomock.Ca
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DomainData", reflect.TypeOf((*MockValidatorClient)(nil).DomainData), arg0, arg1)
|
||||
}
|
||||
|
||||
// Duties mocks base method.
|
||||
func (m *MockValidatorClient) Duties(arg0 context.Context, arg1 *eth.DutiesRequest) (*eth.DutiesResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Duties", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.DutiesResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Duties indicates an expected call of Duties.
|
||||
func (mr *MockValidatorClientMockRecorder) Duties(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Duties", reflect.TypeOf((*MockValidatorClient)(nil).Duties), arg0, arg1)
|
||||
}
|
||||
|
||||
// EventStreamIsRunning mocks base method.
|
||||
func (m *MockValidatorClient) EventStreamIsRunning() bool {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -88,139 +163,19 @@ func (mr *MockValidatorClientMockRecorder) EventStreamIsRunning() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EventStreamIsRunning", reflect.TypeOf((*MockValidatorClient)(nil).EventStreamIsRunning))
|
||||
}
|
||||
|
||||
// GetAggregatedSelections mocks base method.
|
||||
func (m *MockValidatorClient) GetAggregatedSelections(arg0 context.Context, arg1 []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) {
|
||||
// FeeRecipientByPubKey mocks base method.
|
||||
func (m *MockValidatorClient) FeeRecipientByPubKey(arg0 context.Context, arg1 *eth.FeeRecipientByPubKeyRequest) (*eth.FeeRecipientByPubKeyResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAggregatedSelections", arg0, arg1)
|
||||
ret0, _ := ret[0].([]iface.BeaconCommitteeSelection)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetAggregatedSelections indicates an expected call of GetAggregatedSelections.
|
||||
func (mr *MockValidatorClientMockRecorder) GetAggregatedSelections(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAggregatedSelections", reflect.TypeOf((*MockValidatorClient)(nil).GetAggregatedSelections), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetAggregatedSyncSelections mocks base method.
|
||||
func (m *MockValidatorClient) GetAggregatedSyncSelections(arg0 context.Context, arg1 []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAggregatedSyncSelections", arg0, arg1)
|
||||
ret0, _ := ret[0].([]iface.SyncCommitteeSelection)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetAggregatedSyncSelections indicates an expected call of GetAggregatedSyncSelections.
|
||||
func (mr *MockValidatorClientMockRecorder) GetAggregatedSyncSelections(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAggregatedSyncSelections", reflect.TypeOf((*MockValidatorClient)(nil).GetAggregatedSyncSelections), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetAttestationData mocks base method.
|
||||
func (m *MockValidatorClient) GetAttestationData(arg0 context.Context, arg1 *eth.AttestationDataRequest) (*eth.AttestationData, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAttestationData", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.AttestationData)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetAttestationData indicates an expected call of GetAttestationData.
|
||||
func (mr *MockValidatorClientMockRecorder) GetAttestationData(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAttestationData", reflect.TypeOf((*MockValidatorClient)(nil).GetAttestationData), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetBeaconBlock mocks base method.
|
||||
func (m *MockValidatorClient) GetBeaconBlock(arg0 context.Context, arg1 *eth.BlockRequest) (*eth.GenericBeaconBlock, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBeaconBlock", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.GenericBeaconBlock)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetBeaconBlock indicates an expected call of GetBeaconBlock.
|
||||
func (mr *MockValidatorClientMockRecorder) GetBeaconBlock(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBeaconBlock", reflect.TypeOf((*MockValidatorClient)(nil).GetBeaconBlock), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetDuties mocks base method.
|
||||
func (m *MockValidatorClient) GetDuties(arg0 context.Context, arg1 *eth.DutiesRequest) (*eth.DutiesResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetDuties", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.DutiesResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetDuties indicates an expected call of GetDuties.
|
||||
func (mr *MockValidatorClientMockRecorder) GetDuties(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDuties", reflect.TypeOf((*MockValidatorClient)(nil).GetDuties), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetFeeRecipientByPubKey mocks base method.
|
||||
func (m *MockValidatorClient) GetFeeRecipientByPubKey(arg0 context.Context, arg1 *eth.FeeRecipientByPubKeyRequest) (*eth.FeeRecipientByPubKeyResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetFeeRecipientByPubKey", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "FeeRecipientByPubKey", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.FeeRecipientByPubKeyResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetFeeRecipientByPubKey indicates an expected call of GetFeeRecipientByPubKey.
|
||||
func (mr *MockValidatorClientMockRecorder) GetFeeRecipientByPubKey(arg0, arg1 any) *gomock.Call {
|
||||
// FeeRecipientByPubKey indicates an expected call of FeeRecipientByPubKey.
|
||||
func (mr *MockValidatorClientMockRecorder) FeeRecipientByPubKey(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFeeRecipientByPubKey", reflect.TypeOf((*MockValidatorClient)(nil).GetFeeRecipientByPubKey), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetSyncCommitteeContribution mocks base method.
|
||||
func (m *MockValidatorClient) GetSyncCommitteeContribution(arg0 context.Context, arg1 *eth.SyncCommitteeContributionRequest) (*eth.SyncCommitteeContribution, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetSyncCommitteeContribution", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.SyncCommitteeContribution)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetSyncCommitteeContribution indicates an expected call of GetSyncCommitteeContribution.
|
||||
func (mr *MockValidatorClientMockRecorder) GetSyncCommitteeContribution(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncCommitteeContribution", reflect.TypeOf((*MockValidatorClient)(nil).GetSyncCommitteeContribution), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetSyncMessageBlockRoot mocks base method.
|
||||
func (m *MockValidatorClient) GetSyncMessageBlockRoot(arg0 context.Context, arg1 *emptypb.Empty) (*eth.SyncMessageBlockRootResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetSyncMessageBlockRoot", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.SyncMessageBlockRootResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetSyncMessageBlockRoot indicates an expected call of GetSyncMessageBlockRoot.
|
||||
func (mr *MockValidatorClientMockRecorder) GetSyncMessageBlockRoot(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncMessageBlockRoot", reflect.TypeOf((*MockValidatorClient)(nil).GetSyncMessageBlockRoot), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetSyncSubcommitteeIndex mocks base method.
|
||||
func (m *MockValidatorClient) GetSyncSubcommitteeIndex(arg0 context.Context, arg1 *eth.SyncSubcommitteeIndexRequest) (*eth.SyncSubcommitteeIndexResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetSyncSubcommitteeIndex", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.SyncSubcommitteeIndexResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetSyncSubcommitteeIndex indicates an expected call of GetSyncSubcommitteeIndex.
|
||||
func (mr *MockValidatorClientMockRecorder) GetSyncSubcommitteeIndex(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncSubcommitteeIndex", reflect.TypeOf((*MockValidatorClient)(nil).GetSyncSubcommitteeIndex), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FeeRecipientByPubKey", reflect.TypeOf((*MockValidatorClient)(nil).FeeRecipientByPubKey), arg0, arg1)
|
||||
}
|
||||
|
||||
// Host mocks base method.
|
||||
@@ -426,6 +381,51 @@ func (mr *MockValidatorClientMockRecorder) SubscribeCommitteeSubnets(arg0, arg1,
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeCommitteeSubnets", reflect.TypeOf((*MockValidatorClient)(nil).SubscribeCommitteeSubnets), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// SyncCommitteeContribution mocks base method.
|
||||
func (m *MockValidatorClient) SyncCommitteeContribution(arg0 context.Context, arg1 *eth.SyncCommitteeContributionRequest) (*eth.SyncCommitteeContribution, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SyncCommitteeContribution", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.SyncCommitteeContribution)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SyncCommitteeContribution indicates an expected call of SyncCommitteeContribution.
|
||||
func (mr *MockValidatorClientMockRecorder) SyncCommitteeContribution(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncCommitteeContribution", reflect.TypeOf((*MockValidatorClient)(nil).SyncCommitteeContribution), arg0, arg1)
|
||||
}
|
||||
|
||||
// SyncMessageBlockRoot mocks base method.
|
||||
func (m *MockValidatorClient) SyncMessageBlockRoot(arg0 context.Context, arg1 *emptypb.Empty) (*eth.SyncMessageBlockRootResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SyncMessageBlockRoot", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.SyncMessageBlockRootResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SyncMessageBlockRoot indicates an expected call of SyncMessageBlockRoot.
|
||||
func (mr *MockValidatorClientMockRecorder) SyncMessageBlockRoot(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncMessageBlockRoot", reflect.TypeOf((*MockValidatorClient)(nil).SyncMessageBlockRoot), arg0, arg1)
|
||||
}
|
||||
|
||||
// SyncSubcommitteeIndex mocks base method.
|
||||
func (m *MockValidatorClient) SyncSubcommitteeIndex(arg0 context.Context, arg1 *eth.SyncSubcommitteeIndexRequest) (*eth.SyncSubcommitteeIndexResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SyncSubcommitteeIndex", arg0, arg1)
|
||||
ret0, _ := ret[0].(*eth.SyncSubcommitteeIndexResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SyncSubcommitteeIndex indicates an expected call of SyncSubcommitteeIndex.
|
||||
func (mr *MockValidatorClientMockRecorder) SyncSubcommitteeIndex(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncSubcommitteeIndex", reflect.TypeOf((*MockValidatorClient)(nil).SyncSubcommitteeIndex), arg0, arg1)
|
||||
}
|
||||
|
||||
// ValidatorIndex mocks base method.
|
||||
func (m *MockValidatorClient) ValidatorIndex(arg0 context.Context, arg1 *eth.ValidatorIndexRequest) (*eth.ValidatorIndexResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
@@ -47,7 +47,7 @@ func (acm *CLIManager) Exit(ctx context.Context) error {
|
||||
if nodeClient == nil {
|
||||
return errors.New("could not prepare beacon node client")
|
||||
}
|
||||
syncStatus, err := (*nodeClient).GetSyncStatus(ctx, &emptypb.Empty{})
|
||||
syncStatus, err := (*nodeClient).SyncStatus(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func PerformVoluntaryExit(
|
||||
ctx context.Context, cfg PerformExitCfg,
|
||||
) (rawExitedKeys [][]byte, formattedExitedKeys []string, err error) {
|
||||
var rawNotExitedKeys [][]byte
|
||||
genesisResponse, err := cfg.NodeClient.GetGenesis(ctx, &emptypb.Empty{})
|
||||
genesisResponse, err := cfg.NodeClient.Genesis(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
log.WithError(err).Errorf("voluntary exit failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -217,8 +217,8 @@ func (m *Validator) SetProposerSettings(_ context.Context, settings *proposer.Se
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetGraffiti for mocking
|
||||
func (m *Validator) GetGraffiti(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte) ([]byte, error) {
|
||||
// Graffiti for mocking
|
||||
func (m *Validator) Graffiti(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte) ([]byte, error) {
|
||||
return []byte(m.graffiti), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ func (v *validator) SubmitAggregateAndProof(ctx context.Context, slot primitives
|
||||
|
||||
var slotSig []byte
|
||||
if v.distributed {
|
||||
slotSig, err = v.getAttSelection(attSelectionKey{slot: slot, index: duty.ValidatorIndex})
|
||||
slotSig, err = v.attSelection(attSelectionKey{slot: slot, index: duty.ValidatorIndex})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not find aggregated selection proof")
|
||||
if v.emitAccountMetrics {
|
||||
|
||||
@@ -75,7 +75,7 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot primitives.Slot,
|
||||
Slot: slot,
|
||||
CommitteeIndex: duty.CommitteeIndex,
|
||||
}
|
||||
data, err := v.validatorClient.GetAttestationData(ctx, req)
|
||||
data, err := v.validatorClient.AttestationData(ctx, req)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not request attestation to sign at slot")
|
||||
if v.emitAccountMetrics {
|
||||
@@ -90,7 +90,7 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot primitives.Slot,
|
||||
Data: data,
|
||||
}
|
||||
|
||||
_, signingRoot, err := v.getDomainAndSigningRoot(ctx, indexedAtt.Data)
|
||||
_, signingRoot, err := v.domainAndSigningRoot(ctx, indexedAtt.Data)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not get domain and signing root from attestation")
|
||||
if v.emitAccountMetrics {
|
||||
@@ -199,7 +199,7 @@ func (v *validator) duty(pubKey [fieldparams.BLSPubkeyLength]byte) (*ethpb.Dutie
|
||||
|
||||
// Given validator's public key, this function returns the signature of an attestation data and its signing root.
|
||||
func (v *validator) signAtt(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, data *ethpb.AttestationData, slot primitives.Slot) ([]byte, [32]byte, error) {
|
||||
domain, root, err := v.getDomainAndSigningRoot(ctx, data)
|
||||
domain, root, err := v.domainAndSigningRoot(ctx, data)
|
||||
if err != nil {
|
||||
return nil, [32]byte{}, err
|
||||
}
|
||||
@@ -217,7 +217,7 @@ func (v *validator) signAtt(ctx context.Context, pubKey [fieldparams.BLSPubkeyLe
|
||||
return sig.Marshal(), root, nil
|
||||
}
|
||||
|
||||
func (v *validator) getDomainAndSigningRoot(ctx context.Context, data *ethpb.AttestationData) (*ethpb.DomainResponse, [32]byte, error) {
|
||||
func (v *validator) domainAndSigningRoot(ctx context.Context, data *ethpb.AttestationData) (*ethpb.DomainResponse, [32]byte, error) {
|
||||
domain, err := v.domainData(ctx, data.Target.Epoch, params.BeaconConfig().DomainBeaconAttester[:])
|
||||
if err != nil {
|
||||
return nil, [32]byte{}, err
|
||||
|
||||
@@ -81,7 +81,7 @@ func TestAttestToBlockHead_SubmitAttestation_RequestFailure(t *testing.T) {
|
||||
Committee: make([]primitives.ValidatorIndex, 111),
|
||||
ValidatorIndex: 0,
|
||||
}}}
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Return(ðpb.AttestationData{
|
||||
@@ -128,7 +128,7 @@ func TestAttestToBlockHead_AttestsCorrectly(t *testing.T) {
|
||||
beaconBlockRoot := bytesutil.ToBytes32([]byte("A"))
|
||||
targetRoot := bytesutil.ToBytes32([]byte("B"))
|
||||
sourceRoot := bytesutil.ToBytes32([]byte("C"))
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Return(ðpb.AttestationData{
|
||||
@@ -206,7 +206,7 @@ func TestAttestToBlockHead_BlocksDoubleAtt(t *testing.T) {
|
||||
sourceRoot := bytesutil.ToBytes32([]byte("C"))
|
||||
beaconBlockRoot2 := bytesutil.ToBytes32([]byte("D"))
|
||||
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Return(ðpb.AttestationData{
|
||||
@@ -214,7 +214,7 @@ func TestAttestToBlockHead_BlocksDoubleAtt(t *testing.T) {
|
||||
Target: ðpb.Checkpoint{Root: targetRoot[:], Epoch: 4},
|
||||
Source: ðpb.Checkpoint{Root: sourceRoot[:], Epoch: 3},
|
||||
}, nil)
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Return(ðpb.AttestationData{
|
||||
@@ -261,7 +261,7 @@ func TestAttestToBlockHead_BlocksSurroundAtt(t *testing.T) {
|
||||
targetRoot := bytesutil.ToBytes32([]byte("B"))
|
||||
sourceRoot := bytesutil.ToBytes32([]byte("C"))
|
||||
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Return(ðpb.AttestationData{
|
||||
@@ -269,7 +269,7 @@ func TestAttestToBlockHead_BlocksSurroundAtt(t *testing.T) {
|
||||
Target: ðpb.Checkpoint{Root: targetRoot[:], Epoch: 2},
|
||||
Source: ðpb.Checkpoint{Root: sourceRoot[:], Epoch: 1},
|
||||
}, nil)
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Return(ðpb.AttestationData{
|
||||
@@ -317,7 +317,7 @@ func TestAttestToBlockHead_BlocksSurroundedAtt(t *testing.T) {
|
||||
targetRoot := bytesutil.ToBytes32([]byte("B"))
|
||||
sourceRoot := bytesutil.ToBytes32([]byte("C"))
|
||||
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Return(ðpb.AttestationData{
|
||||
@@ -339,7 +339,7 @@ func TestAttestToBlockHead_BlocksSurroundedAtt(t *testing.T) {
|
||||
validator.SubmitAttestation(context.Background(), 30, pubKey)
|
||||
require.LogsDoNotContain(t, hook, failedAttLocalProtectionErr)
|
||||
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Return(ðpb.AttestationData{
|
||||
@@ -363,12 +363,12 @@ func TestAttestToBlockHead_DoesNotAttestBeforeDelay(t *testing.T) {
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
validator.genesisTime = uint64(prysmTime.Now().Unix())
|
||||
m.validatorClient.EXPECT().GetDuties(
|
||||
m.validatorClient.EXPECT().Duties(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.DutiesRequest{}),
|
||||
).Times(0)
|
||||
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Times(0)
|
||||
@@ -408,7 +408,7 @@ func TestAttestToBlockHead_DoesAttestAfterDelay(t *testing.T) {
|
||||
ValidatorIndex: validatorIndex,
|
||||
}}}
|
||||
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Return(ðpb.AttestationData{
|
||||
@@ -450,7 +450,7 @@ func TestAttestToBlockHead_CorrectBitfieldLength(t *testing.T) {
|
||||
Committee: committee,
|
||||
ValidatorIndex: validatorIndex,
|
||||
}}}
|
||||
m.validatorClient.EXPECT().GetAttestationData(
|
||||
m.validatorClient.EXPECT().AttestationData(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.AttestationDataRequest{}),
|
||||
).Return(ðpb.AttestationData{
|
||||
@@ -643,7 +643,7 @@ func Test_slashableAttestationCheck_UpdatesLowestSignedEpochs(t *testing.T) {
|
||||
gomock.Any(), // ctx
|
||||
ðpb.DomainRequest{Epoch: 10, Domain: []byte{1, 0, 0, 0}},
|
||||
).Return(ðpb.DomainResponse{SignatureDomain: make([]byte, 32)}, nil /*err*/)
|
||||
_, sr, err := validator.getDomainAndSigningRoot(ctx, att.Data)
|
||||
_, sr, err := validator.domainAndSigningRoot(ctx, att.Data)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = validator.db.SlashableAttestationCheck(context.Background(), att, pubKey, sr, false, nil)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func (c beaconApiValidatorClient) waitForActivation(ctx context.Context, in *ethpb.ValidatorActivationRequest) (ethpb.BeaconNodeValidator_WaitForActivationClient, error) {
|
||||
func (c *beaconApiValidatorClient) waitForActivation(ctx context.Context, in *ethpb.ValidatorActivationRequest) (ethpb.BeaconNodeValidator_WaitForActivationClient, error) {
|
||||
return &waitForActivationClient{
|
||||
ctx: ctx,
|
||||
beaconApiValidatorClient: c,
|
||||
@@ -24,12 +24,12 @@ func (c beaconApiValidatorClient) waitForActivation(ctx context.Context, in *eth
|
||||
type waitForActivationClient struct {
|
||||
grpc.ClientStream
|
||||
ctx context.Context
|
||||
beaconApiValidatorClient
|
||||
*beaconApiValidatorClient
|
||||
*ethpb.ValidatorActivationRequest
|
||||
lastRecvTime time.Time
|
||||
}
|
||||
|
||||
func computeWaitElements(now time.Time, lastRecvTime time.Time) (time.Duration, time.Time) {
|
||||
func computeWaitElements(now, lastRecvTime time.Time) (time.Duration, time.Time) {
|
||||
nextRecvTime := lastRecvTime.Add(time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second)
|
||||
|
||||
if lastRecvTime.IsZero() {
|
||||
@@ -68,7 +68,7 @@ func (c *waitForActivationClient) Recv() (*ethpb.ValidatorActivationResponse, er
|
||||
stringTargetPubKeys[index] = stringPubKey
|
||||
}
|
||||
|
||||
stateValidators, err := c.stateValidatorsProvider.GetStateValidators(c.ctx, stringTargetPubKeys, nil, nil)
|
||||
stateValidators, err := c.stateValidatorsProvider.StateValidators(c.ctx, stringTargetPubKeys, nil, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get state validators")
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func (c beaconApiValidatorClient) getAttestationData(
|
||||
func (c *beaconApiValidatorClient) attestationData(
|
||||
ctx context.Context,
|
||||
reqSlot primitives.Slot,
|
||||
reqCommitteeIndex primitives.CommitteeIndex,
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestGetAttestationData_ValidAttestation(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
resp, err := validatorClient.getAttestationData(ctx, primitives.Slot(expectedSlot), primitives.CommitteeIndex(expectedCommitteeIndex))
|
||||
resp, err := validatorClient.attestationData(ctx, primitives.Slot(expectedSlot), primitives.CommitteeIndex(expectedCommitteeIndex))
|
||||
assert.NoError(t, err)
|
||||
|
||||
require.NotNil(t, resp)
|
||||
@@ -194,7 +194,7 @@ func TestGetAttestationData_InvalidData(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
_, err := validatorClient.getAttestationData(ctx, 1, 2)
|
||||
_, err := validatorClient.attestationData(ctx, 1, 2)
|
||||
assert.ErrorContains(t, testCase.expectedErrorMessage, err)
|
||||
})
|
||||
}
|
||||
@@ -220,11 +220,11 @@ func TestGetAttestationData_JsonResponseError(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
_, err := validatorClient.getAttestationData(ctx, slot, committeeIndex)
|
||||
_, err := validatorClient.attestationData(ctx, slot, committeeIndex)
|
||||
assert.ErrorContains(t, "some specific json response error", err)
|
||||
}
|
||||
|
||||
func generateValidAttestation(slot uint64, committeeIndex uint64) structs.GetAttestationDataResponse {
|
||||
func generateValidAttestation(slot, committeeIndex uint64) structs.GetAttestationDataResponse {
|
||||
return structs.GetAttestationDataResponse{
|
||||
Data: &structs.AttestationData{
|
||||
Slot: strconv.FormatUint(slot, 10),
|
||||
|
||||
@@ -25,7 +25,7 @@ type beaconApiChainClient struct {
|
||||
|
||||
const getValidatorPerformanceEndpoint = "/prysm/validators/performance"
|
||||
|
||||
func (c beaconApiChainClient) getHeadBlockHeaders(ctx context.Context) (*structs.GetBlockHeaderResponse, error) {
|
||||
func (c beaconApiChainClient) headBlockHeaders(ctx context.Context) (*structs.GetBlockHeaderResponse, error) {
|
||||
blockHeader := structs.GetBlockHeaderResponse{}
|
||||
err := c.jsonRestHandler.Get(ctx, "/eth/v1/beacon/headers/head", &blockHeader)
|
||||
if err != nil {
|
||||
@@ -43,7 +43,7 @@ func (c beaconApiChainClient) getHeadBlockHeaders(ctx context.Context) (*structs
|
||||
return &blockHeader, nil
|
||||
}
|
||||
|
||||
func (c beaconApiChainClient) GetChainHead(ctx context.Context, _ *empty.Empty) (*ethpb.ChainHead, error) {
|
||||
func (c beaconApiChainClient) ChainHead(ctx context.Context, _ *empty.Empty) (*ethpb.ChainHead, error) {
|
||||
const endpoint = "/eth/v1/beacon/states/head/finality_checkpoints"
|
||||
|
||||
finalityCheckpoints := structs.GetFinalityCheckpointsResponse{}
|
||||
@@ -112,7 +112,7 @@ func (c beaconApiChainClient) GetChainHead(ctx context.Context, _ *empty.Empty)
|
||||
return nil, errors.Wrapf(err, "failed to decode previous justified checkpoint root `%s`", finalityCheckpoints.Data.PreviousJustified.Root)
|
||||
}
|
||||
|
||||
blockHeader, err := c.getHeadBlockHeaders(ctx)
|
||||
blockHeader, err := c.headBlockHeaders(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get head block headers")
|
||||
}
|
||||
@@ -146,16 +146,16 @@ func (c beaconApiChainClient) GetChainHead(ctx context.Context, _ *empty.Empty)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c beaconApiChainClient) ListValidatorBalances(ctx context.Context, in *ethpb.ListValidatorBalancesRequest) (*ethpb.ValidatorBalances, error) {
|
||||
func (c beaconApiChainClient) ValidatorBalances(ctx context.Context, in *ethpb.ListValidatorBalancesRequest) (*ethpb.ValidatorBalances, error) {
|
||||
if c.fallbackClient != nil {
|
||||
return c.fallbackClient.ListValidatorBalances(ctx, in)
|
||||
return c.fallbackClient.ValidatorBalances(ctx, in)
|
||||
}
|
||||
|
||||
// TODO: Implement me
|
||||
panic("beaconApiChainClient.ListValidatorBalances is not implemented. To use a fallback client, pass a fallback client as the last argument of NewBeaconApiChainClientWithFallback.")
|
||||
panic("beaconApiChainClient.ValidatorBalances is not implemented. To use a fallback client, pass a fallback client as the last argument of NewBeaconApiChainClientWithFallback.")
|
||||
}
|
||||
|
||||
func (c beaconApiChainClient) ListValidators(ctx context.Context, in *ethpb.ListValidatorsRequest) (*ethpb.Validators, error) {
|
||||
func (c beaconApiChainClient) Validators(ctx context.Context, in *ethpb.ListValidatorsRequest) (*ethpb.Validators, error) {
|
||||
pageSize := in.PageSize
|
||||
|
||||
// We follow the gRPC behavior here, which returns a maximum of 250 results when pageSize == 0
|
||||
@@ -191,21 +191,21 @@ func (c beaconApiChainClient) ListValidators(ctx context.Context, in *ethpb.List
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get first slot for epoch `%d`", queryFilter.Epoch)
|
||||
}
|
||||
if stateValidators, err = c.stateValidatorsProvider.GetStateValidatorsForSlot(ctx, slot, pubkeys, in.Indices, statuses); err != nil {
|
||||
if stateValidators, err = c.stateValidatorsProvider.StateValidatorsForSlot(ctx, slot, pubkeys, in.Indices, statuses); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get state validators for slot `%d`", slot)
|
||||
}
|
||||
epoch = slots.ToEpoch(slot)
|
||||
case *ethpb.ListValidatorsRequest_Genesis:
|
||||
if stateValidators, err = c.stateValidatorsProvider.GetStateValidatorsForSlot(ctx, 0, pubkeys, in.Indices, statuses); err != nil {
|
||||
if stateValidators, err = c.stateValidatorsProvider.StateValidatorsForSlot(ctx, 0, pubkeys, in.Indices, statuses); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get genesis state validators")
|
||||
}
|
||||
epoch = 0
|
||||
case nil:
|
||||
if stateValidators, err = c.stateValidatorsProvider.GetStateValidatorsForHead(ctx, pubkeys, in.Indices, statuses); err != nil {
|
||||
if stateValidators, err = c.stateValidatorsProvider.StateValidatorsForHead(ctx, pubkeys, in.Indices, statuses); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get head state validators")
|
||||
}
|
||||
|
||||
blockHeader, err := c.getHeadBlockHeaders(ctx)
|
||||
blockHeader, err := c.headBlockHeaders(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get head block headers")
|
||||
}
|
||||
@@ -310,16 +310,16 @@ func (c beaconApiChainClient) ListValidators(ctx context.Context, in *ethpb.List
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c beaconApiChainClient) GetValidatorQueue(ctx context.Context, in *empty.Empty) (*ethpb.ValidatorQueue, error) {
|
||||
func (c beaconApiChainClient) ValidatorQueue(ctx context.Context, in *empty.Empty) (*ethpb.ValidatorQueue, error) {
|
||||
if c.fallbackClient != nil {
|
||||
return c.fallbackClient.GetValidatorQueue(ctx, in)
|
||||
return c.fallbackClient.ValidatorQueue(ctx, in)
|
||||
}
|
||||
|
||||
// TODO: Implement me
|
||||
panic("beaconApiChainClient.GetValidatorQueue is not implemented. To use a fallback client, pass a fallback client as the last argument of NewBeaconApiChainClientWithFallback.")
|
||||
panic("beaconApiChainClient.ValidatorQueue is not implemented. To use a fallback client, pass a fallback client as the last argument of NewBeaconApiChainClientWithFallback.")
|
||||
}
|
||||
|
||||
func (c beaconApiChainClient) GetValidatorPerformance(ctx context.Context, in *ethpb.ValidatorPerformanceRequest) (*ethpb.ValidatorPerformanceResponse, error) {
|
||||
func (c beaconApiChainClient) ValidatorPerformance(ctx context.Context, in *ethpb.ValidatorPerformanceRequest) (*ethpb.ValidatorPerformanceResponse, error) {
|
||||
request, err := json.Marshal(structs.GetValidatorPerformanceRequest{
|
||||
PublicKeys: in.PublicKeys,
|
||||
Indices: in.Indices,
|
||||
@@ -345,13 +345,13 @@ func (c beaconApiChainClient) GetValidatorPerformance(ctx context.Context, in *e
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c beaconApiChainClient) GetValidatorParticipation(ctx context.Context, in *ethpb.GetValidatorParticipationRequest) (*ethpb.ValidatorParticipationResponse, error) {
|
||||
func (c beaconApiChainClient) ValidatorParticipation(ctx context.Context, in *ethpb.GetValidatorParticipationRequest) (*ethpb.ValidatorParticipationResponse, error) {
|
||||
if c.fallbackClient != nil {
|
||||
return c.fallbackClient.GetValidatorParticipation(ctx, in)
|
||||
return c.fallbackClient.ValidatorParticipation(ctx, in)
|
||||
}
|
||||
|
||||
// TODO: Implement me
|
||||
panic("beaconApiChainClient.GetValidatorParticipation is not implemented. To use a fallback client, pass a fallback client as the last argument of NewBeaconApiChainClientWithFallback.")
|
||||
panic("beaconApiChainClient.ValidatorParticipation is not implemented. To use a fallback client, pass a fallback client as the last argument of NewBeaconApiChainClientWithFallback.")
|
||||
}
|
||||
|
||||
func NewBeaconApiChainClientWithFallback(jsonRestHandler JsonRestHandler, fallbackClient iface.ChainClient) iface.ChainClient {
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestListValidators(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
beaconChainClient := beaconApiChainClient{}
|
||||
_, err := beaconChainClient.ListValidators(ctx, ðpb.ListValidatorsRequest{
|
||||
_, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
PageToken: "foo",
|
||||
})
|
||||
assert.ErrorContains(t, "failed to parse page token `foo`", err)
|
||||
@@ -44,7 +44,7 @@ func TestListValidators(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
beaconChainClient := beaconApiChainClient{}
|
||||
_, err := beaconChainClient.ListValidators(ctx, ðpb.ListValidatorsRequest{
|
||||
_, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
QueryFilter: ðpb.ListValidatorsRequest_Epoch{
|
||||
Epoch: math.MaxUint64,
|
||||
},
|
||||
@@ -58,13 +58,13 @@ func TestListValidators(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidatorsForSlot(ctx, gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForSlot(ctx, gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
nil,
|
||||
errors.New("foo error"),
|
||||
)
|
||||
|
||||
beaconChainClient := beaconApiChainClient{stateValidatorsProvider: stateValidatorsProvider}
|
||||
_, err := beaconChainClient.ListValidators(ctx, ðpb.ListValidatorsRequest{
|
||||
_, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
QueryFilter: ðpb.ListValidatorsRequest_Epoch{
|
||||
Epoch: 0,
|
||||
},
|
||||
@@ -78,13 +78,13 @@ func TestListValidators(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidatorsForSlot(ctx, gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForSlot(ctx, gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
nil,
|
||||
errors.New("bar error"),
|
||||
)
|
||||
|
||||
beaconChainClient := beaconApiChainClient{stateValidatorsProvider: stateValidatorsProvider}
|
||||
_, err := beaconChainClient.ListValidators(ctx, ðpb.ListValidatorsRequest{
|
||||
_, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
QueryFilter: ðpb.ListValidatorsRequest_Genesis{},
|
||||
})
|
||||
assert.ErrorContains(t, "failed to get genesis state validators: bar error", err)
|
||||
@@ -96,13 +96,13 @@ func TestListValidators(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidatorsForHead(ctx, gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForHead(ctx, gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
nil,
|
||||
errors.New("foo error"),
|
||||
)
|
||||
|
||||
beaconChainClient := beaconApiChainClient{stateValidatorsProvider: stateValidatorsProvider}
|
||||
_, err := beaconChainClient.ListValidators(ctx, ðpb.ListValidatorsRequest{
|
||||
_, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
QueryFilter: nil,
|
||||
})
|
||||
assert.ErrorContains(t, "failed to get head state validators: foo error", err)
|
||||
@@ -114,7 +114,7 @@ func TestListValidators(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidatorsForHead(ctx, gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForHead(ctx, gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
@@ -126,7 +126,7 @@ func TestListValidators(t *testing.T) {
|
||||
stateValidatorsProvider: stateValidatorsProvider,
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
}
|
||||
_, err := beaconChainClient.ListValidators(ctx, ðpb.ListValidatorsRequest{
|
||||
_, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
QueryFilter: nil,
|
||||
})
|
||||
assert.ErrorContains(t, "bar error", err)
|
||||
@@ -187,7 +187,7 @@ func TestListValidators(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidatorsForHead(ctx, gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForHead(ctx, gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
@@ -204,7 +204,7 @@ func TestListValidators(t *testing.T) {
|
||||
stateValidatorsProvider: stateValidatorsProvider,
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
}
|
||||
_, err := beaconChainClient.ListValidators(ctx, ðpb.ListValidatorsRequest{
|
||||
_, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
QueryFilter: nil,
|
||||
})
|
||||
assert.ErrorContains(t, testCase.expectedError, err)
|
||||
@@ -328,13 +328,13 @@ func TestListValidators(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidatorsForSlot(ctx, gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForSlot(ctx, gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
testCase.generateStateValidatorsResponse(),
|
||||
nil,
|
||||
)
|
||||
|
||||
beaconChainClient := beaconApiChainClient{stateValidatorsProvider: stateValidatorsProvider}
|
||||
_, err := beaconChainClient.ListValidators(ctx, ðpb.ListValidatorsRequest{
|
||||
_, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
QueryFilter: ðpb.ListValidatorsRequest_Genesis{},
|
||||
})
|
||||
assert.ErrorContains(t, testCase.expectedError, err)
|
||||
@@ -556,13 +556,13 @@ func TestListValidators(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidatorsForSlot(ctx, primitives.Slot(0), make([]string, 0), []primitives.ValidatorIndex{}, nil).Return(
|
||||
stateValidatorsProvider.EXPECT().StateValidatorsForSlot(ctx, primitives.Slot(0), make([]string, 0), []primitives.ValidatorIndex{}, nil).Return(
|
||||
testCase.generateJsonStateValidatorsResponse(),
|
||||
nil,
|
||||
)
|
||||
|
||||
beaconChainClient := beaconApiChainClient{stateValidatorsProvider: stateValidatorsProvider}
|
||||
validators, err := beaconChainClient.ListValidators(ctx, ðpb.ListValidatorsRequest{
|
||||
validators, err := beaconChainClient.Validators(ctx, ðpb.ListValidatorsRequest{
|
||||
QueryFilter: ðpb.ListValidatorsRequest_Genesis{},
|
||||
PublicKeys: [][]byte{},
|
||||
Indices: []primitives.ValidatorIndex{},
|
||||
@@ -753,7 +753,7 @@ func TestGetChainHead(t *testing.T) {
|
||||
)
|
||||
|
||||
beaconChainClient := beaconApiChainClient{jsonRestHandler: jsonRestHandler}
|
||||
_, err := beaconChainClient.GetChainHead(ctx, &emptypb.Empty{})
|
||||
_, err := beaconChainClient.ChainHead(ctx, &emptypb.Empty{})
|
||||
assert.ErrorContains(t, testCase.expectedError, err)
|
||||
})
|
||||
}
|
||||
@@ -860,7 +860,7 @@ func TestGetChainHead(t *testing.T) {
|
||||
)
|
||||
|
||||
beaconChainClient := beaconApiChainClient{jsonRestHandler: jsonRestHandler}
|
||||
_, err := beaconChainClient.GetChainHead(ctx, &emptypb.Empty{})
|
||||
_, err := beaconChainClient.ChainHead(ctx, &emptypb.Empty{})
|
||||
assert.ErrorContains(t, testCase.expectedError, err)
|
||||
})
|
||||
}
|
||||
@@ -914,7 +914,7 @@ func TestGetChainHead(t *testing.T) {
|
||||
}
|
||||
|
||||
beaconChainClient := beaconApiChainClient{jsonRestHandler: jsonRestHandler}
|
||||
chainHead, err := beaconChainClient.GetChainHead(ctx, &emptypb.Empty{})
|
||||
chainHead, err := beaconChainClient.ChainHead(ctx, &emptypb.Empty{})
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedChainHead, chainHead)
|
||||
})
|
||||
@@ -953,7 +953,7 @@ func Test_beaconApiBeaconChainClient_GetValidatorPerformance(t *testing.T) {
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
}
|
||||
|
||||
got, err := c.GetValidatorPerformance(ctx, ðpb.ValidatorPerformanceRequest{
|
||||
got, err := c.ValidatorPerformance(ctx, ðpb.ValidatorPerformanceRequest{
|
||||
PublicKeys: [][]byte{publicKeys[0][:], publicKeys[2][:], publicKeys[1][:]},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -48,7 +48,7 @@ func buildURL(path string, queryParams ...neturl.Values) string {
|
||||
return fmt.Sprintf("%s?%s", path, queryParams[0].Encode())
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getFork(ctx context.Context) (*structs.GetStateForkResponse, error) {
|
||||
func (c *beaconApiValidatorClient) fork(ctx context.Context) (*structs.GetStateForkResponse, error) {
|
||||
const endpoint = "/eth/v1/beacon/states/head/fork"
|
||||
|
||||
stateForkResponseJson := &structs.GetStateForkResponse{}
|
||||
@@ -60,7 +60,7 @@ func (c *beaconApiValidatorClient) getFork(ctx context.Context) (*structs.GetSta
|
||||
return stateForkResponseJson, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getHeaders(ctx context.Context) (*structs.GetBlockHeadersResponse, error) {
|
||||
func (c *beaconApiValidatorClient) headers(ctx context.Context) (*structs.GetBlockHeadersResponse, error) {
|
||||
const endpoint = "/eth/v1/beacon/headers"
|
||||
|
||||
blockHeadersResponseJson := &structs.GetBlockHeadersResponse{}
|
||||
@@ -72,7 +72,7 @@ func (c *beaconApiValidatorClient) getHeaders(ctx context.Context) (*structs.Get
|
||||
return blockHeadersResponseJson, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getLiveness(ctx context.Context, epoch primitives.Epoch, validatorIndexes []string) (*structs.GetLivenessResponse, error) {
|
||||
func (c *beaconApiValidatorClient) liveness(ctx context.Context, epoch primitives.Epoch, validatorIndexes []string) (*structs.GetLivenessResponse, error) {
|
||||
const endpoint = "/eth/v1/validator/liveness/"
|
||||
url := endpoint + strconv.FormatUint(uint64(epoch), 10)
|
||||
|
||||
@@ -90,7 +90,7 @@ func (c *beaconApiValidatorClient) getLiveness(ctx context.Context, epoch primit
|
||||
return livenessResponseJson, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getSyncing(ctx context.Context) (*structs.SyncStatusResponse, error) {
|
||||
func (c *beaconApiValidatorClient) syncing(ctx context.Context) (*structs.SyncStatusResponse, error) {
|
||||
const endpoint = "/eth/v1/node/syncing"
|
||||
|
||||
syncingResponseJson := &structs.SyncStatusResponse{}
|
||||
@@ -103,7 +103,7 @@ func (c *beaconApiValidatorClient) getSyncing(ctx context.Context) (*structs.Syn
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) isSyncing(ctx context.Context) (bool, error) {
|
||||
response, err := c.getSyncing(ctx)
|
||||
response, err := c.syncing(ctx)
|
||||
if err != nil || response == nil || response.Data == nil {
|
||||
return true, errors.Wrapf(err, "failed to get syncing status")
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func (c *beaconApiValidatorClient) isSyncing(ctx context.Context) (bool, error)
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) isOptimistic(ctx context.Context) (bool, error) {
|
||||
response, err := c.getSyncing(ctx)
|
||||
response, err := c.syncing(ctx)
|
||||
if err != nil || response == nil || response.Data == nil {
|
||||
return true, errors.Wrapf(err, "failed to get syncing status")
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func TestGetFork_Nominal(t *testing.T) {
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
}
|
||||
|
||||
fork, err := validatorClient.getFork(ctx)
|
||||
fork, err := validatorClient.fork(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, &expected, fork)
|
||||
}
|
||||
@@ -148,7 +148,7 @@ func TestGetFork_Invalid(t *testing.T) {
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
}
|
||||
|
||||
_, err := validatorClient.getFork(ctx)
|
||||
_, err := validatorClient.fork(ctx)
|
||||
require.ErrorContains(t, "custom error", err)
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ func TestGetHeaders_Nominal(t *testing.T) {
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
}
|
||||
|
||||
headers, err := validatorClient.getHeaders(ctx)
|
||||
headers, err := validatorClient.headers(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, &expected, headers)
|
||||
}
|
||||
@@ -215,7 +215,7 @@ func TestGetHeaders_Invalid(t *testing.T) {
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
}
|
||||
|
||||
_, err := validatorClient.getHeaders(ctx)
|
||||
_, err := validatorClient.headers(ctx)
|
||||
require.ErrorContains(t, "custom error", err)
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ func TestGetLiveness_Nominal(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
liveness, err := validatorClient.getLiveness(ctx, 42, indexes)
|
||||
liveness, err := validatorClient.liveness(ctx, 42, indexes)
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, &expected, liveness)
|
||||
@@ -285,12 +285,12 @@ func TestGetLiveness_Invalid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
_, err := validatorClient.getLiveness(ctx, 42, nil)
|
||||
_, err := validatorClient.liveness(ctx, 42, nil)
|
||||
|
||||
require.ErrorContains(t, "custom error", err)
|
||||
}
|
||||
|
||||
const syncingEnpoint = "/eth/v1/node/syncing"
|
||||
const syncingEndpoint = "/eth/v1/node/syncing"
|
||||
|
||||
func TestGetIsSyncing_Nominal(t *testing.T) {
|
||||
testCases := []struct {
|
||||
@@ -325,7 +325,7 @@ func TestGetIsSyncing_Nominal(t *testing.T) {
|
||||
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
ctx,
|
||||
syncingEnpoint,
|
||||
syncingEndpoint,
|
||||
&syncingResponseJson,
|
||||
).Return(
|
||||
nil,
|
||||
@@ -356,7 +356,7 @@ func TestGetIsSyncing_Invalid(t *testing.T) {
|
||||
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
ctx,
|
||||
syncingEnpoint,
|
||||
syncingEndpoint,
|
||||
&syncingResponseJson,
|
||||
).Return(
|
||||
errors.New("custom error"),
|
||||
|
||||
@@ -25,7 +25,7 @@ type beaconApiNodeClient struct {
|
||||
healthTracker *beacon.NodeHealthTracker
|
||||
}
|
||||
|
||||
func (c *beaconApiNodeClient) GetSyncStatus(ctx context.Context, _ *empty.Empty) (*ethpb.SyncStatus, error) {
|
||||
func (c *beaconApiNodeClient) SyncStatus(ctx context.Context, _ *empty.Empty) (*ethpb.SyncStatus, error) {
|
||||
syncingResponse := structs.SyncStatusResponse{}
|
||||
if err := c.jsonRestHandler.Get(ctx, "/eth/v1/node/syncing", &syncingResponse); err != nil {
|
||||
return nil, err
|
||||
@@ -40,8 +40,8 @@ func (c *beaconApiNodeClient) GetSyncStatus(ctx context.Context, _ *empty.Empty)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiNodeClient) GetGenesis(ctx context.Context, _ *empty.Empty) (*ethpb.Genesis, error) {
|
||||
genesisJson, err := c.genesisProvider.GetGenesis(ctx)
|
||||
func (c *beaconApiNodeClient) Genesis(ctx context.Context, _ *empty.Empty) (*ethpb.Genesis, error) {
|
||||
genesisJson, err := c.genesisProvider.Genesis(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get genesis")
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func (c *beaconApiNodeClient) GetGenesis(ctx context.Context, _ *empty.Empty) (*
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiNodeClient) GetVersion(ctx context.Context, _ *empty.Empty) (*ethpb.Version, error) {
|
||||
func (c *beaconApiNodeClient) Version(ctx context.Context, _ *empty.Empty) (*ethpb.Version, error) {
|
||||
var versionResponse structs.GetVersionResponse
|
||||
if err := c.jsonRestHandler.Get(ctx, "/eth/v1/node/version", &versionResponse); err != nil {
|
||||
return nil, err
|
||||
@@ -94,13 +94,13 @@ func (c *beaconApiNodeClient) GetVersion(ctx context.Context, _ *empty.Empty) (*
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiNodeClient) ListPeers(ctx context.Context, in *empty.Empty) (*ethpb.Peers, error) {
|
||||
func (c *beaconApiNodeClient) Peers(ctx context.Context, in *empty.Empty) (*ethpb.Peers, error) {
|
||||
if c.fallbackClient != nil {
|
||||
return c.fallbackClient.ListPeers(ctx, in)
|
||||
return c.fallbackClient.Peers(ctx, in)
|
||||
}
|
||||
|
||||
// TODO: Implement me
|
||||
panic("beaconApiNodeClient.ListPeers is not implemented. To use a fallback client, pass a fallback client as the last argument of NewBeaconApiNodeClientWithFallback.")
|
||||
panic("beaconApiNodeClient.Peers is not implemented. To use a fallback client, pass a fallback client as the last argument of NewBeaconApiNodeClientWithFallback.")
|
||||
}
|
||||
|
||||
func (c *beaconApiNodeClient) IsHealthy(ctx context.Context) bool {
|
||||
|
||||
@@ -112,7 +112,7 @@ func TestGetGenesis(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
genesisProvider := mock.NewMockGenesisProvider(ctrl)
|
||||
genesisProvider.EXPECT().GetGenesis(
|
||||
genesisProvider.EXPECT().Genesis(
|
||||
ctx,
|
||||
).Return(
|
||||
testCase.genesisResponse,
|
||||
@@ -139,7 +139,7 @@ func TestGetGenesis(t *testing.T) {
|
||||
genesisProvider: genesisProvider,
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
}
|
||||
response, err := nodeClient.GetGenesis(ctx, &emptypb.Empty{})
|
||||
response, err := nodeClient.Genesis(ctx, &emptypb.Empty{})
|
||||
|
||||
if testCase.expectedResponse == nil {
|
||||
assert.ErrorContains(t, testCase.expectedError, err)
|
||||
@@ -214,7 +214,7 @@ func TestGetSyncStatus(t *testing.T) {
|
||||
)
|
||||
|
||||
nodeClient := &beaconApiNodeClient{jsonRestHandler: jsonRestHandler}
|
||||
syncStatus, err := nodeClient.GetSyncStatus(ctx, &emptypb.Empty{})
|
||||
syncStatus, err := nodeClient.SyncStatus(ctx, &emptypb.Empty{})
|
||||
|
||||
if testCase.expectedResponse == nil {
|
||||
assert.ErrorContains(t, testCase.expectedError, err)
|
||||
@@ -278,7 +278,7 @@ func TestGetVersion(t *testing.T) {
|
||||
)
|
||||
|
||||
nodeClient := &beaconApiNodeClient{jsonRestHandler: jsonRestHandler}
|
||||
version, err := nodeClient.GetVersion(ctx, &emptypb.Empty{})
|
||||
version, err := nodeClient.Version(ctx, &emptypb.Empty{})
|
||||
|
||||
if testCase.expectedResponse == nil {
|
||||
assert.ErrorContains(t, testCase.expectedError, err)
|
||||
|
||||
@@ -46,9 +46,9 @@ func NewBeaconApiValidatorClient(jsonRestHandler JsonRestHandler, opts ...Valida
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) GetDuties(ctx context.Context, in *ethpb.DutiesRequest) (*ethpb.DutiesResponse, error) {
|
||||
return wrapInMetrics[*ethpb.DutiesResponse]("GetDuties", func() (*ethpb.DutiesResponse, error) {
|
||||
return c.getDuties(ctx, in)
|
||||
func (c *beaconApiValidatorClient) Duties(ctx context.Context, in *ethpb.DutiesRequest) (*ethpb.DutiesResponse, error) {
|
||||
return wrapInMetrics[*ethpb.DutiesResponse]("Duties", func() (*ethpb.DutiesResponse, error) {
|
||||
return c.duties(ctx, in)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -65,41 +65,41 @@ func (c *beaconApiValidatorClient) DomainData(ctx context.Context, in *ethpb.Dom
|
||||
domainType := bytesutil.ToBytes4(in.Domain)
|
||||
|
||||
return wrapInMetrics[*ethpb.DomainResponse]("DomainData", func() (*ethpb.DomainResponse, error) {
|
||||
return c.getDomainData(ctx, in.Epoch, domainType)
|
||||
return c.domainData(ctx, in.Epoch, domainType)
|
||||
})
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) GetAttestationData(ctx context.Context, in *ethpb.AttestationDataRequest) (*ethpb.AttestationData, error) {
|
||||
return wrapInMetrics[*ethpb.AttestationData]("GetAttestationData", func() (*ethpb.AttestationData, error) {
|
||||
return c.getAttestationData(ctx, in.Slot, in.CommitteeIndex)
|
||||
func (c *beaconApiValidatorClient) AttestationData(ctx context.Context, in *ethpb.AttestationDataRequest) (*ethpb.AttestationData, error) {
|
||||
return wrapInMetrics[*ethpb.AttestationData]("AttestationData", func() (*ethpb.AttestationData, error) {
|
||||
return c.attestationData(ctx, in.Slot, in.CommitteeIndex)
|
||||
})
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) GetBeaconBlock(ctx context.Context, in *ethpb.BlockRequest) (*ethpb.GenericBeaconBlock, error) {
|
||||
return wrapInMetrics[*ethpb.GenericBeaconBlock]("GetBeaconBlock", func() (*ethpb.GenericBeaconBlock, error) {
|
||||
return c.getBeaconBlock(ctx, in.Slot, in.RandaoReveal, in.Graffiti)
|
||||
func (c *beaconApiValidatorClient) BeaconBlock(ctx context.Context, in *ethpb.BlockRequest) (*ethpb.GenericBeaconBlock, error) {
|
||||
return wrapInMetrics[*ethpb.GenericBeaconBlock]("BeaconBlock", func() (*ethpb.GenericBeaconBlock, error) {
|
||||
return c.beaconBlock(ctx, in.Slot, in.RandaoReveal, in.Graffiti)
|
||||
})
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) GetFeeRecipientByPubKey(_ context.Context, _ *ethpb.FeeRecipientByPubKeyRequest) (*ethpb.FeeRecipientByPubKeyResponse, error) {
|
||||
func (c *beaconApiValidatorClient) FeeRecipientByPubKey(_ context.Context, _ *ethpb.FeeRecipientByPubKeyRequest) (*ethpb.FeeRecipientByPubKeyResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) GetSyncCommitteeContribution(ctx context.Context, in *ethpb.SyncCommitteeContributionRequest) (*ethpb.SyncCommitteeContribution, error) {
|
||||
return wrapInMetrics[*ethpb.SyncCommitteeContribution]("GetSyncCommitteeContribution", func() (*ethpb.SyncCommitteeContribution, error) {
|
||||
return c.getSyncCommitteeContribution(ctx, in)
|
||||
func (c *beaconApiValidatorClient) SyncCommitteeContribution(ctx context.Context, in *ethpb.SyncCommitteeContributionRequest) (*ethpb.SyncCommitteeContribution, error) {
|
||||
return wrapInMetrics[*ethpb.SyncCommitteeContribution]("SyncCommitteeContribution", func() (*ethpb.SyncCommitteeContribution, error) {
|
||||
return c.syncCommitteeContribution(ctx, in)
|
||||
})
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) GetSyncMessageBlockRoot(ctx context.Context, _ *empty.Empty) (*ethpb.SyncMessageBlockRootResponse, error) {
|
||||
return wrapInMetrics[*ethpb.SyncMessageBlockRootResponse]("GetSyncMessageBlockRoot", func() (*ethpb.SyncMessageBlockRootResponse, error) {
|
||||
return c.getSyncMessageBlockRoot(ctx)
|
||||
func (c *beaconApiValidatorClient) SyncMessageBlockRoot(ctx context.Context, _ *empty.Empty) (*ethpb.SyncMessageBlockRootResponse, error) {
|
||||
return wrapInMetrics[*ethpb.SyncMessageBlockRootResponse]("SyncMessageBlockRoot", func() (*ethpb.SyncMessageBlockRootResponse, error) {
|
||||
return c.syncMessageBlockRoot(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) GetSyncSubcommitteeIndex(ctx context.Context, in *ethpb.SyncSubcommitteeIndexRequest) (*ethpb.SyncSubcommitteeIndexResponse, error) {
|
||||
return wrapInMetrics[*ethpb.SyncSubcommitteeIndexResponse]("GetSyncSubcommitteeIndex", func() (*ethpb.SyncSubcommitteeIndexResponse, error) {
|
||||
return c.getSyncSubcommitteeIndex(ctx, in)
|
||||
func (c *beaconApiValidatorClient) SyncSubcommitteeIndex(ctx context.Context, in *ethpb.SyncSubcommitteeIndexRequest) (*ethpb.SyncSubcommitteeIndexResponse, error) {
|
||||
return wrapInMetrics[*ethpb.SyncSubcommitteeIndexResponse]("SyncSubcommitteeIndex", func() (*ethpb.SyncSubcommitteeIndexResponse, error) {
|
||||
return c.syncSubcommitteeIndex(ctx, in)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -211,12 +211,12 @@ func (c *beaconApiValidatorClient) EventStreamIsRunning() bool {
|
||||
return c.isEventStreamRunning
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) GetAggregatedSelections(ctx context.Context, selections []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) {
|
||||
return c.getAggregatedSelection(ctx, selections)
|
||||
func (c *beaconApiValidatorClient) AggregatedSelections(ctx context.Context, selections []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) {
|
||||
return c.aggregatedSelection(ctx, selections)
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) GetAggregatedSyncSelections(ctx context.Context, selections []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) {
|
||||
return c.getAggregatedSyncSelections(ctx, selections)
|
||||
func (c *beaconApiValidatorClient) AggregatedSyncSelections(ctx context.Context, selections []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) {
|
||||
return c.aggregatedSyncSelections(ctx, selections)
|
||||
}
|
||||
|
||||
func wrapInMetrics[Resp any](action string, f func() (Resp, error)) (Resp, error) {
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
)
|
||||
|
||||
// Make sure that GetAttestationData() returns the same thing as the internal getAttestationData()
|
||||
// Make sure that AttestationData() returns the same thing as the internal attestationData()
|
||||
func TestBeaconApiValidatorClient_GetAttestationDataValid(t *testing.T) {
|
||||
const slot = primitives.Slot(1)
|
||||
const committeeIndex = primitives.CommitteeIndex(2)
|
||||
@@ -43,9 +43,9 @@ func TestBeaconApiValidatorClient_GetAttestationDataValid(t *testing.T) {
|
||||
).Times(2)
|
||||
|
||||
validatorClient := beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
expectedResp, expectedErr := validatorClient.getAttestationData(ctx, slot, committeeIndex)
|
||||
expectedResp, expectedErr := validatorClient.attestationData(ctx, slot, committeeIndex)
|
||||
|
||||
resp, err := validatorClient.GetAttestationData(
|
||||
resp, err := validatorClient.AttestationData(
|
||||
context.Background(),
|
||||
ðpb.AttestationDataRequest{Slot: slot, CommitteeIndex: committeeIndex},
|
||||
)
|
||||
@@ -77,9 +77,9 @@ func TestBeaconApiValidatorClient_GetAttestationDataError(t *testing.T) {
|
||||
).Times(2)
|
||||
|
||||
validatorClient := beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
expectedResp, expectedErr := validatorClient.getAttestationData(ctx, slot, committeeIndex)
|
||||
expectedResp, expectedErr := validatorClient.attestationData(ctx, slot, committeeIndex)
|
||||
|
||||
resp, err := validatorClient.GetAttestationData(
|
||||
resp, err := validatorClient.AttestationData(
|
||||
context.Background(),
|
||||
ðpb.AttestationDataRequest{Slot: slot, CommitteeIndex: committeeIndex},
|
||||
)
|
||||
@@ -93,7 +93,7 @@ func TestBeaconApiValidatorClient_GetFeeRecipientByPubKey(t *testing.T) {
|
||||
validatorClient := beaconApiValidatorClient{}
|
||||
var expected *ethpb.FeeRecipientByPubKeyResponse = nil
|
||||
|
||||
resp, err := validatorClient.GetFeeRecipientByPubKey(ctx, nil)
|
||||
resp, err := validatorClient.FeeRecipientByPubKey(ctx, nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expected, resp)
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func TestBeaconApiValidatorClient_DomainDataValid(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
genesisProvider := mock.NewMockGenesisProvider(ctrl)
|
||||
genesisProvider.EXPECT().GetGenesis(ctx).Return(
|
||||
genesisProvider.EXPECT().Genesis(ctx).Return(
|
||||
&structs.Genesis{GenesisValidatorsRoot: genesisValidatorRoot},
|
||||
nil,
|
||||
).Times(2)
|
||||
@@ -118,7 +118,7 @@ func TestBeaconApiValidatorClient_DomainDataValid(t *testing.T) {
|
||||
resp, err := validatorClient.DomainData(context.Background(), ðpb.DomainRequest{Epoch: epoch, Domain: domainType})
|
||||
|
||||
domainTypeArray := bytesutil.ToBytes4(domainType)
|
||||
expectedResp, expectedErr := validatorClient.getDomainData(ctx, epoch, domainTypeArray)
|
||||
expectedResp, expectedErr := validatorClient.domainData(ctx, epoch, domainTypeArray)
|
||||
assert.DeepEqual(t, expectedErr, err)
|
||||
assert.DeepEqual(t, expectedResp, resp)
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
)
|
||||
|
||||
func TestGetBeaconBlockConverter_Phase0Valid(t *testing.T) {
|
||||
expectedBeaconBlock := test_helpers.GenerateProtoPhase0BeaconBlock()
|
||||
expectedBeaconBlock := testhelpers.GenerateProtoPhase0BeaconBlock()
|
||||
beaconBlockConverter := &beaconApiBeaconBlockConverter{}
|
||||
beaconBlock, err := beaconBlockConverter.ConvertRESTPhase0BlockToProto(test_helpers.GenerateJsonPhase0BeaconBlock())
|
||||
beaconBlock, err := beaconBlockConverter.ConvertRESTPhase0BlockToProto(testhelpers.GenerateJsonPhase0BeaconBlock())
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedBeaconBlock, beaconBlock)
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "nil body",
|
||||
expectedErrorMessage: "block body is nil",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -36,7 +36,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "nil eth1 data",
|
||||
expectedErrorMessage: "eth1 data is nil",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.Eth1Data = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -45,7 +45,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad slot",
|
||||
expectedErrorMessage: "failed to parse slot `foo`",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Slot = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -54,7 +54,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad proposer index",
|
||||
expectedErrorMessage: "failed to parse proposer index `bar`",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.ProposerIndex = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -63,7 +63,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad parent root",
|
||||
expectedErrorMessage: "failed to decode parent root `foo`",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.ParentRoot = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -72,7 +72,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad state root",
|
||||
expectedErrorMessage: "failed to decode state root `bar`",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.StateRoot = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -81,7 +81,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad randao reveal",
|
||||
expectedErrorMessage: "failed to decode randao reveal `foo`",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.RandaoReveal = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -90,7 +90,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad deposit root",
|
||||
expectedErrorMessage: "failed to decode deposit root `bar`",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.Eth1Data.DepositRoot = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -99,7 +99,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad deposit count",
|
||||
expectedErrorMessage: "failed to parse deposit count `foo`",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.Eth1Data.DepositCount = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -108,7 +108,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad block hash",
|
||||
expectedErrorMessage: "failed to decode block hash `bar`",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.Eth1Data.BlockHash = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -117,7 +117,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad graffiti",
|
||||
expectedErrorMessage: "failed to decode graffiti `foo`",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.Graffiti = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -126,7 +126,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad proposer slashings",
|
||||
expectedErrorMessage: "failed to get proposer slashings",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.ProposerSlashings[0] = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -135,7 +135,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad attester slashings",
|
||||
expectedErrorMessage: "failed to get attester slashings",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.AttesterSlashings[0] = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -144,7 +144,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad attestations",
|
||||
expectedErrorMessage: "failed to get attestations",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.Attestations[0] = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -153,7 +153,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad deposits",
|
||||
expectedErrorMessage: "failed to get deposits",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.Deposits[0] = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -162,7 +162,7 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
name: "bad voluntary exits",
|
||||
expectedErrorMessage: "failed to get voluntary exits",
|
||||
generateData: func() *structs.BeaconBlock {
|
||||
beaconBlock := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
beaconBlock.Body.VoluntaryExits[0] = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -181,9 +181,9 @@ func TestGetBeaconBlockConverter_Phase0Error(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetBeaconBlockConverter_AltairValid(t *testing.T) {
|
||||
expectedBeaconBlock := test_helpers.GenerateProtoAltairBeaconBlock()
|
||||
expectedBeaconBlock := testhelpers.GenerateProtoAltairBeaconBlock()
|
||||
beaconBlockConverter := &beaconApiBeaconBlockConverter{}
|
||||
beaconBlock, err := beaconBlockConverter.ConvertRESTAltairBlockToProto(test_helpers.GenerateJsonAltairBeaconBlock())
|
||||
beaconBlock, err := beaconBlockConverter.ConvertRESTAltairBlockToProto(testhelpers.GenerateJsonAltairBeaconBlock())
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedBeaconBlock, beaconBlock)
|
||||
}
|
||||
@@ -198,7 +198,7 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
|
||||
name: "nil body",
|
||||
expectedErrorMessage: "block body is nil",
|
||||
generateData: func() *structs.BeaconBlockAltair {
|
||||
beaconBlock := test_helpers.GenerateJsonAltairBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonAltairBeaconBlock()
|
||||
beaconBlock.Body = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -207,7 +207,7 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
|
||||
name: "nil sync aggregate",
|
||||
expectedErrorMessage: "sync aggregate is nil",
|
||||
generateData: func() *structs.BeaconBlockAltair {
|
||||
beaconBlock := test_helpers.GenerateJsonAltairBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonAltairBeaconBlock()
|
||||
beaconBlock.Body.SyncAggregate = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -216,7 +216,7 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
|
||||
name: "bad phase0 fields",
|
||||
expectedErrorMessage: "failed to get the phase0 fields of the altair block",
|
||||
generateData: func() *structs.BeaconBlockAltair {
|
||||
beaconBlock := test_helpers.GenerateJsonAltairBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonAltairBeaconBlock()
|
||||
beaconBlock.Body.Eth1Data = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -225,7 +225,7 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
|
||||
name: "bad sync committee bits",
|
||||
expectedErrorMessage: "failed to decode sync committee bits `foo`",
|
||||
generateData: func() *structs.BeaconBlockAltair {
|
||||
beaconBlock := test_helpers.GenerateJsonAltairBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonAltairBeaconBlock()
|
||||
beaconBlock.Body.SyncAggregate.SyncCommitteeBits = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -234,7 +234,7 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
|
||||
name: "bad sync committee signature",
|
||||
expectedErrorMessage: "failed to decode sync committee signature `bar`",
|
||||
generateData: func() *structs.BeaconBlockAltair {
|
||||
beaconBlock := test_helpers.GenerateJsonAltairBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonAltairBeaconBlock()
|
||||
beaconBlock.Body.SyncAggregate.SyncCommitteeSignature = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -253,9 +253,9 @@ func TestGetBeaconBlockConverter_AltairError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetBeaconBlockConverter_BellatrixValid(t *testing.T) {
|
||||
expectedBeaconBlock := test_helpers.GenerateProtoBellatrixBeaconBlock()
|
||||
expectedBeaconBlock := testhelpers.GenerateProtoBellatrixBeaconBlock()
|
||||
beaconBlockConverter := &beaconApiBeaconBlockConverter{}
|
||||
beaconBlock, err := beaconBlockConverter.ConvertRESTBellatrixBlockToProto(test_helpers.GenerateJsonBellatrixBeaconBlock())
|
||||
beaconBlock, err := beaconBlockConverter.ConvertRESTBellatrixBlockToProto(testhelpers.GenerateJsonBellatrixBeaconBlock())
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedBeaconBlock, beaconBlock)
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "nil body",
|
||||
expectedErrorMessage: "block body is nil",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -279,7 +279,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "nil execution payload",
|
||||
expectedErrorMessage: "execution payload is nil",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -288,7 +288,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad altair fields",
|
||||
expectedErrorMessage: "failed to get the altair fields of the bellatrix block",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.Eth1Data = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -297,7 +297,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad parent hash",
|
||||
expectedErrorMessage: "failed to decode execution payload parent hash `foo`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.ParentHash = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -306,7 +306,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad fee recipient",
|
||||
expectedErrorMessage: "failed to decode execution payload fee recipient `bar`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.FeeRecipient = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -315,7 +315,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad state root",
|
||||
expectedErrorMessage: "failed to decode execution payload state root `foo`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.StateRoot = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -324,7 +324,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad receipts root",
|
||||
expectedErrorMessage: "failed to decode execution payload receipts root `bar`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.ReceiptsRoot = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -333,7 +333,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad logs bloom",
|
||||
expectedErrorMessage: "failed to decode execution payload logs bloom `foo`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.LogsBloom = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -342,7 +342,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad prev randao",
|
||||
expectedErrorMessage: "failed to decode execution payload prev randao `bar`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.PrevRandao = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -351,7 +351,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad block number",
|
||||
expectedErrorMessage: "failed to parse execution payload block number `foo`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.BlockNumber = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -360,7 +360,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad gas limit",
|
||||
expectedErrorMessage: "failed to parse execution payload gas limit `bar`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.GasLimit = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -369,7 +369,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad gas used",
|
||||
expectedErrorMessage: "failed to parse execution payload gas used `foo`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.GasUsed = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -378,7 +378,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad timestamp",
|
||||
expectedErrorMessage: "failed to parse execution payload timestamp `bar`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.Timestamp = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -387,7 +387,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad extra data",
|
||||
expectedErrorMessage: "failed to decode execution payload extra data `foo`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.ExtraData = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -396,7 +396,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad base fee per gas",
|
||||
expectedErrorMessage: "failed to parse execution payload base fee per gas `bar`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.BaseFeePerGas = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -405,7 +405,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad block hash",
|
||||
expectedErrorMessage: "failed to decode execution payload block hash `foo`",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.BlockHash = "foo"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -414,7 +414,7 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
name: "bad transactions",
|
||||
expectedErrorMessage: "failed to get execution payload transactions",
|
||||
generateData: func() *structs.BeaconBlockBellatrix {
|
||||
beaconBlock := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.Transactions[0] = "bar"
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -433,9 +433,9 @@ func TestGetBeaconBlockConverter_BellatrixError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetBeaconBlockConverter_CapellaValid(t *testing.T) {
|
||||
expectedBeaconBlock := test_helpers.GenerateProtoCapellaBeaconBlock()
|
||||
expectedBeaconBlock := testhelpers.GenerateProtoCapellaBeaconBlock()
|
||||
beaconBlockConverter := &beaconApiBeaconBlockConverter{}
|
||||
beaconBlock, err := beaconBlockConverter.ConvertRESTCapellaBlockToProto(test_helpers.GenerateJsonCapellaBeaconBlock())
|
||||
beaconBlock, err := beaconBlockConverter.ConvertRESTCapellaBlockToProto(testhelpers.GenerateJsonCapellaBeaconBlock())
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedBeaconBlock, beaconBlock)
|
||||
}
|
||||
@@ -450,7 +450,7 @@ func TestGetBeaconBlockConverter_CapellaError(t *testing.T) {
|
||||
name: "nil body",
|
||||
expectedErrorMessage: "block body is nil",
|
||||
generateData: func() *structs.BeaconBlockCapella {
|
||||
beaconBlock := test_helpers.GenerateJsonCapellaBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonCapellaBeaconBlock()
|
||||
beaconBlock.Body = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -459,7 +459,7 @@ func TestGetBeaconBlockConverter_CapellaError(t *testing.T) {
|
||||
name: "nil execution payload",
|
||||
expectedErrorMessage: "execution payload is nil",
|
||||
generateData: func() *structs.BeaconBlockCapella {
|
||||
beaconBlock := test_helpers.GenerateJsonCapellaBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonCapellaBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -468,7 +468,7 @@ func TestGetBeaconBlockConverter_CapellaError(t *testing.T) {
|
||||
name: "bad bellatrix fields",
|
||||
expectedErrorMessage: "failed to get the bellatrix fields of the capella block",
|
||||
generateData: func() *structs.BeaconBlockCapella {
|
||||
beaconBlock := test_helpers.GenerateJsonCapellaBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonCapellaBeaconBlock()
|
||||
beaconBlock.Body.Eth1Data = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -477,7 +477,7 @@ func TestGetBeaconBlockConverter_CapellaError(t *testing.T) {
|
||||
name: "bad withdrawals",
|
||||
expectedErrorMessage: "failed to get withdrawals",
|
||||
generateData: func() *structs.BeaconBlockCapella {
|
||||
beaconBlock := test_helpers.GenerateJsonCapellaBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonCapellaBeaconBlock()
|
||||
beaconBlock.Body.ExecutionPayload.Withdrawals[0] = nil
|
||||
return beaconBlock
|
||||
},
|
||||
@@ -486,7 +486,7 @@ func TestGetBeaconBlockConverter_CapellaError(t *testing.T) {
|
||||
name: "bad bls execution changes",
|
||||
expectedErrorMessage: "failed to get bls to execution changes",
|
||||
generateData: func() *structs.BeaconBlockCapella {
|
||||
beaconBlock := test_helpers.GenerateJsonCapellaBeaconBlock()
|
||||
beaconBlock := testhelpers.GenerateJsonCapellaBeaconBlock()
|
||||
beaconBlock.Body.BLSToExecutionChanges[0] = nil
|
||||
return beaconBlock
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ type aggregatedSelectionResponse struct {
|
||||
Data []iface.BeaconCommitteeSelection `json:"data"`
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getAggregatedSelection(ctx context.Context, selections []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) {
|
||||
func (c *beaconApiValidatorClient) aggregatedSelection(ctx context.Context, selections []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) {
|
||||
body, err := json.Marshal(selections)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to marshal selections")
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -27,14 +27,14 @@ func TestGetAggregatedSelections(t *testing.T) {
|
||||
name: "valid",
|
||||
req: []iface.BeaconCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 82),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 82),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
},
|
||||
},
|
||||
res: []iface.BeaconCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 100),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 100),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
},
|
||||
@@ -44,7 +44,7 @@ func TestGetAggregatedSelections(t *testing.T) {
|
||||
name: "endpoint error",
|
||||
req: []iface.BeaconCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 82),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 82),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
},
|
||||
@@ -56,7 +56,7 @@ func TestGetAggregatedSelections(t *testing.T) {
|
||||
name: "no response error",
|
||||
req: []iface.BeaconCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 82),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 82),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
},
|
||||
@@ -67,19 +67,19 @@ func TestGetAggregatedSelections(t *testing.T) {
|
||||
name: "mismatch response",
|
||||
req: []iface.BeaconCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 82),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 82),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
},
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 102),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 102),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 79,
|
||||
},
|
||||
},
|
||||
res: []iface.BeaconCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 100),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 100),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
},
|
||||
@@ -111,7 +111,7 @@ func TestGetAggregatedSelections(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
res, err := validatorClient.GetAggregatedSelections(ctx, test.req)
|
||||
res, err := validatorClient.AggregatedSelections(ctx, test.req)
|
||||
if test.expectedErrorMessage != "" {
|
||||
require.ErrorContains(t, test.expectedErrorMessage, err)
|
||||
return
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func (c beaconApiValidatorClient) getDomainData(ctx context.Context, epoch primitives.Epoch, domainType [4]byte) (*ethpb.DomainResponse, error) {
|
||||
func (c *beaconApiValidatorClient) domainData(ctx context.Context, epoch primitives.Epoch, domainType [4]byte) (*ethpb.DomainResponse, error) {
|
||||
// Get the fork version from the given epoch
|
||||
fork, err := forks.Fork(epoch)
|
||||
if err != nil {
|
||||
@@ -19,7 +19,7 @@ func (c beaconApiValidatorClient) getDomainData(ctx context.Context, epoch primi
|
||||
}
|
||||
|
||||
// Get the genesis validator root
|
||||
genesis, err := c.genesisProvider.GetGenesis(ctx)
|
||||
genesis, err := c.genesisProvider.Genesis(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get genesis info")
|
||||
}
|
||||
|
||||
@@ -35,15 +35,15 @@ func TestGetDomainData_ValidDomainData(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Make sure that GetGenesis() is called exactly once
|
||||
// Make sure that Genesis() is called exactly once
|
||||
genesisProvider := mock.NewMockGenesisProvider(ctrl)
|
||||
genesisProvider.EXPECT().GetGenesis(ctx).Return(
|
||||
genesisProvider.EXPECT().Genesis(ctx).Return(
|
||||
&structs.Genesis{GenesisValidatorsRoot: genesisValidatorRoot},
|
||||
nil,
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{genesisProvider: genesisProvider}
|
||||
resp, err := validatorClient.getDomainData(ctx, epoch, domainType)
|
||||
resp, err := validatorClient.domainData(ctx, epoch, domainType)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, resp)
|
||||
|
||||
@@ -64,12 +64,12 @@ func TestGetDomainData_GenesisError(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Make sure that GetGenesis() is called exactly once
|
||||
// Make sure that Genesis() is called exactly once
|
||||
genesisProvider := mock.NewMockGenesisProvider(ctrl)
|
||||
genesisProvider.EXPECT().GetGenesis(ctx).Return(nil, errors.New("foo error")).Times(1)
|
||||
genesisProvider.EXPECT().Genesis(ctx).Return(nil, errors.New("foo error")).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{genesisProvider: genesisProvider}
|
||||
_, err := validatorClient.getDomainData(ctx, epoch, domainType)
|
||||
_, err := validatorClient.domainData(ctx, epoch, domainType)
|
||||
assert.ErrorContains(t, "failed to get genesis info", err)
|
||||
assert.ErrorContains(t, "foo error", err)
|
||||
}
|
||||
@@ -83,14 +83,14 @@ func TestGetDomainData_InvalidGenesisRoot(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Make sure that GetGenesis() is called exactly once
|
||||
// Make sure that Genesis() is called exactly once
|
||||
genesisProvider := mock.NewMockGenesisProvider(ctrl)
|
||||
genesisProvider.EXPECT().GetGenesis(ctx).Return(
|
||||
genesisProvider.EXPECT().Genesis(ctx).Return(
|
||||
&structs.Genesis{GenesisValidatorsRoot: "foo"},
|
||||
nil,
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{genesisProvider: genesisProvider}
|
||||
_, err := validatorClient.getDomainData(ctx, epoch, domainType)
|
||||
_, err := validatorClient.domainData(ctx, epoch, domainType)
|
||||
assert.ErrorContains(t, "invalid genesis validators root: foo", err)
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func (c *beaconApiValidatorClient) checkDoppelGanger(ctx context.Context, in *et
|
||||
}
|
||||
|
||||
// Retrieve fork version -- Return early if we are in phase0.
|
||||
forkResponse, err := c.getFork(ctx)
|
||||
forkResponse, err := c.fork(ctx)
|
||||
if err != nil || forkResponse == nil || forkResponse.Data == nil {
|
||||
return nil, errors.Wrapf(err, "failed to get fork")
|
||||
}
|
||||
@@ -91,7 +91,7 @@ func (c *beaconApiValidatorClient) checkDoppelGanger(ctx context.Context, in *et
|
||||
}
|
||||
|
||||
// Retrieve current epoch.
|
||||
headers, err := c.getHeaders(ctx)
|
||||
headers, err := c.headers(ctx)
|
||||
if err != nil || headers == nil || headers.Data == nil || len(headers.Data) == 0 ||
|
||||
headers.Data[0].Header == nil || headers.Data[0].Header.Message == nil {
|
||||
return nil, errors.Wrapf(err, "failed to get headers")
|
||||
@@ -127,7 +127,7 @@ func (c *beaconApiValidatorClient) checkDoppelGanger(ctx context.Context, in *et
|
||||
}
|
||||
|
||||
// Retrieve correspondence between validator pubkey and index.
|
||||
stateValidators, err := c.stateValidatorsProvider.GetStateValidators(ctx, notRecentStringPubKeys, nil, nil)
|
||||
stateValidators, err := c.stateValidatorsProvider.StateValidators(ctx, notRecentStringPubKeys, nil, nil)
|
||||
if err != nil || stateValidators == nil || stateValidators.Data == nil {
|
||||
return nil, errors.Wrapf(err, "failed to get state validators")
|
||||
}
|
||||
@@ -156,13 +156,13 @@ func (c *beaconApiValidatorClient) checkDoppelGanger(ctx context.Context, in *et
|
||||
// since we assume that we are not in phase0.
|
||||
previousEpoch := currentEpoch - 1
|
||||
|
||||
indexToPreviousLiveness, err := c.getIndexToLiveness(ctx, previousEpoch, indexes)
|
||||
indexToPreviousLiveness, err := c.indexToLiveness(ctx, previousEpoch, indexes)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get map from validator index to liveness for previous epoch %d", previousEpoch)
|
||||
}
|
||||
|
||||
// Get validators liveness for the current epoch.
|
||||
indexToCurrentLiveness, err := c.getIndexToLiveness(ctx, currentEpoch, indexes)
|
||||
indexToCurrentLiveness, err := c.indexToLiveness(ctx, currentEpoch, indexes)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get map from validator index to liveness for current epoch %d", currentEpoch)
|
||||
}
|
||||
@@ -218,8 +218,8 @@ func buildResponse(
|
||||
}
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getIndexToLiveness(ctx context.Context, epoch primitives.Epoch, indexes []string) (map[string]bool, error) {
|
||||
livenessResponse, err := c.getLiveness(ctx, epoch, indexes)
|
||||
func (c *beaconApiValidatorClient) indexToLiveness(ctx context.Context, epoch primitives.Epoch, indexes []string) (map[string]bool, error) {
|
||||
livenessResponse, err := c.liveness(ctx, epoch, indexes)
|
||||
if err != nil || livenessResponse.Data == nil {
|
||||
return nil, errors.Wrapf(err, fmt.Sprintf("failed to get liveness for epoch %d", epoch))
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
|
||||
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
ctx,
|
||||
syncingEnpoint,
|
||||
syncingEndpoint,
|
||||
&syncingResponseJson,
|
||||
).Return(
|
||||
nil,
|
||||
@@ -363,7 +363,7 @@ func TestCheckDoppelGanger_Nominal(t *testing.T) {
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
if testCase.getStateValidatorsInterface != nil {
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
testCase.getStateValidatorsInterface.input,
|
||||
nil,
|
||||
@@ -489,7 +489,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "getFork on error",
|
||||
name: "fork on error",
|
||||
expectedErrorMessage: "failed to get fork",
|
||||
inputValidatorRequests: standardInputValidatorRequests,
|
||||
getSyncingOutput: standardGetSyncingOutput,
|
||||
@@ -734,7 +734,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
|
||||
|
||||
jsonRestHandler.EXPECT().Get(
|
||||
ctx,
|
||||
syncingEnpoint,
|
||||
syncingEndpoint,
|
||||
&syncingResponseJson,
|
||||
).Return(
|
||||
testCase.getSyncingError,
|
||||
@@ -777,7 +777,7 @@ func TestCheckDoppelGanger_Errors(t *testing.T) {
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
if testCase.getStateValidatorsInterface != nil {
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
testCase.getStateValidatorsInterface.input,
|
||||
nil,
|
||||
|
||||
@@ -19,10 +19,10 @@ import (
|
||||
)
|
||||
|
||||
type dutiesProvider interface {
|
||||
GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.AttesterDuty, error)
|
||||
GetProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*structs.ProposerDuty, error)
|
||||
GetSyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.SyncCommitteeDuty, error)
|
||||
GetCommittees(ctx context.Context, epoch primitives.Epoch) ([]*structs.Committee, error)
|
||||
AttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.AttesterDuty, error)
|
||||
ProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*structs.ProposerDuty, error)
|
||||
SyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.SyncCommitteeDuty, error)
|
||||
Committees(ctx context.Context, epoch primitives.Epoch) ([]*structs.Committee, error)
|
||||
}
|
||||
|
||||
type beaconApiDutiesProvider struct {
|
||||
@@ -40,8 +40,8 @@ type validatorForDuty struct {
|
||||
status ethpb.ValidatorStatus
|
||||
}
|
||||
|
||||
func (c beaconApiValidatorClient) getDuties(ctx context.Context, in *ethpb.DutiesRequest) (*ethpb.DutiesResponse, error) {
|
||||
vals, err := c.getValidatorsForDuties(ctx, in.PublicKeys)
|
||||
func (c *beaconApiValidatorClient) duties(ctx context.Context, in *ethpb.DutiesRequest) (*ethpb.DutiesResponse, error) {
|
||||
vals, err := c.validatorsForDuties(ctx, in.PublicKeys)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get validators for duties")
|
||||
}
|
||||
@@ -53,7 +53,7 @@ func (c beaconApiValidatorClient) getDuties(ctx context.Context, in *ethpb.Dutie
|
||||
|
||||
var currentEpochDuties []*ethpb.DutiesResponse_Duty
|
||||
go func() {
|
||||
currentEpochDuties, err = c.getDutiesForEpoch(ctx, in.Epoch, vals, fetchSyncDuties)
|
||||
currentEpochDuties, err = c.dutiesForEpoch(ctx, in.Epoch, vals, fetchSyncDuties)
|
||||
if err != nil {
|
||||
errCh <- errors.Wrapf(err, "failed to get duties for current epoch `%d`", in.Epoch)
|
||||
return
|
||||
@@ -61,7 +61,7 @@ func (c beaconApiValidatorClient) getDuties(ctx context.Context, in *ethpb.Dutie
|
||||
errCh <- nil
|
||||
}()
|
||||
|
||||
nextEpochDuties, err := c.getDutiesForEpoch(ctx, in.Epoch+1, vals, fetchSyncDuties)
|
||||
nextEpochDuties, err := c.dutiesForEpoch(ctx, in.Epoch+1, vals, fetchSyncDuties)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get duties for next epoch `%d`", in.Epoch+1)
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func (c beaconApiValidatorClient) getDuties(ctx context.Context, in *ethpb.Dutie
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c beaconApiValidatorClient) getDutiesForEpoch(
|
||||
func (c *beaconApiValidatorClient) dutiesForEpoch(
|
||||
ctx context.Context,
|
||||
epoch primitives.Epoch,
|
||||
vals []validatorForDuty,
|
||||
@@ -103,7 +103,7 @@ func (c beaconApiValidatorClient) getDutiesForEpoch(
|
||||
var wg errgroup.Group
|
||||
|
||||
wg.Go(func() error {
|
||||
attesterDuties, err := c.dutiesProvider.GetAttesterDuties(ctx, epoch, indices)
|
||||
attesterDuties, err := c.dutiesProvider.AttesterDuties(ctx, epoch, indices)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get attester duties for epoch `%d`", epoch)
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func (c beaconApiValidatorClient) getDutiesForEpoch(
|
||||
|
||||
if fetchSyncDuties {
|
||||
wg.Go(func() error {
|
||||
syncDuties, err := c.dutiesProvider.GetSyncDuties(ctx, epoch, indices)
|
||||
syncDuties, err := c.dutiesProvider.SyncDuties(ctx, epoch, indices)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get sync duties for epoch `%d`", epoch)
|
||||
}
|
||||
@@ -148,7 +148,7 @@ func (c beaconApiValidatorClient) getDutiesForEpoch(
|
||||
}
|
||||
|
||||
wg.Go(func() error {
|
||||
proposerDuties, err := c.dutiesProvider.GetProposerDuties(ctx, epoch)
|
||||
proposerDuties, err := c.dutiesProvider.ProposerDuties(ctx, epoch)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get proposer duties for epoch `%d`", epoch)
|
||||
}
|
||||
@@ -168,7 +168,7 @@ func (c beaconApiValidatorClient) getDutiesForEpoch(
|
||||
return nil
|
||||
})
|
||||
|
||||
committees, err := c.dutiesProvider.GetCommittees(ctx, epoch)
|
||||
committees, err := c.dutiesProvider.Committees(ctx, epoch)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get committees for epoch `%d`", epoch)
|
||||
}
|
||||
@@ -242,7 +242,7 @@ func (c beaconApiValidatorClient) getDutiesForEpoch(
|
||||
return duties, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getValidatorsForDuties(ctx context.Context, pubkeys [][]byte) ([]validatorForDuty, error) {
|
||||
func (c *beaconApiValidatorClient) validatorsForDuties(ctx context.Context, pubkeys [][]byte) ([]validatorForDuty, error) {
|
||||
vals := make([]validatorForDuty, 0, len(pubkeys))
|
||||
stringPubkeysToPubkeys := make(map[string][]byte, len(pubkeys))
|
||||
stringPubkeys := make([]string, len(pubkeys))
|
||||
@@ -254,7 +254,7 @@ func (c *beaconApiValidatorClient) getValidatorsForDuties(ctx context.Context, p
|
||||
}
|
||||
|
||||
statusesWithDuties := []string{validator.ActiveOngoing.String(), validator.ActiveExiting.String()}
|
||||
stateValidatorsResponse, err := c.stateValidatorsProvider.GetStateValidators(ctx, stringPubkeys, nil, statusesWithDuties)
|
||||
stateValidatorsResponse, err := c.stateValidatorsProvider.StateValidators(ctx, stringPubkeys, nil, statusesWithDuties)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get state validators")
|
||||
}
|
||||
@@ -288,7 +288,7 @@ func (c *beaconApiValidatorClient) getValidatorsForDuties(ctx context.Context, p
|
||||
}
|
||||
|
||||
// GetCommittees retrieves the committees for the given epoch
|
||||
func (c beaconApiDutiesProvider) GetCommittees(ctx context.Context, epoch primitives.Epoch) ([]*structs.Committee, error) {
|
||||
func (c beaconApiDutiesProvider) Committees(ctx context.Context, epoch primitives.Epoch) ([]*structs.Committee, error) {
|
||||
committeeParams := url.Values{}
|
||||
committeeParams.Add("epoch", strconv.FormatUint(uint64(epoch), 10))
|
||||
committeesRequest := buildURL("/eth/v1/beacon/states/head/committees", committeeParams)
|
||||
@@ -312,7 +312,7 @@ func (c beaconApiDutiesProvider) GetCommittees(ctx context.Context, epoch primit
|
||||
}
|
||||
|
||||
// GetAttesterDuties retrieves the attester duties for the given epoch and validatorIndices
|
||||
func (c beaconApiDutiesProvider) GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.AttesterDuty, error) {
|
||||
func (c beaconApiDutiesProvider) AttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.AttesterDuty, error) {
|
||||
jsonValidatorIndices := make([]string, len(validatorIndices))
|
||||
for index, validatorIndex := range validatorIndices {
|
||||
jsonValidatorIndices[index] = strconv.FormatUint(uint64(validatorIndex), 10)
|
||||
@@ -344,7 +344,7 @@ func (c beaconApiDutiesProvider) GetAttesterDuties(ctx context.Context, epoch pr
|
||||
}
|
||||
|
||||
// GetProposerDuties retrieves the proposer duties for the given epoch
|
||||
func (c beaconApiDutiesProvider) GetProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*structs.ProposerDuty, error) {
|
||||
func (c beaconApiDutiesProvider) ProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*structs.ProposerDuty, error) {
|
||||
proposerDuties := structs.GetProposerDutiesResponse{}
|
||||
if err := c.jsonRestHandler.Get(ctx, fmt.Sprintf("/eth/v1/validator/duties/proposer/%d", epoch), &proposerDuties); err != nil {
|
||||
return nil, err
|
||||
@@ -364,7 +364,7 @@ func (c beaconApiDutiesProvider) GetProposerDuties(ctx context.Context, epoch pr
|
||||
}
|
||||
|
||||
// GetSyncDuties retrieves the sync committee duties for the given epoch and validatorIndices
|
||||
func (c beaconApiDutiesProvider) GetSyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.SyncCommitteeDuty, error) {
|
||||
func (c beaconApiDutiesProvider) SyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.SyncCommitteeDuty, error) {
|
||||
jsonValidatorIndices := make([]string, len(validatorIndices))
|
||||
for index, validatorIndex := range validatorIndices {
|
||||
jsonValidatorIndices[index] = strconv.FormatUint(uint64(validatorIndex), 10)
|
||||
|
||||
@@ -76,7 +76,7 @@ func TestGetAttesterDuties_Valid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
attesterDuties, err := dutiesProvider.GetAttesterDuties(ctx, epoch, validatorIndices)
|
||||
attesterDuties, err := dutiesProvider.AttesterDuties(ctx, epoch, validatorIndices)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedAttesterDuties.Data, attesterDuties)
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func TestGetAttesterDuties_HttpError(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetAttesterDuties(ctx, epoch, nil)
|
||||
_, err := dutiesProvider.AttesterDuties(ctx, epoch, nil)
|
||||
assert.ErrorContains(t, "foo error", err)
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ func TestGetAttesterDuties_NilAttesterDuty(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetAttesterDuties(ctx, epoch, nil)
|
||||
_, err := dutiesProvider.AttesterDuties(ctx, epoch, nil)
|
||||
assert.ErrorContains(t, "attester duty at index `0` is nil", err)
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ func TestGetProposerDuties_Valid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
proposerDuties, err := dutiesProvider.GetProposerDuties(ctx, epoch)
|
||||
proposerDuties, err := dutiesProvider.ProposerDuties(ctx, epoch)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedProposerDuties.Data, proposerDuties)
|
||||
}
|
||||
@@ -193,7 +193,7 @@ func TestGetProposerDuties_HttpError(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetProposerDuties(ctx, epoch)
|
||||
_, err := dutiesProvider.ProposerDuties(ctx, epoch)
|
||||
assert.ErrorContains(t, "foo error", err)
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ func TestGetProposerDuties_NilData(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetProposerDuties(ctx, epoch)
|
||||
_, err := dutiesProvider.ProposerDuties(ctx, epoch)
|
||||
assert.ErrorContains(t, "proposer duties data is nil", err)
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ func TestGetProposerDuties_NilProposerDuty(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetProposerDuties(ctx, epoch)
|
||||
_, err := dutiesProvider.ProposerDuties(ctx, epoch)
|
||||
assert.ErrorContains(t, "proposer duty at index `0` is nil", err)
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ func TestGetSyncDuties_Valid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
syncDuties, err := dutiesProvider.GetSyncDuties(ctx, epoch, validatorIndices)
|
||||
syncDuties, err := dutiesProvider.SyncDuties(ctx, epoch, validatorIndices)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedSyncDuties.Data, syncDuties)
|
||||
}
|
||||
@@ -325,7 +325,7 @@ func TestGetSyncDuties_HttpError(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetSyncDuties(ctx, epoch, nil)
|
||||
_, err := dutiesProvider.SyncDuties(ctx, epoch, nil)
|
||||
assert.ErrorContains(t, "foo error", err)
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ func TestGetSyncDuties_NilData(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetSyncDuties(ctx, epoch, nil)
|
||||
_, err := dutiesProvider.SyncDuties(ctx, epoch, nil)
|
||||
assert.ErrorContains(t, "sync duties data is nil", err)
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ func TestGetSyncDuties_NilSyncDuty(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetSyncDuties(ctx, epoch, nil)
|
||||
_, err := dutiesProvider.SyncDuties(ctx, epoch, nil)
|
||||
assert.ErrorContains(t, "sync duty at index `0` is nil", err)
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ func TestGetCommittees_Valid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
committees, err := dutiesProvider.GetCommittees(ctx, epoch)
|
||||
committees, err := dutiesProvider.Committees(ctx, epoch)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedCommittees.Data, committees)
|
||||
}
|
||||
@@ -452,7 +452,7 @@ func TestGetCommittees_HttpError(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetCommittees(ctx, epoch)
|
||||
_, err := dutiesProvider.Committees(ctx, epoch)
|
||||
assert.ErrorContains(t, "foo error", err)
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ func TestGetCommittees_NilData(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetCommittees(ctx, epoch)
|
||||
_, err := dutiesProvider.Committees(ctx, epoch)
|
||||
assert.ErrorContains(t, "state committees data is nil", err)
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ func TestGetCommittees_NilCommittee(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := &beaconApiDutiesProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := dutiesProvider.GetCommittees(ctx, epoch)
|
||||
_, err := dutiesProvider.Committees(ctx, epoch)
|
||||
assert.ErrorContains(t, "committee at index `0` is nil", err)
|
||||
}
|
||||
|
||||
@@ -682,7 +682,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
|
||||
}
|
||||
|
||||
dutiesProvider := mock.NewMockdutiesProvider(ctrl)
|
||||
dutiesProvider.EXPECT().GetAttesterDuties(
|
||||
dutiesProvider.EXPECT().AttesterDuties(
|
||||
ctx,
|
||||
epoch,
|
||||
gomock.Any(),
|
||||
@@ -691,7 +691,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
|
||||
testCase.fetchAttesterDutiesError,
|
||||
).AnyTimes()
|
||||
|
||||
dutiesProvider.EXPECT().GetProposerDuties(
|
||||
dutiesProvider.EXPECT().ProposerDuties(
|
||||
ctx,
|
||||
epoch,
|
||||
).Return(
|
||||
@@ -699,7 +699,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
|
||||
testCase.fetchProposerDutiesError,
|
||||
).AnyTimes()
|
||||
|
||||
dutiesProvider.EXPECT().GetSyncDuties(
|
||||
dutiesProvider.EXPECT().SyncDuties(
|
||||
ctx,
|
||||
epoch,
|
||||
gomock.Any(),
|
||||
@@ -708,7 +708,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
|
||||
testCase.fetchSyncDutiesError,
|
||||
).AnyTimes()
|
||||
|
||||
dutiesProvider.EXPECT().GetCommittees(
|
||||
dutiesProvider.EXPECT().Committees(
|
||||
ctx,
|
||||
epoch,
|
||||
).Return(
|
||||
@@ -726,7 +726,7 @@ func TestGetDutiesForEpoch_Error(t *testing.T) {
|
||||
}
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{dutiesProvider: dutiesProvider}
|
||||
_, err := validatorClient.getDutiesForEpoch(
|
||||
_, err := validatorClient.dutiesForEpoch(
|
||||
ctx,
|
||||
epoch,
|
||||
vals,
|
||||
@@ -767,7 +767,7 @@ func TestGetDutiesForEpoch_Valid(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
dutiesProvider := mock.NewMockdutiesProvider(ctrl)
|
||||
dutiesProvider.EXPECT().GetCommittees(
|
||||
dutiesProvider.EXPECT().Committees(
|
||||
ctx,
|
||||
epoch,
|
||||
).Return(
|
||||
@@ -775,7 +775,7 @@ func TestGetDutiesForEpoch_Valid(t *testing.T) {
|
||||
nil,
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider.EXPECT().GetAttesterDuties(
|
||||
dutiesProvider.EXPECT().AttesterDuties(
|
||||
ctx,
|
||||
epoch,
|
||||
validatorIndices,
|
||||
@@ -784,7 +784,7 @@ func TestGetDutiesForEpoch_Valid(t *testing.T) {
|
||||
nil,
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider.EXPECT().GetProposerDuties(
|
||||
dutiesProvider.EXPECT().ProposerDuties(
|
||||
ctx,
|
||||
epoch,
|
||||
).Return(
|
||||
@@ -793,7 +793,7 @@ func TestGetDutiesForEpoch_Valid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
if testCase.fetchSyncDuties {
|
||||
dutiesProvider.EXPECT().GetSyncDuties(
|
||||
dutiesProvider.EXPECT().SyncDuties(
|
||||
ctx,
|
||||
epoch,
|
||||
validatorIndices,
|
||||
@@ -951,7 +951,7 @@ func TestGetDutiesForEpoch_Valid(t *testing.T) {
|
||||
status: ethpb.ValidatorStatus_ACTIVE,
|
||||
}
|
||||
}
|
||||
duties, err := validatorClient.getDutiesForEpoch(
|
||||
duties, err := validatorClient.dutiesForEpoch(
|
||||
ctx,
|
||||
epoch,
|
||||
vals,
|
||||
@@ -1004,7 +1004,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
dutiesProvider := mock.NewMockdutiesProvider(ctrl)
|
||||
dutiesProvider.EXPECT().GetCommittees(
|
||||
dutiesProvider.EXPECT().Committees(
|
||||
ctx,
|
||||
testCase.epoch,
|
||||
).Return(
|
||||
@@ -1012,7 +1012,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
nil,
|
||||
).Times(2)
|
||||
|
||||
dutiesProvider.EXPECT().GetAttesterDuties(
|
||||
dutiesProvider.EXPECT().AttesterDuties(
|
||||
ctx,
|
||||
testCase.epoch,
|
||||
validatorIndices,
|
||||
@@ -1021,7 +1021,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
nil,
|
||||
).Times(2)
|
||||
|
||||
dutiesProvider.EXPECT().GetProposerDuties(
|
||||
dutiesProvider.EXPECT().ProposerDuties(
|
||||
ctx,
|
||||
testCase.epoch,
|
||||
).Return(
|
||||
@@ -1031,7 +1031,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
|
||||
fetchSyncDuties := testCase.epoch >= params.BeaconConfig().AltairForkEpoch
|
||||
if fetchSyncDuties {
|
||||
dutiesProvider.EXPECT().GetSyncDuties(
|
||||
dutiesProvider.EXPECT().SyncDuties(
|
||||
ctx,
|
||||
testCase.epoch,
|
||||
validatorIndices,
|
||||
@@ -1041,7 +1041,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
).Times(2)
|
||||
}
|
||||
|
||||
dutiesProvider.EXPECT().GetCommittees(
|
||||
dutiesProvider.EXPECT().Committees(
|
||||
ctx,
|
||||
testCase.epoch+1,
|
||||
).Return(
|
||||
@@ -1049,7 +1049,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
nil,
|
||||
).Times(2)
|
||||
|
||||
dutiesProvider.EXPECT().GetAttesterDuties(
|
||||
dutiesProvider.EXPECT().AttesterDuties(
|
||||
ctx,
|
||||
testCase.epoch+1,
|
||||
validatorIndices,
|
||||
@@ -1058,7 +1058,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
nil,
|
||||
).Times(2)
|
||||
|
||||
dutiesProvider.EXPECT().GetProposerDuties(
|
||||
dutiesProvider.EXPECT().ProposerDuties(
|
||||
ctx,
|
||||
testCase.epoch+1,
|
||||
).Return(
|
||||
@@ -1067,7 +1067,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
).Times(2)
|
||||
|
||||
if fetchSyncDuties {
|
||||
dutiesProvider.EXPECT().GetSyncDuties(
|
||||
dutiesProvider.EXPECT().SyncDuties(
|
||||
ctx,
|
||||
testCase.epoch+1,
|
||||
validatorIndices,
|
||||
@@ -1078,7 +1078,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
}
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
@@ -1187,13 +1187,13 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
nil,
|
||||
).MinTimes(1)
|
||||
|
||||
// Make sure that our values are equal to what would be returned by calling getDutiesForEpoch individually
|
||||
// Make sure that our values are equal to what would be returned by calling dutiesForEpoch individually
|
||||
validatorClient := &beaconApiValidatorClient{
|
||||
dutiesProvider: dutiesProvider,
|
||||
stateValidatorsProvider: stateValidatorsProvider,
|
||||
}
|
||||
|
||||
expectedCurrentEpochDuties, err := validatorClient.getDutiesForEpoch(
|
||||
expectedCurrentEpochDuties, err := validatorClient.dutiesForEpoch(
|
||||
ctx,
|
||||
testCase.epoch,
|
||||
vals,
|
||||
@@ -1201,7 +1201,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedNextEpochDuties, err := validatorClient.getDutiesForEpoch(
|
||||
expectedNextEpochDuties, err := validatorClient.dutiesForEpoch(
|
||||
ctx,
|
||||
testCase.epoch+1,
|
||||
vals,
|
||||
@@ -1214,7 +1214,7 @@ func TestGetDuties_Valid(t *testing.T) {
|
||||
NextEpochDuties: expectedNextEpochDuties,
|
||||
}
|
||||
|
||||
duties, err := validatorClient.getDuties(ctx, ðpb.DutiesRequest{
|
||||
duties, err := validatorClient.duties(ctx, ðpb.DutiesRequest{
|
||||
Epoch: testCase.epoch,
|
||||
PublicKeys: append(pubkeys, []byte("0xunknown")),
|
||||
})
|
||||
@@ -1232,7 +1232,7 @@ func TestGetDuties_GetStateValidatorsFailed(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
@@ -1246,7 +1246,7 @@ func TestGetDuties_GetStateValidatorsFailed(t *testing.T) {
|
||||
stateValidatorsProvider: stateValidatorsProvider,
|
||||
}
|
||||
|
||||
_, err := validatorClient.getDuties(ctx, ðpb.DutiesRequest{
|
||||
_, err := validatorClient.duties(ctx, ðpb.DutiesRequest{
|
||||
Epoch: 1,
|
||||
PublicKeys: [][]byte{},
|
||||
})
|
||||
@@ -1262,7 +1262,7 @@ func TestGetDuties_GetDutiesForEpochFailed(t *testing.T) {
|
||||
pubkey := []byte{1, 2, 3}
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
@@ -1281,7 +1281,7 @@ func TestGetDuties_GetDutiesForEpochFailed(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
dutiesProvider := mock.NewMockdutiesProvider(ctrl)
|
||||
dutiesProvider.EXPECT().GetAttesterDuties(
|
||||
dutiesProvider.EXPECT().AttesterDuties(
|
||||
ctx,
|
||||
primitives.Epoch(1),
|
||||
gomock.Any(),
|
||||
@@ -1289,16 +1289,16 @@ func TestGetDuties_GetDutiesForEpochFailed(t *testing.T) {
|
||||
nil,
|
||||
errors.New("foo error"),
|
||||
).Times(1)
|
||||
dutiesProvider.EXPECT().GetAttesterDuties(
|
||||
dutiesProvider.EXPECT().AttesterDuties(
|
||||
ctx,
|
||||
primitives.Epoch(2),
|
||||
gomock.Any(),
|
||||
).Times(1)
|
||||
dutiesProvider.EXPECT().GetProposerDuties(
|
||||
dutiesProvider.EXPECT().ProposerDuties(
|
||||
ctx,
|
||||
gomock.Any(),
|
||||
).Times(2)
|
||||
dutiesProvider.EXPECT().GetCommittees(
|
||||
dutiesProvider.EXPECT().Committees(
|
||||
ctx,
|
||||
gomock.Any(),
|
||||
).Times(2)
|
||||
@@ -1308,7 +1308,7 @@ func TestGetDuties_GetDutiesForEpochFailed(t *testing.T) {
|
||||
dutiesProvider: dutiesProvider,
|
||||
}
|
||||
|
||||
_, err := validatorClient.getDuties(ctx, ðpb.DutiesRequest{
|
||||
_, err := validatorClient.duties(ctx, ðpb.DutiesRequest{
|
||||
Epoch: 1,
|
||||
PublicKeys: [][]byte{pubkey},
|
||||
})
|
||||
@@ -1456,7 +1456,7 @@ func generateValidSyncDuties(pubkeys [][]byte, validatorIndices []primitives.Val
|
||||
}
|
||||
}
|
||||
|
||||
// We will use a reverse function to easily make sure that the current epoch and next epoch data returned by getDutiesForEpoch
|
||||
// We will use a reverse function to easily make sure that the current epoch and next epoch data returned by dutiesForEpoch
|
||||
// are not the same
|
||||
func reverseSlice[T interface{}](slice []T) []T {
|
||||
reversedSlice := make([]T, len(slice))
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
type GenesisProvider interface {
|
||||
GetGenesis(ctx context.Context) (*structs.Genesis, error)
|
||||
Genesis(ctx context.Context) (*structs.Genesis, error)
|
||||
}
|
||||
|
||||
type beaconApiGenesisProvider struct {
|
||||
@@ -24,8 +24,8 @@ type beaconApiGenesisProvider struct {
|
||||
once sync.Once
|
||||
}
|
||||
|
||||
func (c beaconApiValidatorClient) waitForChainStart(ctx context.Context) (*ethpb.ChainStartResponse, error) {
|
||||
genesis, err := c.genesisProvider.GetGenesis(ctx)
|
||||
func (c *beaconApiValidatorClient) waitForChainStart(ctx context.Context) (*ethpb.ChainStartResponse, error) {
|
||||
genesis, err := c.genesisProvider.Genesis(ctx)
|
||||
|
||||
for err != nil {
|
||||
jsonErr := &httputil.DefaultJsonError{}
|
||||
@@ -37,7 +37,7 @@ func (c beaconApiValidatorClient) waitForChainStart(ctx context.Context) (*ethpb
|
||||
// Error 404 means that the chain genesis info is not yet known, so we query it every second until it's ready
|
||||
select {
|
||||
case <-time.After(time.Second):
|
||||
genesis, err = c.genesisProvider.GetGenesis(ctx)
|
||||
genesis, err = c.genesisProvider.Genesis(ctx)
|
||||
case <-ctx.Done():
|
||||
return nil, errors.New("context canceled")
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func (c beaconApiValidatorClient) waitForChainStart(ctx context.Context) (*ethpb
|
||||
}
|
||||
|
||||
// GetGenesis gets the genesis information from the beacon node via the /eth/v1/beacon/genesis endpoint
|
||||
func (c *beaconApiGenesisProvider) GetGenesis(ctx context.Context) (*structs.Genesis, error) {
|
||||
func (c *beaconApiGenesisProvider) Genesis(ctx context.Context) (*structs.Genesis, error) {
|
||||
genesisJson := &structs.GetGenesisResponse{}
|
||||
var doErr error
|
||||
c.once.Do(func() {
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestGetGenesis_ValidGenesis(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
genesisProvider := &beaconApiGenesisProvider{jsonRestHandler: jsonRestHandler}
|
||||
resp, err := genesisProvider.GetGenesis(ctx)
|
||||
resp, err := genesisProvider.Genesis(ctx)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, "1234", resp.GenesisTime)
|
||||
@@ -64,7 +64,7 @@ func TestGetGenesis_NilData(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
genesisProvider := &beaconApiGenesisProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := genesisProvider.GetGenesis(ctx)
|
||||
_, err := genesisProvider.Genesis(ctx)
|
||||
assert.ErrorContains(t, "genesis data is nil", err)
|
||||
}
|
||||
|
||||
@@ -93,9 +93,9 @@ func TestGetGenesis_EndpointCalledOnlyOnce(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
genesisProvider := &beaconApiGenesisProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := genesisProvider.GetGenesis(ctx)
|
||||
_, err := genesisProvider.Genesis(ctx)
|
||||
assert.NoError(t, err)
|
||||
resp, err := genesisProvider.GetGenesis(ctx)
|
||||
resp, err := genesisProvider.Genesis(ctx)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, "1234", resp.GenesisTime)
|
||||
@@ -134,9 +134,9 @@ func TestGetGenesis_EndpointCanBeCalledAgainAfterError(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
genesisProvider := &beaconApiGenesisProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err := genesisProvider.GetGenesis(ctx)
|
||||
_, err := genesisProvider.Genesis(ctx)
|
||||
require.ErrorContains(t, "foo", err)
|
||||
resp, err := genesisProvider.GetGenesis(ctx)
|
||||
resp, err := genesisProvider.Genesis(ctx)
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, "1234", resp.GenesisTime)
|
||||
|
||||
@@ -22,7 +22,7 @@ type abstractProduceBlockResponseJson struct {
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primitives.Slot, randaoReveal []byte, graffiti []byte) (*ethpb.GenericBeaconBlock, error) {
|
||||
func (c *beaconApiValidatorClient) beaconBlock(ctx context.Context, slot primitives.Slot, randaoReveal, graffiti []byte) (*ethpb.GenericBeaconBlock, error) {
|
||||
queryParams := neturl.Values{}
|
||||
queryParams.Add("randao_reveal", hexutil.Encode(randaoReveal))
|
||||
if len(graffiti) > 0 {
|
||||
@@ -164,7 +164,7 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (c beaconApiValidatorClient) fallBackToBlinded(
|
||||
func (c *beaconApiValidatorClient) fallBackToBlinded(
|
||||
ctx context.Context,
|
||||
slot primitives.Slot,
|
||||
queryParams neturl.Values,
|
||||
@@ -177,7 +177,7 @@ func (c beaconApiValidatorClient) fallBackToBlinded(
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (c beaconApiValidatorClient) fallBackToFull(
|
||||
func (c *beaconApiValidatorClient) fallBackToFull(
|
||||
ctx context.Context,
|
||||
slot primitives.Slot,
|
||||
queryParams neturl.Values,
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestGetBeaconBlock_RequestFailed(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
_, err := validatorClient.getBeaconBlock(ctx, 1, []byte{1}, []byte{2})
|
||||
_, err := validatorClient.beaconBlock(ctx, 1, []byte{1}, []byte{2})
|
||||
assert.ErrorContains(t, "foo error", err)
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func TestGetBeaconBlock_Error(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
_, err := validatorClient.getBeaconBlock(ctx, 1, []byte{1}, []byte{2})
|
||||
_, err := validatorClient.beaconBlock(ctx, 1, []byte{1}, []byte{2})
|
||||
assert.ErrorContains(t, testCase.expectedErrorMessage, err)
|
||||
})
|
||||
}
|
||||
@@ -149,8 +149,8 @@ func TestGetBeaconBlock_Phase0Valid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
proto := test_helpers.GenerateProtoPhase0BeaconBlock()
|
||||
block := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
proto := testhelpers.GenerateProtoPhase0BeaconBlock()
|
||||
block := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
bytes, err := json.Marshal(block)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -175,7 +175,7 @@ func TestGetBeaconBlock_Phase0Valid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
beaconBlock, err := validatorClient.getBeaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
beaconBlock, err := validatorClient.beaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedBeaconBlock := ðpb.GenericBeaconBlock{
|
||||
@@ -191,8 +191,8 @@ func TestGetBeaconBlock_AltairValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
proto := test_helpers.GenerateProtoAltairBeaconBlock()
|
||||
block := test_helpers.GenerateJsonAltairBeaconBlock()
|
||||
proto := testhelpers.GenerateProtoAltairBeaconBlock()
|
||||
block := testhelpers.GenerateJsonAltairBeaconBlock()
|
||||
bytes, err := json.Marshal(block)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -218,7 +218,7 @@ func TestGetBeaconBlock_AltairValid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
beaconBlock, err := validatorClient.getBeaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
beaconBlock, err := validatorClient.beaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedBeaconBlock := ðpb.GenericBeaconBlock{
|
||||
@@ -234,8 +234,8 @@ func TestGetBeaconBlock_BellatrixValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
proto := test_helpers.GenerateProtoBellatrixBeaconBlock()
|
||||
block := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
proto := testhelpers.GenerateProtoBellatrixBeaconBlock()
|
||||
block := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
bytes, err := json.Marshal(block)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -262,7 +262,7 @@ func TestGetBeaconBlock_BellatrixValid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
beaconBlock, err := validatorClient.getBeaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
beaconBlock, err := validatorClient.beaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedBeaconBlock := ðpb.GenericBeaconBlock{
|
||||
@@ -279,8 +279,8 @@ func TestGetBeaconBlock_BlindedBellatrixValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
proto := test_helpers.GenerateProtoBlindedBellatrixBeaconBlock()
|
||||
block := test_helpers.GenerateJsonBlindedBellatrixBeaconBlock()
|
||||
proto := testhelpers.GenerateProtoBlindedBellatrixBeaconBlock()
|
||||
block := testhelpers.GenerateJsonBlindedBellatrixBeaconBlock()
|
||||
bytes, err := json.Marshal(block)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -307,7 +307,7 @@ func TestGetBeaconBlock_BlindedBellatrixValid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
beaconBlock, err := validatorClient.getBeaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
beaconBlock, err := validatorClient.beaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedBeaconBlock := ðpb.GenericBeaconBlock{
|
||||
@@ -324,8 +324,8 @@ func TestGetBeaconBlock_CapellaValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
proto := test_helpers.GenerateProtoCapellaBeaconBlock()
|
||||
block := test_helpers.GenerateJsonCapellaBeaconBlock()
|
||||
proto := testhelpers.GenerateProtoCapellaBeaconBlock()
|
||||
block := testhelpers.GenerateJsonCapellaBeaconBlock()
|
||||
bytes, err := json.Marshal(block)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -352,7 +352,7 @@ func TestGetBeaconBlock_CapellaValid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
beaconBlock, err := validatorClient.getBeaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
beaconBlock, err := validatorClient.beaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedBeaconBlock := ðpb.GenericBeaconBlock{
|
||||
@@ -369,8 +369,8 @@ func TestGetBeaconBlock_BlindedCapellaValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
proto := test_helpers.GenerateProtoBlindedCapellaBeaconBlock()
|
||||
block := test_helpers.GenerateJsonBlindedCapellaBeaconBlock()
|
||||
proto := testhelpers.GenerateProtoBlindedCapellaBeaconBlock()
|
||||
block := testhelpers.GenerateJsonBlindedCapellaBeaconBlock()
|
||||
bytes, err := json.Marshal(block)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -397,7 +397,7 @@ func TestGetBeaconBlock_BlindedCapellaValid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
beaconBlock, err := validatorClient.getBeaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
beaconBlock, err := validatorClient.beaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedBeaconBlock := ðpb.GenericBeaconBlock{
|
||||
@@ -414,8 +414,8 @@ func TestGetBeaconBlock_DenebValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
proto := test_helpers.GenerateProtoDenebBeaconBlockContents()
|
||||
block := test_helpers.GenerateJsonDenebBeaconBlockContents()
|
||||
proto := testhelpers.GenerateProtoDenebBeaconBlockContents()
|
||||
block := testhelpers.GenerateJsonDenebBeaconBlockContents()
|
||||
bytes, err := json.Marshal(block)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -442,7 +442,7 @@ func TestGetBeaconBlock_DenebValid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
beaconBlock, err := validatorClient.getBeaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
beaconBlock, err := validatorClient.beaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedBeaconBlock := ðpb.GenericBeaconBlock{
|
||||
@@ -459,8 +459,8 @@ func TestGetBeaconBlock_BlindedDenebValid(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
proto := test_helpers.GenerateProtoBlindedDenebBeaconBlock()
|
||||
block := test_helpers.GenerateJsonBlindedDenebBeaconBlock()
|
||||
proto := testhelpers.GenerateProtoBlindedDenebBeaconBlock()
|
||||
block := testhelpers.GenerateJsonBlindedDenebBeaconBlock()
|
||||
bytes, err := json.Marshal(block)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -487,7 +487,7 @@ func TestGetBeaconBlock_BlindedDenebValid(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
beaconBlock, err := validatorClient.getBeaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
beaconBlock, err := validatorClient.beaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedBeaconBlock := ðpb.GenericBeaconBlock{
|
||||
@@ -504,8 +504,8 @@ func TestGetBeaconBlock_FallbackToBlindedBlock(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
proto := test_helpers.GenerateProtoBlindedDenebBeaconBlock()
|
||||
block := test_helpers.GenerateJsonBlindedDenebBeaconBlock()
|
||||
proto := testhelpers.GenerateProtoBlindedDenebBeaconBlock()
|
||||
block := testhelpers.GenerateJsonBlindedDenebBeaconBlock()
|
||||
blockBytes, err := json.Marshal(block)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -538,7 +538,7 @@ func TestGetBeaconBlock_FallbackToBlindedBlock(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
beaconBlock, err := validatorClient.getBeaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
beaconBlock, err := validatorClient.beaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedBeaconBlock := ðpb.GenericBeaconBlock{
|
||||
@@ -555,8 +555,8 @@ func TestGetBeaconBlock_FallbackToFullBlock(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
proto := test_helpers.GenerateProtoDenebBeaconBlockContents()
|
||||
block := test_helpers.GenerateJsonDenebBeaconBlockContents()
|
||||
proto := testhelpers.GenerateProtoDenebBeaconBlockContents()
|
||||
block := testhelpers.GenerateJsonDenebBeaconBlockContents()
|
||||
blockBytes, err := json.Marshal(block)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -596,7 +596,7 @@ func TestGetBeaconBlock_FallbackToFullBlock(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
beaconBlock, err := validatorClient.getBeaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
beaconBlock, err := validatorClient.beaconBlock(ctx, slot, randaoReveal, graffiti)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedBeaconBlock := ðpb.GenericBeaconBlock{
|
||||
|
||||
@@ -28,10 +28,10 @@ func (e *IndexNotFoundError) Error() string {
|
||||
return e.message
|
||||
}
|
||||
|
||||
func (c beaconApiValidatorClient) validatorIndex(ctx context.Context, in *ethpb.ValidatorIndexRequest) (*ethpb.ValidatorIndexResponse, error) {
|
||||
func (c *beaconApiValidatorClient) validatorIndex(ctx context.Context, in *ethpb.ValidatorIndexRequest) (*ethpb.ValidatorIndexResponse, error) {
|
||||
stringPubKey := hexutil.Encode(in.PublicKey)
|
||||
|
||||
stateValidator, err := c.stateValidatorsProvider.GetStateValidators(ctx, []string{stringPubKey}, nil, nil)
|
||||
stateValidator, err := c.stateValidatorsProvider.StateValidators(ctx, []string{stringPubKey}, nil, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get state validator")
|
||||
}
|
||||
|
||||
48
validator/client/beacon-api/mock/duties_mock.go
generated
48
validator/client/beacon-api/mock/duties_mock.go
generated
@@ -41,62 +41,62 @@ func (m *MockdutiesProvider) EXPECT() *MockdutiesProviderMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// GetAttesterDuties mocks base method.
|
||||
func (m *MockdutiesProvider) GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.AttesterDuty, error) {
|
||||
// AttesterDuties mocks base method.
|
||||
func (m *MockdutiesProvider) AttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.AttesterDuty, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAttesterDuties", ctx, epoch, validatorIndices)
|
||||
ret := m.ctrl.Call(m, "AttesterDuties", ctx, epoch, validatorIndices)
|
||||
ret0, _ := ret[0].([]*structs.AttesterDuty)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetAttesterDuties indicates an expected call of GetAttesterDuties.
|
||||
func (mr *MockdutiesProviderMockRecorder) GetAttesterDuties(ctx, epoch, validatorIndices any) *gomock.Call {
|
||||
// AttesterDuties indicates an expected call of AttesterDuties.
|
||||
func (mr *MockdutiesProviderMockRecorder) AttesterDuties(ctx, epoch, validatorIndices any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAttesterDuties", reflect.TypeOf((*MockdutiesProvider)(nil).GetAttesterDuties), ctx, epoch, validatorIndices)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AttesterDuties", reflect.TypeOf((*MockdutiesProvider)(nil).AttesterDuties), ctx, epoch, validatorIndices)
|
||||
}
|
||||
|
||||
// GetCommittees mocks base method.
|
||||
func (m *MockdutiesProvider) GetCommittees(ctx context.Context, epoch primitives.Epoch) ([]*structs.Committee, error) {
|
||||
// Committees mocks base method.
|
||||
func (m *MockdutiesProvider) Committees(ctx context.Context, epoch primitives.Epoch) ([]*structs.Committee, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetCommittees", ctx, epoch)
|
||||
ret := m.ctrl.Call(m, "Committees", ctx, epoch)
|
||||
ret0, _ := ret[0].([]*structs.Committee)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetCommittees indicates an expected call of GetCommittees.
|
||||
func (mr *MockdutiesProviderMockRecorder) GetCommittees(ctx, epoch any) *gomock.Call {
|
||||
// Committees indicates an expected call of Committees.
|
||||
func (mr *MockdutiesProviderMockRecorder) Committees(ctx, epoch any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCommittees", reflect.TypeOf((*MockdutiesProvider)(nil).GetCommittees), ctx, epoch)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Committees", reflect.TypeOf((*MockdutiesProvider)(nil).Committees), ctx, epoch)
|
||||
}
|
||||
|
||||
// GetProposerDuties mocks base method.
|
||||
func (m *MockdutiesProvider) GetProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*structs.ProposerDuty, error) {
|
||||
// ProposerDuties mocks base method.
|
||||
func (m *MockdutiesProvider) ProposerDuties(ctx context.Context, epoch primitives.Epoch) ([]*structs.ProposerDuty, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetProposerDuties", ctx, epoch)
|
||||
ret := m.ctrl.Call(m, "ProposerDuties", ctx, epoch)
|
||||
ret0, _ := ret[0].([]*structs.ProposerDuty)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetProposerDuties indicates an expected call of GetProposerDuties.
|
||||
func (mr *MockdutiesProviderMockRecorder) GetProposerDuties(ctx, epoch any) *gomock.Call {
|
||||
// ProposerDuties indicates an expected call of ProposerDuties.
|
||||
func (mr *MockdutiesProviderMockRecorder) ProposerDuties(ctx, epoch any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProposerDuties", reflect.TypeOf((*MockdutiesProvider)(nil).GetProposerDuties), ctx, epoch)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposerDuties", reflect.TypeOf((*MockdutiesProvider)(nil).ProposerDuties), ctx, epoch)
|
||||
}
|
||||
|
||||
// GetSyncDuties mocks base method.
|
||||
func (m *MockdutiesProvider) GetSyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.SyncCommitteeDuty, error) {
|
||||
// SyncDuties mocks base method.
|
||||
func (m *MockdutiesProvider) SyncDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*structs.SyncCommitteeDuty, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetSyncDuties", ctx, epoch, validatorIndices)
|
||||
ret := m.ctrl.Call(m, "SyncDuties", ctx, epoch, validatorIndices)
|
||||
ret0, _ := ret[0].([]*structs.SyncCommitteeDuty)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetSyncDuties indicates an expected call of GetSyncDuties.
|
||||
func (mr *MockdutiesProviderMockRecorder) GetSyncDuties(ctx, epoch, validatorIndices any) *gomock.Call {
|
||||
// SyncDuties indicates an expected call of SyncDuties.
|
||||
func (mr *MockdutiesProviderMockRecorder) SyncDuties(ctx, epoch, validatorIndices any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncDuties", reflect.TypeOf((*MockdutiesProvider)(nil).GetSyncDuties), ctx, epoch, validatorIndices)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncDuties", reflect.TypeOf((*MockdutiesProvider)(nil).SyncDuties), ctx, epoch, validatorIndices)
|
||||
}
|
||||
|
||||
12
validator/client/beacon-api/mock/genesis_mock.go
generated
12
validator/client/beacon-api/mock/genesis_mock.go
generated
@@ -40,17 +40,17 @@ func (m *MockGenesisProvider) EXPECT() *MockGenesisProviderMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// GetGenesis mocks base method.
|
||||
func (m *MockGenesisProvider) GetGenesis(ctx context.Context) (*structs.Genesis, error) {
|
||||
// Genesis mocks base method.
|
||||
func (m *MockGenesisProvider) Genesis(ctx context.Context) (*structs.Genesis, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetGenesis", ctx)
|
||||
ret := m.ctrl.Call(m, "Genesis", ctx)
|
||||
ret0, _ := ret[0].(*structs.Genesis)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetGenesis indicates an expected call of GetGenesis.
|
||||
func (mr *MockGenesisProviderMockRecorder) GetGenesis(ctx any) *gomock.Call {
|
||||
// Genesis indicates an expected call of Genesis.
|
||||
func (mr *MockGenesisProviderMockRecorder) Genesis(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGenesis", reflect.TypeOf((*MockGenesisProvider)(nil).GetGenesis), ctx)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Genesis", reflect.TypeOf((*MockGenesisProvider)(nil).Genesis), ctx)
|
||||
}
|
||||
|
||||
@@ -41,47 +41,47 @@ func (m *MockStateValidatorsProvider) EXPECT() *MockStateValidatorsProviderMockR
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// GetStateValidators mocks base method.
|
||||
func (m *MockStateValidatorsProvider) GetStateValidators(arg0 context.Context, arg1 []string, arg2 []primitives.ValidatorIndex, arg3 []string) (*structs.GetValidatorsResponse, error) {
|
||||
// StateValidators mocks base method.
|
||||
func (m *MockStateValidatorsProvider) StateValidators(arg0 context.Context, arg1 []string, arg2 []primitives.ValidatorIndex, arg3 []string) (*structs.GetValidatorsResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetStateValidators", arg0, arg1, arg2, arg3)
|
||||
ret := m.ctrl.Call(m, "StateValidators", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(*structs.GetValidatorsResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetStateValidators indicates an expected call of GetStateValidators.
|
||||
func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidators(arg0, arg1, arg2, arg3 any) *gomock.Call {
|
||||
// StateValidators indicates an expected call of StateValidators.
|
||||
func (mr *MockStateValidatorsProviderMockRecorder) StateValidators(arg0, arg1, arg2, arg3 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStateValidators", reflect.TypeOf((*MockStateValidatorsProvider)(nil).GetStateValidators), arg0, arg1, arg2, arg3)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateValidators", reflect.TypeOf((*MockStateValidatorsProvider)(nil).StateValidators), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
// GetStateValidatorsForHead mocks base method.
|
||||
func (m *MockStateValidatorsProvider) GetStateValidatorsForHead(arg0 context.Context, arg1 []string, arg2 []primitives.ValidatorIndex, arg3 []string) (*structs.GetValidatorsResponse, error) {
|
||||
// StateValidatorsForHead mocks base method.
|
||||
func (m *MockStateValidatorsProvider) StateValidatorsForHead(arg0 context.Context, arg1 []string, arg2 []primitives.ValidatorIndex, arg3 []string) (*structs.GetValidatorsResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetStateValidatorsForHead", arg0, arg1, arg2, arg3)
|
||||
ret := m.ctrl.Call(m, "StateValidatorsForHead", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(*structs.GetValidatorsResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetStateValidatorsForHead indicates an expected call of GetStateValidatorsForHead.
|
||||
func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidatorsForHead(arg0, arg1, arg2, arg3 any) *gomock.Call {
|
||||
// StateValidatorsForHead indicates an expected call of StateValidatorsForHead.
|
||||
func (mr *MockStateValidatorsProviderMockRecorder) StateValidatorsForHead(arg0, arg1, arg2, arg3 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStateValidatorsForHead", reflect.TypeOf((*MockStateValidatorsProvider)(nil).GetStateValidatorsForHead), arg0, arg1, arg2, arg3)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateValidatorsForHead", reflect.TypeOf((*MockStateValidatorsProvider)(nil).StateValidatorsForHead), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
// GetStateValidatorsForSlot mocks base method.
|
||||
func (m *MockStateValidatorsProvider) GetStateValidatorsForSlot(arg0 context.Context, arg1 primitives.Slot, arg2 []string, arg3 []primitives.ValidatorIndex, arg4 []string) (*structs.GetValidatorsResponse, error) {
|
||||
// StateValidatorsForSlot mocks base method.
|
||||
func (m *MockStateValidatorsProvider) StateValidatorsForSlot(arg0 context.Context, arg1 primitives.Slot, arg2 []string, arg3 []primitives.ValidatorIndex, arg4 []string) (*structs.GetValidatorsResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetStateValidatorsForSlot", arg0, arg1, arg2, arg3, arg4)
|
||||
ret := m.ctrl.Call(m, "StateValidatorsForSlot", arg0, arg1, arg2, arg3, arg4)
|
||||
ret0, _ := ret[0].(*structs.GetValidatorsResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetStateValidatorsForSlot indicates an expected call of GetStateValidatorsForSlot.
|
||||
func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidatorsForSlot(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call {
|
||||
// StateValidatorsForSlot indicates an expected call of StateValidatorsForSlot.
|
||||
func (mr *MockStateValidatorsProviderMockRecorder) StateValidatorsForSlot(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStateValidatorsForSlot", reflect.TypeOf((*MockStateValidatorsProvider)(nil).GetStateValidatorsForSlot), arg0, arg1, arg2, arg3, arg4)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateValidatorsForSlot", reflect.TypeOf((*MockStateValidatorsProvider)(nil).StateValidatorsForSlot), arg0, arg1, arg2, arg3, arg4)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func (c beaconApiValidatorClient) proposeAttestation(ctx context.Context, attestation *ethpb.Attestation) (*ethpb.AttestResponse, error) {
|
||||
func (c *beaconApiValidatorClient) proposeAttestation(ctx context.Context, attestation *ethpb.Attestation) (*ethpb.AttestResponse, error) {
|
||||
if err := checkNilAttestation(attestation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -11,27 +11,27 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
func TestProposeAttestation(t *testing.T) {
|
||||
attestation := ðpb.Attestation{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 74),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 74),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 75,
|
||||
CommitteeIndex: 76,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 78,
|
||||
Root: test_helpers.FillByteSlice(32, 79),
|
||||
Root: testhelpers.FillByteSlice(32, 79),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 80,
|
||||
Root: test_helpers.FillByteSlice(32, 81),
|
||||
Root: testhelpers.FillByteSlice(32, 81),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 82),
|
||||
Signature: testhelpers.FillByteSlice(96, 82),
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@@ -53,30 +53,30 @@ func TestProposeAttestation(t *testing.T) {
|
||||
{
|
||||
name: "nil attestation data",
|
||||
attestation: ðpb.Attestation{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 74),
|
||||
Signature: test_helpers.FillByteSlice(96, 82),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 74),
|
||||
Signature: testhelpers.FillByteSlice(96, 82),
|
||||
},
|
||||
expectedErrorMessage: "attestation data is nil",
|
||||
},
|
||||
{
|
||||
name: "nil source checkpoint",
|
||||
attestation: ðpb.Attestation{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 74),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 74),
|
||||
Data: ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 82),
|
||||
Signature: testhelpers.FillByteSlice(96, 82),
|
||||
},
|
||||
expectedErrorMessage: "source/target in attestation data is nil",
|
||||
},
|
||||
{
|
||||
name: "nil target checkpoint",
|
||||
attestation: ðpb.Attestation{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 74),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 74),
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 82),
|
||||
Signature: testhelpers.FillByteSlice(96, 82),
|
||||
},
|
||||
expectedErrorMessage: "source/target in attestation data is nil",
|
||||
},
|
||||
@@ -87,14 +87,14 @@ func TestProposeAttestation(t *testing.T) {
|
||||
Source: ðpb.Checkpoint{},
|
||||
Target: ðpb.Checkpoint{},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 82),
|
||||
Signature: testhelpers.FillByteSlice(96, 82),
|
||||
},
|
||||
expectedErrorMessage: "attestation aggregation bits is empty",
|
||||
},
|
||||
{
|
||||
name: "nil signature",
|
||||
attestation: ðpb.Attestation{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 74),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 74),
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{},
|
||||
Target: ðpb.Checkpoint{},
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func (c beaconApiValidatorClient) proposeBeaconBlock(ctx context.Context, in *ethpb.GenericSignedBeaconBlock) (*ethpb.ProposeResponse, error) {
|
||||
func (c *beaconApiValidatorClient) proposeBeaconBlock(ctx context.Context, in *ethpb.GenericSignedBeaconBlock) (*ethpb.ProposeResponse, error) {
|
||||
var consensusVersion string
|
||||
var beaconBlockRoot [32]byte
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -80,8 +80,8 @@ func TestProposeBeaconBlock_Altair(t *testing.T) {
|
||||
func generateSignedAltairBlock() *ethpb.GenericSignedBeaconBlock_Altair {
|
||||
return ðpb.GenericSignedBeaconBlock_Altair{
|
||||
Altair: ðpb.SignedBeaconBlockAltair{
|
||||
Block: test_helpers.GenerateProtoAltairBeaconBlock(),
|
||||
Signature: test_helpers.FillByteSlice(96, 112),
|
||||
Block: testhelpers.GenerateProtoAltairBeaconBlock(),
|
||||
Signature: testhelpers.FillByteSlice(96, 112),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -97,8 +97,8 @@ func TestProposeBeaconBlock_Bellatrix(t *testing.T) {
|
||||
func generateSignedBellatrixBlock() *ethpb.GenericSignedBeaconBlock_Bellatrix {
|
||||
return ðpb.GenericSignedBeaconBlock_Bellatrix{
|
||||
Bellatrix: ðpb.SignedBeaconBlockBellatrix{
|
||||
Block: test_helpers.GenerateProtoBellatrixBeaconBlock(),
|
||||
Signature: test_helpers.FillByteSlice(96, 127),
|
||||
Block: testhelpers.GenerateProtoBellatrixBeaconBlock(),
|
||||
Signature: testhelpers.FillByteSlice(96, 127),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -101,37 +101,37 @@ func generateSignedBlindedBellatrixBlock() *ethpb.GenericSignedBeaconBlock_Blind
|
||||
Block: ðpb.BlindedBeaconBlockBellatrix{
|
||||
Slot: 1,
|
||||
ProposerIndex: 2,
|
||||
ParentRoot: test_helpers.FillByteSlice(32, 3),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 4),
|
||||
ParentRoot: testhelpers.FillByteSlice(32, 3),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 4),
|
||||
Body: ðpb.BlindedBeaconBlockBodyBellatrix{
|
||||
RandaoReveal: test_helpers.FillByteSlice(96, 5),
|
||||
RandaoReveal: testhelpers.FillByteSlice(96, 5),
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
DepositRoot: test_helpers.FillByteSlice(32, 6),
|
||||
DepositRoot: testhelpers.FillByteSlice(32, 6),
|
||||
DepositCount: 7,
|
||||
BlockHash: test_helpers.FillByteSlice(32, 8),
|
||||
BlockHash: testhelpers.FillByteSlice(32, 8),
|
||||
},
|
||||
Graffiti: test_helpers.FillByteSlice(32, 9),
|
||||
Graffiti: testhelpers.FillByteSlice(32, 9),
|
||||
ProposerSlashings: []*ethpb.ProposerSlashing{
|
||||
{
|
||||
Header_1: ðpb.SignedBeaconBlockHeader{
|
||||
Header: ðpb.BeaconBlockHeader{
|
||||
Slot: 10,
|
||||
ProposerIndex: 11,
|
||||
ParentRoot: test_helpers.FillByteSlice(32, 12),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 13),
|
||||
BodyRoot: test_helpers.FillByteSlice(32, 14),
|
||||
ParentRoot: testhelpers.FillByteSlice(32, 12),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 13),
|
||||
BodyRoot: testhelpers.FillByteSlice(32, 14),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 15),
|
||||
Signature: testhelpers.FillByteSlice(96, 15),
|
||||
},
|
||||
Header_2: ðpb.SignedBeaconBlockHeader{
|
||||
Header: ðpb.BeaconBlockHeader{
|
||||
Slot: 16,
|
||||
ProposerIndex: 17,
|
||||
ParentRoot: test_helpers.FillByteSlice(32, 18),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 19),
|
||||
BodyRoot: test_helpers.FillByteSlice(32, 20),
|
||||
ParentRoot: testhelpers.FillByteSlice(32, 18),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 19),
|
||||
BodyRoot: testhelpers.FillByteSlice(32, 20),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 21),
|
||||
Signature: testhelpers.FillByteSlice(96, 21),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -139,21 +139,21 @@ func generateSignedBlindedBellatrixBlock() *ethpb.GenericSignedBeaconBlock_Blind
|
||||
Header: ðpb.BeaconBlockHeader{
|
||||
Slot: 22,
|
||||
ProposerIndex: 23,
|
||||
ParentRoot: test_helpers.FillByteSlice(32, 24),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 25),
|
||||
BodyRoot: test_helpers.FillByteSlice(32, 26),
|
||||
ParentRoot: testhelpers.FillByteSlice(32, 24),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 25),
|
||||
BodyRoot: testhelpers.FillByteSlice(32, 26),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 27),
|
||||
Signature: testhelpers.FillByteSlice(96, 27),
|
||||
},
|
||||
Header_2: ðpb.SignedBeaconBlockHeader{
|
||||
Header: ðpb.BeaconBlockHeader{
|
||||
Slot: 28,
|
||||
ProposerIndex: 29,
|
||||
ParentRoot: test_helpers.FillByteSlice(32, 30),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 31),
|
||||
BodyRoot: test_helpers.FillByteSlice(32, 32),
|
||||
ParentRoot: testhelpers.FillByteSlice(32, 30),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 31),
|
||||
BodyRoot: testhelpers.FillByteSlice(32, 32),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 33),
|
||||
Signature: testhelpers.FillByteSlice(96, 33),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -164,34 +164,34 @@ func generateSignedBlindedBellatrixBlock() *ethpb.GenericSignedBeaconBlock_Blind
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 36,
|
||||
CommitteeIndex: 37,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 39,
|
||||
Root: test_helpers.FillByteSlice(32, 40),
|
||||
Root: testhelpers.FillByteSlice(32, 40),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 41,
|
||||
Root: test_helpers.FillByteSlice(32, 42),
|
||||
Root: testhelpers.FillByteSlice(32, 42),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 43),
|
||||
Signature: testhelpers.FillByteSlice(96, 43),
|
||||
},
|
||||
Attestation_2: ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{44, 45},
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 46,
|
||||
CommitteeIndex: 47,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 49,
|
||||
Root: test_helpers.FillByteSlice(32, 50),
|
||||
Root: testhelpers.FillByteSlice(32, 50),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 51,
|
||||
Root: test_helpers.FillByteSlice(32, 52),
|
||||
Root: testhelpers.FillByteSlice(32, 52),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 53),
|
||||
Signature: testhelpers.FillByteSlice(96, 53),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -200,90 +200,90 @@ func generateSignedBlindedBellatrixBlock() *ethpb.GenericSignedBeaconBlock_Blind
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 56,
|
||||
CommitteeIndex: 57,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 59,
|
||||
Root: test_helpers.FillByteSlice(32, 60),
|
||||
Root: testhelpers.FillByteSlice(32, 60),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 61,
|
||||
Root: test_helpers.FillByteSlice(32, 62),
|
||||
Root: testhelpers.FillByteSlice(32, 62),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 63),
|
||||
Signature: testhelpers.FillByteSlice(96, 63),
|
||||
},
|
||||
Attestation_2: ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{64, 65},
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 66,
|
||||
CommitteeIndex: 67,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 69,
|
||||
Root: test_helpers.FillByteSlice(32, 70),
|
||||
Root: testhelpers.FillByteSlice(32, 70),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 71,
|
||||
Root: test_helpers.FillByteSlice(32, 72),
|
||||
Root: testhelpers.FillByteSlice(32, 72),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 73),
|
||||
Signature: testhelpers.FillByteSlice(96, 73),
|
||||
},
|
||||
},
|
||||
},
|
||||
Attestations: []*ethpb.Attestation{
|
||||
{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 74),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 74),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 75,
|
||||
CommitteeIndex: 76,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 78,
|
||||
Root: test_helpers.FillByteSlice(32, 79),
|
||||
Root: testhelpers.FillByteSlice(32, 79),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 80,
|
||||
Root: test_helpers.FillByteSlice(32, 81),
|
||||
Root: testhelpers.FillByteSlice(32, 81),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 82),
|
||||
Signature: testhelpers.FillByteSlice(96, 82),
|
||||
},
|
||||
{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 83),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 83),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 84,
|
||||
CommitteeIndex: 85,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 87,
|
||||
Root: test_helpers.FillByteSlice(32, 88),
|
||||
Root: testhelpers.FillByteSlice(32, 88),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 89,
|
||||
Root: test_helpers.FillByteSlice(32, 90),
|
||||
Root: testhelpers.FillByteSlice(32, 90),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 91),
|
||||
Signature: testhelpers.FillByteSlice(96, 91),
|
||||
},
|
||||
},
|
||||
Deposits: []*ethpb.Deposit{
|
||||
{
|
||||
Proof: test_helpers.FillByteArraySlice(33, test_helpers.FillByteSlice(32, 92)),
|
||||
Proof: testhelpers.FillByteArraySlice(33, testhelpers.FillByteSlice(32, 92)),
|
||||
Data: ðpb.Deposit_Data{
|
||||
PublicKey: test_helpers.FillByteSlice(48, 94),
|
||||
WithdrawalCredentials: test_helpers.FillByteSlice(32, 95),
|
||||
PublicKey: testhelpers.FillByteSlice(48, 94),
|
||||
WithdrawalCredentials: testhelpers.FillByteSlice(32, 95),
|
||||
Amount: 96,
|
||||
Signature: test_helpers.FillByteSlice(96, 97),
|
||||
Signature: testhelpers.FillByteSlice(96, 97),
|
||||
},
|
||||
},
|
||||
{
|
||||
Proof: test_helpers.FillByteArraySlice(33, test_helpers.FillByteSlice(32, 98)),
|
||||
Proof: testhelpers.FillByteArraySlice(33, testhelpers.FillByteSlice(32, 98)),
|
||||
Data: ðpb.Deposit_Data{
|
||||
PublicKey: test_helpers.FillByteSlice(48, 100),
|
||||
WithdrawalCredentials: test_helpers.FillByteSlice(32, 101),
|
||||
PublicKey: testhelpers.FillByteSlice(48, 100),
|
||||
WithdrawalCredentials: testhelpers.FillByteSlice(32, 101),
|
||||
Amount: 102,
|
||||
Signature: test_helpers.FillByteSlice(96, 103),
|
||||
Signature: testhelpers.FillByteSlice(96, 103),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -293,39 +293,39 @@ func generateSignedBlindedBellatrixBlock() *ethpb.GenericSignedBeaconBlock_Blind
|
||||
Epoch: 104,
|
||||
ValidatorIndex: 105,
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 106),
|
||||
Signature: testhelpers.FillByteSlice(96, 106),
|
||||
},
|
||||
{
|
||||
Exit: ðpb.VoluntaryExit{
|
||||
Epoch: 107,
|
||||
ValidatorIndex: 108,
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 109),
|
||||
Signature: testhelpers.FillByteSlice(96, 109),
|
||||
},
|
||||
},
|
||||
SyncAggregate: ðpb.SyncAggregate{
|
||||
SyncCommitteeBits: test_helpers.FillByteSlice(64, 110),
|
||||
SyncCommitteeSignature: test_helpers.FillByteSlice(96, 111),
|
||||
SyncCommitteeBits: testhelpers.FillByteSlice(64, 110),
|
||||
SyncCommitteeSignature: testhelpers.FillByteSlice(96, 111),
|
||||
},
|
||||
ExecutionPayloadHeader: &enginev1.ExecutionPayloadHeader{
|
||||
ParentHash: test_helpers.FillByteSlice(32, 112),
|
||||
FeeRecipient: test_helpers.FillByteSlice(20, 113),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 114),
|
||||
ReceiptsRoot: test_helpers.FillByteSlice(32, 115),
|
||||
LogsBloom: test_helpers.FillByteSlice(256, 116),
|
||||
PrevRandao: test_helpers.FillByteSlice(32, 117),
|
||||
ParentHash: testhelpers.FillByteSlice(32, 112),
|
||||
FeeRecipient: testhelpers.FillByteSlice(20, 113),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 114),
|
||||
ReceiptsRoot: testhelpers.FillByteSlice(32, 115),
|
||||
LogsBloom: testhelpers.FillByteSlice(256, 116),
|
||||
PrevRandao: testhelpers.FillByteSlice(32, 117),
|
||||
BlockNumber: 118,
|
||||
GasLimit: 119,
|
||||
GasUsed: 120,
|
||||
Timestamp: 121,
|
||||
ExtraData: test_helpers.FillByteSlice(32, 122),
|
||||
BaseFeePerGas: test_helpers.FillByteSlice(32, 123),
|
||||
BlockHash: test_helpers.FillByteSlice(32, 124),
|
||||
TransactionsRoot: test_helpers.FillByteSlice(32, 125),
|
||||
ExtraData: testhelpers.FillByteSlice(32, 122),
|
||||
BaseFeePerGas: testhelpers.FillByteSlice(32, 123),
|
||||
BlockHash: testhelpers.FillByteSlice(32, 124),
|
||||
TransactionsRoot: testhelpers.FillByteSlice(32, 125),
|
||||
},
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 126),
|
||||
Signature: testhelpers.FillByteSlice(96, 126),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -103,37 +103,37 @@ func generateSignedBlindedCapellaBlock() *ethpb.GenericSignedBeaconBlock_Blinded
|
||||
Block: ðpb.BlindedBeaconBlockCapella{
|
||||
Slot: 1,
|
||||
ProposerIndex: 2,
|
||||
ParentRoot: test_helpers.FillByteSlice(32, 3),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 4),
|
||||
ParentRoot: testhelpers.FillByteSlice(32, 3),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 4),
|
||||
Body: ðpb.BlindedBeaconBlockBodyCapella{
|
||||
RandaoReveal: test_helpers.FillByteSlice(96, 5),
|
||||
RandaoReveal: testhelpers.FillByteSlice(96, 5),
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
DepositRoot: test_helpers.FillByteSlice(32, 6),
|
||||
DepositRoot: testhelpers.FillByteSlice(32, 6),
|
||||
DepositCount: 7,
|
||||
BlockHash: test_helpers.FillByteSlice(32, 8),
|
||||
BlockHash: testhelpers.FillByteSlice(32, 8),
|
||||
},
|
||||
Graffiti: test_helpers.FillByteSlice(32, 9),
|
||||
Graffiti: testhelpers.FillByteSlice(32, 9),
|
||||
ProposerSlashings: []*ethpb.ProposerSlashing{
|
||||
{
|
||||
Header_1: ðpb.SignedBeaconBlockHeader{
|
||||
Header: ðpb.BeaconBlockHeader{
|
||||
Slot: 10,
|
||||
ProposerIndex: 11,
|
||||
ParentRoot: test_helpers.FillByteSlice(32, 12),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 13),
|
||||
BodyRoot: test_helpers.FillByteSlice(32, 14),
|
||||
ParentRoot: testhelpers.FillByteSlice(32, 12),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 13),
|
||||
BodyRoot: testhelpers.FillByteSlice(32, 14),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 15),
|
||||
Signature: testhelpers.FillByteSlice(96, 15),
|
||||
},
|
||||
Header_2: ðpb.SignedBeaconBlockHeader{
|
||||
Header: ðpb.BeaconBlockHeader{
|
||||
Slot: 16,
|
||||
ProposerIndex: 17,
|
||||
ParentRoot: test_helpers.FillByteSlice(32, 18),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 19),
|
||||
BodyRoot: test_helpers.FillByteSlice(32, 20),
|
||||
ParentRoot: testhelpers.FillByteSlice(32, 18),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 19),
|
||||
BodyRoot: testhelpers.FillByteSlice(32, 20),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 21),
|
||||
Signature: testhelpers.FillByteSlice(96, 21),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -141,21 +141,21 @@ func generateSignedBlindedCapellaBlock() *ethpb.GenericSignedBeaconBlock_Blinded
|
||||
Header: ðpb.BeaconBlockHeader{
|
||||
Slot: 22,
|
||||
ProposerIndex: 23,
|
||||
ParentRoot: test_helpers.FillByteSlice(32, 24),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 25),
|
||||
BodyRoot: test_helpers.FillByteSlice(32, 26),
|
||||
ParentRoot: testhelpers.FillByteSlice(32, 24),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 25),
|
||||
BodyRoot: testhelpers.FillByteSlice(32, 26),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 27),
|
||||
Signature: testhelpers.FillByteSlice(96, 27),
|
||||
},
|
||||
Header_2: ðpb.SignedBeaconBlockHeader{
|
||||
Header: ðpb.BeaconBlockHeader{
|
||||
Slot: 28,
|
||||
ProposerIndex: 29,
|
||||
ParentRoot: test_helpers.FillByteSlice(32, 30),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 31),
|
||||
BodyRoot: test_helpers.FillByteSlice(32, 32),
|
||||
ParentRoot: testhelpers.FillByteSlice(32, 30),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 31),
|
||||
BodyRoot: testhelpers.FillByteSlice(32, 32),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 33),
|
||||
Signature: testhelpers.FillByteSlice(96, 33),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -166,34 +166,34 @@ func generateSignedBlindedCapellaBlock() *ethpb.GenericSignedBeaconBlock_Blinded
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 36,
|
||||
CommitteeIndex: 37,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 39,
|
||||
Root: test_helpers.FillByteSlice(32, 40),
|
||||
Root: testhelpers.FillByteSlice(32, 40),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 41,
|
||||
Root: test_helpers.FillByteSlice(32, 42),
|
||||
Root: testhelpers.FillByteSlice(32, 42),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 43),
|
||||
Signature: testhelpers.FillByteSlice(96, 43),
|
||||
},
|
||||
Attestation_2: ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{44, 45},
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 46,
|
||||
CommitteeIndex: 47,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 49,
|
||||
Root: test_helpers.FillByteSlice(32, 50),
|
||||
Root: testhelpers.FillByteSlice(32, 50),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 51,
|
||||
Root: test_helpers.FillByteSlice(32, 52),
|
||||
Root: testhelpers.FillByteSlice(32, 52),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 53),
|
||||
Signature: testhelpers.FillByteSlice(96, 53),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -202,90 +202,90 @@ func generateSignedBlindedCapellaBlock() *ethpb.GenericSignedBeaconBlock_Blinded
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 56,
|
||||
CommitteeIndex: 57,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 59,
|
||||
Root: test_helpers.FillByteSlice(32, 60),
|
||||
Root: testhelpers.FillByteSlice(32, 60),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 61,
|
||||
Root: test_helpers.FillByteSlice(32, 62),
|
||||
Root: testhelpers.FillByteSlice(32, 62),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 63),
|
||||
Signature: testhelpers.FillByteSlice(96, 63),
|
||||
},
|
||||
Attestation_2: ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{64, 65},
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 66,
|
||||
CommitteeIndex: 67,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 69,
|
||||
Root: test_helpers.FillByteSlice(32, 70),
|
||||
Root: testhelpers.FillByteSlice(32, 70),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 71,
|
||||
Root: test_helpers.FillByteSlice(32, 72),
|
||||
Root: testhelpers.FillByteSlice(32, 72),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 73),
|
||||
Signature: testhelpers.FillByteSlice(96, 73),
|
||||
},
|
||||
},
|
||||
},
|
||||
Attestations: []*ethpb.Attestation{
|
||||
{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 74),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 74),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 75,
|
||||
CommitteeIndex: 76,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 78,
|
||||
Root: test_helpers.FillByteSlice(32, 79),
|
||||
Root: testhelpers.FillByteSlice(32, 79),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 80,
|
||||
Root: test_helpers.FillByteSlice(32, 81),
|
||||
Root: testhelpers.FillByteSlice(32, 81),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 82),
|
||||
Signature: testhelpers.FillByteSlice(96, 82),
|
||||
},
|
||||
{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 83),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 83),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 84,
|
||||
CommitteeIndex: 85,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 87,
|
||||
Root: test_helpers.FillByteSlice(32, 88),
|
||||
Root: testhelpers.FillByteSlice(32, 88),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 89,
|
||||
Root: test_helpers.FillByteSlice(32, 90),
|
||||
Root: testhelpers.FillByteSlice(32, 90),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 91),
|
||||
Signature: testhelpers.FillByteSlice(96, 91),
|
||||
},
|
||||
},
|
||||
Deposits: []*ethpb.Deposit{
|
||||
{
|
||||
Proof: test_helpers.FillByteArraySlice(33, test_helpers.FillByteSlice(32, 92)),
|
||||
Proof: testhelpers.FillByteArraySlice(33, testhelpers.FillByteSlice(32, 92)),
|
||||
Data: ðpb.Deposit_Data{
|
||||
PublicKey: test_helpers.FillByteSlice(48, 94),
|
||||
WithdrawalCredentials: test_helpers.FillByteSlice(32, 95),
|
||||
PublicKey: testhelpers.FillByteSlice(48, 94),
|
||||
WithdrawalCredentials: testhelpers.FillByteSlice(32, 95),
|
||||
Amount: 96,
|
||||
Signature: test_helpers.FillByteSlice(96, 97),
|
||||
Signature: testhelpers.FillByteSlice(96, 97),
|
||||
},
|
||||
},
|
||||
{
|
||||
Proof: test_helpers.FillByteArraySlice(33, test_helpers.FillByteSlice(32, 98)),
|
||||
Proof: testhelpers.FillByteArraySlice(33, testhelpers.FillByteSlice(32, 98)),
|
||||
Data: ðpb.Deposit_Data{
|
||||
PublicKey: test_helpers.FillByteSlice(48, 100),
|
||||
WithdrawalCredentials: test_helpers.FillByteSlice(32, 101),
|
||||
PublicKey: testhelpers.FillByteSlice(48, 100),
|
||||
WithdrawalCredentials: testhelpers.FillByteSlice(32, 101),
|
||||
Amount: 102,
|
||||
Signature: test_helpers.FillByteSlice(96, 103),
|
||||
Signature: testhelpers.FillByteSlice(96, 103),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -295,58 +295,58 @@ func generateSignedBlindedCapellaBlock() *ethpb.GenericSignedBeaconBlock_Blinded
|
||||
Epoch: 104,
|
||||
ValidatorIndex: 105,
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 106),
|
||||
Signature: testhelpers.FillByteSlice(96, 106),
|
||||
},
|
||||
{
|
||||
Exit: ðpb.VoluntaryExit{
|
||||
Epoch: 107,
|
||||
ValidatorIndex: 108,
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 109),
|
||||
Signature: testhelpers.FillByteSlice(96, 109),
|
||||
},
|
||||
},
|
||||
SyncAggregate: ðpb.SyncAggregate{
|
||||
SyncCommitteeBits: test_helpers.FillByteSlice(64, 110),
|
||||
SyncCommitteeSignature: test_helpers.FillByteSlice(96, 111),
|
||||
SyncCommitteeBits: testhelpers.FillByteSlice(64, 110),
|
||||
SyncCommitteeSignature: testhelpers.FillByteSlice(96, 111),
|
||||
},
|
||||
ExecutionPayloadHeader: &enginev1.ExecutionPayloadHeaderCapella{
|
||||
ParentHash: test_helpers.FillByteSlice(32, 112),
|
||||
FeeRecipient: test_helpers.FillByteSlice(20, 113),
|
||||
StateRoot: test_helpers.FillByteSlice(32, 114),
|
||||
ReceiptsRoot: test_helpers.FillByteSlice(32, 115),
|
||||
LogsBloom: test_helpers.FillByteSlice(256, 116),
|
||||
PrevRandao: test_helpers.FillByteSlice(32, 117),
|
||||
ParentHash: testhelpers.FillByteSlice(32, 112),
|
||||
FeeRecipient: testhelpers.FillByteSlice(20, 113),
|
||||
StateRoot: testhelpers.FillByteSlice(32, 114),
|
||||
ReceiptsRoot: testhelpers.FillByteSlice(32, 115),
|
||||
LogsBloom: testhelpers.FillByteSlice(256, 116),
|
||||
PrevRandao: testhelpers.FillByteSlice(32, 117),
|
||||
BlockNumber: 118,
|
||||
GasLimit: 119,
|
||||
GasUsed: 120,
|
||||
Timestamp: 121,
|
||||
ExtraData: test_helpers.FillByteSlice(32, 122),
|
||||
BaseFeePerGas: test_helpers.FillByteSlice(32, 123),
|
||||
BlockHash: test_helpers.FillByteSlice(32, 124),
|
||||
TransactionsRoot: test_helpers.FillByteSlice(32, 125),
|
||||
WithdrawalsRoot: test_helpers.FillByteSlice(32, 126),
|
||||
ExtraData: testhelpers.FillByteSlice(32, 122),
|
||||
BaseFeePerGas: testhelpers.FillByteSlice(32, 123),
|
||||
BlockHash: testhelpers.FillByteSlice(32, 124),
|
||||
TransactionsRoot: testhelpers.FillByteSlice(32, 125),
|
||||
WithdrawalsRoot: testhelpers.FillByteSlice(32, 126),
|
||||
},
|
||||
BlsToExecutionChanges: []*ethpb.SignedBLSToExecutionChange{
|
||||
{
|
||||
Message: ðpb.BLSToExecutionChange{
|
||||
ValidatorIndex: 127,
|
||||
FromBlsPubkey: test_helpers.FillByteSlice(48, 128),
|
||||
ToExecutionAddress: test_helpers.FillByteSlice(20, 129),
|
||||
FromBlsPubkey: testhelpers.FillByteSlice(48, 128),
|
||||
ToExecutionAddress: testhelpers.FillByteSlice(20, 129),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 130),
|
||||
Signature: testhelpers.FillByteSlice(96, 130),
|
||||
},
|
||||
{
|
||||
Message: ðpb.BLSToExecutionChange{
|
||||
ValidatorIndex: 131,
|
||||
FromBlsPubkey: test_helpers.FillByteSlice(48, 132),
|
||||
ToExecutionAddress: test_helpers.FillByteSlice(20, 133),
|
||||
FromBlsPubkey: testhelpers.FillByteSlice(48, 132),
|
||||
ToExecutionAddress: testhelpers.FillByteSlice(20, 133),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 134),
|
||||
Signature: testhelpers.FillByteSlice(96, 134),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 135),
|
||||
Signature: testhelpers.FillByteSlice(96, 135),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -97,8 +97,8 @@ func TestProposeBeaconBlock_Capella(t *testing.T) {
|
||||
func generateSignedCapellaBlock() *ethpb.GenericSignedBeaconBlock_Capella {
|
||||
return ðpb.GenericSignedBeaconBlock_Capella{
|
||||
Capella: ðpb.SignedBeaconBlockCapella{
|
||||
Block: test_helpers.GenerateProtoCapellaBeaconBlock(),
|
||||
Signature: test_helpers.FillByteSlice(96, 127),
|
||||
Block: testhelpers.GenerateProtoCapellaBeaconBlock(),
|
||||
Signature: testhelpers.FillByteSlice(96, 127),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -76,8 +76,8 @@ func TestProposeBeaconBlock_Phase0(t *testing.T) {
|
||||
func generateSignedPhase0Block() *ethpb.GenericSignedBeaconBlock_Phase0 {
|
||||
return ðpb.GenericSignedBeaconBlock_Phase0{
|
||||
Phase0: ðpb.SignedBeaconBlock{
|
||||
Block: test_helpers.GenerateProtoPhase0BeaconBlock(),
|
||||
Signature: test_helpers.FillByteSlice(96, 110),
|
||||
Block: testhelpers.GenerateProtoPhase0BeaconBlock(),
|
||||
Signature: testhelpers.FillByteSlice(96, 110),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func (c beaconApiValidatorClient) proposeExit(ctx context.Context, signedVoluntaryExit *ethpb.SignedVoluntaryExit) (*ethpb.ProposeExitResponse, error) {
|
||||
func (c *beaconApiValidatorClient) proposeExit(ctx context.Context, signedVoluntaryExit *ethpb.SignedVoluntaryExit) (*ethpb.ProposeExitResponse, error) {
|
||||
if signedVoluntaryExit == nil {
|
||||
return nil, errors.New("signed voluntary exit is nil")
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ type prysmChainClient struct {
|
||||
nodeClient iface.NodeClient
|
||||
}
|
||||
|
||||
func (c prysmChainClient) GetValidatorCount(ctx context.Context, stateID string, statuses []validator2.Status) ([]iface.ValidatorCount, error) {
|
||||
func (c prysmChainClient) ValidatorCount(ctx context.Context, stateID string, statuses []validator2.Status) ([]iface.ValidatorCount, error) {
|
||||
// Check node version for prysm beacon node as it is a custom endpoint for prysm beacon node.
|
||||
nodeVersion, err := c.nodeClient.GetVersion(ctx, nil)
|
||||
nodeVersion, err := c.nodeClient.Version(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get node version")
|
||||
}
|
||||
|
||||
@@ -14,16 +14,16 @@ import (
|
||||
)
|
||||
|
||||
type StateValidatorsProvider interface {
|
||||
GetStateValidators(context.Context, []string, []primitives.ValidatorIndex, []string) (*structs.GetValidatorsResponse, error)
|
||||
GetStateValidatorsForSlot(context.Context, primitives.Slot, []string, []primitives.ValidatorIndex, []string) (*structs.GetValidatorsResponse, error)
|
||||
GetStateValidatorsForHead(context.Context, []string, []primitives.ValidatorIndex, []string) (*structs.GetValidatorsResponse, error)
|
||||
StateValidators(context.Context, []string, []primitives.ValidatorIndex, []string) (*structs.GetValidatorsResponse, error)
|
||||
StateValidatorsForSlot(context.Context, primitives.Slot, []string, []primitives.ValidatorIndex, []string) (*structs.GetValidatorsResponse, error)
|
||||
StateValidatorsForHead(context.Context, []string, []primitives.ValidatorIndex, []string) (*structs.GetValidatorsResponse, error)
|
||||
}
|
||||
|
||||
type beaconApiStateValidatorsProvider struct {
|
||||
jsonRestHandler JsonRestHandler
|
||||
}
|
||||
|
||||
func (c beaconApiStateValidatorsProvider) GetStateValidators(
|
||||
func (c beaconApiStateValidatorsProvider) StateValidators(
|
||||
ctx context.Context,
|
||||
stringPubkeys []string,
|
||||
indexes []primitives.ValidatorIndex,
|
||||
@@ -33,7 +33,7 @@ func (c beaconApiStateValidatorsProvider) GetStateValidators(
|
||||
return c.getStateValidatorsHelper(ctx, "/eth/v1/beacon/states/head/validators", append(stringIndices, stringPubkeys...), statuses)
|
||||
}
|
||||
|
||||
func (c beaconApiStateValidatorsProvider) GetStateValidatorsForSlot(
|
||||
func (c beaconApiStateValidatorsProvider) StateValidatorsForSlot(
|
||||
ctx context.Context,
|
||||
slot primitives.Slot,
|
||||
stringPubkeys []string,
|
||||
@@ -41,11 +41,10 @@ func (c beaconApiStateValidatorsProvider) GetStateValidatorsForSlot(
|
||||
statuses []string,
|
||||
) (*structs.GetValidatorsResponse, error) {
|
||||
stringIndices := convertValidatorIndicesToStrings(indices)
|
||||
url := fmt.Sprintf("/eth/v1/beacon/states/%d/validators", slot)
|
||||
return c.getStateValidatorsHelper(ctx, url, append(stringIndices, stringPubkeys...), statuses)
|
||||
return c.getStateValidatorsHelper(ctx, fmt.Sprintf("/eth/v1/beacon/states/%d/validators", slot), append(stringIndices, stringPubkeys...), statuses)
|
||||
}
|
||||
|
||||
func (c beaconApiStateValidatorsProvider) GetStateValidatorsForHead(
|
||||
func (c beaconApiStateValidatorsProvider) StateValidatorsForHead(
|
||||
ctx context.Context,
|
||||
stringPubkeys []string,
|
||||
indices []primitives.ValidatorIndex,
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestGetStateValidators_Nominal_POST(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
stateValidatorsProvider := beaconApiStateValidatorsProvider{jsonRestHandler: jsonRestHandler}
|
||||
actual, err := stateValidatorsProvider.GetStateValidators(ctx, []string{
|
||||
actual, err := stateValidatorsProvider.StateValidators(ctx, []string{
|
||||
"0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13", // active_ongoing
|
||||
"0x80000e851c0f53c3246ff726d7ff7766661ca5e12a07c45c114d208d54f0f8233d4380b2e9aff759d69795d1df905526", // active_exiting
|
||||
"0x424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242", // does not exist
|
||||
@@ -191,7 +191,7 @@ func TestGetStateValidators_Nominal_GET(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
stateValidatorsProvider := beaconApiStateValidatorsProvider{jsonRestHandler: jsonRestHandler}
|
||||
actual, err := stateValidatorsProvider.GetStateValidators(ctx, []string{
|
||||
actual, err := stateValidatorsProvider.StateValidators(ctx, []string{
|
||||
"0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13", // active_ongoing
|
||||
"0x80000e851c0f53c3246ff726d7ff7766661ca5e12a07c45c114d208d54f0f8233d4380b2e9aff759d69795d1df905526", // active_exiting
|
||||
"0x424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242", // does not exist
|
||||
@@ -255,7 +255,7 @@ func TestGetStateValidators_GetRestJsonResponseOnError(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
stateValidatorsProvider := beaconApiStateValidatorsProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err = stateValidatorsProvider.GetStateValidators(ctx, []string{
|
||||
_, err = stateValidatorsProvider.StateValidators(ctx, []string{
|
||||
"0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13", // active_ongoing
|
||||
},
|
||||
nil,
|
||||
@@ -294,7 +294,7 @@ func TestGetStateValidators_DataIsNil_POST(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
stateValidatorsProvider := beaconApiStateValidatorsProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err = stateValidatorsProvider.GetStateValidators(ctx, []string{
|
||||
_, err = stateValidatorsProvider.StateValidators(ctx, []string{
|
||||
"0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13", // active_ongoing
|
||||
},
|
||||
nil,
|
||||
@@ -354,7 +354,7 @@ func TestGetStateValidators_DataIsNil_GET(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
stateValidatorsProvider := beaconApiStateValidatorsProvider{jsonRestHandler: jsonRestHandler}
|
||||
_, err = stateValidatorsProvider.GetStateValidators(ctx, []string{
|
||||
_, err = stateValidatorsProvider.StateValidators(ctx, []string{
|
||||
"0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13", // active_ongoing
|
||||
},
|
||||
nil,
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func (c *beaconApiValidatorClient) validatorStatus(ctx context.Context, in *ethpb.ValidatorStatusRequest) (*ethpb.ValidatorStatusResponse, error) {
|
||||
_, _, validatorsStatusResponse, err := c.getValidatorsStatusResponse(ctx, [][]byte{in.PublicKey}, nil)
|
||||
_, _, validatorsStatusResponse, err := c.validatorsStatusResponse(ctx, [][]byte{in.PublicKey}, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get validator status response")
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func (c *beaconApiValidatorClient) multipleValidatorStatus(ctx context.Context,
|
||||
for i, ix := range in.Indices {
|
||||
indices[i] = primitives.ValidatorIndex(ix)
|
||||
}
|
||||
publicKeys, indices, statuses, err := c.getValidatorsStatusResponse(ctx, in.PublicKeys, indices)
|
||||
publicKeys, indices, statuses, err := c.validatorsStatusResponse(ctx, in.PublicKeys, indices)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get validators status response")
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func (c *beaconApiValidatorClient) multipleValidatorStatus(ctx context.Context,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getValidatorsStatusResponse(ctx context.Context, inPubKeys [][]byte, inIndexes []primitives.ValidatorIndex) (
|
||||
func (c *beaconApiValidatorClient) validatorsStatusResponse(ctx context.Context, inPubKeys [][]byte, inIndexes []primitives.ValidatorIndex) (
|
||||
[][]byte,
|
||||
[]primitives.ValidatorIndex,
|
||||
[]*ethpb.ValidatorStatusResponse,
|
||||
@@ -74,12 +74,12 @@ func (c *beaconApiValidatorClient) getValidatorsStatusResponse(ctx context.Conte
|
||||
}
|
||||
|
||||
// Get state for the current validator
|
||||
stateValidatorsResponse, err := c.stateValidatorsProvider.GetStateValidators(ctx, stringTargetPubKeys, inIndexes, nil)
|
||||
stateValidatorsResponse, err := c.stateValidatorsProvider.StateValidators(ctx, stringTargetPubKeys, inIndexes, nil)
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrap(err, "failed to get state validators")
|
||||
}
|
||||
|
||||
validatorsCountResponse, err := c.prysmChainClient.GetValidatorCount(ctx, "head", nil)
|
||||
validatorsCountResponse, err := c.prysmChainClient.ValidatorCount(ctx, "head", nil)
|
||||
if err != nil && !errors.Is(err, iface.ErrNotSupported) {
|
||||
return nil, nil, nil, errors.Wrap(err, "failed to get total validator count")
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestValidatorStatus_Nominal(t *testing.T) {
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
[]string{stringValidatorPubKey},
|
||||
nil,
|
||||
@@ -96,7 +96,7 @@ func TestValidatorStatus_Error(t *testing.T) {
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
gomock.Any(),
|
||||
nil,
|
||||
@@ -138,7 +138,7 @@ func TestMultipleValidatorStatus_Nominal(t *testing.T) {
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
stringValidatorsPubKey,
|
||||
[]primitives.ValidatorIndex{},
|
||||
@@ -223,7 +223,7 @@ func TestMultipleValidatorStatus_Error(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
gomock.Any(),
|
||||
[]primitives.ValidatorIndex{},
|
||||
@@ -275,7 +275,7 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
|
||||
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
stringValidatorsPubKey,
|
||||
validatorsIndex,
|
||||
@@ -436,7 +436,7 @@ func TestGetValidatorsStatusResponse_Nominal_SomeActiveValidators(t *testing.T)
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
},
|
||||
}
|
||||
actualValidatorsPubKey, actualValidatorsIndex, actualValidatorsStatusResponse, err := validatorClient.getValidatorsStatusResponse(ctx, validatorsPubKey, validatorsIndex)
|
||||
actualValidatorsPubKey, actualValidatorsIndex, actualValidatorsStatusResponse, err := validatorClient.validatorsStatusResponse(ctx, validatorsPubKey, validatorsIndex)
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, wantedValidatorsPubKey, actualValidatorsPubKey)
|
||||
@@ -455,7 +455,7 @@ func TestGetValidatorsStatusResponse_Nominal_NoActiveValidators(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
[]string{stringValidatorPubKey},
|
||||
nil,
|
||||
@@ -506,7 +506,7 @@ func TestGetValidatorsStatusResponse_Nominal_NoActiveValidators(t *testing.T) {
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
},
|
||||
}
|
||||
actualValidatorsPubKey, actualValidatorsIndex, actualValidatorsStatusResponse, err := validatorClient.getValidatorsStatusResponse(ctx, wantedValidatorsPubKey, nil)
|
||||
actualValidatorsPubKey, actualValidatorsIndex, actualValidatorsStatusResponse, err := validatorClient.validatorsStatusResponse(ctx, wantedValidatorsPubKey, nil)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
@@ -705,7 +705,7 @@ func TestValidatorStatusResponse_InvalidData(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
stateValidatorsProvider := mock.NewMockStateValidatorsProvider(ctrl)
|
||||
stateValidatorsProvider.EXPECT().GetStateValidators(
|
||||
stateValidatorsProvider.EXPECT().StateValidators(
|
||||
ctx,
|
||||
testCase.inputGetStateValidatorsInterface.inputStringPubKeys,
|
||||
testCase.inputGetStateValidatorsInterface.inputIndexes,
|
||||
@@ -737,7 +737,7 @@ func TestValidatorStatusResponse_InvalidData(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
_, _, _, err := validatorClient.getValidatorsStatusResponse(
|
||||
_, _, _, err := validatorClient.validatorsStatusResponse(
|
||||
ctx,
|
||||
testCase.inputPubKeys,
|
||||
testCase.inputIndexes,
|
||||
|
||||
@@ -24,7 +24,7 @@ type abstractSignedBlockResponseJson struct {
|
||||
type streamBlocksAltairClient struct {
|
||||
grpc.ClientStream
|
||||
ctx context.Context
|
||||
beaconApiClient beaconApiValidatorClient
|
||||
beaconApiClient *beaconApiValidatorClient
|
||||
streamBlocksRequest *ethpb.StreamBlocksRequest
|
||||
prevBlockSlot primitives.Slot
|
||||
pingDelay time.Duration
|
||||
@@ -36,7 +36,7 @@ type headSignedBeaconBlockResult struct {
|
||||
slot primitives.Slot
|
||||
}
|
||||
|
||||
func (c beaconApiValidatorClient) streamBlocks(ctx context.Context, in *ethpb.StreamBlocksRequest, pingDelay time.Duration) ethpb.BeaconNodeValidator_StreamBlocksAltairClient {
|
||||
func (c *beaconApiValidatorClient) streamBlocks(ctx context.Context, in *ethpb.StreamBlocksRequest, pingDelay time.Duration) ethpb.BeaconNodeValidator_StreamBlocksAltairClient {
|
||||
return &streamBlocksAltairClient{
|
||||
ctx: ctx,
|
||||
beaconApiClient: c,
|
||||
@@ -46,7 +46,7 @@ func (c beaconApiValidatorClient) streamBlocks(ctx context.Context, in *ethpb.St
|
||||
}
|
||||
|
||||
func (c *streamBlocksAltairClient) Recv() (*ethpb.StreamBlocksResponse, error) {
|
||||
result, err := c.beaconApiClient.getHeadSignedBeaconBlock(c.ctx)
|
||||
result, err := c.beaconApiClient.headSignedBeaconBlock(c.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get latest signed block")
|
||||
}
|
||||
@@ -55,7 +55,7 @@ func (c *streamBlocksAltairClient) Recv() (*ethpb.StreamBlocksResponse, error) {
|
||||
for (c.streamBlocksRequest.VerifiedOnly && result.executionOptimistic) || c.prevBlockSlot == result.slot {
|
||||
select {
|
||||
case <-time.After(c.pingDelay):
|
||||
result, err = c.beaconApiClient.getHeadSignedBeaconBlock(c.ctx)
|
||||
result, err = c.beaconApiClient.headSignedBeaconBlock(c.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get latest signed block")
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func (c *streamBlocksAltairClient) Recv() (*ethpb.StreamBlocksResponse, error) {
|
||||
return result.streamBlocksResponse, nil
|
||||
}
|
||||
|
||||
func (c beaconApiValidatorClient) getHeadSignedBeaconBlock(ctx context.Context) (*headSignedBeaconBlockResult, error) {
|
||||
func (c *beaconApiValidatorClient) headSignedBeaconBlock(ctx context.Context) (*headSignedBeaconBlockResult, error) {
|
||||
// Since we don't know yet what the json looks like, we unmarshal into an abstract structure that has only a version
|
||||
// and a blob of data
|
||||
signedBlockResponseJson := abstractSignedBlockResponseJson{}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -203,7 +203,7 @@ func TestStreamBlocks_Phase0Valid(t *testing.T) {
|
||||
|
||||
// For the first call, return a block that satisfies the verifiedOnly condition. This block should be returned by the first Recv().
|
||||
// For the second call, return the same block as the previous one. This block shouldn't be returned by the second Recv().
|
||||
phase0BeaconBlock1 := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
phase0BeaconBlock1 := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
phase0BeaconBlock1.Slot = "1"
|
||||
signedBeaconBlockContainer1 := structs.SignedBeaconBlock{
|
||||
Message: phase0BeaconBlock1,
|
||||
@@ -228,7 +228,7 @@ func TestStreamBlocks_Phase0Valid(t *testing.T) {
|
||||
},
|
||||
).Times(2)
|
||||
|
||||
phase0ProtoBeaconBlock1 := test_helpers.GenerateProtoPhase0BeaconBlock()
|
||||
phase0ProtoBeaconBlock1 := testhelpers.GenerateProtoPhase0BeaconBlock()
|
||||
phase0ProtoBeaconBlock1.Slot = 1
|
||||
|
||||
beaconBlockConverter.EXPECT().ConvertRESTPhase0BlockToProto(
|
||||
@@ -240,7 +240,7 @@ func TestStreamBlocks_Phase0Valid(t *testing.T) {
|
||||
|
||||
// For the third call, return a block with a different slot than the previous one, but with the verifiedOnly condition not satisfied.
|
||||
// If verifiedOnly == false, this block will be returned by the second Recv(); otherwise, another block will be requested.
|
||||
phase0BeaconBlock2 := test_helpers.GenerateJsonPhase0BeaconBlock()
|
||||
phase0BeaconBlock2 := testhelpers.GenerateJsonPhase0BeaconBlock()
|
||||
phase0BeaconBlock2.Slot = "2"
|
||||
signedBeaconBlockContainer2 := structs.SignedBeaconBlock{
|
||||
Message: phase0BeaconBlock2,
|
||||
@@ -265,7 +265,7 @@ func TestStreamBlocks_Phase0Valid(t *testing.T) {
|
||||
},
|
||||
).Times(1)
|
||||
|
||||
phase0ProtoBeaconBlock2 := test_helpers.GenerateProtoPhase0BeaconBlock()
|
||||
phase0ProtoBeaconBlock2 := testhelpers.GenerateProtoPhase0BeaconBlock()
|
||||
phase0ProtoBeaconBlock2.Slot = 2
|
||||
|
||||
beaconBlockConverter.EXPECT().ConvertRESTPhase0BlockToProto(
|
||||
@@ -364,7 +364,7 @@ func TestStreamBlocks_AltairValid(t *testing.T) {
|
||||
|
||||
// For the first call, return a block that satisfies the verifiedOnly condition. This block should be returned by the first Recv().
|
||||
// For the second call, return the same block as the previous one. This block shouldn't be returned by the second Recv().
|
||||
altairBeaconBlock1 := test_helpers.GenerateJsonAltairBeaconBlock()
|
||||
altairBeaconBlock1 := testhelpers.GenerateJsonAltairBeaconBlock()
|
||||
altairBeaconBlock1.Slot = "1"
|
||||
signedBeaconBlockContainer1 := structs.SignedBeaconBlockAltair{
|
||||
Message: altairBeaconBlock1,
|
||||
@@ -389,7 +389,7 @@ func TestStreamBlocks_AltairValid(t *testing.T) {
|
||||
},
|
||||
).Times(2)
|
||||
|
||||
altairProtoBeaconBlock1 := test_helpers.GenerateProtoAltairBeaconBlock()
|
||||
altairProtoBeaconBlock1 := testhelpers.GenerateProtoAltairBeaconBlock()
|
||||
altairProtoBeaconBlock1.Slot = 1
|
||||
|
||||
beaconBlockConverter.EXPECT().ConvertRESTAltairBlockToProto(
|
||||
@@ -401,7 +401,7 @@ func TestStreamBlocks_AltairValid(t *testing.T) {
|
||||
|
||||
// For the third call, return a block with a different slot than the previous one, but with the verifiedOnly condition not satisfied.
|
||||
// If verifiedOnly == false, this block will be returned by the second Recv(); otherwise, another block will be requested.
|
||||
altairBeaconBlock2 := test_helpers.GenerateJsonAltairBeaconBlock()
|
||||
altairBeaconBlock2 := testhelpers.GenerateJsonAltairBeaconBlock()
|
||||
altairBeaconBlock2.Slot = "2"
|
||||
signedBeaconBlockContainer2 := structs.SignedBeaconBlockAltair{
|
||||
Message: altairBeaconBlock2,
|
||||
@@ -426,7 +426,7 @@ func TestStreamBlocks_AltairValid(t *testing.T) {
|
||||
},
|
||||
).Times(1)
|
||||
|
||||
altairProtoBeaconBlock2 := test_helpers.GenerateProtoAltairBeaconBlock()
|
||||
altairProtoBeaconBlock2 := testhelpers.GenerateProtoAltairBeaconBlock()
|
||||
altairProtoBeaconBlock2.Slot = 2
|
||||
|
||||
beaconBlockConverter.EXPECT().ConvertRESTAltairBlockToProto(
|
||||
@@ -525,7 +525,7 @@ func TestStreamBlocks_BellatrixValid(t *testing.T) {
|
||||
|
||||
// For the first call, return a block that satisfies the verifiedOnly condition. This block should be returned by the first Recv().
|
||||
// For the second call, return the same block as the previous one. This block shouldn't be returned by the second Recv().
|
||||
bellatrixBeaconBlock1 := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
bellatrixBeaconBlock1 := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
bellatrixBeaconBlock1.Slot = "1"
|
||||
signedBeaconBlockContainer1 := structs.SignedBeaconBlockBellatrix{
|
||||
Message: bellatrixBeaconBlock1,
|
||||
@@ -550,7 +550,7 @@ func TestStreamBlocks_BellatrixValid(t *testing.T) {
|
||||
},
|
||||
).Times(2)
|
||||
|
||||
bellatrixProtoBeaconBlock1 := test_helpers.GenerateProtoBellatrixBeaconBlock()
|
||||
bellatrixProtoBeaconBlock1 := testhelpers.GenerateProtoBellatrixBeaconBlock()
|
||||
bellatrixProtoBeaconBlock1.Slot = 1
|
||||
|
||||
beaconBlockConverter.EXPECT().ConvertRESTBellatrixBlockToProto(
|
||||
@@ -562,7 +562,7 @@ func TestStreamBlocks_BellatrixValid(t *testing.T) {
|
||||
|
||||
// For the third call, return a block with a different slot than the previous one, but with the verifiedOnly condition not satisfied.
|
||||
// If verifiedOnly == false, this block will be returned by the second Recv(); otherwise, another block will be requested.
|
||||
bellatrixBeaconBlock2 := test_helpers.GenerateJsonBellatrixBeaconBlock()
|
||||
bellatrixBeaconBlock2 := testhelpers.GenerateJsonBellatrixBeaconBlock()
|
||||
bellatrixBeaconBlock2.Slot = "2"
|
||||
signedBeaconBlockContainer2 := structs.SignedBeaconBlockBellatrix{
|
||||
Message: bellatrixBeaconBlock2,
|
||||
@@ -587,7 +587,7 @@ func TestStreamBlocks_BellatrixValid(t *testing.T) {
|
||||
},
|
||||
).Times(1)
|
||||
|
||||
bellatrixProtoBeaconBlock2 := test_helpers.GenerateProtoBellatrixBeaconBlock()
|
||||
bellatrixProtoBeaconBlock2 := testhelpers.GenerateProtoBellatrixBeaconBlock()
|
||||
bellatrixProtoBeaconBlock2.Slot = 2
|
||||
|
||||
beaconBlockConverter.EXPECT().ConvertRESTBellatrixBlockToProto(
|
||||
@@ -686,7 +686,7 @@ func TestStreamBlocks_CapellaValid(t *testing.T) {
|
||||
|
||||
// For the first call, return a block that satisfies the verifiedOnly condition. This block should be returned by the first Recv().
|
||||
// For the second call, return the same block as the previous one. This block shouldn't be returned by the second Recv().
|
||||
capellaBeaconBlock1 := test_helpers.GenerateJsonCapellaBeaconBlock()
|
||||
capellaBeaconBlock1 := testhelpers.GenerateJsonCapellaBeaconBlock()
|
||||
capellaBeaconBlock1.Slot = "1"
|
||||
signedBeaconBlockContainer1 := structs.SignedBeaconBlockCapella{
|
||||
Message: capellaBeaconBlock1,
|
||||
@@ -711,7 +711,7 @@ func TestStreamBlocks_CapellaValid(t *testing.T) {
|
||||
},
|
||||
).Times(2)
|
||||
|
||||
capellaProtoBeaconBlock1 := test_helpers.GenerateProtoCapellaBeaconBlock()
|
||||
capellaProtoBeaconBlock1 := testhelpers.GenerateProtoCapellaBeaconBlock()
|
||||
capellaProtoBeaconBlock1.Slot = 1
|
||||
|
||||
beaconBlockConverter.EXPECT().ConvertRESTCapellaBlockToProto(
|
||||
@@ -723,7 +723,7 @@ func TestStreamBlocks_CapellaValid(t *testing.T) {
|
||||
|
||||
// For the third call, return a block with a different slot than the previous one, but with the verifiedOnly condition not satisfied.
|
||||
// If verifiedOnly == false, this block will be returned by the second Recv(); otherwise, another block will be requested.
|
||||
capellaBeaconBlock2 := test_helpers.GenerateJsonCapellaBeaconBlock()
|
||||
capellaBeaconBlock2 := testhelpers.GenerateJsonCapellaBeaconBlock()
|
||||
capellaBeaconBlock2.Slot = "2"
|
||||
signedBeaconBlockContainer2 := structs.SignedBeaconBlockCapella{
|
||||
Message: capellaBeaconBlock2,
|
||||
@@ -748,7 +748,7 @@ func TestStreamBlocks_CapellaValid(t *testing.T) {
|
||||
},
|
||||
).Times(1)
|
||||
|
||||
capellaProtoBeaconBlock2 := test_helpers.GenerateProtoCapellaBeaconBlock()
|
||||
capellaProtoBeaconBlock2 := testhelpers.GenerateProtoCapellaBeaconBlock()
|
||||
capellaProtoBeaconBlock2.Slot = 2
|
||||
|
||||
beaconBlockConverter.EXPECT().ConvertRESTCapellaBlockToProto(
|
||||
|
||||
@@ -37,7 +37,7 @@ func (c *beaconApiValidatorClient) submitAggregateSelectionProof(
|
||||
return nil, errors.New("validator is not an aggregator")
|
||||
}
|
||||
|
||||
attestationData, err := c.getAttestationData(ctx, in.Slot, in.CommitteeIndex)
|
||||
attestationData, err := c.attestationData(ctx, in.Slot, in.CommitteeIndex)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get attestation data for slot=%d and committee_index=%d", in.Slot, in.CommitteeIndex)
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func (c *beaconApiValidatorClient) submitAggregateSelectionProof(
|
||||
return nil, errors.Wrap(err, "failed to calculate attestation data root")
|
||||
}
|
||||
|
||||
aggregateAttestationResponse, err := c.getAggregateAttestation(ctx, in.Slot, attestationDataRoot[:])
|
||||
aggregateAttestationResponse, err := c.aggregateAttestation(ctx, in.Slot, attestationDataRoot[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func (c *beaconApiValidatorClient) submitAggregateSelectionProof(
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getAggregateAttestation(
|
||||
func (c *beaconApiValidatorClient) aggregateAttestation(
|
||||
ctx context.Context,
|
||||
slot primitives.Slot,
|
||||
attestationDataRoot []byte,
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -37,9 +37,9 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
aggregateAttestation := ðpb.Attestation{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 74),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 74),
|
||||
Data: attestationDataProto,
|
||||
Signature: test_helpers.FillByteSlice(96, 82),
|
||||
Signature: testhelpers.FillByteSlice(96, 82),
|
||||
}
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@@ -80,24 +80,24 @@ func generateSignedAggregateAndProofJson() *ethpb.SignedAggregateAttestationAndP
|
||||
Message: ðpb.AggregateAttestationAndProof{
|
||||
AggregatorIndex: 72,
|
||||
Aggregate: ðpb.Attestation{
|
||||
AggregationBits: test_helpers.FillByteSlice(4, 74),
|
||||
AggregationBits: testhelpers.FillByteSlice(4, 74),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 75,
|
||||
CommitteeIndex: 76,
|
||||
BeaconBlockRoot: test_helpers.FillByteSlice(32, 38),
|
||||
BeaconBlockRoot: testhelpers.FillByteSlice(32, 38),
|
||||
Source: ðpb.Checkpoint{
|
||||
Epoch: 78,
|
||||
Root: test_helpers.FillByteSlice(32, 79),
|
||||
Root: testhelpers.FillByteSlice(32, 79),
|
||||
},
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 80,
|
||||
Root: test_helpers.FillByteSlice(32, 81),
|
||||
Root: testhelpers.FillByteSlice(32, 81),
|
||||
},
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 82),
|
||||
Signature: testhelpers.FillByteSlice(96, 82),
|
||||
},
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 82),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 82),
|
||||
},
|
||||
Signature: test_helpers.FillByteSlice(96, 82),
|
||||
Signature: testhelpers.FillByteSlice(96, 82),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func (c beaconApiValidatorClient) submitSignedContributionAndProof(ctx context.Context, in *ethpb.SignedContributionAndProof) error {
|
||||
func (c *beaconApiValidatorClient) submitSignedContributionAndProof(ctx context.Context, in *ethpb.SignedContributionAndProof) error {
|
||||
if in == nil {
|
||||
return errors.New("signed contribution and proof is nil")
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func (c beaconApiValidatorClient) subscribeCommitteeSubnets(ctx context.Context, in *ethpb.CommitteeSubnetsSubscribeRequest, duties []*ethpb.DutiesResponse_Duty) error {
|
||||
func (c *beaconApiValidatorClient) subscribeCommitteeSubnets(ctx context.Context, in *ethpb.CommitteeSubnetsSubscribeRequest, duties []*ethpb.DutiesResponse_Duty) error {
|
||||
if in == nil {
|
||||
return errors.New("committee subnets subscribe request is nil")
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func (c *beaconApiValidatorClient) submitSyncMessage(ctx context.Context, syncMe
|
||||
return c.jsonRestHandler.Post(ctx, endpoint, nil, bytes.NewBuffer(marshalledJsonSyncCommitteeMessage), nil)
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getSyncMessageBlockRoot(ctx context.Context) (*ethpb.SyncMessageBlockRootResponse, error) {
|
||||
func (c *beaconApiValidatorClient) syncMessageBlockRoot(ctx context.Context) (*ethpb.SyncMessageBlockRootResponse, error) {
|
||||
// Get head beacon block root.
|
||||
var resp structs.BlockRootResponse
|
||||
if err := c.jsonRestHandler.Get(ctx, "/eth/v1/beacon/blocks/head/root", &resp); err != nil {
|
||||
@@ -64,11 +64,11 @@ func (c *beaconApiValidatorClient) getSyncMessageBlockRoot(ctx context.Context)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getSyncCommitteeContribution(
|
||||
func (c *beaconApiValidatorClient) syncCommitteeContribution(
|
||||
ctx context.Context,
|
||||
req *ethpb.SyncCommitteeContributionRequest,
|
||||
) (*ethpb.SyncCommitteeContribution, error) {
|
||||
blockRootResponse, err := c.getSyncMessageBlockRoot(ctx)
|
||||
blockRootResponse, err := c.syncMessageBlockRoot(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get sync message block root")
|
||||
}
|
||||
@@ -80,23 +80,21 @@ func (c *beaconApiValidatorClient) getSyncCommitteeContribution(
|
||||
params.Add("subcommittee_index", strconv.FormatUint(req.SubnetId, 10))
|
||||
params.Add("beacon_block_root", blockRoot)
|
||||
|
||||
url := buildURL("/eth/v1/validator/sync_committee_contribution", params)
|
||||
|
||||
var resp structs.ProduceSyncCommitteeContributionResponse
|
||||
if err = c.jsonRestHandler.Get(ctx, url, &resp); err != nil {
|
||||
if err = c.jsonRestHandler.Get(ctx, buildURL("/eth/v1/validator/sync_committee_contribution", params), &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return convertSyncContributionJsonToProto(resp.Data)
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getSyncSubcommitteeIndex(ctx context.Context, in *ethpb.SyncSubcommitteeIndexRequest) (*ethpb.SyncSubcommitteeIndexResponse, error) {
|
||||
func (c *beaconApiValidatorClient) syncSubcommitteeIndex(ctx context.Context, in *ethpb.SyncSubcommitteeIndexRequest) (*ethpb.SyncSubcommitteeIndexResponse, error) {
|
||||
validatorIndexResponse, err := c.validatorIndex(ctx, ðpb.ValidatorIndexRequest{PublicKey: in.PublicKey})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get validator index")
|
||||
}
|
||||
|
||||
syncDuties, err := c.dutiesProvider.GetSyncDuties(ctx, slots.ToEpoch(in.Slot), []primitives.ValidatorIndex{validatorIndexResponse.Index})
|
||||
syncDuties, err := c.dutiesProvider.SyncDuties(ctx, slots.ToEpoch(in.Slot), []primitives.ValidatorIndex{validatorIndexResponse.Index})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get sync committee duties")
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type aggregatedSyncSelectionResponse struct {
|
||||
Data []iface.SyncCommitteeSelection `json:"data"`
|
||||
}
|
||||
|
||||
func (c *beaconApiValidatorClient) getAggregatedSyncSelections(ctx context.Context, selections []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) {
|
||||
func (c *beaconApiValidatorClient) aggregatedSyncSelections(ctx context.Context, selections []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) {
|
||||
body, err := json.Marshal(selections)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to marshal selections")
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock"
|
||||
test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
testhelpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/iface"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
@@ -26,7 +26,7 @@ func TestGetAggregatedSyncSelections(t *testing.T) {
|
||||
name: "valid",
|
||||
req: []iface.SyncCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 82),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 82),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
SubcommitteeIndex: 77,
|
||||
@@ -34,7 +34,7 @@ func TestGetAggregatedSyncSelections(t *testing.T) {
|
||||
},
|
||||
res: []iface.SyncCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 100),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 100),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
SubcommitteeIndex: 77,
|
||||
@@ -45,7 +45,7 @@ func TestGetAggregatedSyncSelections(t *testing.T) {
|
||||
name: "endpoint error",
|
||||
req: []iface.SyncCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 82),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 82),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
SubcommitteeIndex: 77,
|
||||
@@ -58,7 +58,7 @@ func TestGetAggregatedSyncSelections(t *testing.T) {
|
||||
name: "no response error",
|
||||
req: []iface.SyncCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 82),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 82),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
SubcommitteeIndex: 77,
|
||||
@@ -70,13 +70,13 @@ func TestGetAggregatedSyncSelections(t *testing.T) {
|
||||
name: "mismatch response",
|
||||
req: []iface.SyncCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 82),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 82),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
SubcommitteeIndex: 77,
|
||||
},
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 100),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 100),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
SubcommitteeIndex: 78,
|
||||
@@ -84,7 +84,7 @@ func TestGetAggregatedSyncSelections(t *testing.T) {
|
||||
},
|
||||
res: []iface.SyncCommitteeSelection{
|
||||
{
|
||||
SelectionProof: test_helpers.FillByteSlice(96, 100),
|
||||
SelectionProof: testhelpers.FillByteSlice(96, 100),
|
||||
Slot: 75,
|
||||
ValidatorIndex: 76,
|
||||
SubcommitteeIndex: 77,
|
||||
@@ -117,7 +117,7 @@ func TestGetAggregatedSyncSelections(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
res, err := validatorClient.GetAggregatedSyncSelections(ctx, test.req)
|
||||
res, err := validatorClient.AggregatedSyncSelections(ctx, test.req)
|
||||
if test.expectedErrorMessage != "" {
|
||||
require.ErrorContains(t, test.expectedErrorMessage, err)
|
||||
return
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestSubmitSyncMessage_Valid(t *testing.T) {
|
||||
nil,
|
||||
).Times(1)
|
||||
|
||||
protoSyncCommiteeMessage := ethpb.SyncCommitteeMessage{
|
||||
protoSyncCommitteeMessage := ethpb.SyncCommitteeMessage{
|
||||
Slot: primitives.Slot(42),
|
||||
BlockRoot: decodedBeaconBlockRoot,
|
||||
ValidatorIndex: primitives.ValidatorIndex(12345),
|
||||
@@ -63,7 +63,7 @@ func TestSubmitSyncMessage_Valid(t *testing.T) {
|
||||
}
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
res, err := validatorClient.SubmitSyncMessage(context.Background(), &protoSyncCommiteeMessage)
|
||||
res, err := validatorClient.SubmitSyncMessage(context.Background(), &protoSyncCommitteeMessage)
|
||||
|
||||
assert.DeepEqual(t, new(empty.Empty), res)
|
||||
require.NoError(t, err)
|
||||
@@ -150,7 +150,7 @@ func TestGetSyncMessageBlockRoot(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
actualResponse, err := validatorClient.getSyncMessageBlockRoot(ctx)
|
||||
actualResponse, err := validatorClient.syncMessageBlockRoot(ctx)
|
||||
if test.expectedErrorMessage != "" {
|
||||
require.ErrorContains(t, test.expectedErrorMessage, err)
|
||||
return
|
||||
@@ -236,7 +236,7 @@ func TestGetSyncCommitteeContribution(t *testing.T) {
|
||||
).Times(1)
|
||||
|
||||
validatorClient := &beaconApiValidatorClient{jsonRestHandler: jsonRestHandler}
|
||||
actualResponse, err := validatorClient.getSyncCommitteeContribution(ctx, request)
|
||||
actualResponse, err := validatorClient.syncCommitteeContribution(ctx, request)
|
||||
if test.expectedErrMsg != "" {
|
||||
require.ErrorContains(t, test.expectedErrMsg, err)
|
||||
return
|
||||
@@ -394,7 +394,7 @@ func TestGetSyncSubCommitteeIndex(t *testing.T) {
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
},
|
||||
}
|
||||
actualResponse, err := validatorClient.getSyncSubcommitteeIndex(ctx, ðpb.SyncSubcommitteeIndexRequest{
|
||||
actualResponse, err := validatorClient.syncSubcommitteeIndex(ctx, ðpb.SyncSubcommitteeIndexRequest{
|
||||
PublicKey: pubkey,
|
||||
Slot: slot,
|
||||
})
|
||||
|
||||
@@ -146,7 +146,7 @@ func TestGetValidatorCount(t *testing.T) {
|
||||
jsonRestHandler: jsonRestHandler,
|
||||
}
|
||||
|
||||
countResponse, err := client.GetValidatorCount(ctx, "head", []validator.Status{validator.Active})
|
||||
countResponse, err := client.ValidatorCount(ctx, "head", []validator.Status{validator.Active})
|
||||
|
||||
if len(test.expectedResponse) == 0 {
|
||||
require.ErrorContains(t, test.expectedError, err)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package validator_client_factory
|
||||
package beacon_chain_client_factory
|
||||
|
||||
import (
|
||||
"github.com/prysmaticlabs/prysm/v5/config/features"
|
||||
|
||||
@@ -13,27 +13,27 @@ type grpcChainClient struct {
|
||||
beaconChainClient ethpb.BeaconChainClient
|
||||
}
|
||||
|
||||
func (c *grpcChainClient) GetChainHead(ctx context.Context, in *empty.Empty) (*ethpb.ChainHead, error) {
|
||||
func (c *grpcChainClient) ChainHead(ctx context.Context, in *empty.Empty) (*ethpb.ChainHead, error) {
|
||||
return c.beaconChainClient.GetChainHead(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcChainClient) ListValidatorBalances(ctx context.Context, in *ethpb.ListValidatorBalancesRequest) (*ethpb.ValidatorBalances, error) {
|
||||
func (c *grpcChainClient) ValidatorBalances(ctx context.Context, in *ethpb.ListValidatorBalancesRequest) (*ethpb.ValidatorBalances, error) {
|
||||
return c.beaconChainClient.ListValidatorBalances(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcChainClient) ListValidators(ctx context.Context, in *ethpb.ListValidatorsRequest) (*ethpb.Validators, error) {
|
||||
func (c *grpcChainClient) Validators(ctx context.Context, in *ethpb.ListValidatorsRequest) (*ethpb.Validators, error) {
|
||||
return c.beaconChainClient.ListValidators(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcChainClient) GetValidatorQueue(ctx context.Context, in *empty.Empty) (*ethpb.ValidatorQueue, error) {
|
||||
func (c *grpcChainClient) ValidatorQueue(ctx context.Context, in *empty.Empty) (*ethpb.ValidatorQueue, error) {
|
||||
return c.beaconChainClient.GetValidatorQueue(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcChainClient) GetValidatorPerformance(ctx context.Context, in *ethpb.ValidatorPerformanceRequest) (*ethpb.ValidatorPerformanceResponse, error) {
|
||||
func (c *grpcChainClient) ValidatorPerformance(ctx context.Context, in *ethpb.ValidatorPerformanceRequest) (*ethpb.ValidatorPerformanceResponse, error) {
|
||||
return c.beaconChainClient.GetValidatorPerformance(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcChainClient) GetValidatorParticipation(ctx context.Context, in *ethpb.GetValidatorParticipationRequest) (*ethpb.ValidatorParticipationResponse, error) {
|
||||
func (c *grpcChainClient) ValidatorParticipation(ctx context.Context, in *ethpb.GetValidatorParticipationRequest) (*ethpb.ValidatorParticipationResponse, error) {
|
||||
return c.beaconChainClient.GetValidatorParticipation(ctx, in)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,19 +20,19 @@ type grpcNodeClient struct {
|
||||
healthTracker *beacon.NodeHealthTracker
|
||||
}
|
||||
|
||||
func (c *grpcNodeClient) GetSyncStatus(ctx context.Context, in *empty.Empty) (*ethpb.SyncStatus, error) {
|
||||
func (c *grpcNodeClient) SyncStatus(ctx context.Context, in *empty.Empty) (*ethpb.SyncStatus, error) {
|
||||
return c.nodeClient.GetSyncStatus(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcNodeClient) GetGenesis(ctx context.Context, in *empty.Empty) (*ethpb.Genesis, error) {
|
||||
func (c *grpcNodeClient) Genesis(ctx context.Context, in *empty.Empty) (*ethpb.Genesis, error) {
|
||||
return c.nodeClient.GetGenesis(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcNodeClient) GetVersion(ctx context.Context, in *empty.Empty) (*ethpb.Version, error) {
|
||||
func (c *grpcNodeClient) Version(ctx context.Context, in *empty.Empty) (*ethpb.Version, error) {
|
||||
return c.nodeClient.GetVersion(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcNodeClient) ListPeers(ctx context.Context, in *empty.Empty) (*ethpb.Peers, error) {
|
||||
func (c *grpcNodeClient) Peers(ctx context.Context, in *empty.Empty) (*ethpb.Peers, error) {
|
||||
return c.nodeClient.ListPeers(ctx, in)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ type grpcPrysmChainClient struct {
|
||||
chainClient iface.ChainClient
|
||||
}
|
||||
|
||||
func (g grpcPrysmChainClient) GetValidatorCount(ctx context.Context, _ string, statuses []validator.Status) ([]iface.ValidatorCount, error) {
|
||||
resp, err := g.chainClient.ListValidators(ctx, ðpb.ListValidatorsRequest{PageSize: 0})
|
||||
func (g grpcPrysmChainClient) ValidatorCount(ctx context.Context, _ string, statuses []validator.Status) ([]iface.ValidatorCount, error) {
|
||||
resp, err := g.chainClient.Validators(ctx, ðpb.ListValidatorsRequest{PageSize: 0})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "list validators failed")
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func (g grpcPrysmChainClient) GetValidatorCount(ctx context.Context, _ string, s
|
||||
vals = append(vals, val.Validator)
|
||||
}
|
||||
|
||||
head, err := g.chainClient.GetChainHead(ctx, &empty.Empty{})
|
||||
head, err := g.chainClient.ChainHead(ctx, &empty.Empty{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get chain head")
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ func TestGetValidatorCount(t *testing.T) {
|
||||
Slashed: false,
|
||||
},
|
||||
}
|
||||
for _, validator := range validators {
|
||||
require.NoError(t, st.AppendValidator(validator))
|
||||
for _, v := range validators {
|
||||
require.NoError(t, st.AppendValidator(v))
|
||||
require.NoError(t, st.AppendBalance(params.BeaconConfig().MaxEffectiveBalance))
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ func TestGetValidatorCount(t *testing.T) {
|
||||
require.Equal(t, true, ok)
|
||||
statuses = append(statuses, valStatus)
|
||||
}
|
||||
vcCountResp, err := prysmBeaconChainClient.GetValidatorCount(context.Background(), "", statuses)
|
||||
vcCountResp, err := prysmBeaconChainClient.ValidatorCount(context.Background(), "", statuses)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, test.expectedResponse, vcCountResp)
|
||||
})
|
||||
|
||||
@@ -23,7 +23,7 @@ type grpcValidatorClient struct {
|
||||
isEventStreamRunning bool
|
||||
}
|
||||
|
||||
func (c *grpcValidatorClient) GetDuties(ctx context.Context, in *ethpb.DutiesRequest) (*ethpb.DutiesResponse, error) {
|
||||
func (c *grpcValidatorClient) Duties(ctx context.Context, in *ethpb.DutiesRequest) (*ethpb.DutiesResponse, error) {
|
||||
return c.beaconNodeValidatorClient.GetDuties(ctx, in)
|
||||
}
|
||||
|
||||
@@ -35,27 +35,27 @@ func (c *grpcValidatorClient) DomainData(ctx context.Context, in *ethpb.DomainRe
|
||||
return c.beaconNodeValidatorClient.DomainData(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcValidatorClient) GetAttestationData(ctx context.Context, in *ethpb.AttestationDataRequest) (*ethpb.AttestationData, error) {
|
||||
func (c *grpcValidatorClient) AttestationData(ctx context.Context, in *ethpb.AttestationDataRequest) (*ethpb.AttestationData, error) {
|
||||
return c.beaconNodeValidatorClient.GetAttestationData(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcValidatorClient) GetBeaconBlock(ctx context.Context, in *ethpb.BlockRequest) (*ethpb.GenericBeaconBlock, error) {
|
||||
func (c *grpcValidatorClient) BeaconBlock(ctx context.Context, in *ethpb.BlockRequest) (*ethpb.GenericBeaconBlock, error) {
|
||||
return c.beaconNodeValidatorClient.GetBeaconBlock(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcValidatorClient) GetFeeRecipientByPubKey(ctx context.Context, in *ethpb.FeeRecipientByPubKeyRequest) (*ethpb.FeeRecipientByPubKeyResponse, error) {
|
||||
func (c *grpcValidatorClient) FeeRecipientByPubKey(ctx context.Context, in *ethpb.FeeRecipientByPubKeyRequest) (*ethpb.FeeRecipientByPubKeyResponse, error) {
|
||||
return c.beaconNodeValidatorClient.GetFeeRecipientByPubKey(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcValidatorClient) GetSyncCommitteeContribution(ctx context.Context, in *ethpb.SyncCommitteeContributionRequest) (*ethpb.SyncCommitteeContribution, error) {
|
||||
func (c *grpcValidatorClient) SyncCommitteeContribution(ctx context.Context, in *ethpb.SyncCommitteeContributionRequest) (*ethpb.SyncCommitteeContribution, error) {
|
||||
return c.beaconNodeValidatorClient.GetSyncCommitteeContribution(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcValidatorClient) GetSyncMessageBlockRoot(ctx context.Context, in *empty.Empty) (*ethpb.SyncMessageBlockRootResponse, error) {
|
||||
func (c *grpcValidatorClient) SyncMessageBlockRoot(ctx context.Context, in *empty.Empty) (*ethpb.SyncMessageBlockRootResponse, error) {
|
||||
return c.beaconNodeValidatorClient.GetSyncMessageBlockRoot(ctx, in)
|
||||
}
|
||||
|
||||
func (c *grpcValidatorClient) GetSyncSubcommitteeIndex(ctx context.Context, in *ethpb.SyncSubcommitteeIndexRequest) (*ethpb.SyncSubcommitteeIndexResponse, error) {
|
||||
func (c *grpcValidatorClient) SyncSubcommitteeIndex(ctx context.Context, in *ethpb.SyncSubcommitteeIndexRequest) (*ethpb.SyncSubcommitteeIndexResponse, error) {
|
||||
return c.beaconNodeValidatorClient.GetSyncSubcommitteeIndex(ctx, in)
|
||||
}
|
||||
|
||||
@@ -142,11 +142,11 @@ func (c *grpcValidatorClient) AggregatedSigAndAggregationBits(
|
||||
return c.beaconNodeValidatorClient.AggregatedSigAndAggregationBits(ctx, in)
|
||||
}
|
||||
|
||||
func (*grpcValidatorClient) GetAggregatedSelections(context.Context, []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) {
|
||||
func (*grpcValidatorClient) AggregatedSelections(context.Context, []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) {
|
||||
return nil, iface.ErrNotSupported
|
||||
}
|
||||
|
||||
func (*grpcValidatorClient) GetAggregatedSyncSelections(context.Context, []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) {
|
||||
func (*grpcValidatorClient) AggregatedSyncSelections(context.Context, []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) {
|
||||
return nil, iface.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ load("@prysm//tools/go:def.bzl", "go_library")
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"beacon_chain_client.go",
|
||||
"chain_client.go",
|
||||
"node_client.go",
|
||||
"prysm_beacon_chain_client.go",
|
||||
"prysm_chain_client.go",
|
||||
"validator.go",
|
||||
"validator_client.go",
|
||||
],
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package iface
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
type ChainClient interface {
|
||||
GetChainHead(ctx context.Context, in *empty.Empty) (*ethpb.ChainHead, error)
|
||||
ListValidatorBalances(ctx context.Context, in *ethpb.ListValidatorBalancesRequest) (*ethpb.ValidatorBalances, error)
|
||||
ListValidators(ctx context.Context, in *ethpb.ListValidatorsRequest) (*ethpb.Validators, error)
|
||||
GetValidatorQueue(ctx context.Context, in *empty.Empty) (*ethpb.ValidatorQueue, error)
|
||||
GetValidatorPerformance(ctx context.Context, in *ethpb.ValidatorPerformanceRequest) (*ethpb.ValidatorPerformanceResponse, error)
|
||||
GetValidatorParticipation(ctx context.Context, in *ethpb.GetValidatorParticipationRequest) (*ethpb.ValidatorParticipationResponse, error)
|
||||
}
|
||||
17
validator/client/iface/chain_client.go
Normal file
17
validator/client/iface/chain_client.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package iface
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
type ChainClient interface {
|
||||
ChainHead(ctx context.Context, in *empty.Empty) (*ethpb.ChainHead, error)
|
||||
ValidatorBalances(ctx context.Context, in *ethpb.ListValidatorBalancesRequest) (*ethpb.ValidatorBalances, error)
|
||||
Validators(ctx context.Context, in *ethpb.ListValidatorsRequest) (*ethpb.Validators, error)
|
||||
ValidatorQueue(ctx context.Context, in *empty.Empty) (*ethpb.ValidatorQueue, error)
|
||||
ValidatorPerformance(ctx context.Context, in *ethpb.ValidatorPerformanceRequest) (*ethpb.ValidatorPerformanceResponse, error)
|
||||
ValidatorParticipation(ctx context.Context, in *ethpb.GetValidatorParticipationRequest) (*ethpb.ValidatorParticipationResponse, error)
|
||||
}
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
)
|
||||
|
||||
type NodeClient interface {
|
||||
GetSyncStatus(ctx context.Context, in *empty.Empty) (*ethpb.SyncStatus, error)
|
||||
GetGenesis(ctx context.Context, in *empty.Empty) (*ethpb.Genesis, error)
|
||||
GetVersion(ctx context.Context, in *empty.Empty) (*ethpb.Version, error)
|
||||
ListPeers(ctx context.Context, in *empty.Empty) (*ethpb.Peers, error)
|
||||
SyncStatus(ctx context.Context, in *empty.Empty) (*ethpb.SyncStatus, error)
|
||||
Genesis(ctx context.Context, in *empty.Empty) (*ethpb.Genesis, error)
|
||||
Version(ctx context.Context, in *empty.Empty) (*ethpb.Version, error)
|
||||
Peers(ctx context.Context, in *empty.Empty) (*ethpb.Peers, error)
|
||||
HealthTracker() *beacon.NodeHealthTracker
|
||||
}
|
||||
|
||||
@@ -16,5 +16,5 @@ type ValidatorCount struct {
|
||||
|
||||
// PrysmChainClient defines an interface required to implement all the prysm specific custom endpoints.
|
||||
type PrysmChainClient interface {
|
||||
GetValidatorCount(context.Context, string, []validator.Status) ([]ValidatorCount, error)
|
||||
ValidatorCount(context.Context, string, []validator.Status) ([]ValidatorCount, error)
|
||||
}
|
||||
@@ -64,7 +64,7 @@ type Validator interface {
|
||||
ProcessEvent(event *event.Event)
|
||||
ProposerSettings() *proposer.Settings
|
||||
SetProposerSettings(context.Context, *proposer.Settings) error
|
||||
GetGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]byte, error)
|
||||
Graffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]byte, error)
|
||||
SetGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, graffiti []byte) error
|
||||
DeleteGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) error
|
||||
HealthTracker() *beacon.NodeHealthTracker
|
||||
|
||||
@@ -26,7 +26,7 @@ type beaconCommitteeSelectionJson struct {
|
||||
ValidatorIndex string `json:"validator_index"`
|
||||
}
|
||||
|
||||
func (b BeaconCommitteeSelection) MarshalJSON() ([]byte, error) {
|
||||
func (b *BeaconCommitteeSelection) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(beaconCommitteeSelectionJson{
|
||||
SelectionProof: hexutil.Encode(b.SelectionProof),
|
||||
Slot: strconv.FormatUint(uint64(b.Slot), 10),
|
||||
@@ -77,7 +77,7 @@ type syncCommitteeSelectionJson struct {
|
||||
ValidatorIndex string `json:"validator_index"`
|
||||
}
|
||||
|
||||
func (s SyncCommitteeSelection) MarshalJSON() ([]byte, error) {
|
||||
func (s *SyncCommitteeSelection) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(syncCommitteeSelectionJson{
|
||||
SelectionProof: hexutil.Encode(s.SelectionProof),
|
||||
Slot: strconv.FormatUint(uint64(s.Slot), 10),
|
||||
@@ -122,34 +122,34 @@ func (s *SyncCommitteeSelection) UnmarshalJSON(input []byte) error {
|
||||
}
|
||||
|
||||
type ValidatorClient interface {
|
||||
GetDuties(ctx context.Context, in *ethpb.DutiesRequest) (*ethpb.DutiesResponse, error)
|
||||
Duties(ctx context.Context, in *ethpb.DutiesRequest) (*ethpb.DutiesResponse, error)
|
||||
DomainData(ctx context.Context, in *ethpb.DomainRequest) (*ethpb.DomainResponse, error)
|
||||
WaitForChainStart(ctx context.Context, in *empty.Empty) (*ethpb.ChainStartResponse, error)
|
||||
WaitForActivation(ctx context.Context, in *ethpb.ValidatorActivationRequest) (ethpb.BeaconNodeValidator_WaitForActivationClient, error)
|
||||
ValidatorIndex(ctx context.Context, in *ethpb.ValidatorIndexRequest) (*ethpb.ValidatorIndexResponse, error)
|
||||
ValidatorStatus(ctx context.Context, in *ethpb.ValidatorStatusRequest) (*ethpb.ValidatorStatusResponse, error)
|
||||
MultipleValidatorStatus(ctx context.Context, in *ethpb.MultipleValidatorStatusRequest) (*ethpb.MultipleValidatorStatusResponse, error)
|
||||
GetBeaconBlock(ctx context.Context, in *ethpb.BlockRequest) (*ethpb.GenericBeaconBlock, error)
|
||||
BeaconBlock(ctx context.Context, in *ethpb.BlockRequest) (*ethpb.GenericBeaconBlock, error)
|
||||
ProposeBeaconBlock(ctx context.Context, in *ethpb.GenericSignedBeaconBlock) (*ethpb.ProposeResponse, error)
|
||||
PrepareBeaconProposer(ctx context.Context, in *ethpb.PrepareBeaconProposerRequest) (*empty.Empty, error)
|
||||
GetFeeRecipientByPubKey(ctx context.Context, in *ethpb.FeeRecipientByPubKeyRequest) (*ethpb.FeeRecipientByPubKeyResponse, error)
|
||||
GetAttestationData(ctx context.Context, in *ethpb.AttestationDataRequest) (*ethpb.AttestationData, error)
|
||||
FeeRecipientByPubKey(ctx context.Context, in *ethpb.FeeRecipientByPubKeyRequest) (*ethpb.FeeRecipientByPubKeyResponse, error)
|
||||
AttestationData(ctx context.Context, in *ethpb.AttestationDataRequest) (*ethpb.AttestationData, error)
|
||||
ProposeAttestation(ctx context.Context, in *ethpb.Attestation) (*ethpb.AttestResponse, error)
|
||||
SubmitAggregateSelectionProof(ctx context.Context, in *ethpb.AggregateSelectionRequest, index primitives.ValidatorIndex, committeeLength uint64) (*ethpb.AggregateSelectionResponse, error)
|
||||
SubmitSignedAggregateSelectionProof(ctx context.Context, in *ethpb.SignedAggregateSubmitRequest) (*ethpb.SignedAggregateSubmitResponse, error)
|
||||
ProposeExit(ctx context.Context, in *ethpb.SignedVoluntaryExit) (*ethpb.ProposeExitResponse, error)
|
||||
SubscribeCommitteeSubnets(ctx context.Context, in *ethpb.CommitteeSubnetsSubscribeRequest, duties []*ethpb.DutiesResponse_Duty) (*empty.Empty, error)
|
||||
CheckDoppelGanger(ctx context.Context, in *ethpb.DoppelGangerRequest) (*ethpb.DoppelGangerResponse, error)
|
||||
GetSyncMessageBlockRoot(ctx context.Context, in *empty.Empty) (*ethpb.SyncMessageBlockRootResponse, error)
|
||||
SyncMessageBlockRoot(ctx context.Context, in *empty.Empty) (*ethpb.SyncMessageBlockRootResponse, error)
|
||||
SubmitSyncMessage(ctx context.Context, in *ethpb.SyncCommitteeMessage) (*empty.Empty, error)
|
||||
GetSyncSubcommitteeIndex(ctx context.Context, in *ethpb.SyncSubcommitteeIndexRequest) (*ethpb.SyncSubcommitteeIndexResponse, error)
|
||||
GetSyncCommitteeContribution(ctx context.Context, in *ethpb.SyncCommitteeContributionRequest) (*ethpb.SyncCommitteeContribution, error)
|
||||
SyncSubcommitteeIndex(ctx context.Context, in *ethpb.SyncSubcommitteeIndexRequest) (*ethpb.SyncSubcommitteeIndexResponse, error)
|
||||
SyncCommitteeContribution(ctx context.Context, in *ethpb.SyncCommitteeContributionRequest) (*ethpb.SyncCommitteeContribution, error)
|
||||
SubmitSignedContributionAndProof(ctx context.Context, in *ethpb.SignedContributionAndProof) (*empty.Empty, error)
|
||||
SubmitValidatorRegistrations(ctx context.Context, in *ethpb.SignedValidatorRegistrationsV1) (*empty.Empty, error)
|
||||
StartEventStream(ctx context.Context, topics []string, eventsChannel chan<- *event.Event)
|
||||
EventStreamIsRunning() bool
|
||||
GetAggregatedSelections(ctx context.Context, selections []BeaconCommitteeSelection) ([]BeaconCommitteeSelection, error)
|
||||
GetAggregatedSyncSelections(ctx context.Context, selections []SyncCommitteeSelection) ([]SyncCommitteeSelection, error)
|
||||
AggregatedSelections(ctx context.Context, selections []BeaconCommitteeSelection) ([]BeaconCommitteeSelection, error)
|
||||
AggregatedSyncSelections(ctx context.Context, selections []SyncCommitteeSelection) ([]SyncCommitteeSelection, error)
|
||||
Host() string
|
||||
SetHost(host string)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func (v *validator) HandleKeyReload(ctx context.Context, currentKeys [][fieldpar
|
||||
|
||||
// "-1" indicates that validator count endpoint is not supported by the beacon node.
|
||||
var valCount int64 = -1
|
||||
valCounts, err := v.prysmChainClient.GetValidatorCount(ctx, "head", []validator2.Status{validator2.Active})
|
||||
valCounts, err := v.prysmChainClient.ValidatorCount(ctx, "head", []validator2.Status{validator2.Active})
|
||||
if err != nil && !errors.Is(err, iface.ErrNotSupported) {
|
||||
return false, errors.Wrap(err, "could not get active validator count")
|
||||
}
|
||||
|
||||
@@ -67,16 +67,6 @@ var (
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
// ValidatorProposeFailVecSlasher used to count failed proposals by slashing protection.
|
||||
ValidatorProposeFailVecSlasher = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "validator_proposals_rejected_total",
|
||||
Help: "Count the block proposals rejected by slashing protection.",
|
||||
},
|
||||
[]string{
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
// ValidatorBalancesGaugeVec used to keep track of validator balances by public key.
|
||||
ValidatorBalancesGaugeVec = promauto.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
@@ -158,16 +148,6 @@ var (
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
// ValidatorAttestFailVecSlasher used to count failed attestations by slashing protection.
|
||||
ValidatorAttestFailVecSlasher = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "validator_attestations_rejected_total",
|
||||
Help: "Count the attestations rejected by slashing protection.",
|
||||
},
|
||||
[]string{
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
// ValidatorNextAttestationSlotGaugeVec used to track validator statuses by public key.
|
||||
ValidatorNextAttestationSlotGaugeVec = promauto.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
@@ -195,7 +175,7 @@ var (
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: "validator",
|
||||
Name: "in_sync_committee",
|
||||
Help: "validator sync committee.New in Altair hardfork",
|
||||
Help: "validator sync committee.New in Altair hard fork",
|
||||
},
|
||||
[]string{
|
||||
"pubkey",
|
||||
@@ -206,7 +186,7 @@ var (
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: "validator",
|
||||
Name: "in_next_sync_committee",
|
||||
Help: "validator next sync committee. New in Altair hardfork",
|
||||
Help: "validator next sync committee. New in Altair hard fork",
|
||||
},
|
||||
[]string{
|
||||
"pubkey",
|
||||
@@ -217,7 +197,7 @@ var (
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: "validator",
|
||||
Name: "inactivity_score",
|
||||
Help: "Validator inactivity score. 0 is optimum number. New in Altair hardfork",
|
||||
Help: "Validator inactivity score. 0 is optimum number. New in Altair hard fork",
|
||||
},
|
||||
[]string{
|
||||
"pubkey",
|
||||
@@ -249,7 +229,7 @@ func (v *validator) LogValidatorGainsAndLosses(ctx context.Context, slot primiti
|
||||
req := ðpb.ValidatorPerformanceRequest{
|
||||
PublicKeys: pubKeys,
|
||||
}
|
||||
resp, err := v.chainClient.GetValidatorPerformance(ctx, req)
|
||||
resp, err := v.chainClient.ValidatorPerformance(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package validator_client_factory
|
||||
package node_client_factory
|
||||
|
||||
import (
|
||||
"github.com/prysmaticlabs/prysm/v5/config/features"
|
||||
|
||||
@@ -70,7 +70,7 @@ func (v *validator) ProposeBlock(ctx context.Context, slot primitives.Slot, pubK
|
||||
return
|
||||
}
|
||||
|
||||
g, err := v.GetGraffiti(ctx, pubKey)
|
||||
g, err := v.Graffiti(ctx, pubKey)
|
||||
if err != nil {
|
||||
// Graffiti is not a critical enough to fail block production and cause
|
||||
// validator to miss block reward. When failed, validator should continue
|
||||
@@ -79,7 +79,7 @@ func (v *validator) ProposeBlock(ctx context.Context, slot primitives.Slot, pubK
|
||||
}
|
||||
|
||||
// Request block from beacon node
|
||||
b, err := v.validatorClient.GetBeaconBlock(ctx, ðpb.BlockRequest{
|
||||
b, err := v.validatorClient.BeaconBlock(ctx, ðpb.BlockRequest{
|
||||
Slot: slot,
|
||||
RandaoReveal: randaoReveal,
|
||||
Graffiti: g,
|
||||
@@ -148,6 +148,8 @@ func (v *validator) ProposeBlock(ctx context.Context, slot primitives.Slot, pubK
|
||||
log.WithError(err).Error("Failed to build generic signed block")
|
||||
return
|
||||
}
|
||||
default:
|
||||
log.Errorf("Unsupported block version %s", version.String(blk.Version()))
|
||||
}
|
||||
} else {
|
||||
genericSignedBlock, err = blk.PbGenericBlock()
|
||||
@@ -426,8 +428,8 @@ func signVoluntaryExit(
|
||||
return sig.Marshal(), nil
|
||||
}
|
||||
|
||||
// GetGraffiti gets the graffiti from cli or file for the validator public key.
|
||||
func (v *validator) GetGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]byte, error) {
|
||||
// Graffiti gets the graffiti from cli or file for the validator public key.
|
||||
func (v *validator) Graffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]byte, error) {
|
||||
if v.proposerSettings != nil {
|
||||
// Check proposer settings for specific key first
|
||||
if v.proposerSettings.ProposeConfig != nil {
|
||||
|
||||
@@ -199,7 +199,7 @@ func TestProposeBlock_RequestBlockFailed(t *testing.T) {
|
||||
gomock.Any(), // epoch
|
||||
).Return(ðpb.DomainResponse{SignatureDomain: make([]byte, 32)}, nil /*err*/)
|
||||
|
||||
m.validatorClient.EXPECT().GetBeaconBlock(
|
||||
m.validatorClient.EXPECT().BeaconBlock(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.BlockRequest{}),
|
||||
).Return(nil /*response*/, errors.New("uh oh"))
|
||||
@@ -255,7 +255,7 @@ func TestProposeBlock_ProposeBlockFailed(t *testing.T) {
|
||||
gomock.Any(), // epoch
|
||||
).Return(ðpb.DomainResponse{SignatureDomain: make([]byte, 32)}, nil /*err*/)
|
||||
|
||||
m.validatorClient.EXPECT().GetBeaconBlock(
|
||||
m.validatorClient.EXPECT().BeaconBlock(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.BlockRequest{}),
|
||||
).Return(tt.block, nil /*err*/)
|
||||
@@ -294,16 +294,16 @@ func TestProposeBlock_BlocksDoubleProposal(t *testing.T) {
|
||||
block0, block1 := util.NewBeaconBlock(), util.NewBeaconBlock()
|
||||
block1.Block.Body.Graffiti = blockGraffiti[:]
|
||||
|
||||
var blocks []*ethpb.GenericBeaconBlock
|
||||
var bs []*ethpb.GenericBeaconBlock
|
||||
for _, block := range []*ethpb.SignedBeaconBlock{block0, block1} {
|
||||
block.Block.Slot = slot
|
||||
blocks = append(blocks, ðpb.GenericBeaconBlock{
|
||||
bs = append(bs, ðpb.GenericBeaconBlock{
|
||||
Block: ðpb.GenericBeaconBlock_Phase0{
|
||||
Phase0: block.Block,
|
||||
},
|
||||
})
|
||||
}
|
||||
return blocks
|
||||
return bs
|
||||
}(),
|
||||
},
|
||||
{
|
||||
@@ -312,16 +312,16 @@ func TestProposeBlock_BlocksDoubleProposal(t *testing.T) {
|
||||
block0, block1 := util.NewBeaconBlockAltair(), util.NewBeaconBlockAltair()
|
||||
block1.Block.Body.Graffiti = blockGraffiti[:]
|
||||
|
||||
var blocks []*ethpb.GenericBeaconBlock
|
||||
var bs []*ethpb.GenericBeaconBlock
|
||||
for _, block := range []*ethpb.SignedBeaconBlockAltair{block0, block1} {
|
||||
block.Block.Slot = slot
|
||||
blocks = append(blocks, ðpb.GenericBeaconBlock{
|
||||
bs = append(bs, ðpb.GenericBeaconBlock{
|
||||
Block: ðpb.GenericBeaconBlock_Altair{
|
||||
Altair: block.Block,
|
||||
},
|
||||
})
|
||||
}
|
||||
return blocks
|
||||
return bs
|
||||
}(),
|
||||
},
|
||||
{
|
||||
@@ -330,16 +330,16 @@ func TestProposeBlock_BlocksDoubleProposal(t *testing.T) {
|
||||
block0, block1 := util.NewBeaconBlockBellatrix(), util.NewBeaconBlockBellatrix()
|
||||
block1.Block.Body.Graffiti = blockGraffiti[:]
|
||||
|
||||
var blocks []*ethpb.GenericBeaconBlock
|
||||
var bs []*ethpb.GenericBeaconBlock
|
||||
for _, block := range []*ethpb.SignedBeaconBlockBellatrix{block0, block1} {
|
||||
block.Block.Slot = slot
|
||||
blocks = append(blocks, ðpb.GenericBeaconBlock{
|
||||
bs = append(bs, ðpb.GenericBeaconBlock{
|
||||
Block: ðpb.GenericBeaconBlock_Bellatrix{
|
||||
Bellatrix: block.Block,
|
||||
},
|
||||
})
|
||||
}
|
||||
return blocks
|
||||
return bs
|
||||
}(),
|
||||
},
|
||||
}
|
||||
@@ -362,12 +362,12 @@ func TestProposeBlock_BlocksDoubleProposal(t *testing.T) {
|
||||
gomock.Any(), // epoch
|
||||
).Times(1).Return(ðpb.DomainResponse{SignatureDomain: make([]byte, 32)}, nil /*err*/)
|
||||
|
||||
m.validatorClient.EXPECT().GetBeaconBlock(
|
||||
m.validatorClient.EXPECT().BeaconBlock(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.BlockRequest{}),
|
||||
).Return(tt.blocks[0], nil /*err*/)
|
||||
|
||||
m.validatorClient.EXPECT().GetBeaconBlock(
|
||||
m.validatorClient.EXPECT().BeaconBlock(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.BlockRequest{}),
|
||||
).Return(tt.blocks[1], nil /*err*/)
|
||||
@@ -414,7 +414,7 @@ func TestProposeBlock_BlocksDoubleProposal_After54KEpochs(t *testing.T) {
|
||||
testBlock := util.NewBeaconBlock()
|
||||
farFuture := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().WeakSubjectivityPeriod + 9))
|
||||
testBlock.Block.Slot = farFuture
|
||||
m.validatorClient.EXPECT().GetBeaconBlock(
|
||||
m.validatorClient.EXPECT().BeaconBlock(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.BlockRequest{}),
|
||||
).Return(ðpb.GenericBeaconBlock{
|
||||
@@ -428,7 +428,7 @@ func TestProposeBlock_BlocksDoubleProposal_After54KEpochs(t *testing.T) {
|
||||
var blockGraffiti [32]byte
|
||||
copy(blockGraffiti[:], "someothergraffiti")
|
||||
secondTestBlock.Block.Body.Graffiti = blockGraffiti[:]
|
||||
m.validatorClient.EXPECT().GetBeaconBlock(
|
||||
m.validatorClient.EXPECT().BeaconBlock(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.BlockRequest{}),
|
||||
).Return(ðpb.GenericBeaconBlock{
|
||||
@@ -491,7 +491,7 @@ func TestProposeBlock_AllowsOrNotPastProposals(t *testing.T) {
|
||||
|
||||
blk := util.NewBeaconBlock()
|
||||
blk.Block.Slot = slot
|
||||
m.validatorClient.EXPECT().GetBeaconBlock(
|
||||
m.validatorClient.EXPECT().BeaconBlock(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.BlockRequest{}),
|
||||
).Return(ðpb.GenericBeaconBlock{
|
||||
@@ -520,7 +520,7 @@ func TestProposeBlock_AllowsOrNotPastProposals(t *testing.T) {
|
||||
|
||||
blk2 := util.NewBeaconBlock()
|
||||
blk2.Block.Slot = tt.pastSlot
|
||||
m.validatorClient.EXPECT().GetBeaconBlock(
|
||||
m.validatorClient.EXPECT().BeaconBlock(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.BlockRequest{}),
|
||||
).Return(ðpb.GenericBeaconBlock{
|
||||
@@ -683,7 +683,7 @@ func testProposeBlock(t *testing.T, graffiti []byte) {
|
||||
gomock.Any(), // epoch
|
||||
).Return(ðpb.DomainResponse{SignatureDomain: make([]byte, 32)}, nil /*err*/)
|
||||
|
||||
m.validatorClient.EXPECT().GetBeaconBlock(
|
||||
m.validatorClient.EXPECT().BeaconBlock(
|
||||
gomock.Any(), // ctx
|
||||
gomock.AssignableToTypeOf(ðpb.BlockRequest{}),
|
||||
).DoAndReturn(func(ctx context.Context, req *ethpb.BlockRequest) (*ethpb.GenericBeaconBlock, error) {
|
||||
@@ -1081,7 +1081,7 @@ func TestGetGraffiti_Ok(t *testing.T) {
|
||||
ValidatorIndex(gomock.Any(), ðpb.ValidatorIndexRequest{PublicKey: pubKey[:]}).
|
||||
Return(ðpb.ValidatorIndexResponse{Index: 2}, nil)
|
||||
}
|
||||
got, err := tt.v.GetGraffiti(context.Background(), pubKey)
|
||||
got, err := tt.v.Graffiti(context.Background(), pubKey)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, tt.want, got)
|
||||
})
|
||||
@@ -1111,7 +1111,7 @@ func TestGetGraffitiOrdered_Ok(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, want := range [][]byte{bytesutil.PadTo([]byte{'a'}, 32), bytesutil.PadTo([]byte{'b'}, 32), bytesutil.PadTo([]byte{'c'}, 32), bytesutil.PadTo([]byte{'d'}, 32), bytesutil.PadTo([]byte{'d'}, 32)} {
|
||||
got, err := v.GetGraffiti(context.Background(), pubKey)
|
||||
got, err := v.Graffiti(context.Background(), pubKey)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, want, got)
|
||||
}
|
||||
|
||||
@@ -372,14 +372,14 @@ func TestUpdateProposerSettingsAt_EpochEndOk(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateProposerSettings_ContinuesAfterValidatorRegistrationFails(t *testing.T) {
|
||||
errSomeotherError := errors.New("some internal error")
|
||||
errSomeOtherError := errors.New("some internal error")
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
node := healthTesting.NewMockHealthClient(ctrl)
|
||||
tracker := beacon.NewNodeHealthTracker(node)
|
||||
node.EXPECT().IsHealthy(gomock.Any()).Return(true).AnyTimes()
|
||||
v := &testutil.FakeValidator{
|
||||
ProposerSettingsErr: errors.Wrap(ErrBuilderValidatorRegistration, errSomeotherError.Error()),
|
||||
ProposerSettingsErr: errors.Wrap(ErrBuilderValidatorRegistration, errSomeOtherError.Error()),
|
||||
Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}},
|
||||
Tracker: tracker,
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
beaconApi "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api"
|
||||
beaconChainClientFactory "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-chain-client-factory"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/iface"
|
||||
nodeClientFactory "github.com/prysmaticlabs/prysm/v5/validator/client/node-client-factory"
|
||||
validatorClientFactory "github.com/prysmaticlabs/prysm/v5/validator/client/validator-client-factory"
|
||||
nodeclientfactory "github.com/prysmaticlabs/prysm/v5/validator/client/node-client-factory"
|
||||
validatorclientfactory "github.com/prysmaticlabs/prysm/v5/validator/client/validator-client-factory"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/db"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/graffiti"
|
||||
validatorHelpers "github.com/prysmaticlabs/prysm/v5/validator/helpers"
|
||||
@@ -177,7 +177,7 @@ func (v *ValidatorService) Start() {
|
||||
hosts[0],
|
||||
)
|
||||
|
||||
validatorClient := validatorClientFactory.NewValidatorClient(v.conn, restHandler)
|
||||
validatorClient := validatorclientfactory.NewValidatorClient(v.conn, restHandler)
|
||||
|
||||
valStruct := &validator{
|
||||
slotFeed: new(event.Feed),
|
||||
@@ -195,7 +195,7 @@ func (v *ValidatorService) Start() {
|
||||
currentHostIndex: 0,
|
||||
validatorClient: validatorClient,
|
||||
chainClient: beaconChainClientFactory.NewChainClient(v.conn, restHandler),
|
||||
nodeClient: nodeClientFactory.NewNodeClient(v.conn, restHandler),
|
||||
nodeClient: nodeclientfactory.NewNodeClient(v.conn, restHandler),
|
||||
prysmChainClient: beaconChainClientFactory.NewPrysmChainClient(v.conn, restHandler),
|
||||
db: v.db,
|
||||
km: nil,
|
||||
@@ -270,7 +270,7 @@ func (v *ValidatorService) SetProposerSettings(ctx context.Context, settings *pr
|
||||
v.proposerSettings = settings
|
||||
|
||||
// passes settings down to be updated in database and saved in memory.
|
||||
// updates to validator porposer settings will be in the validator object and not validator service.
|
||||
// updates to validator proposer settings will be in the validator object and not validator service.
|
||||
return v.validator.SetProposerSettings(ctx, settings)
|
||||
}
|
||||
|
||||
@@ -328,11 +328,11 @@ func ConstructDialOptions(
|
||||
return dialOpts
|
||||
}
|
||||
|
||||
func (v *ValidatorService) GetGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]byte, error) {
|
||||
func (v *ValidatorService) Graffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]byte, error) {
|
||||
if v.validator == nil {
|
||||
return nil, errors.New("validator is unavailable")
|
||||
}
|
||||
return v.validator.GetGraffiti(ctx, pubKey)
|
||||
return v.validator.Graffiti(ctx, pubKey)
|
||||
}
|
||||
|
||||
func (v *ValidatorService) SetGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, graffiti []byte) error {
|
||||
|
||||
@@ -33,7 +33,7 @@ func (v *validator) SubmitSyncCommitteeMessage(ctx context.Context, slot primiti
|
||||
|
||||
v.waitOneThirdOrValidBlock(ctx, slot)
|
||||
|
||||
res, err := v.validatorClient.GetSyncMessageBlockRoot(ctx, &emptypb.Empty{})
|
||||
res, err := v.validatorClient.SyncMessageBlockRoot(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not request sync message block root to sign")
|
||||
tracing.AnnotateError(span, err)
|
||||
@@ -107,7 +107,7 @@ func (v *validator) SubmitSignedContributionAndProof(ctx context.Context, slot p
|
||||
return
|
||||
}
|
||||
|
||||
indexRes, err := v.validatorClient.GetSyncSubcommitteeIndex(ctx, ðpb.SyncSubcommitteeIndexRequest{
|
||||
indexRes, err := v.validatorClient.SyncSubcommitteeIndex(ctx, ðpb.SyncSubcommitteeIndexRequest{
|
||||
PublicKey: pubKey[:],
|
||||
Slot: slot,
|
||||
})
|
||||
@@ -139,7 +139,7 @@ func (v *validator) SubmitSignedContributionAndProof(ctx context.Context, slot p
|
||||
}
|
||||
subCommitteeSize := params.BeaconConfig().SyncCommitteeSize / params.BeaconConfig().SyncCommitteeSubnetCount
|
||||
subnet := uint64(comIdx) / subCommitteeSize
|
||||
contribution, err := v.validatorClient.GetSyncCommitteeContribution(ctx, ðpb.SyncCommitteeContributionRequest{
|
||||
contribution, err := v.validatorClient.SyncCommitteeContribution(ctx, ðpb.SyncCommitteeContributionRequest{
|
||||
Slot: slot,
|
||||
PublicKey: pubKey[:],
|
||||
SubnetId: subnet,
|
||||
@@ -216,7 +216,7 @@ func (v *validator) selectionProofs(ctx context.Context, slot primitives.Slot, p
|
||||
// Override selection proofs with aggregated ones if the node is part of a Distributed Validator.
|
||||
if v.distributed && len(selections) > 0 {
|
||||
var err error
|
||||
selections, err := v.validatorClient.GetAggregatedSyncSelections(ctx, selections)
|
||||
selections, err := v.validatorClient.AggregatedSyncSelections(ctx, selections)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get aggregated sync selections")
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestSubmitSyncCommitteeMessage_ValidatorDutiesRequestFailure(t *testing.T)
|
||||
validator.duties = ðpb.DutiesResponse{CurrentEpochDuties: []*ethpb.DutiesResponse_Duty{}}
|
||||
defer finish()
|
||||
|
||||
m.validatorClient.EXPECT().GetSyncMessageBlockRoot(
|
||||
m.validatorClient.EXPECT().SyncMessageBlockRoot(
|
||||
gomock.Any(), // ctx
|
||||
&emptypb.Empty{},
|
||||
).Return(ðpb.SyncMessageBlockRootResponse{
|
||||
@@ -60,7 +60,7 @@ func TestSubmitSyncCommitteeMessage_BadDomainData(t *testing.T) {
|
||||
}}
|
||||
|
||||
r := []byte{'a'}
|
||||
m.validatorClient.EXPECT().GetSyncMessageBlockRoot(
|
||||
m.validatorClient.EXPECT().SyncMessageBlockRoot(
|
||||
gomock.Any(), // ctx
|
||||
&emptypb.Empty{},
|
||||
).Return(ðpb.SyncMessageBlockRootResponse{
|
||||
@@ -96,7 +96,7 @@ func TestSubmitSyncCommitteeMessage_CouldNotSubmit(t *testing.T) {
|
||||
}}
|
||||
|
||||
r := []byte{'a'}
|
||||
m.validatorClient.EXPECT().GetSyncMessageBlockRoot(
|
||||
m.validatorClient.EXPECT().SyncMessageBlockRoot(
|
||||
gomock.Any(), // ctx
|
||||
&emptypb.Empty{},
|
||||
).Return(ðpb.SyncMessageBlockRootResponse{
|
||||
@@ -141,7 +141,7 @@ func TestSubmitSyncCommitteeMessage_OK(t *testing.T) {
|
||||
}}
|
||||
|
||||
r := []byte{'a'}
|
||||
m.validatorClient.EXPECT().GetSyncMessageBlockRoot(
|
||||
m.validatorClient.EXPECT().SyncMessageBlockRoot(
|
||||
gomock.Any(), // ctx
|
||||
&emptypb.Empty{},
|
||||
).Return(ðpb.SyncMessageBlockRootResponse{
|
||||
@@ -191,7 +191,7 @@ func TestSubmitSignedContributionAndProof_ValidatorDutiesRequestFailure(t *testi
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubmitSignedContributionAndProof_GetSyncSubcommitteeIndexFailure(t *testing.T) {
|
||||
func TestSubmitSignedContributionAndProof_SyncSubcommitteeIndexFailure(t *testing.T) {
|
||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
@@ -209,7 +209,7 @@ func TestSubmitSignedContributionAndProof_GetSyncSubcommitteeIndexFailure(t *tes
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
Slot: 1,
|
||||
@@ -241,7 +241,7 @@ func TestSubmitSignedContributionAndProof_NothingToDo(t *testing.T) {
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
Slot: 1,
|
||||
@@ -273,7 +273,7 @@ func TestSubmitSignedContributionAndProof_BadDomain(t *testing.T) {
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
Slot: 1,
|
||||
@@ -319,7 +319,7 @@ func TestSubmitSignedContributionAndProof_CouldNotGetContribution(t *testing.T)
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
Slot: 1,
|
||||
@@ -334,7 +334,7 @@ func TestSubmitSignedContributionAndProof_CouldNotGetContribution(t *testing.T)
|
||||
SignatureDomain: make([]byte, 32),
|
||||
}, nil)
|
||||
|
||||
m.validatorClient.EXPECT().GetSyncCommitteeContribution(
|
||||
m.validatorClient.EXPECT().SyncCommitteeContribution(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncCommitteeContributionRequest{
|
||||
Slot: 1,
|
||||
@@ -373,7 +373,7 @@ func TestSubmitSignedContributionAndProof_CouldNotSubmitContribution(t *testing.
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
Slot: 1,
|
||||
@@ -390,7 +390,7 @@ func TestSubmitSignedContributionAndProof_CouldNotSubmitContribution(t *testing.
|
||||
|
||||
aggBits := bitfield.NewBitvector128()
|
||||
aggBits.SetBitAt(0, true)
|
||||
m.validatorClient.EXPECT().GetSyncCommitteeContribution(
|
||||
m.validatorClient.EXPECT().SyncCommitteeContribution(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncCommitteeContributionRequest{
|
||||
Slot: 1,
|
||||
@@ -455,7 +455,7 @@ func TestSubmitSignedContributionAndProof_Ok(t *testing.T) {
|
||||
|
||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
Slot: 1,
|
||||
@@ -472,7 +472,7 @@ func TestSubmitSignedContributionAndProof_Ok(t *testing.T) {
|
||||
|
||||
aggBits := bitfield.NewBitvector128()
|
||||
aggBits.SetBitAt(0, true)
|
||||
m.validatorClient.EXPECT().GetSyncCommitteeContribution(
|
||||
m.validatorClient.EXPECT().SyncCommitteeContribution(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncCommitteeContributionRequest{
|
||||
Slot: 1,
|
||||
|
||||
@@ -254,7 +254,7 @@ func (*FakeValidator) HasProposerSettings() bool {
|
||||
}
|
||||
|
||||
// PushProposerSettings for mocking
|
||||
func (fv *FakeValidator) PushProposerSettings(ctx context.Context, km keymanager.IKeymanager, slot primitives.Slot, deadline time.Time) error {
|
||||
func (fv *FakeValidator) PushProposerSettings(ctx context.Context, _ keymanager.IKeymanager, _ primitives.Slot, deadline time.Time) error {
|
||||
nctx, cancel := context.WithDeadline(ctx, deadline)
|
||||
ctx = nctx
|
||||
defer cancel()
|
||||
@@ -294,8 +294,8 @@ func (fv *FakeValidator) SetProposerSettings(_ context.Context, settings *propos
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetGraffiti for mocking
|
||||
func (fv *FakeValidator) GetGraffiti(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte) ([]byte, error) {
|
||||
// Graffiti for mocking
|
||||
func (fv *FakeValidator) Graffiti(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte) ([]byte, error) {
|
||||
return []byte(fv.graffiti), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/time/slots"
|
||||
accountsiface "github.com/prysmaticlabs/prysm/v5/validator/accounts/iface"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/accounts/wallet"
|
||||
beacon_api "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api"
|
||||
beaconapi "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/client/iface"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/db"
|
||||
dbCommon "github.com/prysmaticlabs/prysm/v5/validator/db/common"
|
||||
@@ -134,7 +134,7 @@ func (v *validator) Done() {
|
||||
v.ticker.Done()
|
||||
}
|
||||
|
||||
// WaitForKmInitialization checks if the validator needs to wait for keymanager initialization.
|
||||
// WaitForKeymanagerInitialization checks if the validator needs to wait for keymanager initialization.
|
||||
func (v *validator) WaitForKeymanagerInitialization(ctx context.Context) error {
|
||||
genesisRoot, err := v.db.GenesisValidatorsRoot(ctx)
|
||||
if err != nil {
|
||||
@@ -257,7 +257,7 @@ func (v *validator) WaitForChainStart(ctx context.Context) error {
|
||||
return client.ErrConnectionIssue
|
||||
}
|
||||
|
||||
if ctx.Err() == context.Canceled {
|
||||
if errors.Is(ctx.Err(), context.Canceled) {
|
||||
return errors.Wrap(ctx.Err(), "context has been canceled so shutting down the loop")
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ func (v *validator) WaitForSync(ctx context.Context) error {
|
||||
ctx, span := trace.StartSpan(ctx, "validator.WaitForSync")
|
||||
defer span.End()
|
||||
|
||||
s, err := v.nodeClient.GetSyncStatus(ctx, &emptypb.Empty{})
|
||||
s, err := v.nodeClient.SyncStatus(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
return errors.Wrap(client.ErrConnectionIssue, errors.Wrap(err, "could not get sync status").Error())
|
||||
}
|
||||
@@ -326,7 +326,7 @@ func (v *validator) WaitForSync(ctx context.Context) error {
|
||||
select {
|
||||
// Poll every half slot.
|
||||
case <-time.After(slots.DivideSlotBy(2 /* twice per slot */)):
|
||||
s, err := v.nodeClient.GetSyncStatus(ctx, &emptypb.Empty{})
|
||||
s, err := v.nodeClient.SyncStatus(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
return errors.Wrap(client.ErrConnectionIssue, errors.Wrap(err, "could not get sync status").Error())
|
||||
}
|
||||
@@ -343,48 +343,48 @@ func (v *validator) WaitForSync(ctx context.Context) error {
|
||||
func (v *validator) checkAndLogValidatorStatus(statuses []*validatorStatus, activeValCount int64) bool {
|
||||
nonexistentIndex := primitives.ValidatorIndex(^uint64(0))
|
||||
var validatorActivated bool
|
||||
for _, status := range statuses {
|
||||
for _, s := range statuses {
|
||||
fields := logrus.Fields{
|
||||
"pubkey": fmt.Sprintf("%#x", bytesutil.Trunc(status.publicKey)),
|
||||
"status": status.status.Status.String(),
|
||||
"pubkey": fmt.Sprintf("%#x", bytesutil.Trunc(s.publicKey)),
|
||||
"status": s.status.Status.String(),
|
||||
}
|
||||
if status.index != nonexistentIndex {
|
||||
fields["validatorIndex"] = status.index
|
||||
if s.index != nonexistentIndex {
|
||||
fields["validatorIndex"] = s.index
|
||||
}
|
||||
log := log.WithFields(fields)
|
||||
if v.emitAccountMetrics {
|
||||
fmtKey := fmt.Sprintf("%#x", status.publicKey)
|
||||
ValidatorStatusesGaugeVec.WithLabelValues(fmtKey).Set(float64(status.status.Status))
|
||||
fmtKey := fmt.Sprintf("%#x", s.publicKey)
|
||||
ValidatorStatusesGaugeVec.WithLabelValues(fmtKey).Set(float64(s.status.Status))
|
||||
}
|
||||
switch status.status.Status {
|
||||
switch s.status.Status {
|
||||
case ethpb.ValidatorStatus_UNKNOWN_STATUS:
|
||||
log.Info("Waiting for deposit to be observed by beacon node")
|
||||
case ethpb.ValidatorStatus_DEPOSITED:
|
||||
if status.status.PositionInActivationQueue != 0 {
|
||||
if s.status.PositionInActivationQueue != 0 {
|
||||
log.WithField(
|
||||
"positionInActivationQueue", status.status.PositionInActivationQueue,
|
||||
"positionInActivationQueue", s.status.PositionInActivationQueue,
|
||||
).Info("Deposit processed, entering activation queue after finalization")
|
||||
}
|
||||
case ethpb.ValidatorStatus_PENDING:
|
||||
if activeValCount >= 0 && status.status.ActivationEpoch == params.BeaconConfig().FarFutureEpoch {
|
||||
if activeValCount >= 0 && s.status.ActivationEpoch == params.BeaconConfig().FarFutureEpoch {
|
||||
activationsPerEpoch :=
|
||||
uint64(math.Max(float64(params.BeaconConfig().MinPerEpochChurnLimit), float64(uint64(activeValCount)/params.BeaconConfig().ChurnLimitQuotient)))
|
||||
secondsPerEpoch := uint64(params.BeaconConfig().SlotsPerEpoch.Mul(params.BeaconConfig().SecondsPerSlot))
|
||||
expectedWaitingTime :=
|
||||
time.Duration((status.status.PositionInActivationQueue+activationsPerEpoch)/activationsPerEpoch*secondsPerEpoch) * time.Second
|
||||
time.Duration((s.status.PositionInActivationQueue+activationsPerEpoch)/activationsPerEpoch*secondsPerEpoch) * time.Second
|
||||
log.WithFields(logrus.Fields{
|
||||
"positionInActivationQueue": status.status.PositionInActivationQueue,
|
||||
"positionInActivationQueue": s.status.PositionInActivationQueue,
|
||||
"expectedWaitingTime": expectedWaitingTime.String(),
|
||||
}).Info("Waiting to be assigned activation epoch")
|
||||
} else if status.status.ActivationEpoch != params.BeaconConfig().FarFutureEpoch {
|
||||
} else if s.status.ActivationEpoch != params.BeaconConfig().FarFutureEpoch {
|
||||
log.WithFields(logrus.Fields{
|
||||
"activationEpoch": status.status.ActivationEpoch,
|
||||
"activationEpoch": s.status.ActivationEpoch,
|
||||
}).Info("Waiting for activation")
|
||||
}
|
||||
case ethpb.ValidatorStatus_ACTIVE, ethpb.ValidatorStatus_EXITING:
|
||||
validatorActivated = true
|
||||
log.WithFields(logrus.Fields{
|
||||
"index": status.index,
|
||||
"index": s.index,
|
||||
}).Info("Validator activated")
|
||||
case ethpb.ValidatorStatus_EXITED:
|
||||
log.Info("Validator exited")
|
||||
@@ -392,7 +392,7 @@ func (v *validator) checkAndLogValidatorStatus(statuses []*validatorStatus, acti
|
||||
log.Warn("Invalid Eth1 deposit")
|
||||
default:
|
||||
log.WithFields(logrus.Fields{
|
||||
"activationEpoch": status.status.ActivationEpoch,
|
||||
"activationEpoch": s.status.ActivationEpoch,
|
||||
}).Info("Validator status")
|
||||
}
|
||||
}
|
||||
@@ -404,7 +404,7 @@ func (v *validator) checkAndLogValidatorStatus(statuses []*validatorStatus, acti
|
||||
func (v *validator) CanonicalHeadSlot(ctx context.Context) (primitives.Slot, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "validator.CanonicalHeadSlot")
|
||||
defer span.End()
|
||||
head, err := v.chainClient.GetChainHead(ctx, &emptypb.Empty{})
|
||||
head, err := v.chainClient.ChainHead(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(client.ErrConnectionIssue, err.Error())
|
||||
}
|
||||
@@ -560,7 +560,7 @@ func (v *validator) UpdateDuties(ctx context.Context, slot primitives.Slot) erro
|
||||
}
|
||||
|
||||
// If duties is nil it means we have had no prior duties and just started up.
|
||||
resp, err := v.validatorClient.GetDuties(ctx, req)
|
||||
resp, err := v.validatorClient.Duties(ctx, req)
|
||||
if err != nil {
|
||||
v.dutiesLock.Lock()
|
||||
v.duties = nil // Clear assignments so we know to retry the request.
|
||||
@@ -611,7 +611,7 @@ func (v *validator) subscribeToSubnets(ctx context.Context, duties *ethpb.Duties
|
||||
|
||||
if v.distributed {
|
||||
// Get aggregated selection proofs to calculate isAggregator.
|
||||
if err := v.getAggregatedSelectionProofs(ctx, duties); err != nil {
|
||||
if err := v.aggregatedSelectionProofs(ctx, duties); err != nil {
|
||||
return errors.Wrap(err, "could not get aggregated selection proofs")
|
||||
}
|
||||
}
|
||||
@@ -779,7 +779,7 @@ func (v *validator) isAggregator(
|
||||
err error
|
||||
)
|
||||
if v.distributed {
|
||||
slotSig, err = v.getAttSelection(attSelectionKey{slot: slot, index: validatorIndex})
|
||||
slotSig, err = v.attSelection(attSelectionKey{slot: slot, index: validatorIndex})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -804,7 +804,7 @@ func (v *validator) isAggregator(
|
||||
// modulo = max(1, SYNC_COMMITTEE_SIZE // SYNC_COMMITTEE_SUBNET_COUNT // TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE)
|
||||
// return bytes_to_uint64(hash(signature)[0:8]) % modulo == 0
|
||||
func (v *validator) isSyncCommitteeAggregator(ctx context.Context, slot primitives.Slot, pubKey [fieldparams.BLSPubkeyLength]byte, validatorIndex primitives.ValidatorIndex) (bool, error) {
|
||||
res, err := v.validatorClient.GetSyncSubcommitteeIndex(ctx, ðpb.SyncSubcommitteeIndexRequest{
|
||||
res, err := v.validatorClient.SyncSubcommitteeIndex(ctx, ðpb.SyncSubcommitteeIndexRequest{
|
||||
PublicKey: pubKey[:],
|
||||
Slot: slot,
|
||||
})
|
||||
@@ -831,7 +831,7 @@ func (v *validator) isSyncCommitteeAggregator(ctx context.Context, slot primitiv
|
||||
|
||||
// Override selections with aggregated ones if the node is part of a Distributed Validator.
|
||||
if v.distributed && len(selections) > 0 {
|
||||
selections, err = v.validatorClient.GetAggregatedSyncSelections(ctx, selections)
|
||||
selections, err = v.validatorClient.AggregatedSyncSelections(ctx, selections)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "failed to get aggregated sync selections")
|
||||
}
|
||||
@@ -1156,19 +1156,19 @@ func (v *validator) filterAndCacheActiveKeys(ctx context.Context, pubkeys [][fie
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i, status := range resp.Statuses {
|
||||
for i, s := range resp.Statuses {
|
||||
currEpoch := primitives.Epoch(slot / params.BeaconConfig().SlotsPerEpoch)
|
||||
currActivating := status.Status == ethpb.ValidatorStatus_PENDING && currEpoch >= status.ActivationEpoch
|
||||
currActivating := s.Status == ethpb.ValidatorStatus_PENDING && currEpoch >= s.ActivationEpoch
|
||||
|
||||
active := status.Status == ethpb.ValidatorStatus_ACTIVE
|
||||
exiting := status.Status == ethpb.ValidatorStatus_EXITING
|
||||
active := s.Status == ethpb.ValidatorStatus_ACTIVE
|
||||
exiting := s.Status == ethpb.ValidatorStatus_EXITING
|
||||
|
||||
if currActivating || active || exiting {
|
||||
filteredKeys = append(filteredKeys, bytesutil.ToBytes48(resp.PublicKeys[i]))
|
||||
} else {
|
||||
log.WithFields(logrus.Fields{
|
||||
"pubkey": hexutil.Encode(resp.PublicKeys[i]),
|
||||
"status": status.Status.String(),
|
||||
"status": s.Status.String(),
|
||||
}).Debugf("Skipping non-active status key.")
|
||||
}
|
||||
}
|
||||
@@ -1304,7 +1304,7 @@ func (v *validator) validatorIndex(ctx context.Context, pubkey [fieldparams.BLSP
|
||||
"Perhaps the validator is not yet active.", pubkey)
|
||||
return 0, false, nil
|
||||
case err != nil:
|
||||
notFoundErr := &beacon_api.IndexNotFoundError{}
|
||||
notFoundErr := &beaconapi.IndexNotFoundError{}
|
||||
if errors.As(err, ¬FoundErr) {
|
||||
log.Debugf("Could not find validator index for public key %#x. "+
|
||||
"Perhaps the validator is not yet active.", pubkey)
|
||||
@@ -1315,7 +1315,7 @@ func (v *validator) validatorIndex(ctx context.Context, pubkey [fieldparams.BLSP
|
||||
return resp.Index, true, nil
|
||||
}
|
||||
|
||||
func (v *validator) getAggregatedSelectionProofs(ctx context.Context, duties *ethpb.DutiesResponse) error {
|
||||
func (v *validator) aggregatedSelectionProofs(ctx context.Context, duties *ethpb.DutiesResponse) error {
|
||||
// Create new instance of attestation selections map.
|
||||
v.newAttSelections()
|
||||
|
||||
@@ -1356,7 +1356,7 @@ func (v *validator) getAggregatedSelectionProofs(ctx context.Context, duties *et
|
||||
})
|
||||
}
|
||||
|
||||
resp, err := v.validatorClient.GetAggregatedSelections(ctx, req)
|
||||
resp, err := v.validatorClient.AggregatedSelections(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1386,7 +1386,7 @@ func (v *validator) newAttSelections() {
|
||||
v.attSelections = make(map[attSelectionKey]iface.BeaconCommitteeSelection)
|
||||
}
|
||||
|
||||
func (v *validator) getAttSelection(key attSelectionKey) ([]byte, error) {
|
||||
func (v *validator) attSelection(key attSelectionKey) ([]byte, error) {
|
||||
v.attSelectionLock.Lock()
|
||||
defer v.attSelectionLock.Unlock()
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ func (m *mockKeymanager) add(pairs ...keypair) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockKeymanager) FetchValidatingPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error) {
|
||||
func (m *mockKeymanager) FetchValidatingPublicKeys(_ context.Context) ([][fieldparams.BLSPubkeyLength]byte, error) {
|
||||
m.lock.RLock()
|
||||
defer m.lock.RUnlock()
|
||||
if m.fetchNoKeys {
|
||||
@@ -385,7 +385,7 @@ func TestWaitSync_ContextCanceled(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
|
||||
n.EXPECT().GetSyncStatus(
|
||||
n.EXPECT().SyncStatus(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(ðpb.SyncStatus{Syncing: true}, nil)
|
||||
@@ -402,7 +402,7 @@ func TestWaitSync_NotSyncing(t *testing.T) {
|
||||
nodeClient: n,
|
||||
}
|
||||
|
||||
n.EXPECT().GetSyncStatus(
|
||||
n.EXPECT().SyncStatus(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(ðpb.SyncStatus{Syncing: false}, nil)
|
||||
@@ -419,12 +419,12 @@ func TestWaitSync_Syncing(t *testing.T) {
|
||||
nodeClient: n,
|
||||
}
|
||||
|
||||
n.EXPECT().GetSyncStatus(
|
||||
n.EXPECT().SyncStatus(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(ðpb.SyncStatus{Syncing: true}, nil)
|
||||
|
||||
n.EXPECT().GetSyncStatus(
|
||||
n.EXPECT().SyncStatus(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(ðpb.SyncStatus{Syncing: false}, nil)
|
||||
@@ -450,7 +450,7 @@ func TestUpdateDuties_DoesNothingWhenNotEpochStart_AlreadyExistingAssignments(t
|
||||
},
|
||||
},
|
||||
}
|
||||
client.EXPECT().GetDuties(
|
||||
client.EXPECT().Duties(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Times(0)
|
||||
@@ -477,7 +477,7 @@ func TestUpdateDuties_ReturnsError(t *testing.T) {
|
||||
|
||||
expected := errors.New("bad")
|
||||
|
||||
client.EXPECT().GetDuties(
|
||||
client.EXPECT().Duties(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(nil, expected)
|
||||
@@ -508,7 +508,7 @@ func TestUpdateDuties_OK(t *testing.T) {
|
||||
km: newMockKeymanager(t, randKeypair(t)),
|
||||
validatorClient: client,
|
||||
}
|
||||
client.EXPECT().GetDuties(
|
||||
client.EXPECT().Duties(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(resp, nil)
|
||||
@@ -557,7 +557,7 @@ func TestUpdateDuties_OK_FilterBlacklistedPublicKeys(t *testing.T) {
|
||||
resp := ðpb.DutiesResponse{
|
||||
CurrentEpochDuties: []*ethpb.DutiesResponse_Duty{},
|
||||
}
|
||||
client.EXPECT().GetDuties(
|
||||
client.EXPECT().Duties(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(resp, nil)
|
||||
@@ -614,7 +614,7 @@ func TestUpdateDuties_AllValidatorsExited(t *testing.T) {
|
||||
km: newMockKeymanager(t, randKeypair(t)),
|
||||
validatorClient: client,
|
||||
}
|
||||
client.EXPECT().GetDuties(
|
||||
client.EXPECT().Duties(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(resp, nil)
|
||||
@@ -661,7 +661,7 @@ func TestUpdateDuties_Distributed(t *testing.T) {
|
||||
|
||||
sigDomain := make([]byte, 32)
|
||||
|
||||
client.EXPECT().GetDuties(
|
||||
client.EXPECT().Duties(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(resp, nil)
|
||||
@@ -674,7 +674,7 @@ func TestUpdateDuties_Distributed(t *testing.T) {
|
||||
nil, /*err*/
|
||||
).Times(2)
|
||||
|
||||
client.EXPECT().GetAggregatedSelections(
|
||||
client.EXPECT().AggregatedSelections(
|
||||
gomock.Any(),
|
||||
gomock.Any(), // fill this properly
|
||||
).Return(
|
||||
@@ -740,7 +740,7 @@ func TestRolesAt_OK(t *testing.T) {
|
||||
gomock.Any(), // epoch
|
||||
).Return(ðpb.DomainResponse{SignatureDomain: make([]byte, 32)}, nil /*err*/)
|
||||
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
PublicKey: validatorKey.PublicKey().Marshal(),
|
||||
@@ -775,7 +775,7 @@ func TestRolesAt_OK(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
PublicKey: validatorKey.PublicKey().Marshal(),
|
||||
@@ -1250,7 +1250,7 @@ func TestIsSyncCommitteeAggregator_OK(t *testing.T) {
|
||||
slot := primitives.Slot(1)
|
||||
pubKey := validatorKey.PublicKey().Marshal()
|
||||
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
PublicKey: validatorKey.PublicKey().Marshal(),
|
||||
@@ -1271,7 +1271,7 @@ func TestIsSyncCommitteeAggregator_OK(t *testing.T) {
|
||||
gomock.Any(), // epoch
|
||||
).Return(ðpb.DomainResponse{SignatureDomain: make([]byte, 32)}, nil /*err*/)
|
||||
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
PublicKey: validatorKey.PublicKey().Marshal(),
|
||||
@@ -1297,7 +1297,7 @@ func TestIsSyncCommitteeAggregator_Distributed_OK(t *testing.T) {
|
||||
slot := primitives.Slot(1)
|
||||
pubKey := validatorKey.PublicKey().Marshal()
|
||||
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
PublicKey: validatorKey.PublicKey().Marshal(),
|
||||
@@ -1318,7 +1318,7 @@ func TestIsSyncCommitteeAggregator_Distributed_OK(t *testing.T) {
|
||||
gomock.Any(), // epoch
|
||||
).Return(ðpb.DomainResponse{SignatureDomain: make([]byte, 32)}, nil /*err*/).Times(2)
|
||||
|
||||
m.validatorClient.EXPECT().GetSyncSubcommitteeIndex(
|
||||
m.validatorClient.EXPECT().SyncSubcommitteeIndex(
|
||||
gomock.Any(), // ctx
|
||||
ðpb.SyncSubcommitteeIndexRequest{
|
||||
PublicKey: validatorKey.PublicKey().Marshal(),
|
||||
@@ -1335,7 +1335,7 @@ func TestIsSyncCommitteeAggregator_Distributed_OK(t *testing.T) {
|
||||
ValidatorIndex: 123,
|
||||
SubcommitteeIndex: 0,
|
||||
}
|
||||
m.validatorClient.EXPECT().GetAggregatedSyncSelections(
|
||||
m.validatorClient.EXPECT().AggregatedSyncSelections(
|
||||
gomock.Any(), // ctx
|
||||
[]iface.SyncCommitteeSelection{selection},
|
||||
).Return([]iface.SyncCommitteeSelection{selection}, nil)
|
||||
@@ -2031,7 +2031,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func getPubkeyFromString(t *testing.T, stringPubkey string) [fieldparams.BLSPubkeyLength]byte {
|
||||
func pubkeyFromString(t *testing.T, stringPubkey string) [fieldparams.BLSPubkeyLength]byte {
|
||||
pubkeyTemp, err := hexutil.Decode(stringPubkey)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -2041,7 +2041,7 @@ func getPubkeyFromString(t *testing.T, stringPubkey string) [fieldparams.BLSPubk
|
||||
return pubkey
|
||||
}
|
||||
|
||||
func getFeeRecipientFromString(t *testing.T, stringFeeRecipient string) common.Address {
|
||||
func feeRecipientFromString(t *testing.T, stringFeeRecipient string) common.Address {
|
||||
feeRecipientTemp, err := hexutil.Decode(stringFeeRecipient)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -2058,15 +2058,15 @@ func TestValidator_buildPrepProposerReqs_WithoutDefaultConfig(t *testing.T) {
|
||||
// pubkey4 => Nothing (already in `v.validatorIndex`)
|
||||
|
||||
// Public keys
|
||||
pubkey1 := getPubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
pubkey2 := getPubkeyFromString(t, "0x222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
|
||||
pubkey3 := getPubkeyFromString(t, "0x333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
|
||||
pubkey4 := getPubkeyFromString(t, "0x444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444")
|
||||
pubkey1 := pubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
pubkey2 := pubkeyFromString(t, "0x222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
|
||||
pubkey3 := pubkeyFromString(t, "0x333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
|
||||
pubkey4 := pubkeyFromString(t, "0x444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444")
|
||||
|
||||
// Fee recipients
|
||||
feeRecipient1 := getFeeRecipientFromString(t, "0x1111111111111111111111111111111111111111")
|
||||
feeRecipient2 := getFeeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
|
||||
feeRecipient3 := getFeeRecipientFromString(t, "0x3333333333333333333333333333333333333333")
|
||||
feeRecipient1 := feeRecipientFromString(t, "0x1111111111111111111111111111111111111111")
|
||||
feeRecipient2 := feeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
|
||||
feeRecipient3 := feeRecipientFromString(t, "0x3333333333333333333333333333333333333333")
|
||||
feeRecipient4 := common.Address{}
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
@@ -2164,22 +2164,22 @@ func TestValidator_buildPrepProposerReqs_WithDefaultConfig(t *testing.T) {
|
||||
// pubkey8 => feeRecipient8 - Status: exiting (already in `v.validatorIndex`)
|
||||
|
||||
// Public keys
|
||||
pubkey1 := getPubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
pubkey2 := getPubkeyFromString(t, "0x222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
|
||||
pubkey3 := getPubkeyFromString(t, "0x333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
|
||||
pubkey4 := getPubkeyFromString(t, "0x444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444")
|
||||
pubkey5 := getPubkeyFromString(t, "0x555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555")
|
||||
pubkey6 := getPubkeyFromString(t, "0x666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666")
|
||||
pubkey7 := getPubkeyFromString(t, "0x777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777")
|
||||
pubkey8 := getPubkeyFromString(t, "0x888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888")
|
||||
pubkey1 := pubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
pubkey2 := pubkeyFromString(t, "0x222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
|
||||
pubkey3 := pubkeyFromString(t, "0x333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
|
||||
pubkey4 := pubkeyFromString(t, "0x444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444")
|
||||
pubkey5 := pubkeyFromString(t, "0x555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555")
|
||||
pubkey6 := pubkeyFromString(t, "0x666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666")
|
||||
pubkey7 := pubkeyFromString(t, "0x777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777")
|
||||
pubkey8 := pubkeyFromString(t, "0x888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888")
|
||||
|
||||
// Fee recipients
|
||||
feeRecipient1 := getFeeRecipientFromString(t, "0x1111111111111111111111111111111111111111")
|
||||
feeRecipient2 := getFeeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
|
||||
feeRecipient3 := getFeeRecipientFromString(t, "0x3333333333333333333333333333333333333333")
|
||||
feeRecipient8 := getFeeRecipientFromString(t, "0x8888888888888888888888888888888888888888")
|
||||
feeRecipient1 := feeRecipientFromString(t, "0x1111111111111111111111111111111111111111")
|
||||
feeRecipient2 := feeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
|
||||
feeRecipient3 := feeRecipientFromString(t, "0x3333333333333333333333333333333333333333")
|
||||
feeRecipient8 := feeRecipientFromString(t, "0x8888888888888888888888888888888888888888")
|
||||
|
||||
defaultFeeRecipient := getFeeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
|
||||
defaultFeeRecipient := feeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
|
||||
|
||||
pubkeyToStatus := map[[fieldparams.BLSPubkeyLength]byte]ethpb.ValidatorStatus{
|
||||
pubkey1: ethpb.ValidatorStatus_ACTIVE,
|
||||
@@ -2327,15 +2327,15 @@ func TestValidator_buildSignedRegReqs_DefaultConfigDisabled(t *testing.T) {
|
||||
// pubkey3 => Nothing, builder enabled
|
||||
|
||||
// Public keys
|
||||
pubkey1 := getPubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
pubkey2 := getPubkeyFromString(t, "0x222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
|
||||
pubkey3 := getPubkeyFromString(t, "0x333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
|
||||
pubkey1 := pubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
pubkey2 := pubkeyFromString(t, "0x222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
|
||||
pubkey3 := pubkeyFromString(t, "0x333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
|
||||
|
||||
// Fee recipients
|
||||
feeRecipient1 := getFeeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
|
||||
feeRecipient2 := getFeeRecipientFromString(t, "0x2222222222222222222222222222222222222222")
|
||||
feeRecipient1 := feeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
|
||||
feeRecipient2 := feeRecipientFromString(t, "0x2222222222222222222222222222222222222222")
|
||||
|
||||
defaultFeeRecipient := getFeeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
|
||||
defaultFeeRecipient := feeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
@@ -2412,15 +2412,15 @@ func TestValidator_buildSignedRegReqs_DefaultConfigEnabled(t *testing.T) {
|
||||
// pubkey3 => Nothing, builder enabled
|
||||
|
||||
// Public keys
|
||||
pubkey1 := getPubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
pubkey2 := getPubkeyFromString(t, "0x222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
|
||||
pubkey3 := getPubkeyFromString(t, "0x333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
|
||||
pubkey1 := pubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
pubkey2 := pubkeyFromString(t, "0x222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
|
||||
pubkey3 := pubkeyFromString(t, "0x333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
|
||||
|
||||
// Fee recipients
|
||||
feeRecipient1 := getFeeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
|
||||
feeRecipient2 := getFeeRecipientFromString(t, "0x2222222222222222222222222222222222222222")
|
||||
feeRecipient1 := feeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
|
||||
feeRecipient2 := feeRecipientFromString(t, "0x2222222222222222222222222222222222222222")
|
||||
|
||||
defaultFeeRecipient := getFeeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
|
||||
defaultFeeRecipient := feeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
@@ -2498,10 +2498,10 @@ func TestValidator_buildSignedRegReqs_DefaultConfigEnabled(t *testing.T) {
|
||||
|
||||
func TestValidator_buildSignedRegReqs_SignerOnError(t *testing.T) {
|
||||
// Public keys
|
||||
pubkey1 := getPubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
pubkey1 := pubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
|
||||
// Fee recipients
|
||||
defaultFeeRecipient := getFeeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
|
||||
defaultFeeRecipient := feeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
@@ -2537,12 +2537,12 @@ func TestValidator_buildSignedRegReqs_SignerOnError(t *testing.T) {
|
||||
|
||||
func TestValidator_buildSignedRegReqs_TimestampBeforeGenesis(t *testing.T) {
|
||||
// Public keys
|
||||
pubkey1 := getPubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
pubkey1 := pubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
|
||||
|
||||
// Fee recipients
|
||||
feeRecipient1 := getFeeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
|
||||
feeRecipient1 := feeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
|
||||
|
||||
defaultFeeRecipient := getFeeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
|
||||
defaultFeeRecipient := feeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
@@ -96,7 +96,7 @@ func (v *validator) internalWaitForActivation(ctx context.Context, accountsChang
|
||||
break
|
||||
}
|
||||
// If context is canceled we return from the function.
|
||||
if ctx.Err() == context.Canceled {
|
||||
if errors.Is(ctx.Err(), context.Canceled) {
|
||||
return errors.Wrap(ctx.Err(), "context has been canceled so shutting down the loop")
|
||||
}
|
||||
if err != nil {
|
||||
@@ -120,7 +120,7 @@ func (v *validator) internalWaitForActivation(ctx context.Context, accountsChang
|
||||
|
||||
// "-1" indicates that validator count endpoint is not supported by the beacon node.
|
||||
var valCount int64 = -1
|
||||
valCounts, err := v.prysmChainClient.GetValidatorCount(ctx, "head", []validator2.Status{validator2.Active})
|
||||
valCounts, err := v.prysmChainClient.ValidatorCount(ctx, "head", []validator2.Status{validator2.Active})
|
||||
if err != nil && !errors.Is(err, iface.ErrNotSupported) {
|
||||
return errors.Wrap(err, "could not get active validator count")
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ func TestServer_VoluntaryExit(t *testing.T) {
|
||||
}
|
||||
|
||||
mockNodeClient.EXPECT().
|
||||
GetGenesis(gomock.Any(), gomock.Any()).
|
||||
Genesis(gomock.Any(), gomock.Any()).
|
||||
Return(ðpb.Genesis{GenesisTime: genesisTime}, nil)
|
||||
|
||||
mockValidatorClient.EXPECT().
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
func (s *Server) GetBeaconStatus(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "validator.web.beacon.GetBeaconStatus")
|
||||
defer span.End()
|
||||
syncStatus, err := s.nodeClient.GetSyncStatus(ctx, &emptypb.Empty{})
|
||||
syncStatus, err := s.nodeClient.SyncStatus(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("beacon node call to get sync status failed")
|
||||
httputil.WriteJson(w, &BeaconStatusResponse{
|
||||
@@ -35,16 +35,16 @@ func (s *Server) GetBeaconStatus(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
return
|
||||
}
|
||||
genesis, err := s.nodeClient.GetGenesis(ctx, &emptypb.Empty{})
|
||||
genesis, err := s.nodeClient.Genesis(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
httputil.HandleError(w, errors.Wrap(err, "GetGenesis call failed").Error(), http.StatusInternalServerError)
|
||||
httputil.HandleError(w, errors.Wrap(err, "Genesis call failed").Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
genesisTime := uint64(time.Unix(genesis.GenesisTime.Seconds, 0).Unix())
|
||||
address := genesis.DepositContractAddress
|
||||
chainHead, err := s.chainClient.GetChainHead(ctx, &emptypb.Empty{})
|
||||
chainHead, err := s.chainClient.ChainHead(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
httputil.HandleError(w, errors.Wrap(err, "GetChainHead").Error(), http.StatusInternalServerError)
|
||||
httputil.HandleError(w, errors.Wrap(err, "ChainHead").Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
httputil.WriteJson(w, &BeaconStatusResponse{
|
||||
@@ -59,7 +59,7 @@ func (s *Server) GetBeaconStatus(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// GetValidatorPerformance is a wrapper around the /eth/v1alpha1 endpoint of the same name.
|
||||
func (s *Server) GetValidatorPerformance(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "validator.web.beacon.GetValidatorPerformance")
|
||||
ctx, span := trace.StartSpan(r.Context(), "validator.web.beacon.ValidatorPerformance")
|
||||
defer span.End()
|
||||
publicKeys := r.URL.Query()["public_keys"]
|
||||
pubkeys := make([][]byte, len(publicKeys))
|
||||
@@ -85,9 +85,9 @@ func (s *Server) GetValidatorPerformance(w http.ResponseWriter, r *http.Request)
|
||||
req := ðpb.ValidatorPerformanceRequest{
|
||||
PublicKeys: pubkeys,
|
||||
}
|
||||
validatorPerformance, err := s.chainClient.GetValidatorPerformance(ctx, req)
|
||||
validatorPerformance, err := s.chainClient.ValidatorPerformance(ctx, req)
|
||||
if err != nil {
|
||||
httputil.HandleError(w, errors.Wrap(err, "GetValidatorPerformance call failed").Error(), http.StatusInternalServerError)
|
||||
httputil.HandleError(w, errors.Wrap(err, "ValidatorPerformance call failed").Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
httputil.WriteJson(w, ValidatorPerformanceResponseFromConsensus(validatorPerformance))
|
||||
@@ -133,9 +133,9 @@ func (s *Server) GetValidatorBalances(w http.ResponseWriter, r *http.Request) {
|
||||
PageSize: int32(ps),
|
||||
PageToken: pageToken,
|
||||
}
|
||||
listValidatorBalances, err := s.chainClient.ListValidatorBalances(ctx, req)
|
||||
listValidatorBalances, err := s.chainClient.ValidatorBalances(ctx, req)
|
||||
if err != nil {
|
||||
httputil.HandleError(w, errors.Wrap(err, "ListValidatorBalances call failed").Error(), http.StatusInternalServerError)
|
||||
httputil.HandleError(w, errors.Wrap(err, "ValidatorBalances call failed").Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
response, err := ValidatorBalancesResponseFromConsensus(listValidatorBalances)
|
||||
@@ -187,9 +187,9 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) {
|
||||
PageSize: int32(ps),
|
||||
PageToken: pageToken,
|
||||
}
|
||||
validators, err := s.chainClient.ListValidators(ctx, req)
|
||||
validators, err := s.chainClient.Validators(ctx, req)
|
||||
if err != nil {
|
||||
httputil.HandleError(w, errors.Wrap(err, "ListValidators call failed").Error(), http.StatusInternalServerError)
|
||||
httputil.HandleError(w, errors.Wrap(err, "Validators call failed").Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
response, err := ValidatorsResponseFromConsensus(validators)
|
||||
@@ -204,9 +204,9 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) GetPeers(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "validator.web.beacon.GetPeers")
|
||||
defer span.End()
|
||||
peers, err := s.nodeClient.ListPeers(ctx, &emptypb.Empty{})
|
||||
peers, err := s.nodeClient.Peers(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
httputil.HandleError(w, errors.Wrap(err, "ListPeers call failed").Error(), http.StatusInternalServerError)
|
||||
httputil.HandleError(w, errors.Wrap(err, "Peers call failed").Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
httputil.WriteJson(w, peers)
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
func TestGetBeaconStatus_NotConnected(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
nodeClient := validatormock.NewMockNodeClient(ctrl)
|
||||
nodeClient.EXPECT().GetSyncStatus(
|
||||
nodeClient.EXPECT().SyncStatus(
|
||||
gomock.Any(), // ctx
|
||||
gomock.Any(),
|
||||
).Return(nil /*response*/, errors.New("uh oh"))
|
||||
@@ -48,12 +48,12 @@ func TestGetBeaconStatus_OK(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
nodeClient := validatormock.NewMockNodeClient(ctrl)
|
||||
chainClient := validatormock.NewMockChainClient(ctrl)
|
||||
nodeClient.EXPECT().GetSyncStatus(
|
||||
nodeClient.EXPECT().SyncStatus(
|
||||
gomock.Any(), // ctx
|
||||
gomock.Any(),
|
||||
).Return(ðpb.SyncStatus{Syncing: true}, nil)
|
||||
timeStamp := timestamppb.New(time.Unix(0, 0))
|
||||
nodeClient.EXPECT().GetGenesis(
|
||||
nodeClient.EXPECT().Genesis(
|
||||
gomock.Any(), // ctx
|
||||
gomock.Any(),
|
||||
).Return(ðpb.Genesis{
|
||||
|
||||
@@ -15,10 +15,10 @@ import (
|
||||
|
||||
// GetVersion returns the beacon node and validator client versions
|
||||
func (s *Server) GetVersion(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "validator.web.health.GetVersion")
|
||||
ctx, span := trace.StartSpan(r.Context(), "validator.web.health.Version")
|
||||
defer span.End()
|
||||
|
||||
beacon, err := s.nodeClient.GetVersion(ctx, &emptypb.Empty{})
|
||||
beacon, err := s.nodeClient.Version(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
httputil.HandleError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
@@ -173,7 +173,7 @@ func TestServer_GetVersion(t *testing.T) {
|
||||
ctx: ctx,
|
||||
nodeClient: mockNodeClient,
|
||||
}
|
||||
mockNodeClient.EXPECT().GetVersion(gomock.Any(), gomock.Any()).Return(ð.Version{
|
||||
mockNodeClient.EXPECT().Version(gomock.Any(), gomock.Any()).Return(ð.Version{
|
||||
Version: "4.10.1",
|
||||
Metadata: "beacon node",
|
||||
}, nil)
|
||||
|
||||
@@ -347,7 +347,7 @@ func (s *Server) SetVoluntaryExit(w http.ResponseWriter, r *http.Request) {
|
||||
epoch := primitives.Epoch(e)
|
||||
|
||||
if rawEpoch == "" {
|
||||
genesisResponse, err := s.nodeClient.GetGenesis(ctx, &emptypb.Empty{})
|
||||
genesisResponse, err := s.nodeClient.Genesis(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
httputil.HandleError(w, errors.Wrap(err, "Failed to get genesis time").Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@@ -842,7 +842,7 @@ func (s *Server) DeleteGasLimit(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (s *Server) GetGraffiti(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "validator.keymanagerAPI.GetGraffiti")
|
||||
ctx, span := trace.StartSpan(r.Context(), "validator.keymanagerAPI.Graffiti")
|
||||
defer span.End()
|
||||
|
||||
if s.validatorService == nil {
|
||||
@@ -854,7 +854,7 @@ func (s *Server) GetGraffiti(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
graffiti, err := s.validatorService.GetGraffiti(ctx, bytesutil.ToBytes48(pubkey))
|
||||
graffiti, err := s.validatorService.Graffiti(ctx, bytesutil.ToBytes48(pubkey))
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "unavailable") {
|
||||
httputil.HandleError(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
@@ -738,7 +738,7 @@ func TestServer_SetVoluntaryExit(t *testing.T) {
|
||||
Return(ð.DomainResponse{SignatureDomain: make([]byte, common.HashLength)}, nil /*err*/)
|
||||
|
||||
mockNodeClient.EXPECT().
|
||||
GetGenesis(gomock.Any(), gomock.Any()).
|
||||
Genesis(gomock.Any(), gomock.Any()).
|
||||
Times(3).
|
||||
Return(ð.Genesis{GenesisTime: genesisTime}, nil)
|
||||
|
||||
@@ -841,7 +841,7 @@ func TestServer_SetVoluntaryExit(t *testing.T) {
|
||||
resp := &SetVoluntaryExitResponse{}
|
||||
require.NoError(t, json.Unmarshal(w.Body.Bytes(), resp))
|
||||
if tt.w.epoch == 0 {
|
||||
genesisResponse, err := s.nodeClient.GetGenesis(ctx, &emptypb.Empty{})
|
||||
genesisResponse, err := s.nodeClient.Genesis(ctx, &emptypb.Empty{})
|
||||
require.NoError(t, err)
|
||||
tt.w.epoch, err = client.CurrentEpoch(genesisResponse.GenesisTime)
|
||||
require.NoError(t, err)
|
||||
@@ -1102,7 +1102,7 @@ func TestServer_SetGasLimit(t *testing.T) {
|
||||
}
|
||||
|
||||
if tt.beaconReturn != nil {
|
||||
beaconClient.EXPECT().GetFeeRecipientByPubKey(
|
||||
beaconClient.EXPECT().FeeRecipientByPubKey(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(tt.beaconReturn.resp, tt.beaconReturn.error)
|
||||
|
||||
Reference in New Issue
Block a user