Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/common/api/babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func GetFinalityVotesByHeight(c common.CommonClient, height int64) ([]string, er
return votes.BTCPKs, nil
}

func GetBabylonFinalityProviderInfos(c common.CommonClient) ([]types.FinalityProviderInfo, error) {
func GetBabylonFinalityProviderInfos(c common.CommonClient, chainID string) ([]types.FinalityProviderInfo, error) {
ctx, cancel := context.WithTimeout(context.Background(), common.Timeout)
defer cancel()

Expand All @@ -68,7 +68,7 @@ func GetBabylonFinalityProviderInfos(c common.CommonClient) ([]types.FinalityPro
maxCnt := 10
key := ""
for cnt := 0; cnt <= maxCnt; cnt++ {
resp, err := requester.Get(types.BabylonFinalityProviderInfosQueryPath(key))
resp, err := requester.Get(types.BabylonFinalityProviderInfosQueryPath(key, chainID))
if err != nil {
return nil, errors.Errorf("rpc call is failed from %s: %s", resp.Request.URL, err)
}
Expand All @@ -86,7 +86,7 @@ func GetBabylonFinalityProviderInfos(c common.CommonClient) ([]types.FinalityPro

if fpInfos.Pagination.NextKey != "" {
key = url.QueryEscape(fpInfos.Pagination.NextKey)
c.Debugf("there is next key, keep collecting finality providers by using this path: %s", types.BabylonFinalityProviderInfosQueryPath(key))
c.Debugf("there is next key, keep collecting finality providers by using this path: %s", types.BabylonFinalityProviderInfosQueryPath(key, chainID))
} else {
// got all finality provider infos
c.Debugf("collected all finality providers")
Expand Down
4 changes: 2 additions & 2 deletions internal/common/api/babylon_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func TestCheckGetBlockResultAndExtractFpVoting(t *testing.T) {
func Test_Babylon_GetFP(t *testing.T) {
commonApp := common.NewCommonApp(p)
commonApp.SetAPIEndPoint("https://lcd-office.cosmostation.io/babylon-testnet")

fps, err := GetBabylonFinalityProviderInfos(commonApp.CommonClient)
chainID := "bbn-testnet-5"
fps, err := GetBabylonFinalityProviderInfos(commonApp.CommonClient, chainID)
assert.NoError(t, err)

for _, fp := range fps {
Expand Down
4 changes: 2 additions & 2 deletions internal/common/function/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ func GetStakingValidators(client common.CommonClient, chainName string, newStaki
return nil
}

func MakeFinalityProviderInfoList(c common.CommonClient, chainInfoID int64, newFinalityProviderMap map[string]bool) ([]indexermodel.FinalityProviderInfo, error) {
fps, err := api.GetBabylonFinalityProviderInfos(c)
func MakeFinalityProviderInfoList(c common.CommonClient, chainID string, chainInfoID int64, newFinalityProviderMap map[string]bool) ([]indexermodel.FinalityProviderInfo, error) {
fps, err := api.GetBabylonFinalityProviderInfos(c, chainID)
if err != nil {
return nil, errors.Cause(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/common/types/babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ type FinalityVotesResponse struct {
BTCPKs []string `json:"btc_pks"`
}

var BabylonFinalityProviderInfosQueryPath = func(key string) string {
return fmt.Sprintf("/babylon/btcstaking/v1/finality_providers?pagination.key=%s", key)
var BabylonFinalityProviderInfosQueryPath = func(key, chainID string) string {
return fmt.Sprintf("/babylon/btcstaking/v1/finality_providers/%s?pagination.key=%s", chainID, key)
}

type FinalityProviderInfosResponse struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/packages/babylon/finality-provider/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const finalitySigTimeout = 3

func GetFinalityProviderUptime(exporter *common.Exporter) (types.BabylonFinalityProviderUptimeStatues, error) {
// 1. get finality provider infos
finalityProviderInfos, err := commonapi.GetBabylonFinalityProviderInfos(exporter.CommonClient)
finalityProviderInfos, err := commonapi.GetBabylonFinalityProviderInfos(exporter.CommonClient, exporter.ChainID)
if err != nil {
return types.BabylonFinalityProviderUptimeStatues{}, errors.Wrap(err, "failed to get babylon finality provider infos")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const finalitySigTimeout = 3

// NOTE: in this package, the missed height means fp didn't broadcast the finality sig tx in height+1 block
// for example, I didn't broadcast the tx at 100 block, that will make missed block for 99 height.
func (idx *FinalityProviderIndexer) batchSync(lastIndexPointerHeight int64) (
func (idx *FinalityProviderIndexer) batchSync(chainID string, lastIndexPointerHeight int64) (
/* new index pointer */ int64,
/* error */ error,
) {
Expand Down Expand Up @@ -135,7 +135,7 @@ func (idx *FinalityProviderIndexer) batchSync(lastIndexPointerHeight int64) (

// this logic will be progressed only when there are new tendermint validators in this block
if isNewFinalityProvider {
newfpInfoList, err := function.MakeFinalityProviderInfoList(idx.CommonClient, idx.ChainInfoID, newFinalityProviderMap)
newfpInfoList, err := function.MakeFinalityProviderInfoList(idx.CommonClient, chainID, idx.ChainInfoID, newFinalityProviderMap)
if err != nil {
errors.Wrap(err, "failed to make validator info list")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (idx *FinalityProviderIndexer) Loop(indexPoint int64) {
}

// trying to sync with new index pointer height
newIndexPointer, err := idx.batchSync(indexPoint)
newIndexPointer, err := idx.batchSync(idx.ChainID, indexPoint)
if err != nil {
common.Health.With(idx.RootLabels).Set(0)
common.Ops.With(idx.RootLabels).Inc()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ func TestBatchSync(t *testing.T) {
err = idx.FetchValidatorInfoList()
assert.NoError(t, err)

newIndexPointer, err := idx.batchSync(94810)
newIndexPointer, err := idx.batchSync(idx.ChainID, 94810)
assert.NoError(t, err)
t.Logf("new index point: %d", newIndexPointer)
}

func TestGetFinalityProvidersInfo(t *testing.T) {
app := common.NewCommonApp(p)
app.SetAPIEndPoint(BabylonBaseURL)
fpInfoList, err := api.GetBabylonFinalityProviderInfos(app.CommonClient)
chainID := "bbn-testnet-5"
fpInfoList, err := api.GetBabylonFinalityProviderInfos(app.CommonClient, chainID)
assert.NoError(t, err)
t.Logf("new fp infos: %d", len(fpInfoList))
for idx, fp := range fpInfoList {
Expand Down