Skip to content

Commit

Permalink
chore: removed query-each-signing-info (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno authored May 2, 2024
1 parent 3f0ee5c commit 9c30c2d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 118 deletions.
6 changes: 0 additions & 6 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ rpc-endpoints = [
"https://rpc-cosmoshub.ecostake.com",
"https://rpc.cosmos.dragonstake.io"
]
# If set to true, the app will query a signing info for each validator separately.
# There's a bug on Cosmos Hub when some validators do not have signing info address,
# so it's impossible to map signing infos (containing missed blocks counter and tombstone info)
# to a validator. Defaults to false. You may set it to true on Cosmos Hub, or other chains
# if you see errors in logs that the signing info for validator was not found.
query-each-signing-info = true
# Telegram reporter configuration. Needs token and chat. See README.md on how to set it up
telegram = { token = "xxx:yyy", chat = 12345 }
# Discord reporter configuration. Needs token, server ID (aka guild) and channel ID.
Expand Down
19 changes: 9 additions & 10 deletions pkg/config/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ type ChainPagination struct {
SigningInfos uint64 `default:"1000" toml:"signing-infos"`
}
type ChainConfig struct {
Name string `toml:"name"`
PrettyName string `toml:"pretty-name"`
RPCEndpoints []string `toml:"rpc-endpoints"`
StoreBlocks int64 `default:"20000" toml:"store-blocks"`
BlocksWindow int64 `default:"10000" toml:"blocks-window"`
MinSignedPerWindow float64 `default:"0.05" toml:"min-signed-per-window"`
QueryEachSigningInfo null.Bool `default:"false" toml:"query-each-signing-info"`
SnapshotsInterval int64 `default:"1" toml:"snapshots-interval"`
Pagination ChainPagination `toml:"pagination"`
Intervals IntervalsConfig `toml:"intervals"`
Name string `toml:"name"`
PrettyName string `toml:"pretty-name"`
RPCEndpoints []string `toml:"rpc-endpoints"`
StoreBlocks int64 `default:"20000" toml:"store-blocks"`
BlocksWindow int64 `default:"10000" toml:"blocks-window"`
MinSignedPerWindow float64 `default:"0.05" toml:"min-signed-per-window"`
SnapshotsInterval int64 `default:"1" toml:"snapshots-interval"`
Pagination ChainPagination `toml:"pagination"`
Intervals IntervalsConfig `toml:"intervals"`

IsConsumer null.Bool `default:"false" toml:"consumer"`
ProviderRPCEndpoints []string `toml:"provider-rpc-endpoints"`
Expand Down
1 change: 0 additions & 1 deletion pkg/data/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
type Fetcher interface {
GetValidators(height int64) (*stakingTypes.QueryValidatorsResponse, error)
GetSigningInfos(height int64) (*slashingTypes.QuerySigningInfosResponse, error)
GetSigningInfo(valcons string, height int64) (*slashingTypes.QuerySigningInfoResponse, error)
GetValidatorAssignedConsumerKey(
providerValcons string,
height int64,
Expand Down
24 changes: 0 additions & 24 deletions pkg/data/fetchers/cosmos_lcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,30 +130,6 @@ func (f *CosmosLCDFetcher) GetSigningInfos(height int64) (*slashingTypes.QuerySi
return &response, nil
}

func (f *CosmosLCDFetcher) GetSigningInfo(valcons string, height int64) (*slashingTypes.QuerySigningInfoResponse, error) {
var response slashingTypes.QuerySigningInfoResponse

if err := f.Get(
"/cosmos/slashing/v1beta1/signing_infos/"+valcons,
constants.QueryTypeSigningInfo,
&response,
f.clients,
height,
func(v interface{}) error {
_, ok := v.(*slashingTypes.QuerySigningInfoResponse)
if !ok {
return errors.New("error converting signing info response")
}

return nil
},
); err != nil {
return nil, err
}

return &response, nil
}

func (f *CosmosLCDFetcher) GetValidatorAssignedConsumerKey(
providerValcons string,
height int64,
Expand Down
20 changes: 0 additions & 20 deletions pkg/data/fetchers/cosmos_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,26 +160,6 @@ func (f *CosmosRPCFetcher) GetSigningInfos(height int64) (*slashingTypes.QuerySi
return &response, nil
}

func (f *CosmosRPCFetcher) GetSigningInfo(valcons string, height int64) (*slashingTypes.QuerySigningInfoResponse, error) {
query := slashingTypes.QuerySigningInfoRequest{
ConsAddress: valcons,
}

var response slashingTypes.QuerySigningInfoResponse
if err := f.AbciQuery(
"/cosmos.slashing.v1beta1.Query/SigningInfo",
&query,
height,
constants.QueryTypeSigningInfo,
&response,
f.clients,
); err != nil {
return nil, err
}

return &response, nil
}

func (f *CosmosRPCFetcher) GetValidatorAssignedConsumerKey(
providerValcons string,
height int64,
Expand Down
57 changes: 0 additions & 57 deletions pkg/data/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ func (manager *Manager) GetValidators(height int64) (types.Validators, []error)
return manager.GetValidatorsAndSigningInfoForConsumerChain(height)
}

if manager.config.QueryEachSigningInfo.Bool {
return manager.GetValidatorsAndEachSigningInfo(height)
}

var (
wg sync.WaitGroup
validatorsResponse *stakingTypes.QueryValidatorsResponse
Expand Down Expand Up @@ -115,55 +111,6 @@ func (manager *Manager) GetValidators(height int64) (types.Validators, []error)
return validators, nil
}

func (manager *Manager) GetValidatorsAndEachSigningInfo(height int64) (types.Validators, []error) {
validatorsResponse, validatorsError := manager.fetcher.GetValidators(height)
if validatorsError != nil {
return nil, []error{validatorsError}
}

var wg sync.WaitGroup
var mutex sync.Mutex
errs := make([]error, 0)

validators := make(types.Validators, len(validatorsResponse.Validators))
for index, validatorRaw := range validatorsResponse.Validators {
wg.Add(1)
go func(validatorRaw stakingTypes.Validator, index int) {
defer wg.Done()

consensusAddr := manager.converter.GetConsensusAddress(validatorRaw)
signingInfoResponse, signingInfoErr := manager.fetcher.GetSigningInfo(consensusAddr, height)
if signingInfoErr != nil {
manager.logger.Warn().
Str("operator_address", validatorRaw.OperatorAddress).
Err(signingInfoErr).
Msg("Error fetching validator signing info")
mutex.Lock()
errs = append(errs, signingInfoErr)
mutex.Unlock()
return
}

var signingInfo *slashingTypes.ValidatorSigningInfo
if signingInfoResponse != nil {
signingInfo = &signingInfoResponse.ValSigningInfo
}

validator := manager.converter.ValidatorFromCosmosValidator(validatorRaw, signingInfo)

mutex.Lock()
validators[index] = validator
mutex.Unlock()
}(validatorRaw, index)
}

wg.Wait()

validators.SetVotingPowerPercent()

return validators, errs
}

func (manager *Manager) GetValidatorsAndSigningInfoForConsumerChain(height int64) (types.Validators, []error) {
var (
wg sync.WaitGroup
Expand Down Expand Up @@ -294,10 +241,6 @@ func (manager *Manager) GetSigningInfos(height int64) (*slashingTypes.QuerySigni
return manager.fetcher.GetSigningInfos(height)
}

func (manager *Manager) GetSigningInfo(valcons string, height int64) (*slashingTypes.QuerySigningInfoResponse, error) {
return manager.fetcher.GetSigningInfo(valcons, height)
}

func (manager *Manager) GetSlashingParams(height int64) (*slashingTypes.QueryParamsResponse, error) {
return manager.fetcher.GetSlashingParams(height)
}
Expand Down

0 comments on commit 9c30c2d

Please sign in to comment.