Skip to content

Commit b674d00

Browse files
authored
Merge branch 'cosmostation:develop' into develop
2 parents e02a397 + f03d602 commit b674d00

File tree

6 files changed

+53
-24
lines changed

6 files changed

+53
-24
lines changed

docker/cvms/support_chains.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ akashnet-2:
2929
- upgrade
3030
- uptime
3131
- voteindexer
32+
allora-mainnet-1:
33+
chain_name: allora
34+
protocol_type: cosmos
35+
mainnet: true
36+
support_asset:
37+
denom: uallo
38+
decimal: 6
39+
packages:
40+
- block
41+
- upgrade
42+
- uptime
43+
- voteindexer
3244
allora-testnet-1:
3345
chain_name: allora
3446
protocol_type: cosmos
@@ -449,7 +461,7 @@ deluge-1:
449461
- block
450462
- upgrade
451463
- uptime
452-
- voteindexer
464+
- voteindexer
453465
evmos_9000-4:
454466
chain_name: evmos
455467
protocol_type: cosmos
@@ -1267,7 +1279,7 @@ imuachaintestnet_233-8:
12671279
- block
12681280
- upgrade
12691281
# - uptime
1270-
# - voteindexer
1282+
# - voteindexer
12711283
selfchain-testnet:
12721284
chain_name: selfchain
12731285
protocol_type: cosmos
@@ -1364,7 +1376,7 @@ union-testnet-9:
13641376
- block
13651377
- upgrade
13661378
- uptime
1367-
- voteindexer
1379+
- voteindexer
13681380
union-1:
13691381
chain_name: union
13701382
protocol_type: cosmos
@@ -1412,7 +1424,7 @@ xrplevm_1449000-1:
14121424
- block
14131425
- upgrade
14141426
- uptime
1415-
- voteindexer
1427+
- voteindexer
14161428
zetachain_7000-1:
14171429
chain_name: zeta
14181430
protocol_type: cosmos

