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
8 changes: 7 additions & 1 deletion go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ cloud.google.com/go v0.118.3/go.mod h1:Lhs3YLnBlwJ4KA6nuObNMZ/fCbOQBPuWKPoE0Wa/9
cloud.google.com/go v0.120.0/go.mod h1:/beW32s8/pGRuj4IILWQNd4uuebeT4dkOhKmkfit64Q=
cloud.google.com/go v0.120.1/go.mod h1:56Vs7sf/i2jYM6ZL9NYlC82r04PThNcPS5YgFmb0rp8=
cloud.google.com/go v0.121.1/go.mod h1:nRFlrHq39MNVWu+zESP2PosMWA0ryJw8KUBZ2iZpxbw=
cloud.google.com/go v0.121.2/go.mod h1:nRFlrHq39MNVWu+zESP2PosMWA0ryJw8KUBZ2iZpxbw=
cloud.google.com/go/accessapproval v1.8.3 h1:axlU03FRiXDNupsmPG7LKzuS4Enk1gf598M62lWVB74=
cloud.google.com/go/accessapproval v1.8.3/go.mod h1:3speETyAv63TDrDmo5lIkpVueFkQcQchkiw/TAMbBo4=
cloud.google.com/go/accessapproval v1.8.6 h1:UkmDPCKvj24bkGVrvgJPcgSDkmIPw/bAmOiDb9avOiE=
Expand Down Expand Up @@ -87,6 +88,7 @@ cloud.google.com/go/auth v0.14.0/go.mod h1:CYsoRL1PdiDuqeQpZE0bP2pnPrGqFcOkI0nld
cloud.google.com/go/auth v0.15.0/go.mod h1:WJDGqZ1o9E9wKIL+IwStfyn/+s59zl4Bi+1KQNVXLZ8=
cloud.google.com/go/auth v0.16.0/go.mod h1:1howDHJ5IETh/LwYs3ZxvlkXF48aSqqJUM+5o02dNOI=
cloud.google.com/go/auth v0.16.1/go.mod h1:1howDHJ5IETh/LwYs3ZxvlkXF48aSqqJUM+5o02dNOI=
cloud.google.com/go/auth v0.16.2/go.mod h1:sRBas2Y1fB1vZTdurouM0AzuYQBMZinrUYL8EufhtEA=
cloud.google.com/go/auth/oauth2adapt v0.2.2/go.mod h1:wcYjgpZI9+Yu7LyYBg4pqSiaRkfEK3GQcpb7C/uyF1Q=
cloud.google.com/go/auth/oauth2adapt v0.2.6/go.mod h1:AlmsELtlEBnaNTL7jCj8VQFLy6mbZv0s4Q7NGBeQ5E8=
cloud.google.com/go/auth/oauth2adapt v0.2.7/go.mod h1:NTbTTzfvPl1Y3V1nPpOgl2w6d/FjO7NNUQaWSox6ZMc=
Expand Down Expand Up @@ -620,6 +622,8 @@ github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20190129172621-c8b1d7a94ddf
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0/go.mod h1:dppbR7CwXD4pgtV9t3wD1812RaLDcBjtblcDF5f1vI0=
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.2/go.mod h1:dppbR7CwXD4pgtV9t3wD1812RaLDcBjtblcDF5f1vI0=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0/go.mod h1:yAZHSGnqScoU556rBOVkwLze6WP5N+U11RHuWaGVxwY=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.51.0/go.mod h1:BnBReJLvVYx2CS/UHOgVz2BXKXD9wsQPxZug20nZhd0=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.51.0/go.mod h1:otE2jQekW/PqXk1Awf5lmfokJx4uwuqcj1ab5SpGeW0=
github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM=
github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
Expand Down Expand Up @@ -1213,6 +1217,7 @@ github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qK
github.com/googleapis/gax-go/v2 v2.12.3/go.mod h1:AKloxT6GtNbaLm8QTNSidHUVsHYcBHwWRvkNFJUQcS4=
github.com/googleapis/gax-go/v2 v2.14.0/go.mod h1:lhBCnjdLrWRaPvLWhmc8IS24m9mr07qSYnHncrgo+zk=
github.com/googleapis/gax-go/v2 v2.14.1/go.mod h1:Hb/NubMaVM88SrNkvl8X/o8XWwDJEPqouaLeN2IUxoA=
github.com/googleapis/gax-go/v2 v2.14.2/go.mod h1:ON64QhlJkhVtSqp4v1uaK92VyZ2gmvDQsweuyLV+8+w=
github.com/googleapis/go-type-adapters v1.0.0 h1:9XdMn+d/G57qq1s8dNc5IesGCXHf6V2HZ2JwRxfA2tA=
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8 h1:tlyzajkF3030q6M8SvmJSemC9DTHL/xaMa18b65+JM4=
github.com/googleapis/google-cloud-go-testing v0.0.0-20210719221736-1c9a4c676720/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
Expand Down Expand Up @@ -1591,7 +1596,6 @@ github.com/nishanths/exhaustive v0.8.3/go.mod h1:qj+zJJUgJ76tR92+25+03oYUhzF4R7/
github.com/nishanths/exhaustive v0.9.5/go.mod h1:IbwrGdVMizvDcIxPYGVdQn5BqWJaOwpCvg4RGb8r/TA=
github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ=
github.com/nunnatsa/ginkgolinter v0.9.0/go.mod h1:FHaMLURXP7qImeH6bvxWJUpyH+2tuqe5j4rW1gxJRmI=
github.com/nunnatsa/ginkgolinter v0.20.0/go.mod h1:dCIuFlTPfQerXgGUju3VygfAFPdC5aE1mdacCDKDJcQ=
github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae h1:FatpGJD2jmJfhZiFDElaC0QhZUDQnxUeAwTGkfAHN3I=
github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s=
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a h1:dlRvE5fWabOchtH7znfiFCcOvmIYgOeAS5ifBXBlh9Q=
Expand Down Expand Up @@ -2035,10 +2039,12 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.4
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0/go.mod h1:B9yO6b04uB80CzjedvewuqDhxJxi11s7/GtiGa8bAjI=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0/go.mod h1:rg+RlpR5dKwaS95IyyZqj5Wd4E13lk/msnTS0Xl9lJM=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0/go.mod h1:snMWehoOh2wsEwnvvwtDyFCxVeDAODenXHtn5vzrKjo=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0/go.mod h1:UHB22Z8QsdRDrnAtX4PntOl36ajSxcdUMt1sF7Y6E7Q=
go.opentelemetry.io/contrib/zpages v0.62.0/go.mod h1:C8kXoiC1Ytvereztus2R+kqdSa6W/MZ8FfS8Zwj+LiM=
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo=
Expand Down
1 change: 1 addition & 0 deletions x/interchainstaking/keeper/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ func AllBalancesCallback(k *Keeper, ctx sdk.Context, args []byte, query icqtypes
zone.PerformanceAddress.BalanceWaitgroup = 0
k.Logger(ctx).Info("zeroing performance balance waitgroup")
}
default:
}
k.SetZone(ctx, &zone)

