From 37769e2131cc26dae94a8d3d5405ab88123d1831 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Mon, 5 Dec 2022 15:02:11 -0500 Subject: [PATCH] Add generic set and sorting (#1064) * use generics from avalanchego * bump version Co-authored-by: Stephen --- go.mod | 2 +- go.sum | 4 ++-- peer/network.go | 3 ++- peer/network_test.go | 15 ++++++++------- peer/peer_tracker.go | 9 +++++---- plugin/evm/atomic_tx_repository_test.go | 3 ++- plugin/evm/export_tx.go | 5 +++-- plugin/evm/gossiper_atomic_gossiping_test.go | 5 +++-- plugin/evm/gossiper_eth_gossiping_test.go | 3 ++- plugin/evm/import_tx.go | 5 +++-- plugin/evm/import_tx_test.go | 3 ++- plugin/evm/service.go | 3 ++- plugin/evm/syncervm_test.go | 5 +++-- plugin/evm/test_tx.go | 5 +++-- plugin/evm/tx.go | 3 ++- plugin/evm/vm.go | 9 +++++---- plugin/evm/vm_test.go | 5 +++-- scripts/versions.sh | 2 +- sync/statesync/code_syncer.go | 5 +++-- 19 files changed, 55 insertions(+), 39 deletions(-) diff --git a/go.mod b/go.mod index a74f45809e..21c0f8ba6a 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/VictoriaMetrics/fastcache v1.10.0 - github.com/ava-labs/avalanchego v1.9.4-rc.0 + github.com/ava-labs/avalanchego v1.9.4-rc.7 github.com/cespare/cp v0.1.0 github.com/davecgh/go-spew v1.1.1 github.com/deckarep/golang-set v1.8.0 diff --git a/go.sum b/go.sum index d49dfc8d5e..d450358207 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0= github.com/ava-labs/avalanche-ledger-go v0.0.13 h1:YTdaSuaZS/1ct1RGirBEJeo2tiSfVeJGaE12XtUSGnE= github.com/ava-labs/avalanche-ledger-go v0.0.13/go.mod h1:LolCV2cdtkD67V/BSfy/ELUqleG1sbVyNdo5qe1u4y4= -github.com/ava-labs/avalanchego v1.9.4-rc.0 h1:YjOjOsaZ150x1SSb1QxIA1S934zkmOY9+mtFBordkjQ= -github.com/ava-labs/avalanchego v1.9.4-rc.0/go.mod h1:UFrNSk2i1RGo/HWVl+psXxeoQ0n7YOUb75duxAclYP0= +github.com/ava-labs/avalanchego v1.9.4-rc.7 h1:VeYRykNkmx4JpZQZpJZ98t/K4LzSGhmqHdX7j052rS4= +github.com/ava-labs/avalanchego v1.9.4-rc.7/go.mod h1:IgZ35Xyt4obyex1wS4rcf5ecF721NK+bdBkSaUxkQUU= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= diff --git a/peer/network.go b/peer/network.go index aba1b983ac..7d44f976bb 100644 --- a/peer/network.go +++ b/peer/network.go @@ -18,6 +18,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/version" "github.com/ava-labs/coreth/peer/stats" @@ -153,7 +154,7 @@ func (n *network) request(nodeID ids.NodeID, request []byte, responseHandler mes n.outstandingRequestHandlers[requestID] = responseHandler - nodeIDs := ids.NewNodeIDSet(1) + nodeIDs := set.NewSet[ids.NodeID](1) nodeIDs.Add(nodeID) // send app request to the peer diff --git a/peer/network_test.go b/peer/network_test.go index 1f8b2137b0..53eb3e866d 100644 --- a/peer/network_test.go +++ b/peer/network_test.go @@ -13,6 +13,7 @@ import ( "time" "github.com/ava-labs/avalanchego/snow/engine/common" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/coreth/plugin/evm/message" @@ -57,7 +58,7 @@ func TestRequestAnyRequestsRoutingAndResponse(t *testing.T) { senderWg := &sync.WaitGroup{} var net Network sender := testAppSender{ - sendAppRequestFn: func(nodes ids.NodeIDSet, requestID uint32, requestBytes []byte) error { + sendAppRequestFn: func(nodes set.Set[ids.NodeID], requestID uint32, requestBytes []byte) error { nodeID, _ := nodes.Pop() senderWg.Add(1) go func() { @@ -128,7 +129,7 @@ func TestRequestRequestsRoutingAndResponse(t *testing.T) { var lock sync.Mutex contactedNodes := make(map[ids.NodeID]struct{}) sender := testAppSender{ - sendAppRequestFn: func(nodes ids.NodeIDSet, requestID uint32, requestBytes []byte) error { + sendAppRequestFn: func(nodes set.Set[ids.NodeID], requestID uint32, requestBytes []byte) error { nodeID, _ := nodes.Pop() lock.Lock() contactedNodes[nodeID] = struct{}{} @@ -222,7 +223,7 @@ func TestRequestMinVersion(t *testing.T) { var net Network sender := testAppSender{ - sendAppRequestFn: func(nodes ids.NodeIDSet, reqID uint32, messageBytes []byte) error { + sendAppRequestFn: func(nodes set.Set[ids.NodeID], reqID uint32, messageBytes []byte) error { atomic.AddUint32(&callNum, 1) assert.True(t, nodes.Contains(nodeID), "request nodes should contain expected nodeID") assert.Len(t, nodes, 1, "request nodes should contain exactly one node") @@ -286,7 +287,7 @@ func TestOnRequestHonoursDeadline(t *testing.T) { var net Network responded := false sender := testAppSender{ - sendAppRequestFn: func(nodes ids.NodeIDSet, reqID uint32, message []byte) error { + sendAppRequestFn: func(nodes set.Set[ids.NodeID], reqID uint32, message []byte) error { return nil }, sendAppResponseFn: func(nodeID ids.NodeID, reqID uint32, message []byte) error { @@ -456,7 +457,7 @@ func buildGossip(codec codec.Manager, msg message.GossipMessage) ([]byte, error) type testAppSender struct { sendCrossChainAppRequestFn func(ids.ID, uint32, []byte) error sendCrossChainAppResponseFn func(ids.ID, uint32, []byte) error - sendAppRequestFn func(ids.NodeIDSet, uint32, []byte) error + sendAppRequestFn func(set.Set[ids.NodeID], uint32, []byte) error sendAppResponseFn func(ids.NodeID, uint32, []byte) error sendAppGossipFn func([]byte) error } @@ -469,11 +470,11 @@ func (t testAppSender) SendCrossChainAppResponse(_ context.Context, chainID ids. return t.sendCrossChainAppResponseFn(chainID, requestID, appResponseBytes) } -func (t testAppSender) SendAppGossipSpecific(context.Context, ids.NodeIDSet, []byte) error { +func (t testAppSender) SendAppGossipSpecific(context.Context, set.Set[ids.NodeID], []byte) error { panic("not implemented") } -func (t testAppSender) SendAppRequest(_ context.Context, nodeIDs ids.NodeIDSet, requestID uint32, message []byte) error { +func (t testAppSender) SendAppRequest(_ context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, message []byte) error { return t.sendAppRequestFn(nodeIDs, requestID, message) } diff --git a/peer/peer_tracker.go b/peer/peer_tracker.go index 05eeb3c113..8070005ca6 100644 --- a/peer/peer_tracker.go +++ b/peer/peer_tracker.go @@ -10,6 +10,7 @@ import ( "github.com/ava-labs/avalanchego/ids" utils_math "github.com/ava-labs/avalanchego/utils/math" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/version" "github.com/ethereum/go-ethereum/log" @@ -43,9 +44,9 @@ type peerInfo struct { type peerTracker struct { peers map[ids.NodeID]*peerInfo // all peers we are connected to numTrackedPeers metrics.Gauge - trackedPeers ids.NodeIDSet // peers that we have sent a request to + trackedPeers set.Set[ids.NodeID] // peers that we have sent a request to numResponsivePeers metrics.Gauge - responsivePeers ids.NodeIDSet // peers that responded to the last request they were sent + responsivePeers set.Set[ids.NodeID] // peers that responded to the last request they were sent bandwidthHeap utils_math.AveragerHeap // tracks bandwidth peers are responding with averageBandwidthMetric metrics.GaugeFloat64 averageBandwidth utils_math.Averager @@ -55,9 +56,9 @@ func NewPeerTracker() *peerTracker { return &peerTracker{ peers: make(map[ids.NodeID]*peerInfo), numTrackedPeers: metrics.GetOrRegisterGauge("net_tracked_peers", nil), - trackedPeers: make(ids.NodeIDSet), + trackedPeers: make(set.Set[ids.NodeID]), numResponsivePeers: metrics.GetOrRegisterGauge("net_responsive_peers", nil), - responsivePeers: make(ids.NodeIDSet), + responsivePeers: make(set.Set[ids.NodeID]), bandwidthHeap: utils_math.NewMaxAveragerHeap(), averageBandwidthMetric: metrics.GetOrRegisterGaugeFloat64("net_average_bandwidth", nil), averageBandwidth: utils_math.NewAverager(0, bandwidthHalflife, time.Now()), diff --git a/plugin/evm/atomic_tx_repository_test.go b/plugin/evm/atomic_tx_repository_test.go index 8bdeaacd0b..614d9c9e94 100644 --- a/plugin/evm/atomic_tx_repository_test.go +++ b/plugin/evm/atomic_tx_repository_test.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ava-labs/avalanchego/codec" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/wrappers" "github.com/stretchr/testify/assert" @@ -109,7 +110,7 @@ func verifyTxs(t testing.TB, repo AtomicTxRepository, txMap map[uint64][]*Tx) { // txs should be stored in order of txID sort.Slice(expectedTxs, getComparator(expectedTxs)) - txIDs := ids.Set{} + txIDs := set.Set[ids.ID]{} for i := 0; i < len(txs); i++ { assert.Equalf(t, expectedTxs[i].ID().Hex(), txs[i].ID().Hex(), "wrong txID at height=%d idx=%d", height, i) txIDs.Add(txs[i].ID()) diff --git a/plugin/evm/export_tx.go b/plugin/evm/export_tx.go index 0984c3ea27..7e0e14cb2e 100644 --- a/plugin/evm/export_tx.go +++ b/plugin/evm/export_tx.go @@ -17,6 +17,7 @@ import ( "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto" "github.com/ava-labs/avalanchego/utils/math" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/wrappers" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/components/verify" @@ -48,8 +49,8 @@ type UnsignedExportTx struct { } // InputUTXOs returns a set of all the hash(address:nonce) exporting funds. -func (utx *UnsignedExportTx) InputUTXOs() ids.Set { - set := ids.NewSet(len(utx.Ins)) +func (utx *UnsignedExportTx) InputUTXOs() set.Set[ids.ID] { + set := set.NewSet[ids.ID](len(utx.Ins)) for _, in := range utx.Ins { // Total populated bytes is exactly 32 bytes. // 8 (Nonce) + 4 (Address Length) + 20 (Address) diff --git a/plugin/evm/gossiper_atomic_gossiping_test.go b/plugin/evm/gossiper_atomic_gossiping_test.go index 4a3f11b528..30ca78f1c0 100644 --- a/plugin/evm/gossiper_atomic_gossiping_test.go +++ b/plugin/evm/gossiper_atomic_gossiping_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/utils/set" "github.com/stretchr/testify/assert" @@ -99,7 +100,7 @@ func TestMempoolAtmTxsAppGossipHandling(t *testing.T) { txGossiped++ return nil } - sender.SendAppRequestF = func(context.Context, ids.NodeIDSet, uint32, []byte) error { + sender.SendAppRequestF = func(context.Context, set.Set[ids.NodeID], uint32, []byte) error { txRequested = true return nil } @@ -169,7 +170,7 @@ func TestMempoolAtmTxsAppGossipHandlingDiscardedTx(t *testing.T) { txGossiped++ return nil } - sender.SendAppRequestF = func(context.Context, ids.NodeIDSet, uint32, []byte) error { + sender.SendAppRequestF = func(context.Context, set.Set[ids.NodeID], uint32, []byte) error { txRequested = true return nil } diff --git a/plugin/evm/gossiper_eth_gossiping_test.go b/plugin/evm/gossiper_eth_gossiping_test.go index ba4775d857..82a4f2113e 100644 --- a/plugin/evm/gossiper_eth_gossiping_test.go +++ b/plugin/evm/gossiper_eth_gossiping_test.go @@ -14,6 +14,7 @@ import ( "time" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -251,7 +252,7 @@ func TestMempoolEthTxsAppGossipHandling(t *testing.T) { txRequested bool ) sender.CantSendAppGossip = false - sender.SendAppRequestF = func(context.Context, ids.NodeIDSet, uint32, []byte) error { + sender.SendAppRequestF = func(context.Context, set.Set[ids.NodeID], uint32, []byte) error { txRequested = true return nil } diff --git a/plugin/evm/import_tx.go b/plugin/evm/import_tx.go index 8ad2329a05..f9aee9baf9 100644 --- a/plugin/evm/import_tx.go +++ b/plugin/evm/import_tx.go @@ -17,6 +17,7 @@ import ( "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/crypto" "github.com/ava-labs/avalanchego/utils/math" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/components/verify" "github.com/ava-labs/avalanchego/vms/secp256k1fx" @@ -47,8 +48,8 @@ type UnsignedImportTx struct { } // InputUTXOs returns the UTXOIDs of the imported funds -func (utx *UnsignedImportTx) InputUTXOs() ids.Set { - set := ids.NewSet(len(utx.ImportedInputs)) +func (utx *UnsignedImportTx) InputUTXOs() set.Set[ids.ID] { + set := set.NewSet[ids.ID](len(utx.ImportedInputs)) for _, in := range utx.ImportedInputs { set.Add(in.InputID()) } diff --git a/plugin/evm/import_tx_test.go b/plugin/evm/import_tx_test.go index 0453c5f8cf..981f1e69e6 100644 --- a/plugin/evm/import_tx_test.go +++ b/plugin/evm/import_tx_test.go @@ -15,6 +15,7 @@ import ( "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/secp256k1fx" ) @@ -477,7 +478,7 @@ func TestNewImportTx(t *testing.T) { } // Ensure that the UTXO has been removed from shared memory within Accept - addrSet := ids.ShortSet{} + addrSet := set.Set[ids.ShortID]{} addrSet.Add(testShortIDAddrs[0]) utxos, _, _, err := vm.GetAtomicUTXOs(vm.ctx.XChainID, addrSet, ids.ShortEmpty, ids.Empty, -1) if err != nil { diff --git a/plugin/evm/service.go b/plugin/evm/service.go index bf3d15c185..19e7985983 100644 --- a/plugin/evm/service.go +++ b/plugin/evm/service.go @@ -15,6 +15,7 @@ import ( "github.com/ava-labs/avalanchego/utils/crypto" "github.com/ava-labs/avalanchego/utils/formatting" "github.com/ava-labs/avalanchego/utils/json" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/coreth/params" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -347,7 +348,7 @@ func (service *AvaxAPI) GetUTXOs(r *http.Request, args *api.GetUTXOsArgs, reply } sourceChain := chainID - addrSet := ids.ShortSet{} + addrSet := set.Set[ids.ShortID]{} for _, addrStr := range args.Addresses { addr, err := service.vm.ParseLocalAddress(addrStr) if err != nil { diff --git a/plugin/evm/syncervm_test.go b/plugin/evm/syncervm_test.go index 026d3ffda9..43d39e3b56 100644 --- a/plugin/evm/syncervm_test.go +++ b/plugin/evm/syncervm_test.go @@ -22,6 +22,7 @@ import ( "github.com/ava-labs/avalanchego/snow/choices" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/utils/crypto" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/units" "github.com/ethereum/go-ethereum/common" @@ -117,7 +118,7 @@ func TestStateSyncToggleEnabledToDisabled(t *testing.T) { syncDisabledVM := &VM{} appSender := &commonEng.SenderTest{T: t} appSender.SendAppGossipF = func(context.Context, []byte) error { return nil } - appSender.SendAppRequestF = func(ctx context.Context, nodeSet ids.NodeIDSet, requestID uint32, request []byte) error { + appSender.SendAppRequestF = func(ctx context.Context, nodeSet set.Set[ids.NodeID], requestID uint32, request []byte) error { nodeID, hasItem := nodeSet.Pop() if !hasItem { t.Fatal("expected nodeSet to contain at least 1 nodeID") @@ -387,7 +388,7 @@ func createSyncServerAndClientVMs(t *testing.T, test syncTest) *syncVMSetup { )) // override [syncerVM]'s SendAppRequest function to trigger AppRequest on [serverVM] - syncerAppSender.SendAppRequestF = func(ctx context.Context, nodeSet ids.NodeIDSet, requestID uint32, request []byte) error { + syncerAppSender.SendAppRequestF = func(ctx context.Context, nodeSet set.Set[ids.NodeID], requestID uint32, request []byte) error { nodeID, hasItem := nodeSet.Pop() if !hasItem { t.Fatal("expected nodeSet to contain at least 1 nodeID") diff --git a/plugin/evm/test_tx.go b/plugin/evm/test_tx.go index 2cc7f2b457..c057c874ad 100644 --- a/plugin/evm/test_tx.go +++ b/plugin/evm/test_tx.go @@ -14,6 +14,7 @@ import ( "github.com/ava-labs/avalanchego/codec/linearcodec" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/wrappers" "github.com/ava-labs/coreth/core/state" "github.com/ava-labs/coreth/params" @@ -28,7 +29,7 @@ type TestUnsignedTx struct { BurnedV uint64 `serialize:"true"` UnsignedBytesV []byte SignedBytesV []byte - InputUTXOsV ids.Set + InputUTXOsV set.Set[ids.ID] SemanticVerifyV error EVMStateTransferV error } @@ -62,7 +63,7 @@ func (t *TestUnsignedTx) Bytes() []byte { return t.UnsignedBytesV } func (t *TestUnsignedTx) SignedBytes() []byte { return t.SignedBytesV } // InputUTXOs implements the UnsignedAtomicTx interface -func (t *TestUnsignedTx) InputUTXOs() ids.Set { return t.InputUTXOsV } +func (t *TestUnsignedTx) InputUTXOs() set.Set[ids.ID] { return t.InputUTXOsV } // SemanticVerify implements the UnsignedAtomicTx interface func (t *TestUnsignedTx) SemanticVerify(vm *VM, stx *Tx, parent *Block, baseFee *big.Int, rules params.Rules) error { diff --git a/plugin/evm/tx.go b/plugin/evm/tx.go index 165da9ceaa..9067ac740f 100644 --- a/plugin/evm/tx.go +++ b/plugin/evm/tx.go @@ -22,6 +22,7 @@ import ( "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/crypto" "github.com/ava-labs/avalanchego/utils/hashing" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/wrappers" "github.com/ava-labs/avalanchego/vms/components/verify" "github.com/ava-labs/avalanchego/vms/secp256k1fx" @@ -103,7 +104,7 @@ type UnsignedAtomicTx interface { UnsignedTx // InputUTXOs returns the UTXOs this tx consumes - InputUTXOs() ids.Set + InputUTXOs() set.Set[ids.ID] // Verify attempts to verify that the transaction is well formed Verify(ctx *snow.Context, rules params.Rules) error // Attempts to verify this transaction with the provided state. diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index b0b9aa83ec..9b9067cd5e 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -76,6 +76,7 @@ import ( "github.com/ava-labs/avalanchego/utils/math" "github.com/ava-labs/avalanchego/utils/perms" "github.com/ava-labs/avalanchego/utils/profiler" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/utils/units" "github.com/ava-labs/avalanchego/vms/components/avax" @@ -731,7 +732,7 @@ func (vm *VM) preBatchOnFinalizeAndAssemble(header *types.Header, state *state.S func (vm *VM) postBatchOnFinalizeAndAssemble(header *types.Header, state *state.StateDB, txs []*types.Transaction) ([]byte, *big.Int, *big.Int, error) { var ( batchAtomicTxs []*Tx - batchAtomicUTXOs ids.Set + batchAtomicUTXOs set.Set[ids.ID] batchContribution *big.Int = new(big.Int).Set(common.Big0) batchGasUsed *big.Int = new(big.Int).Set(common.Big0) rules = vm.chainConfig.AvalancheRules(header.Number, new(big.Int).SetUint64(header.Time)) @@ -1230,7 +1231,7 @@ func (vm *VM) CreateStaticHandlers(context.Context) (map[string]*commonEng.HTTPH // or any of its ancestor blocks going back to the last accepted block in its ancestry. If [ancestor] is // accepted, then nil will be returned immediately. // If the ancestry of [ancestor] cannot be fetched, then [errRejectedParent] may be returned. -func (vm *VM) conflicts(inputs ids.Set, ancestor *Block) error { +func (vm *VM) conflicts(inputs set.Set[ids.ID], ancestor *Block) error { for ancestor.Status() != choices.Accepted { // If any of the atomic transactions in the ancestor conflict with [inputs] // return an error. @@ -1420,7 +1421,7 @@ func (vm *VM) verifyTxs(txs []*Tx, parentHash common.Hash, baseFee *big.Int, hei // Ensure each tx in [txs] doesn't conflict with any other atomic tx in // a processing ancestor block. - inputs := &ids.Set{} + inputs := set.Set[ids.ID]{} for _, atomicTx := range txs { utx := atomicTx.UnsignedAtomicTx if err := utx.SemanticVerify(vm, atomicTx, ancestor, baseFee, rules); err != nil { @@ -1439,7 +1440,7 @@ func (vm *VM) verifyTxs(txs []*Tx, parentHash common.Hash, baseFee *big.Int, hei // referenced in. func (vm *VM) GetAtomicUTXOs( chainID ids.ID, - addrs ids.ShortSet, + addrs set.Set[ids.ShortID], startAddr ids.ShortID, startUTXOID ids.ID, limit int, diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go index eee068a9be..8b89d1fe4f 100644 --- a/plugin/evm/vm_test.go +++ b/plugin/evm/vm_test.go @@ -40,6 +40,7 @@ import ( "github.com/ava-labs/avalanchego/utils/formatting" "github.com/ava-labs/avalanchego/utils/hashing" "github.com/ava-labs/avalanchego/utils/logging" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/units" "github.com/ava-labs/avalanchego/version" "github.com/ava-labs/avalanchego/vms/components/avax" @@ -3637,7 +3638,7 @@ func TestAtomicTxBuildBlockDropsConflicts(t *testing.T) { }() // Create a conflict set for each pair of transactions - conflictSets := make([]ids.Set, len(testKeys)) + conflictSets := make([]set.Set[ids.ID], len(testKeys)) for index, key := range testKeys { importTx, err := vm.newImportTx(vm.ctx.XChainID, testEthAddrs[index], initialBaseFee, []*crypto.PrivateKeySECP256K1R{key}) if err != nil { @@ -3667,7 +3668,7 @@ func TestAtomicTxBuildBlockDropsConflicts(t *testing.T) { } atomicTxs := blk.(*chain.BlockWrapper).Block.(*Block).atomicTxs assert.True(t, len(atomicTxs) == len(testKeys), "Conflict transactions should be out of the batch") - atomicTxIDs := ids.Set{} + atomicTxIDs := set.Set[ids.ID]{} for _, tx := range atomicTxs { atomicTxIDs.Add(tx.ID()) } diff --git a/scripts/versions.sh b/scripts/versions.sh index 0a65e53210..dd46b3397a 100644 --- a/scripts/versions.sh +++ b/scripts/versions.sh @@ -3,4 +3,4 @@ # Set up the versions to be used coreth_version=${CORETH_VERSION:-'v0.11.4'} # Don't export them as they're used in the context of other calls -avalanche_version=${AVALANCHE_VERSION:-'v1.9.4-rc.0'} +avalanche_version=${AVALANCHE_VERSION:-'v1.9.4-rc.7'} diff --git a/sync/statesync/code_syncer.go b/sync/statesync/code_syncer.go index 7631ac97cf..28f47044a1 100644 --- a/sync/statesync/code_syncer.go +++ b/sync/statesync/code_syncer.go @@ -10,6 +10,7 @@ import ( "sync" "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/coreth/core/rawdb" "github.com/ava-labs/coreth/ethdb" "github.com/ava-labs/coreth/params" @@ -45,7 +46,7 @@ type codeSyncer struct { CodeSyncerConfig - outstandingCodeHashes ids.Set // Set of code hashes that we need to fetch from the network. + outstandingCodeHashes set.Set[ids.ID] // Set of code hashes that we need to fetch from the network. codeHashes chan common.Hash // Channel of incoming code hash requests // Used to set terminal error or pass nil to [errChan] if successful. @@ -62,7 +63,7 @@ func newCodeSyncer(config CodeSyncerConfig) *codeSyncer { return &codeSyncer{ CodeSyncerConfig: config, codeHashes: make(chan common.Hash, config.MaxOutstandingCodeHashes), - outstandingCodeHashes: ids.NewSet(0), + outstandingCodeHashes: set.NewSet[ids.ID](0), errChan: make(chan error, 1), } }