Skip to content

Commit 1cb7f8e

Browse files
authored
Removed experimental maps package (#1257)
1 parent bad5838 commit 1cb7f8e

File tree

21 files changed

+82
-75
lines changed

21 files changed

+82
-75
lines changed

cmd/carpenter/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250422094245-d734371d67f2
99
github.com/stretchr/testify v1.10.0
1010
github.com/urfave/cli/v3 v3.0.0-beta1
11-
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
1211
golang.org/x/term v0.31.0
1312
)
1413

@@ -48,6 +47,7 @@ require (
4847
go.uber.org/multierr v1.11.0 // indirect
4948
go.uber.org/zap v1.27.0 // indirect
5049
golang.org/x/crypto v0.36.0 // indirect
50+
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
5151
golang.org/x/sync v0.13.0 // indirect
5252
golang.org/x/sys v0.32.0 // indirect
5353
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect

cmd/carpenter/internal/format/summary/summary.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ package summary
33

44
import (
55
"fmt"
6-
"sort"
7-
8-
"golang.org/x/exp/maps"
6+
"maps"
7+
"slices"
98

109
"github.com/smartcontractkit/chainlink-ccip/cmd/carpenter/internal/format"
1110
"github.com/smartcontractkit/chainlink-ccip/cmd/carpenter/internal/parse"
@@ -54,24 +53,20 @@ func (sr summaryFormatter) Format(data *parse.Data) {
5453
}
5554

5655
func (sr summaryFormatter) Close() error {
57-
dons := maps.Keys(sr.commits)
58-
sort.Ints(dons)
56+
dons := slices.Sorted(maps.Keys(sr.commits))
5957
for _, donID := range dons {
6058
fmt.Println("Commit Summary for DON", donID)
61-
keys := maps.Keys(sr.commits[donID])
62-
sort.Ints(keys)
59+
keys := slices.Sorted(maps.Keys(sr.commits[donID]))
6360
for _, key := range keys {
6461
fmt.Println(sr.commits[donID][key].String())
6562
}
6663
fmt.Println()
6764
}
6865

69-
dons = maps.Keys(sr.execs)
70-
sort.Ints(dons)
66+
dons = slices.Sorted(maps.Keys(sr.execs))
7167
for _, donID := range dons {
7268
fmt.Println("Commit logs for DON", donID)
73-
keys := maps.Keys(sr.execs[donID])
74-
sort.Ints(keys)
69+
keys := slices.Sorted(maps.Keys(sr.execs[donID]))
7570
for _, key := range keys {
7671
fmt.Println(sr.execs[donID][key].String())
7772
}

commit/chainfee/observation.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package chainfee
22

33
import (
44
"context"
5+
"maps"
56
"math/big"
7+
"slices"
68
"time"
79

810
mapset "github.com/deckarep/golang-set/v2"
9-
"golang.org/x/exp/maps"
1011

1112
"github.com/smartcontractkit/chainlink-common/pkg/logger"
1213
"github.com/smartcontractkit/chainlink-common/pkg/types"
@@ -62,13 +63,13 @@ func (p *processor) Observation(
6263
asynclib.WaitForAllNoErrOperations(ctx, p.cfg.ChainFeeAsyncObserverSyncTimeout, operations, lggr)
6364
now := time.Now().UTC()
6465

65-
chainsWithNativeTokenPrices := mapset.NewSet(maps.Keys(feeComponents)...).
66+
chainsWithNativeTokenPrices := mapset.NewSet(slices.Collect(maps.Keys(feeComponents))...).
6667
Intersect(
67-
mapset.NewSet(maps.Keys(nativeTokenPrices)...),
68+
mapset.NewSet(slices.Collect(maps.Keys(nativeTokenPrices))...),
6869
)
69-
chainsWithoutNativeTokenPrices := mapset.NewSet(maps.Keys(feeComponents)...).
70+
chainsWithoutNativeTokenPrices := mapset.NewSet(slices.Collect(maps.Keys(feeComponents))...).
7071
Difference(
71-
mapset.NewSet(maps.Keys(nativeTokenPrices)...),
72+
mapset.NewSet(slices.Collect(maps.Keys(nativeTokenPrices))...),
7273
)
7374

7475
lggr.Infow("observed fee components",

commit/chainfee/observation_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package chainfee
22

33
import (
4+
"maps"
45
"math/big"
56
"math/rand"
7+
"slices"
68
"sort"
79
"testing"
810
"time"
911

1012
"github.com/stretchr/testify/mock"
11-
"golang.org/x/exp/maps"
1213

1314
mapset "github.com/deckarep/golang-set/v2"
1415
"github.com/stretchr/testify/require"
@@ -187,11 +188,11 @@ func Test_processor_Observation(t *testing.T) {
187188
require.GreaterOrEqual(t, obs.TimestampNow.UnixNano(), tStart.UnixNano())
188189
require.LessOrEqual(t, obs.TimestampNow.UnixNano(), tEnd.UnixNano())
189190
require.Equal(t, tc.chainFeeComponents, obs.FeeComponents)
190-
require.ElementsMatch(t, slicesWithoutDst, maps.Keys(obs.FeeComponents))
191+
require.ElementsMatch(t, slicesWithoutDst, slices.Collect(maps.Keys(obs.FeeComponents)))
191192
require.Equal(t, tc.nativeTokenPrices, obs.NativeTokenPrices)
192-
require.ElementsMatch(t, slicesWithoutDst, maps.Keys(obs.NativeTokenPrices))
193+
require.ElementsMatch(t, slicesWithoutDst, slices.Collect(maps.Keys(obs.NativeTokenPrices)))
193194
require.Equal(t, tc.expectedChainFeePriceUpdates, obs.ChainFeeUpdates)
194-
require.ElementsMatch(t, slicesWithoutDst, maps.Keys(obs.ChainFeeUpdates))
195+
require.ElementsMatch(t, slicesWithoutDst, slices.Collect(maps.Keys(obs.ChainFeeUpdates)))
195196
require.Equal(t, tc.fChain, obs.FChain)
196197
})
197198
}
@@ -385,9 +386,12 @@ func Test_unique_chain_filter_in_Observation(t *testing.T) {
385386
return
386387
}
387388

388-
require.True(t, tc.expUniqueChains == len(maps.Keys(obs.FeeComponents)))
389-
require.True(t, tc.expUniqueChains == len(maps.Keys(obs.NativeTokenPrices)))
390-
require.ElementsMatch(t, maps.Keys(obs.FeeComponents), maps.Keys(obs.NativeTokenPrices))
389+
require.True(t, tc.expUniqueChains == len(obs.FeeComponents))
390+
require.True(t, tc.expUniqueChains == len(obs.NativeTokenPrices))
391+
require.ElementsMatch(t,
392+
slices.Collect(maps.Keys(obs.FeeComponents)),
393+
slices.Collect(maps.Keys(obs.NativeTokenPrices)),
394+
)
391395
})
392396
}
393397
}

commit/chainfee/validate_observation.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ package chainfee
22

33
import (
44
"fmt"
5+
"maps"
56
"math/big"
7+
"slices"
68
"time"
79

810
mapset "github.com/deckarep/golang-set/v2"
911

1012
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
1113

1214
"github.com/smartcontractkit/chainlink-ccip/internal/plugincommon"
13-
14-
"golang.org/x/exp/maps"
1515
)
1616

1717
func (p *processor) ValidateObservation(
@@ -112,7 +112,10 @@ func validateObservedChains(
112112
return fmt.Errorf("fee components and native token prices have different observed chains")
113113
}
114114

115-
observedChains := append(maps.Keys(obs.FeeComponents), maps.Keys(obs.NativeTokenPrices)...)
115+
observedChains := append(
116+
slices.Collect(maps.Keys(obs.FeeComponents)),
117+
slices.Collect(maps.Keys(obs.NativeTokenPrices))...,
118+
)
116119
if len(obs.ChainFeeUpdates) > 0 {
117120
// chainFeeUpdates are read from the destination chain, if the oracle observed any chain fee updates
118121
// it should support the destination chain.

commit/merkleroot/observation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"encoding/hex"
77
"errors"
88
"fmt"
9+
"maps"
910
"testing"
1011

1112
mapset "github.com/deckarep/golang-set/v2"
1213
"github.com/stretchr/testify/assert"
1314
"github.com/stretchr/testify/mock"
1415
"github.com/stretchr/testify/require"
15-
"golang.org/x/exp/maps"
1616

1717
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
1818
types2 "github.com/smartcontractkit/libocr/offchainreporting2plus/types"

commit/merkleroot/outcome.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package merkleroot
33
import (
44
"context"
55
"fmt"
6+
"maps"
7+
"slices"
68
"sort"
79
"time"
810

9-
"golang.org/x/exp/maps"
10-
1111
mapset "github.com/deckarep/golang-set/v2"
1212

1313
"github.com/smartcontractkit/chainlink-common/pkg/logger"
@@ -189,7 +189,7 @@ func buildMerkleRootsOutcome(
189189
prevOutcome Outcome,
190190
addressCodec cciptypes.AddressCodec,
191191
) (Outcome, error) {
192-
roots := maps.Values(consensusObservation.MerkleRoots)
192+
roots := slices.Collect(maps.Values(consensusObservation.MerkleRoots))
193193

194194
outcomeType := ReportGenerated
195195
if len(roots) == 0 {

commit/merkleroot/rmn/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
"encoding/binary"
1111
"errors"
1212
"fmt"
13+
"maps"
1314
"math/rand"
1415
"slices"
1516
"sort"
1617
"time"
1718

1819
mapset "github.com/deckarep/golang-set/v2"
19-
"golang.org/x/exp/maps"
2020
"google.golang.org/protobuf/proto"
2121

2222
typconv "github.com/smartcontractkit/chainlink-ccip/internal/libs/typeconv"
@@ -585,7 +585,7 @@ func chainsWithSufficientObservationResponses(
585585
continue
586586
}
587587

588-
mostVotedRootVotes := slices.Max(maps.Values(countsPerRoot))
588+
mostVotedRootVotes := slices.Max(slices.Collect(maps.Values(countsPerRoot)))
589589
if consensus.LtFPlusOne(fObserve, mostVotedRootVotes) {
590590
lggr.Infow("chain skipped, maximally voted root doesn't have enough votes",
591591
"chain", sourceChain,

commit/report.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"encoding/hex"
77
"errors"
88
"fmt"
9+
"maps"
10+
"slices"
911
"sort"
1012
"time"
1113

1214
mapset "github.com/deckarep/golang-set/v2"
1315

14-
"golang.org/x/exp/maps"
15-
1616
"github.com/smartcontractkit/chainlink-common/pkg/logger"
1717
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
1818

@@ -87,7 +87,7 @@ func (p *Plugin) Reports(
8787

8888
transmissionSchedule, err := plugincommon.GetTransmissionSchedule(
8989
p.chainSupport,
90-
maps.Keys(p.oracleIDToP2PID),
90+
slices.Collect(maps.Keys(p.oracleIDToP2PID)),
9191
p.offchainCfg.TransmissionDelayMultiplier,
9292
)
9393
if err != nil {

commit/tokenprice/observation.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ package tokenprice
22

33
import (
44
"context"
5-
"sort"
5+
"maps"
6+
"slices"
67
"sync"
78
"time"
89

9-
"golang.org/x/exp/maps"
10-
1110
"github.com/smartcontractkit/chainlink-common/pkg/logger"
1211
"github.com/smartcontractkit/libocr/commontypes"
1312

@@ -128,7 +127,7 @@ func (b *baseObserver) observeFeedTokenPrices(ctx context.Context, lggr logger.L
128127
return cciptypes.TokenPriceMap{}
129128
}
130129

131-
tokensToQuery := maps.Keys(b.offChainCfg.TokenInfo)
130+
tokensToQuery := slices.Collect(maps.Keys(b.offChainCfg.TokenInfo))
132131
lggr.Infow("observing feed token prices", "tokens", tokensToQuery)
133132
tokenPrices, err := b.tokenPriceReader.GetFeedPricesUSD(ctx, tokensToQuery)
134133
if err != nil {
@@ -158,9 +157,8 @@ func (b *baseObserver) observeFeeQuoterTokenUpdates(
158157
return map[cciptypes.UnknownEncodedAddress]cciptypes.TimestampedBig{}
159158
}
160159

161-
tokensToQuery := maps.Keys(b.offChainCfg.TokenInfo)
162160
// sort tokens to query to ensure deterministic order
163-
sort.Slice(tokensToQuery, func(i, j int) bool { return tokensToQuery[i] < tokensToQuery[j] })
161+
tokensToQuery := slices.Sorted(maps.Keys(b.offChainCfg.TokenInfo))
164162
lggr.Infow("observing fee quoter token updates")
165163
priceUpdates, err := b.tokenPriceReader.GetFeeQuoterTokenUpdates(ctx, tokensToQuery, b.destChain)
166164
if err != nil {

0 commit comments

Comments
 (0)