Expand Down
1 change: 1 addition & 0 deletions x/interchainstaking/keeper/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func FuzzZones(f *testing.F) {
return
case "\n\t\n\x01K\x10\x0000(0", "\n\t\n\x030D0 0(0", "\n\t\n\x0301000(0":
return
default:
}

suite := new(FuzzingTestSuite)
Expand Down
1 change: 1 addition & 0 deletions x/interchainstaking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ func (k *Keeper) SetValidatorsForZone(ctx sdk.Context, data []byte, icqQuery icq
case val.Status != validator.Status.String():
k.Logger(ctx).Debug("bond status change; fetching proof", "valoper", validator.OperatorAddress, "from", val.Status, "to", validator.Status.String())
toQuery = true
default:
}

if toQuery {
Expand Down
22 changes: 15 additions & 7 deletions x/interchainstaking/keeper/zones_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package keeper_test
import (
"fmt"
"io"
"sort"
"slices"
"testing"
"time"

Expand Down Expand Up @@ -128,13 +128,21 @@ func TestKeeperWithZonesRoundTrip(t *testing.T) {
wantAllZones := maps.Values(gotZonesMapping)
require.Equal(t, nzones, len(gotAllZones), "expecting unique nzones")
// Sort them for determinism
sort.Slice(gotAllZones, func(i, j int) bool {
zi, zj := gotAllZones[i], gotAllZones[j]
return zi.ChainId < zj.ChainId
slices.SortFunc(gotAllZones, func(i, j types.Zone) int {
if i.ChainId < j.ChainId {
return -1
} else if i.ChainId > j.ChainId {
return 1
}
return 0
})
sort.Slice(wantAllZones, func(i, j int) bool {
zi, zj := wantAllZones[i], wantAllZones[j]
return zi.ChainId < zj.ChainId
slices.SortFunc(wantAllZones, func(i, j types.Zone) int {
if i.ChainId < j.ChainId {
return -1
} else if i.ChainId > j.ChainId {
return 1
}
return 0
})
require.Equal(t, wantAllZones, gotAllZones, "expecting the zones to match")

Expand Down
11 changes: 8 additions & 3 deletions x/interchainstaking/types/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package types

import (
"errors"
"sort"
"slices"

sdkmath "cosmossdk.io/math"

Expand Down Expand Up @@ -69,8 +69,13 @@ func (d Delegation) GetValidatorAddr() sdk.ValAddress {
type ValidatorIntents []*ValidatorIntent

func (vi ValidatorIntents) Sort() ValidatorIntents {
sort.SliceStable(vi, func(i, j int) bool {
return vi[i].ValoperAddress < vi[j].ValoperAddress
slices.SortStableFunc(vi, func(i, j *ValidatorIntent) int {
if i.ValoperAddress < j.ValoperAddress {
return -1
} else if i.ValoperAddress > j.ValoperAddress {
return 1
}
return 0
})
return vi
}
Expand Down
50 changes: 37 additions & 13 deletions x/interchainstaking/types/rebalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
"fmt"
"math"
"slices"
"sort"

sdkmath "cosmossdk.io/math"
Expand Down Expand Up @@ -102,14 +103,23 @@ func (deltas AllocationDeltas) Sort() {
deltas = newAllocationDeltas

// sort keys by relative value of delta
sort.SliceStable(deltas, func(i, j int) bool {
// < sorts alphabetically.
return deltas[i].ValoperAddress < deltas[j].ValoperAddress
slices.SortStableFunc(deltas, func(i, j *AllocationDelta) int {
if i.ValoperAddress < j.ValoperAddress {
return -1
} else if i.ValoperAddress > j.ValoperAddress {
return 1
}
return 0
})

// sort keys by relative value of delta
sort.SliceStable(deltas, func(i, j int) bool {
return deltas[i].Amount.GT(deltas[j].Amount)
slices.SortStableFunc(deltas, func(i, j *AllocationDelta) int {
if i.Amount.GT(j.Amount) {
return -1
} else if i.Amount.LT(j.Amount) {
return 1
}
return 0
})
}

Expand Down Expand Up @@ -180,20 +190,33 @@ type RebalanceTargets []*RebalanceTarget
// Sort RebalanceTargets deterministically.
func (tgts RebalanceTargets) Sort() {
// sort keys by relative value of delta
sort.SliceStable(tgts, func(i, j int) bool {
// < sorts alphabetically.
return tgts[i].Source < tgts[j].Source
slices.SortStableFunc(tgts, func(i, j *RebalanceTarget) int {
if i.Source < j.Source {
return -1
} else if i.Source > j.Source {
return 1
}
return 0
})

// sort keys by relative value of delta
sort.SliceStable(tgts, func(i, j int) bool {
// < sorts alphabetically.
return tgts[i].Target < tgts[j].Target
slices.SortStableFunc(tgts, func(i, j *RebalanceTarget) int {
if i.Target < j.Target {
return -1
} else if i.Target > j.Target {
return 1
}
return 0
})

// sort keys by relative value of delta
sort.SliceStable(tgts, func(i, j int) bool {
return tgts[i].Amount.LT(tgts[j].Amount)
slices.SortStableFunc(tgts, func(i, j *RebalanceTarget) int {
if i.Amount.LT(j.Amount) {
return -1
} else if i.Amount.GT(j.Amount) {
return 1
}
return 0
})
}

Expand Down Expand Up @@ -272,6 +295,7 @@ TARGET:
continue TARGET
}
// otherwise, try next source.
default:
}
}
// we only get here if we are unable to satisfy targets due to rebalanceBudget depletion.
Expand Down
11 changes: 8 additions & 3 deletions x/supply/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package keeper
import (
"bytes"
"fmt"
"sort"
"slices"

"cosmossdk.io/math"

Expand Down Expand Up @@ -128,8 +128,13 @@ func (k Keeper) TopN(ctx sdk.Context, baseDenom string, n uint64) []*types.Accou
accountSlice = append(accountSlice, &types.Account{Address: addr, Balance: balance})
}

sort.Slice(accountSlice, func(i, j int) bool {
return accountSlice[i].Balance.GT(accountSlice[j].Balance)
slices.SortFunc(accountSlice, func(i, j *types.Account) int {
if i.Balance.GT(j.Balance) {
return -1
} else if i.Balance.LT(j.Balance) {
return 1
}
return 0
})

if n > uint64(len(accountSlice)) {
Expand Down
Loading