internal/common/api/babylon.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,21 @@ func GetFinalityProviderUptime(c common.CommonClient, fpInfoList []types.Finalit
114114
jailed := item.Jailed
115115
active := item.Active
116116
vp := item.VotingPower
117-
117+
slashedBTCHeight := item.SlashedBTCHeight
118+
status := "active"
118119
queryPath := types.BabylonFinalityProviderSigninInfoQueryPath(item.BTCPK)
119120
go func(ch chan helper.Result) {
120121
defer helper.HandleOutOfNilResponse(c.Entry)
121122
defer wg.Done()
122123

124+
if jailed {
125+
status = "jailed"
126+
}
127+
128+
if slashedBTCHeight > 0 {
129+
status = "slashed"
130+
}
131+
123132
if !active {
124133
ch <- helper.Result{
125134
Success: true,
@@ -128,7 +137,7 @@ func GetFinalityProviderUptime(c common.CommonClient, fpInfoList []types.Finalit
128137
Address: Address,
129138
BTCPK: BTCPK,
130139
MissedBlockCounter: 0,
131-
Jailed: strconv.FormatBool(jailed),
140+
Status: status,
132141
Active: strconv.FormatBool(active),
133142
VotingPower: 0,
134143
}}
@@ -167,7 +176,7 @@ func GetFinalityProviderUptime(c common.CommonClient, fpInfoList []types.Finalit
167176
Address: Address,
168177
BTCPK: BTCPK,
169178
MissedBlockCounter: missedBlockCounter,
170-
Jailed: strconv.FormatBool(jailed),
179+
Status: status,
171180
Active: strconv.FormatBool(active),
172181
VotingPower: vp,
173182
}}

internal/common/types/babylon.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ type FinalityProviderInfo struct {
5353
Description struct {
5454
Moniker string `json:"moniker"`
5555
} `json:"description"`
56-
Address string `json:"addr"`
57-
BTCPK string `json:"btc_pk"`
58-
Jailed bool `json:"jailed"`
56+
Address string `json:"addr"`
57+
BTCPK string `json:"btc_pk"`
58+
Jailed bool `json:"jailed"`
59+
SlashedBabylonHeight string `json:"slashed_babylon_height"`
60+
SlashedBTCHeight int `json:"slashed_btc_height"`
5961
// injected
62+
Slashed bool
6063
Active bool
6164
VotingPower float64
6265
}

internal/packages/babylon/finality-provider/api/api.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ func GetFinalityProviderUptime(exporter *common.Exporter) (types.BabylonFinality
3434

3535
exporter.Debugf("got active finality providers: %d", len(activeProviders))
3636

37-
fpInfoList, jailedCnt := addActiveStatus(activeProviders, finalityProviderInfos)
37+
fpInfoList, jailedCnt, slashedCnt := addActiveStatus(activeProviders, finalityProviderInfos)
3838
fpTotal := types.FinalityProviderTotal{
3939
Active: len(activeProviders),
4040
Inactive: len(finalityProviderInfos) - len(activeProviders),
4141
Jailed: jailedCnt,
42-
Unjailed: len(finalityProviderInfos) - jailedCnt,
42+
Slashed: slashedCnt,
4343
}
4444

4545
// 5. get lity providers' uptime status
@@ -84,19 +84,24 @@ func GetFinalityProviderUptime(exporter *common.Exporter) (types.BabylonFinality
8484
}, nil
8585
}
8686

87-
func addActiveStatus(activeProviders []commontypes.FinalityProvider, finalityProviderInfos []commontypes.FinalityProviderInfo) ([]commontypes.FinalityProviderInfo, int) {
87+
func addActiveStatus(activeProviders []commontypes.FinalityProvider, finalityProviderInfos []commontypes.FinalityProviderInfo) ([]commontypes.FinalityProviderInfo, int, int) {
8888
activeFpMap := make(map[string]commontypes.FinalityProvider, len(activeProviders))
8989
for _, fp := range activeProviders {
9090
activeFpMap[fp.BtcPkHex] = fp
9191
}
9292

9393
jailedCnt := 0
94+
slashedCnt := 0
9495
// Modify the original slice using index-based iteration
9596
for i := range finalityProviderInfos {
9697
if finalityProviderInfos[i].Jailed {
9798
jailedCnt++
9899
}
99100

101+
if finalityProviderInfos[i].SlashedBTCHeight > 0 {
102+
slashedCnt++
103+
}
104+
100105
fp, exist := activeFpMap[finalityProviderInfos[i].BTCPK]
101106
if exist {
102107
// NOTE: fp.VotingPower must will be integer, so no need to check error
@@ -106,7 +111,7 @@ func addActiveStatus(activeProviders []commontypes.FinalityProvider, finalityPro
106111
}
107112
}
108113

109-
return finalityProviderInfos, jailedCnt
114+
return finalityProviderInfos, jailedCnt, slashedCnt
110115
}
111116

112117
func getLastFinalizedBlockInfo(votes []string, fps []commontypes.FinalityProvider) types.LastFinalizedBlockInfo {

internal/packages/babylon/finality-provider/collector/collector.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const (
3030
LastFinalizedBlockMissingVPMetricName = "last_finalized_block_missing_vp"
3131
LastFinalizedBlockFinalizedVPMetricName = "last_finalized_block_finalized_vp"
3232

33-
METRIC_NAME_FINALITY_PROVIDERS_TOTAL = "finality_providers_total"
33+
METRIC_NAME_FINALITY_PROVIDERS_TOTAL = "total"
3434
)
3535

3636
func Start(p common.Packager) error {
@@ -65,7 +65,7 @@ func loop(exporter *common.Exporter, p common.Packager) {
6565
common.MonikerLabel,
6666
common.OrchestratorAddressLabel,
6767
common.BTCPKLabel,
68-
common.JailedLabel,
68+
common.StatusLabel,
6969
common.ActiveLabel,
7070
})
7171

@@ -78,7 +78,7 @@ func loop(exporter *common.Exporter, p common.Packager) {
7878
common.MonikerLabel,
7979
common.OrchestratorAddressLabel,
8080
common.BTCPKLabel,
81-
common.JailedLabel,
81+
common.StatusLabel,
8282
common.ActiveLabel,
8383
})
8484

@@ -176,7 +176,7 @@ func loop(exporter *common.Exporter, p common.Packager) {
176176
common.MonikerLabel: item.Moniker,
177177
common.BTCPKLabel: item.BTCPK,
178178
common.OrchestratorAddressLabel: item.Address,
179-
common.JailedLabel: item.Jailed,
179+
common.StatusLabel: item.Status,
180180
common.ActiveLabel: item.Active,
181181
}).
182182
Set(float64(item.MissedBlockCounter))
@@ -187,7 +187,7 @@ func loop(exporter *common.Exporter, p common.Packager) {
187187
common.MonikerLabel: item.Moniker,
188188
common.BTCPKLabel: item.BTCPK,
189189
common.OrchestratorAddressLabel: item.Address,
190-
common.JailedLabel: item.Jailed,
190+
common.StatusLabel: item.Status,
191191
common.ActiveLabel: item.Active,
192192
}).
193193
Set(item.VotingPower)
@@ -197,7 +197,7 @@ func loop(exporter *common.Exporter, p common.Packager) {
197197
fpTotalMetric.With(prometheus.Labels{common.StatusLabel: "active"}).Set(float64(status.FinalityProviderTotal.Active))
198198
fpTotalMetric.With(prometheus.Labels{common.StatusLabel: "inactive"}).Set(float64(status.FinalityProviderTotal.Inactive))
199199
fpTotalMetric.With(prometheus.Labels{common.StatusLabel: "jailed"}).Set(float64(status.FinalityProviderTotal.Jailed))
200-
fpTotalMetric.With(prometheus.Labels{common.StatusLabel: "unjailed"}).Set(float64(status.FinalityProviderTotal.Unjailed))
200+
fpTotalMetric.With(prometheus.Labels{common.StatusLabel: "slashed"}).Set(float64(status.FinalityProviderTotal.Slashed))
201201
} else {
202202
for _, item := range status.FinalityProvidersStatus {
203203
if ok := helper.Contains(exporter.Monikers, item.Moniker); ok {
@@ -206,7 +206,7 @@ func loop(exporter *common.Exporter, p common.Packager) {
206206
common.MonikerLabel: item.Moniker,
207207
common.BTCPKLabel: item.BTCPK,
208208
common.OrchestratorAddressLabel: item.Address,
209-
common.JailedLabel: item.Jailed,
209+
common.StatusLabel: item.Status,
210210
common.ActiveLabel: item.Active,
211211
}).
212212
Set(float64(item.MissedBlockCounter))
@@ -217,7 +217,7 @@ func loop(exporter *common.Exporter, p common.Packager) {
217217
common.MonikerLabel: item.Moniker,
218218
common.BTCPKLabel: item.BTCPK,
219219
common.OrchestratorAddressLabel: item.Address,
220-
common.JailedLabel: item.Jailed,
220+
common.StatusLabel: item.Status,
221221
common.ActiveLabel: item.Active,
222222
}).
223223
Set(item.VotingPower)

internal/packages/babylon/finality-provider/types/status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type FinalityProviderUptimeStatus struct {
1414
BTCPK string
1515
MissedBlockCounter float64
1616
Active string
17-
Jailed string
17+
Status string
1818
VotingPower float64
1919
}
2020

@@ -28,5 +28,5 @@ type FinalityProviderTotal struct {
2828
Active int
2929
Inactive int
3030
Jailed int
31-
Unjailed int
31+
Slashed int
3232
}

0 commit comments

Comments
 (0)