Skip to content

Commit

Permalink
Merge pull request #1952 from CortexFoundation/dev
Browse files Browse the repository at this point in the history
remove dependency on golang.org/exp
  • Loading branch information
ucwong authored Mar 26, 2024
2 parents 59be190 + 408efeb commit 186762d
Show file tree
Hide file tree
Showing 52 changed files with 41 additions and 4,679 deletions.
2 changes: 1 addition & 1 deletion accounts/keystore/account_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"time"

mapset "github.com/deckarep/golang-set/v2"
"golang.org/x/exp/slices"
"slices"

"github.com/CortexFoundation/CortexTheseus/accounts"
"github.com/CortexFoundation/CortexTheseus/common"
Expand Down
2 changes: 1 addition & 1 deletion accounts/keystore/account_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/common"
"github.com/cespare/cp"
"github.com/davecgh/go-spew/spew"
"golang.org/x/exp/slices"
"slices"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion accounts/keystore/keystore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/accounts"
"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/event"
"golang.org/x/exp/slices"
"slices"
)

var testSigData = make([]byte, 32)
Expand Down
2 changes: 1 addition & 1 deletion build/update-license.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import (
"text/template"
"time"

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

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/devp2p/dns_route53.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/route53"
"github.com/aws/aws-sdk-go-v2/service/route53/types"
"golang.org/x/exp/slices"
"gopkg.in/urfave/cli.v1"
"slices"

"github.com/CortexFoundation/CortexTheseus/log"
"github.com/CortexFoundation/CortexTheseus/p2p/dnsdisc"
Expand Down
2 changes: 1 addition & 1 deletion cmd/devp2p/nodeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"os"
"time"

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

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/p2p/enode"
Expand Down
10 changes: 5 additions & 5 deletions common/prque/lazyqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"container/heap"
"time"

"golang.org/x/exp/constraints"
"cmp"

"github.com/CortexFoundation/CortexTheseus/common/mclock"
)
Expand All @@ -34,7 +34,7 @@ import (
//
// If the upper estimate is exceeded then Update should be called for that item.
// A global Refresh function should also be called periodically.
type LazyQueue[P constraints.Ordered, V any] struct {
type LazyQueue[P cmp.Ordered, V any] struct {
clock mclock.Clock
// Items are stored in one of two internal queues ordered by estimated max
// priority until the next and the next-after-next refresh. Update and Refresh
Expand All @@ -51,12 +51,12 @@ type LazyQueue[P constraints.Ordered, V any] struct {
}

type (
PriorityCallback[P constraints.Ordered, V any] func(data V) P // actual priority callback
MaxPriorityCallback[P constraints.Ordered, V any] func(data V, until mclock.AbsTime) P // estimated maximum priority callback
PriorityCallback[P cmp.Ordered, V any] func(data V) P // actual priority callback
MaxPriorityCallback[P cmp.Ordered, V any] func(data V, until mclock.AbsTime) P // estimated maximum priority callback
)

// NewLazyQueue creates a new lazy queue
func NewLazyQueue[P constraints.Ordered, V any](setIndex SetIndexCallback[V], priority PriorityCallback[P, V], maxPriority MaxPriorityCallback[P, V], clock mclock.Clock, refreshPeriod time.Duration) *LazyQueue[P, V] {
func NewLazyQueue[P cmp.Ordered, V any](setIndex SetIndexCallback[V], priority PriorityCallback[P, V], maxPriority MaxPriorityCallback[P, V], clock mclock.Clock, refreshPeriod time.Duration) *LazyQueue[P, V] {
q := &LazyQueue[P, V]{
popQueue: newSstack[P, V](nil),
setIndex: setIndex,
Expand Down
6 changes: 3 additions & 3 deletions common/prque/prque.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ package prque
import (
"container/heap"

"golang.org/x/exp/constraints"
"cmp"
)

// Priority queue data structure.
type Prque[P constraints.Ordered, V any] struct {
type Prque[P cmp.Ordered, V any] struct {
cont *sstack[P, V]
}

// New creates a new priority queue.
func New[P constraints.Ordered, V any](setIndex SetIndexCallback[V]) *Prque[P, V] {
func New[P cmp.Ordered, V any](setIndex SetIndexCallback[V]) *Prque[P, V] {
return &Prque[P, V]{newSstack[P, V](setIndex)}
}

Expand Down
8 changes: 4 additions & 4 deletions common/prque/sstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

package prque

import "golang.org/x/exp/constraints"
import "cmp"

// The size of a block of data
const blockSize = 4096

// A prioritized item in the sorted stack.
type item[P constraints.Ordered, V any] struct {
type item[P cmp.Ordered, V any] struct {
value V
priority P
}
Expand All @@ -29,7 +29,7 @@ type SetIndexCallback[V any] func(data V, index int)
// Internal sortable stack data structure. Implements the Push and Pop ops for
// the stack (heap) functionality and the Len, Less and Swap methods for the
// sortability requirements of the heaps.
type sstack[P constraints.Ordered, V any] struct {
type sstack[P cmp.Ordered, V any] struct {
setIndex SetIndexCallback[V]
size int
capacity int
Expand All @@ -40,7 +40,7 @@ type sstack[P constraints.Ordered, V any] struct {
}

// Creates a new, empty stack.
func newSstack[P constraints.Ordered, V any](setIndex SetIndexCallback[V]) *sstack[P, V] {
func newSstack[P cmp.Ordered, V any](setIndex SetIndexCallback[V]) *sstack[P, V] {
result := new(sstack[P, V])
result.setIndex = setIndex
result.active = make([]*item[P, V], blockSize)
Expand Down
2 changes: 1 addition & 1 deletion consensus/clique/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"time"

lru "github.com/hashicorp/golang-lru"
"golang.org/x/exp/slices"
"slices"

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/core/rawdb"
Expand Down
2 changes: 1 addition & 1 deletion consensus/clique/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/core/vm"
"github.com/CortexFoundation/CortexTheseus/crypto"
"github.com/CortexFoundation/CortexTheseus/params"
"golang.org/x/exp/slices"
"slices"
)

// testerAccountPool is a pool to maintain currently active tester accounts,
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"sync/atomic"
"time"

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

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/common/lru"
Expand Down
2 changes: 1 addition & 1 deletion core/forkid/forkid.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"reflect"
"strings"

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

"github.com/CortexFoundation/CortexTheseus/core/types"
"github.com/CortexFoundation/CortexTheseus/log"
Expand Down
2 changes: 1 addition & 1 deletion core/mkalloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"os"
"strconv"

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

"github.com/CortexFoundation/CortexTheseus/core"
"github.com/CortexFoundation/CortexTheseus/rlp"
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"fmt"
"math/big"

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

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/core/types"
Expand Down
2 changes: 1 addition & 1 deletion core/state/snapshot/difflayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"time"

bloomfilter "github.com/holiman/bloomfilter/v2"
"golang.org/x/exp/slices"
"slices"

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/core/types"
Expand Down
2 changes: 1 addition & 1 deletion core/state/snapshot/iterator_fast.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"sort"

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

"github.com/CortexFoundation/CortexTheseus/common"
)
Expand Down
2 changes: 1 addition & 1 deletion core/txpool/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"sync/atomic"
"time"

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

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/core/types"
Expand Down
2 changes: 1 addition & 1 deletion ctxcdb/dbtest/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"testing"

"github.com/CortexFoundation/CortexTheseus/ctxcdb"
"golang.org/x/exp/slices"
"slices"
)

// TestDatabaseSuite runs a suite of tests against a KeyValueStore database
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ require (
github.com/urfave/cli/v2 v2.27.1
go.uber.org/automaxprocs v1.5.3
golang.org/x/crypto v0.21.0
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f
golang.org/x/sync v0.6.0
golang.org/x/sys v0.18.0
Expand Down Expand Up @@ -239,6 +238,7 @@ require (
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/term v0.18.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion metrics/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"time"

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

const rescaleThreshold = time.Hour
Expand Down
2 changes: 1 addition & 1 deletion metrics/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

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

// Write sorts writes each metric in the given registry periodically to the
Expand Down
2 changes: 1 addition & 1 deletion metrics/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package metrics
import (
"testing"

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

func TestMetricsSorting(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion p2p/discover/ntp.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"time"

"github.com/CortexFoundation/CortexTheseus/log"
"golang.org/x/exp/slices"
"slices"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion p2p/discover/table_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/crypto"
"github.com/CortexFoundation/CortexTheseus/p2p/enode"
"github.com/CortexFoundation/CortexTheseus/p2p/enr"
"golang.org/x/exp/slices"
"slices"
)

var nullNode *enode.Node
Expand Down
2 changes: 1 addition & 1 deletion p2p/discover/v4_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/p2p/discover/v4wire"
"github.com/CortexFoundation/CortexTheseus/p2p/enode"
"github.com/CortexFoundation/CortexTheseus/p2p/enr"
"golang.org/x/exp/slices"
"slices"
)

func TestUDPv4_Lookup(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion p2p/discover/v5_udp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/p2p/enr"
"github.com/CortexFoundation/CortexTheseus/rlp"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"slices"
)

// Real sockets, real crypto: this test checks end-to-end connectivity for UDPv5.
Expand Down
2 changes: 1 addition & 1 deletion p2p/dnsdisc/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/p2p/enr"
"github.com/CortexFoundation/CortexTheseus/rlp"
"golang.org/x/crypto/sha3"
"golang.org/x/exp/slices"
"slices"
)

// Tree is a merkle tree of node records.
Expand Down
2 changes: 1 addition & 1 deletion p2p/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/p2p/enode"
"github.com/CortexFoundation/CortexTheseus/p2p/enr"
"github.com/CortexFoundation/CortexTheseus/rlp"
"golang.org/x/exp/slices"
"slices"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion p2p/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/p2p/enr"
"github.com/CortexFoundation/CortexTheseus/p2p/nat"
"github.com/CortexFoundation/CortexTheseus/p2p/netutil"
"golang.org/x/exp/slices"
"slices"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion tests/fuzzers/stacktrie/trie_fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/ctxcdb"
"github.com/CortexFoundation/CortexTheseus/trie"
"golang.org/x/crypto/sha3"
"golang.org/x/exp/slices"
"slices"
)

type fuzzer struct {
Expand Down
2 changes: 1 addition & 1 deletion trie/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/CortexFoundation/CortexTheseus/core/rawdb"
"github.com/CortexFoundation/CortexTheseus/crypto"
"github.com/CortexFoundation/CortexTheseus/ctxcdb/memorydb"
"golang.org/x/exp/slices"
"slices"
)

func init() {
Expand Down
Loading

0 comments on commit 186762d

Please sign in to comment.