Skip to content

Commit 1ea66a9

Browse files
Dan LaineaaronbuchwaldStephenButtolph
authored
use generic set (#391)
* use generic set * bump version * nit * update inner go mod * Bump rpcchainvm version in compatibility.json Co-authored-by: aaronbuchwald <[email protected]> Co-authored-by: Stephen <[email protected]>
1 parent c002776 commit 1ea66a9

File tree

12 files changed

+31
-25
lines changed

12 files changed

+31
-25
lines changed

cmd/simulator/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ replace github.com/ava-labs/subnet-evm => ../..
1515

1616
require (
1717
github.com/VictoriaMetrics/fastcache v1.10.0 // indirect
18-
github.com/ava-labs/avalanchego v1.9.3 // indirect
18+
github.com/ava-labs/avalanchego v1.9.4-rc.11 // indirect
1919
github.com/beorn7/perks v1.0.1 // indirect
2020
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
2121
github.com/cenkalti/backoff/v4 v4.1.3 // indirect

cmd/simulator/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5
4545
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
4646
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
4747
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
48-
github.com/ava-labs/avalanchego v1.9.3 h1:vEIa5R7p9P+q1Tf4DHFQppI0ELgKdv0tLVx4sMDNXZc=
49-
github.com/ava-labs/avalanchego v1.9.3/go.mod h1:UR0FdZiS5+0fEqGk3S8zLIiQ2xdzIfTcCnndBRJQ5NA=
48+
github.com/ava-labs/avalanchego v1.9.4-rc.11 h1:wXu4u/XexkiIQPxUYWkJ6M7kCNUTwoKDOUAsqX/dbms=
49+
github.com/ava-labs/avalanchego v1.9.4-rc.11/go.mod h1:H4pMTYzgudfPs9WX+KXI0nCiUGNkdgPWOwm1nqzGibQ=
5050
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
5151
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
5252
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=

compatibility.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"rpcChainVMProtocolVersion": {
3-
"v0.4.5": 19,
3+
"v0.4.5": 20,
44
"v0.4.4": 19,
55
"v0.4.3": 19,
66
"v0.4.2": 18,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.18
55
require (
66
github.com/VictoriaMetrics/fastcache v1.10.0
77
github.com/ava-labs/avalanche-network-runner-sdk v0.3.0
8-
github.com/ava-labs/avalanchego v1.9.3
8+
github.com/ava-labs/avalanchego v1.9.4-rc.11
99
github.com/cespare/cp v0.1.0
1010
github.com/creack/pty v1.1.18
1111
github.com/davecgh/go-spew v1.1.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
6060
github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0=
6161
github.com/ava-labs/avalanche-network-runner-sdk v0.3.0 h1:TVi9JEdKNU/RevYZ9PyW4pULbEdS+KQDA9Ki2DUvuAs=
6262
github.com/ava-labs/avalanche-network-runner-sdk v0.3.0/go.mod h1:SgKJvtqvgo/Bl/c8fxEHCLaSxEbzimYfBopcfrajxQk=
63-
github.com/ava-labs/avalanchego v1.9.3 h1:vEIa5R7p9P+q1Tf4DHFQppI0ELgKdv0tLVx4sMDNXZc=
64-
github.com/ava-labs/avalanchego v1.9.3/go.mod h1:UR0FdZiS5+0fEqGk3S8zLIiQ2xdzIfTcCnndBRJQ5NA=
63+
github.com/ava-labs/avalanchego v1.9.4-rc.11 h1:wXu4u/XexkiIQPxUYWkJ6M7kCNUTwoKDOUAsqX/dbms=
64+
github.com/ava-labs/avalanchego v1.9.4-rc.11/go.mod h1:H4pMTYzgudfPs9WX+KXI0nCiUGNkdgPWOwm1nqzGibQ=
6565
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
6666
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
6767
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=

peer/network.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/ava-labs/avalanchego/ids"
1919
"github.com/ava-labs/avalanchego/snow/engine/common"
2020
"github.com/ava-labs/avalanchego/snow/validators"
21+
"github.com/ava-labs/avalanchego/utils/set"
2122
"github.com/ava-labs/avalanchego/version"
2223

2324
"github.com/ava-labs/subnet-evm/peer/stats"
@@ -153,7 +154,7 @@ func (n *network) request(nodeID ids.NodeID, request []byte, responseHandler mes
153154

154155
n.outstandingRequestHandlers[requestID] = responseHandler
155156

156-
nodeIDs := ids.NewNodeIDSet(1)
157+
nodeIDs := set.NewSet[ids.NodeID](1)
157158
nodeIDs.Add(nodeID)
158159

159160
// send app request to the peer

peer/network_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"time"
1414

1515
"github.com/ava-labs/avalanchego/snow/engine/common"
16+
"github.com/ava-labs/avalanchego/utils/set"
1617

1718
"github.com/ava-labs/subnet-evm/plugin/evm/message"
1819

@@ -56,7 +57,7 @@ func TestRequestAnyRequestsRoutingAndResponse(t *testing.T) {
5657
senderWg := &sync.WaitGroup{}
5758
var net Network
5859
sender := testAppSender{
59-
sendAppRequestFn: func(nodes ids.NodeIDSet, requestID uint32, requestBytes []byte) error {
60+
sendAppRequestFn: func(nodes set.Set[ids.NodeID], requestID uint32, requestBytes []byte) error {
6061
nodeID, _ := nodes.Pop()
6162
senderWg.Add(1)
6263
go func() {
@@ -127,7 +128,7 @@ func TestRequestRequestsRoutingAndResponse(t *testing.T) {
127128
var lock sync.Mutex
128129
contactedNodes := make(map[ids.NodeID]struct{})
129130
sender := testAppSender{
130-
sendAppRequestFn: func(nodes ids.NodeIDSet, requestID uint32, requestBytes []byte) error {
131+
sendAppRequestFn: func(nodes set.Set[ids.NodeID], requestID uint32, requestBytes []byte) error {
131132
nodeID, _ := nodes.Pop()
132133
lock.Lock()
133134
contactedNodes[nodeID] = struct{}{}
@@ -221,7 +222,7 @@ func TestRequestMinVersion(t *testing.T) {
221222

222223
var net Network
223224
sender := testAppSender{
224-
sendAppRequestFn: func(nodes ids.NodeIDSet, reqID uint32, messageBytes []byte) error {
225+
sendAppRequestFn: func(nodes set.Set[ids.NodeID], reqID uint32, messageBytes []byte) error {
225226
atomic.AddUint32(&callNum, 1)
226227
assert.True(t, nodes.Contains(nodeID), "request nodes should contain expected nodeID")
227228
assert.Len(t, nodes, 1, "request nodes should contain exactly one node")
@@ -285,7 +286,7 @@ func TestOnRequestHonoursDeadline(t *testing.T) {
285286
var net Network
286287
responded := false
287288
sender := testAppSender{
288-
sendAppRequestFn: func(nodes ids.NodeIDSet, reqID uint32, message []byte) error {
289+
sendAppRequestFn: func(nodes set.Set[ids.NodeID], reqID uint32, message []byte) error {
289290
return nil
290291
},
291292
sendAppResponseFn: func(nodeID ids.NodeID, reqID uint32, message []byte) error {
@@ -455,7 +456,7 @@ func buildGossip(codec codec.Manager, msg message.GossipMessage) ([]byte, error)
455456
type testAppSender struct {
456457
sendCrossChainAppRequestFn func(ids.ID, uint32, []byte) error
457458
sendCrossChainAppResponseFn func(ids.ID, uint32, []byte) error
458-
sendAppRequestFn func(ids.NodeIDSet, uint32, []byte) error
459+
sendAppRequestFn func(set.Set[ids.NodeID], uint32, []byte) error
459460
sendAppResponseFn func(ids.NodeID, uint32, []byte) error
460461
sendAppGossipFn func([]byte) error
461462
}
@@ -468,11 +469,11 @@ func (t testAppSender) SendCrossChainAppResponse(_ context.Context, chainID ids.
468469
return t.sendCrossChainAppResponseFn(chainID, requestID, appResponseBytes)
469470
}
470471

471-
func (t testAppSender) SendAppGossipSpecific(context.Context, ids.NodeIDSet, []byte) error {
472+
func (t testAppSender) SendAppGossipSpecific(context.Context, set.Set[ids.NodeID], []byte) error {
472473
panic("not implemented")
473474
}
474475

475-
func (t testAppSender) SendAppRequest(_ context.Context, nodeIDs ids.NodeIDSet, requestID uint32, message []byte) error {
476+
func (t testAppSender) SendAppRequest(_ context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, message []byte) error {
476477
return t.sendAppRequestFn(nodeIDs, requestID, message)
477478
}
478479

peer/peer_tracker.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/ava-labs/avalanchego/ids"
1212
utils_math "github.com/ava-labs/avalanchego/utils/math"
13+
"github.com/ava-labs/avalanchego/utils/set"
1314
"github.com/ava-labs/avalanchego/version"
1415

1516
"github.com/ethereum/go-ethereum/log"
@@ -43,9 +44,9 @@ type peerInfo struct {
4344
type peerTracker struct {
4445
peers map[ids.NodeID]*peerInfo // all peers we are connected to
4546
numTrackedPeers metrics.Gauge
46-
trackedPeers ids.NodeIDSet // peers that we have sent a request to
47+
trackedPeers set.Set[ids.NodeID] // peers that we have sent a request to
4748
numResponsivePeers metrics.Gauge
48-
responsivePeers ids.NodeIDSet // peers that responded to the last request they were sent
49+
responsivePeers set.Set[ids.NodeID] // peers that responded to the last request they were sent
4950
bandwidthHeap utils_math.AveragerHeap // tracks bandwidth peers are responding with
5051
averageBandwidthMetric metrics.GaugeFloat64
5152
averageBandwidth utils_math.Averager
@@ -55,9 +56,9 @@ func NewPeerTracker() *peerTracker {
5556
return &peerTracker{
5657
peers: make(map[ids.NodeID]*peerInfo),
5758
numTrackedPeers: metrics.GetOrRegisterGauge("net_tracked_peers", nil),
58-
trackedPeers: make(ids.NodeIDSet),
59+
trackedPeers: make(set.Set[ids.NodeID]),
5960
numResponsivePeers: metrics.GetOrRegisterGauge("net_responsive_peers", nil),
60-
responsivePeers: make(ids.NodeIDSet),
61+
responsivePeers: make(set.Set[ids.NodeID]),
6162
bandwidthHeap: utils_math.NewMaxAveragerHeap(),
6263
averageBandwidthMetric: metrics.GetOrRegisterGaugeFloat64("net_average_bandwidth", nil),
6364
averageBandwidth: utils_math.NewAverager(0, bandwidthHalflife, time.Now()),

plugin/evm/syncervm_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/ava-labs/avalanchego/snow"
2121
"github.com/ava-labs/avalanchego/snow/choices"
2222
commonEng "github.com/ava-labs/avalanchego/snow/engine/common"
23+
"github.com/ava-labs/avalanchego/utils/set"
2324

2425
"github.com/ava-labs/subnet-evm/accounts/keystore"
2526
"github.com/ava-labs/subnet-evm/consensus/dummy"
@@ -113,7 +114,7 @@ func TestStateSyncToggleEnabledToDisabled(t *testing.T) {
113114
syncDisabledVM := &VM{}
114115
appSender := &commonEng.SenderTest{T: t}
115116
appSender.SendAppGossipF = func(context.Context, []byte) error { return nil }
116-
appSender.SendAppRequestF = func(ctx context.Context, nodeSet ids.NodeIDSet, requestID uint32, request []byte) error {
117+
appSender.SendAppRequestF = func(ctx context.Context, nodeSet set.Set[ids.NodeID], requestID uint32, request []byte) error {
117118
nodeID, hasItem := nodeSet.Pop()
118119
if !hasItem {
119120
t.Fatal("expected nodeSet to contain at least 1 nodeID")
@@ -315,7 +316,7 @@ func createSyncServerAndClientVMs(t *testing.T, test syncTest) *syncVMSetup {
315316
))
316317

317318
// override [syncerVM]'s SendAppRequest function to trigger AppRequest on [serverVM]
318-
syncerAppSender.SendAppRequestF = func(ctx context.Context, nodeSet ids.NodeIDSet, requestID uint32, request []byte) error {
319+
syncerAppSender.SendAppRequestF = func(ctx context.Context, nodeSet set.Set[ids.NodeID], requestID uint32, request []byte) error {
319320
nodeID, hasItem := nodeSet.Pop()
320321
if !hasItem {
321322
t.Fatal("expected nodeSet to contain at least 1 nodeID")

plugin/evm/tx_gossiping_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"time"
1616

1717
"github.com/ava-labs/avalanchego/ids"
18+
"github.com/ava-labs/avalanchego/utils/set"
1819

1920
"github.com/ethereum/go-ethereum/common"
2021
"github.com/ethereum/go-ethereum/crypto"
@@ -245,7 +246,7 @@ func TestMempoolTxsAppGossipHandling(t *testing.T) {
245246
txRequested bool
246247
)
247248
sender.CantSendAppGossip = false
248-
sender.SendAppRequestF = func(context.Context, ids.NodeIDSet, uint32, []byte) error {
249+
sender.SendAppRequestF = func(context.Context, set.Set[ids.NodeID], uint32, []byte) error {
249250
txRequested = true
250251
return nil
251252
}

0 commit comments

Comments
 (0)