diff --git a/config.example.toml b/config.example.toml index 8c62577..c75f13f 100644 --- a/config.example.toml +++ b/config.example.toml @@ -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. diff --git a/pkg/config/chain.go b/pkg/config/chain.go index e6d5bfa..481ba47 100644 --- a/pkg/config/chain.go +++ b/pkg/config/chain.go @@ -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"` diff --git a/pkg/data/fetcher.go b/pkg/data/fetcher.go index 04cf56d..e64daf6 100644 --- a/pkg/data/fetcher.go +++ b/pkg/data/fetcher.go @@ -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, diff --git a/pkg/data/fetchers/cosmos_lcd.go b/pkg/data/fetchers/cosmos_lcd.go index fa05d44..bbceed7 100644 --- a/pkg/data/fetchers/cosmos_lcd.go +++ b/pkg/data/fetchers/cosmos_lcd.go @@ -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, diff --git a/pkg/data/fetchers/cosmos_rpc.go b/pkg/data/fetchers/cosmos_rpc.go index 5d3b732..4a0f4e2 100644 --- a/pkg/data/fetchers/cosmos_rpc.go +++ b/pkg/data/fetchers/cosmos_rpc.go @@ -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, diff --git a/pkg/data/manager.go b/pkg/data/manager.go index 67c4aa7..01d7e23 100644 --- a/pkg/data/manager.go +++ b/pkg/data/manager.go @@ -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 @@ -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 @@ -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) }