Skip to content

Commit 6f30de3

Browse files
authored
refactor: remove x/exp dep (#21281)
1 parent 294b608 commit 6f30de3

File tree

37 files changed

+115
-122
lines changed

37 files changed

+115
-122
lines changed

baseapp/baseapp.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"maps"
78
"math"
8-
"sort"
9+
"slices"
910
"strconv"
1011
"sync"
1112

@@ -14,7 +15,6 @@ import (
1415
"github.com/cometbft/cometbft/crypto/tmhash"
1516
dbm "github.com/cosmos/cosmos-db"
1617
"github.com/cosmos/gogoproto/proto"
17-
"golang.org/x/exp/maps"
1818
"google.golang.org/protobuf/reflect/protoreflect"
1919

2020
"cosmossdk.io/core/header"
@@ -340,8 +340,7 @@ func (app *BaseApp) MountTransientStores(keys map[string]*storetypes.TransientSt
340340
// MountMemoryStores mounts all in-memory KVStores with the BaseApp's internal
341341
// commit multi-store.
342342
func (app *BaseApp) MountMemoryStores(keys map[string]*storetypes.MemoryStoreKey) {
343-
skeys := maps.Keys(keys)
344-
sort.Strings(skeys)
343+
skeys := slices.Sorted(maps.Keys(keys))
345344
for _, key := range skeys {
346345
memKey := keys[key]
347346
app.MountStore(memKey, storetypes.StoreTypeMemory)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ require (
5757
github.com/tendermint/go-amino v0.16.0
5858
gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b
5959
golang.org/x/crypto v0.26.0
60-
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc
6160
golang.org/x/sync v0.8.0
6261
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157
6362
google.golang.org/grpc v1.65.0
@@ -164,6 +163,7 @@ require (
164163
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
165164
go.opencensus.io v0.24.0 // indirect
166165
go.uber.org/multierr v1.11.0 // indirect
166+
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
167167
golang.org/x/mod v0.17.0 // indirect
168168
golang.org/x/net v0.28.0 // indirect
169169
golang.org/x/sys v0.24.0 // indirect

runtime/v2/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package runtime
33
import (
44
"encoding/json"
55
"errors"
6+
"slices"
67

78
gogoproto "github.com/cosmos/gogoproto/proto"
8-
"golang.org/x/exp/slices"
99

1010
runtimev2 "cosmossdk.io/api/cosmos/app/runtime/v2"
1111
"cosmossdk.io/core/legacy"

runtime/v2/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ require (
2424
cosmossdk.io/x/tx v0.13.3
2525
github.com/cosmos/gogoproto v1.7.0
2626
github.com/spf13/viper v1.19.0
27-
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc
2827
google.golang.org/grpc v1.65.0
2928
google.golang.org/protobuf v1.34.2
3029
)
@@ -91,6 +90,7 @@ require (
9190
github.com/tidwall/btree v1.7.0 // indirect
9291
go.uber.org/multierr v1.11.0 // indirect
9392
golang.org/x/crypto v0.26.0 // indirect
93+
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
9494
golang.org/x/net v0.28.0 // indirect
9595
golang.org/x/sync v0.8.0 // indirect
9696
golang.org/x/sys v0.24.0 // indirect

runtime/v2/manager.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"maps"
89
"reflect"
10+
"slices"
911
"sort"
1012

1113
gogoproto "github.com/cosmos/gogoproto/proto"
12-
"golang.org/x/exp/maps"
1314
"google.golang.org/grpc"
1415
proto "google.golang.org/protobuf/proto"
1516
"google.golang.org/protobuf/reflect/protoreflect"
@@ -41,7 +42,7 @@ func NewModuleManager[T transaction.Tx](
4142
modules map[string]appmodulev2.AppModule,
4243
) *MM[T] {
4344
// good defaults for the module manager order
44-
modulesName := maps.Keys(modules)
45+
modulesName := slices.Sorted(maps.Keys(modules))
4546
if len(config.PreBlockers) == 0 {
4647
config.PreBlockers = modulesName
4748
}

scripts/dep-assert.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ done
2222
# no runtime/v2 or server/v2 imports in x/ modules
2323
RUNTIMEV2_REGEX="cosmossdk.io/runtime/v2"
2424
SEVERV2_REGEX="cosmossdk.io/server/v2"
25+
XEXP_REGEX="golang.org/x/exp"
2526
find ./x/ -type f -name 'go.mod' -print0 | while IFS= read -r -d '' file
2627
do
2728
d=$(dirname "$file")
@@ -34,4 +35,9 @@ do
3435
echo "${d} has a dependency on server/v2!"
3536
exit 1
3637
fi
38+
39+
if cd "$CWD/$d" && go list -test -f '{{ .Imports }}' ./... | grep -q -E "${XEXP_REGEX}"; then
40+
echo "${d} has a dependency on golang.org/x/exp"
41+
exit 1
42+
fi
3743
done

server/v2/api/grpc/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"errors"
66
"fmt"
77
"io"
8+
"maps"
89
"net"
10+
"slices"
911
"strconv"
1012

1113
"github.com/cosmos/gogoproto/proto"
1214
"github.com/spf13/pflag"
1315
"github.com/spf13/viper"
14-
"golang.org/x/exp/maps"
1516
"google.golang.org/grpc"
1617
"google.golang.org/grpc/codes"
1718
"google.golang.org/grpc/metadata"
@@ -65,7 +66,7 @@ func (s *Server[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logge
6566
)
6667

6768
// Reflection allows external clients to see what services and methods the gRPC server exposes.
68-
gogoreflection.Register(grpcSrv, maps.Keys(methodsMap), logger.With("sub-module", "grpc-reflection"))
69+
gogoreflection.Register(grpcSrv, slices.Collect(maps.Keys(methodsMap)), logger.With("sub-module", "grpc-reflection"))
6970

7071
s.grpcSrv = grpcSrv
7172
s.config = cfg

server/v2/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ require (
3838
github.com/spf13/pflag v1.0.5
3939
github.com/spf13/viper v1.19.0
4040
github.com/stretchr/testify v1.9.0
41-
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc
4241
golang.org/x/sync v0.8.0
4342
google.golang.org/grpc v1.65.0
4443
google.golang.org/protobuf v1.34.2
@@ -102,6 +101,7 @@ require (
102101
github.com/tidwall/btree v1.7.0 // indirect
103102
go.uber.org/multierr v1.11.0 // indirect
104103
golang.org/x/crypto v0.26.0 // indirect
104+
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
105105
golang.org/x/mod v0.17.0 // indirect
106106
golang.org/x/net v0.28.0 // indirect
107107
golang.org/x/sys v0.24.0 // indirect

server/v2/stf/core_event_service.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"bytes"
55
"context"
66
"encoding/json"
7+
"maps"
78
"slices"
89

910
"github.com/cosmos/gogoproto/jsonpb"
1011
gogoproto "github.com/cosmos/gogoproto/proto"
11-
"golang.org/x/exp/maps"
1212

1313
"cosmossdk.io/core/event"
1414
transaction "cosmossdk.io/core/transaction"
@@ -49,12 +49,6 @@ func (em *eventManager) EmitKV(eventType string, attrs ...event.Attribute) error
4949
return nil
5050
}
5151

52-
// EmitNonConsensus emits an typed event that is defined in the protobuf file.
53-
// These events will not be added to consensus.
54-
func (em *eventManager) EmitNonConsensus(event transaction.Msg) error {
55-
return em.Emit(event)
56-
}
57-
5852
// TypedEventToEvent takes typed event and converts to Event object
5953
func TypedEventToEvent(tev transaction.Msg) (event.Event, error) {
6054
evtType := gogoproto.MessageName(tev)
@@ -70,9 +64,7 @@ func TypedEventToEvent(tev transaction.Msg) (event.Event, error) {
7064
}
7165

7266
// sort the keys to ensure the order is always the same
73-
keys := maps.Keys(attrMap)
74-
slices.Sort(keys)
75-
67+
keys := slices.Sorted(maps.Keys(attrMap))
7668
attrs := make([]event.Attribute, 0, len(attrMap))
7769
for _, k := range keys {
7870
v := attrMap[k]

server/v2/stf/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ require (
99
github.com/cosmos/gogoproto v1.7.0
1010
github.com/stretchr/testify v1.9.0
1111
github.com/tidwall/btree v1.7.0
12-
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
1312
)
1413

1514
require (
1615
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1716
github.com/google/go-cmp v0.6.0 // indirect
1817
github.com/pmezard/go-difflib v1.0.0 // indirect
18+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
1919
google.golang.org/protobuf v1.34.2 // indirect
2020
gopkg.in/yaml.v3 v3.0.1 // indirect
2121
)

0 commit comments

Comments
 (0)