Skip to content

Commit

Permalink
switch from exp/slices pkg to the stable (#10852)
Browse files Browse the repository at this point in the history
* switch from using the exp_slices pkg to the stable slices pkg

* Update core/services/vrf/v2/listener_v2.go

Co-authored-by: Jordan Krage <[email protected]>

* use compare instead of naive responses

* add cmp pkg

---------

Co-authored-by: Jordan Krage <[email protected]>
  • Loading branch information
poopoothegorilla and jmank88 authored Oct 5, 2023
1 parent efcf9f4 commit d030e2c
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion common/txmgr/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"encoding/json"
"fmt"
"math/big"
"slices"
"strings"
"time"

"github.com/google/uuid"
"github.com/pkg/errors"
"golang.org/x/exp/slices"
"gopkg.in/guregu/null.v4"

feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types"
Expand Down
2 changes: 1 addition & 1 deletion core/chains/cosmos/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package cosmos
import (
"fmt"
"net/url"
"slices"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/pelletier/go-toml/v2"
"github.com/shopspring/decimal"
"go.uber.org/multierr"
"golang.org/x/exp/slices"

coscfg "github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/config"
"github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/db"
Expand Down
12 changes: 8 additions & 4 deletions core/chains/cosmos/cosmostxm/txm.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package cosmostxm

import (
"cmp"
"context"
"encoding/hex"
"slices"
"strings"
"time"

"github.com/gogo/protobuf/proto"
"github.com/pkg/errors"
"golang.org/x/exp/slices"

"github.com/smartcontractkit/sqlx"

Expand Down Expand Up @@ -176,12 +177,15 @@ func (e *msgValidator) add(msg adapters.Msg) {
}

func (e *msgValidator) sortValid() {
slices.SortFunc(e.valid, func(a, b adapters.Msg) bool {
slices.SortFunc(e.valid, func(a, b adapters.Msg) int {
ac, bc := a.CreatedAt, b.CreatedAt
if ac.Equal(bc) {
return a.ID < b.ID
return cmp.Compare(a.ID, b.ID)
}
return ac.Before(bc)
if ac.After(bc) {
return 1
}
return -1 // ac.Before(bc)
})
}

Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package toml
import (
"fmt"
"net/url"
"slices"
"strconv"

"github.com/ethereum/go-ethereum/core/txpool"
"github.com/pelletier/go-toml/v2"
"github.com/shopspring/decimal"
"go.uber.org/multierr"
"golang.org/x/exp/slices"
"gopkg.in/guregu/null.v4"

relaytypes "github.com/smartcontractkit/chainlink-relay/pkg/types"
Expand Down
7 changes: 3 additions & 4 deletions core/chains/evm/config/toml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"embed"
"log"
"path/filepath"
"slices"
"strings"

"golang.org/x/exp/slices"

"github.com/smartcontractkit/chainlink/v2/core/config"
"github.com/smartcontractkit/chainlink/v2/core/utils"
configutils "github.com/smartcontractkit/chainlink/v2/core/utils/config"
Expand Down Expand Up @@ -62,8 +61,8 @@ func init() {
defaults[id] = config.Chain
defaultNames[id] = strings.ReplaceAll(strings.TrimSuffix(fe.Name(), ".toml"), "_", " ")
}
slices.SortFunc(DefaultIDs, func(a, b *utils.Big) bool {
return a.Cmp(b) < 0
slices.SortFunc(DefaultIDs, func(a, b *utils.Big) int {
return a.Cmp(b)
})
}

Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/gas/arbitrum_estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"fmt"
"math"
"math/big"
"slices"
"sync"
"time"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
"golang.org/x/exp/slices"

feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types"
"github.com/smartcontractkit/chainlink/v2/core/assets"
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/gas/l2_suggested_estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package gas

import (
"context"
"slices"
"sync"
"time"

"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"golang.org/x/exp/slices"

feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types"
"github.com/smartcontractkit/chainlink/v2/core/assets"
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/gas/rollups/l1_gas_price_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"errors"
"fmt"
"math/big"
"slices"
"sync"
"time"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"golang.org/x/exp/slices"

"github.com/smartcontractkit/chainlink/v2/core/assets"
evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/headtracker/head_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"math/big"
"slices"
"sync"
"testing"
"time"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"

commonmocks "github.com/smartcontractkit/chainlink/v2/common/types/mocks"
evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
Expand Down
2 changes: 1 addition & 1 deletion core/chains/solana/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package solana
import (
"fmt"
"net/url"
"slices"
"time"

"github.com/gagliardetto/solana-go/rpc"
"github.com/pelletier/go-toml/v2"
"go.uber.org/multierr"
"golang.org/x/exp/slices"

relaytypes "github.com/smartcontractkit/chainlink-relay/pkg/types"

Expand Down
2 changes: 1 addition & 1 deletion core/chains/starknet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package starknet
import (
"fmt"
"net/url"
"slices"
"time"

"github.com/pelletier/go-toml/v2"
"go.uber.org/multierr"
"golang.org/x/exp/slices"

"github.com/smartcontractkit/chainlink-relay/pkg/types"

Expand Down
2 changes: 1 addition & 1 deletion core/internal/testutils/evmtest/evmtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package evmtest
import (
"fmt"
"math/big"
"slices"
"sync"
"sync/atomic"
"testing"
Expand All @@ -12,7 +13,6 @@ import (
"github.com/smartcontractkit/sqlx"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink-relay/pkg/types"
Expand Down
3 changes: 1 addition & 2 deletions core/services/gateway/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package common
import (
"crypto/ecdsa"
"encoding/binary"

"golang.org/x/exp/slices"
"slices"

"github.com/smartcontractkit/chainlink/v2/core/utils"
)
Expand Down
3 changes: 1 addition & 2 deletions core/services/job/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import (
"encoding/json"
"fmt"
"reflect"
"slices"
"time"

"golang.org/x/exp/slices"

"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"
"github.com/jackc/pgconn"
Expand Down
2 changes: 1 addition & 1 deletion core/services/ocr2/plugins/functions/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package functions
import (
"encoding/json"
"math/big"
"slices"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
"github.com/smartcontractkit/sqlx"
"golang.org/x/exp/slices"

"github.com/smartcontractkit/libocr/commontypes"
libocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus"
Expand Down
7 changes: 4 additions & 3 deletions core/services/vrf/v2/listener_v2.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package v2

import (
"cmp"
"context"
"database/sql"
"fmt"
"math"
"math/big"
"slices"
"strings"
"sync"
"time"
Expand All @@ -20,7 +22,6 @@ import (
heaps "github.com/theodesp/go-heaps"
"github.com/theodesp/go-heaps/pairing"
"go.uber.org/multierr"
"golang.org/x/exp/slices"

txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr"
txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types"
Expand Down Expand Up @@ -503,8 +504,8 @@ func (lsn *listenerV2) processPendingVRFRequests(ctx context.Context) {
// first. This allows us to break out of the processing loop as early as possible
// in the event that a subscription is too underfunded to have it's
// requests processed.
slices.SortFunc(reqs, func(a, b pendingRequest) bool {
return a.req.CallbackGasLimit() < b.req.CallbackGasLimit()
slices.SortFunc(reqs, func(a, b pendingRequest) int {
return cmp.Compare(a.req.CallbackGasLimit(), b.req.CallbackGasLimit())
})

p := lsn.processRequestsPerSub(ctx, sID, startLinkBalance, startEthBalance, reqs, subIsActive)
Expand Down

0 comments on commit d030e2c

Please sign in to comment.