From 62eb3bf0fbcc03d2047a57ef8c05dc39f8780334 Mon Sep 17 00:00:00 2001 From: cce <51567+cce@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:35:14 -0400 Subject: [PATCH] CI: promote unused linter (#6120) --- .golangci-warnings.yml | 1 - .golangci.yml | 11 +++++ daemon/algod/api/client/restClient.go | 20 -------- data/transactions/verify/txn.go | 1 - ledger/store/trackerdb/generickv/schema.go | 2 +- .../sqlitedriver/spVerificationAccessor.go | 4 +- network/msgOfInterest.go | 27 +++++------ network/msgOfInterest_test.go | 6 +-- network/p2p/capabilities.go | 2 +- network/wsNetwork.go | 6 +-- network/wsNetwork_test.go | 7 ++- network/wsPeer.go | 46 +------------------ network/wsPeer_test.go | 37 +++++++++++++-- node/node_test.go | 4 -- protocol/tags.go | 29 ++++++------ protocol/tags_test.go | 45 ++++++++++++++++-- shared/pingpong/accounts.go | 2 +- util/metrics/service.go | 8 ---- 18 files changed, 130 insertions(+), 128 deletions(-) diff --git a/.golangci-warnings.yml b/.golangci-warnings.yml index 6e58b187c8..d813e97e59 100644 --- a/.golangci-warnings.yml +++ b/.golangci-warnings.yml @@ -7,7 +7,6 @@ linters: enable: - gosec - partitiontest - - unused linters-settings: gosec: # we are mostly only interested in G601 diff --git a/.golangci.yml b/.golangci.yml index db13e1d65a..bb44c1ee36 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -19,6 +19,7 @@ linters: - staticcheck - typecheck - paralleltest + - unused severity: default-severity: error @@ -115,6 +116,14 @@ issues: - "^superfluous-else: if block ends with" exclude-rules: + - path: cmd/algofix/ + linters: unused + - path: cmd/algocfg/ + linters: unused + - path: cmd/catchpointdump/ + linters: unused + - path: tools/ + linters: unused - path: _test\.go linters: - errcheck @@ -129,6 +138,7 @@ issues: # - revive # - staticcheck - typecheck + - unused - path: _test\.go linters: - staticcheck @@ -206,3 +216,4 @@ issues: - govet - ineffassign - misspell + - unused diff --git a/daemon/algod/api/client/restClient.go b/daemon/algod/api/client/restClient.go index a3dc4b769e..c349d3ecbf 100644 --- a/daemon/algod/api/client/restClient.go +++ b/daemon/algod/api/client/restClient.go @@ -347,26 +347,6 @@ type pendingTransactionsByAddrParams struct { Max uint64 `url:"max"` } -type transactionsByAddrParams struct { - FirstRound uint64 `url:"firstRound"` - LastRound uint64 `url:"lastRound"` - Max uint64 `url:"max"` -} - -type assetsParams struct { - AssetIdx uint64 `url:"assetIdx"` - Max uint64 `url:"max"` -} - -type appsParams struct { - AppIdx uint64 `url:"appIdx"` - Max uint64 `url:"max"` -} - -type rawblockParams struct { - Raw uint64 `url:"raw"` -} - type rawFormat struct { Format string `url:"format"` } diff --git a/data/transactions/verify/txn.go b/data/transactions/verify/txn.go index a345c679af..d0f38bca90 100644 --- a/data/transactions/verify/txn.go +++ b/data/transactions/verify/txn.go @@ -81,7 +81,6 @@ type GroupContext struct { } var errTxGroupInvalidFee = errors.New("txgroup fee requirement overflow") -var errTxGroupInsuffientLsigBudget = errors.New("txgroup lsig expectations exceed available budget") var errTxnSigHasNoSig = errors.New("signedtxn has no sig") var errTxnSigNotWellFormed = errors.New("signedtxn should only have one of Sig or Msig or LogicSig") var errRekeyingNotSupported = errors.New("nonempty AuthAddr but rekeying is not supported") diff --git a/ledger/store/trackerdb/generickv/schema.go b/ledger/store/trackerdb/generickv/schema.go index 47168a1288..cabbd8f13d 100644 --- a/ledger/store/trackerdb/generickv/schema.go +++ b/ledger/store/trackerdb/generickv/schema.go @@ -133,7 +133,7 @@ func creatableKey(cidx basics.CreatableIndex) [11]byte { return key } -func creatableMaxRangePrefix(maxIdx basics.CreatableIndex) ([3]byte, [11]byte) { +func creatableMaxRangePrefix(maxIdx basics.CreatableIndex) ([3]byte, [11]byte) { //nolint:unused // TODO var low [prefixLength + separatorLength]byte copy(low[0:], kvPrefixCreatorIndex) diff --git a/ledger/store/trackerdb/sqlitedriver/spVerificationAccessor.go b/ledger/store/trackerdb/sqlitedriver/spVerificationAccessor.go index b5eb3f0cc3..d9b1814c8a 100644 --- a/ledger/store/trackerdb/sqlitedriver/spVerificationAccessor.go +++ b/ledger/store/trackerdb/sqlitedriver/spVerificationAccessor.go @@ -35,7 +35,7 @@ type stateProofVerificationWriter struct { e db.Executable } -type stateProofVerificationReaderWriter struct { +type stateProofVerificationReaderWriter struct { //nolint:unused // TODO stateProofVerificationReader stateProofVerificationWriter } @@ -48,7 +48,7 @@ func makeStateProofVerificationWriter(e db.Executable) *stateProofVerificationWr return &stateProofVerificationWriter{e: e} } -func makeStateProofVerificationReaderWriter(q db.Queryable, e db.Executable) *stateProofVerificationReaderWriter { +func makeStateProofVerificationReaderWriter(q db.Queryable, e db.Executable) *stateProofVerificationReaderWriter { //nolint:unused // TODO return &stateProofVerificationReaderWriter{ stateProofVerificationReader{q: q}, stateProofVerificationWriter{e: e}, diff --git a/network/msgOfInterest.go b/network/msgOfInterest.go index 727405c8a8..be1c7d735e 100644 --- a/network/msgOfInterest.go +++ b/network/msgOfInterest.go @@ -50,6 +50,9 @@ func unmarshallMessageOfInterest(data []byte) (map[protocol.Tag]bool, error) { if len(tag) != protocol.TagLength { return nil, errInvalidMessageOfInterestInvalidTag } + if _, ok := protocol.DeprecatedTagMap[protocol.Tag(tag)]; ok { + continue + } if _, ok := protocol.TagMap[protocol.Tag(tag)]; !ok { return nil, errInvalidMessageOfInterestInvalidTag } @@ -58,23 +61,18 @@ func unmarshallMessageOfInterest(data []byte) (map[protocol.Tag]bool, error) { return msgTagsMap, nil } -// MarshallMessageOfInterest generate a message of interest message body for a given set of message tags. -func MarshallMessageOfInterest(messageTags []protocol.Tag) []byte { - // create a long string with all these messages. - tags := "" +// marshallMessageOfInterest generates a message of interest message body for a given set of message tags. +func marshallMessageOfInterest(messageTags []protocol.Tag) []byte { + m := make(map[protocol.Tag]bool) for _, tag := range messageTags { - tags += topicsEncodingSeparator + string(tag) - } - if len(tags) > 0 { - tags = tags[len(topicsEncodingSeparator):] + m[tag] = true } - topics := Topics{Topic{key: "tags", data: []byte(tags)}} - return topics.MarshallTopics() + return marshallMessageOfInterestMap(m) } -// MarshallMessageOfInterestMap generates a message of interest message body +// marshallMessageOfInterestMap generates a message of interest message body // for the message tags that map to "true" in the map argument. -func MarshallMessageOfInterestMap(tagmap map[protocol.Tag]bool) []byte { +func marshallMessageOfInterestMap(tagmap map[protocol.Tag]bool) []byte { tags := "" for tag, flag := range tagmap { if flag { @@ -95,5 +93,8 @@ func MessageOfInterestMaxSize() int { for _, tag := range protocol.TagList { allTags[tag] = true } - return len(MarshallMessageOfInterest(protocol.TagList)) + for tag := range protocol.DeprecatedTagMap { + allTags[tag] = true + } + return len(marshallMessageOfInterestMap(allTags)) } diff --git a/network/msgOfInterest_test.go b/network/msgOfInterest_test.go index ef13c6c0cc..b8e2c85249 100644 --- a/network/msgOfInterest_test.go +++ b/network/msgOfInterest_test.go @@ -51,20 +51,20 @@ func TestUnmarshallMessageOfInterestErrors(t *testing.T) { func TestMarshallMessageOfInterest(t *testing.T) { partitiontest.PartitionTest(t) - bytes := MarshallMessageOfInterest([]protocol.Tag{protocol.AgreementVoteTag}) + bytes := marshallMessageOfInterest([]protocol.Tag{protocol.AgreementVoteTag}) tags, err := unmarshallMessageOfInterest(bytes) require.NoError(t, err) require.Equal(t, tags[protocol.AgreementVoteTag], true) require.Equal(t, 1, len(tags)) - bytes = MarshallMessageOfInterest([]protocol.Tag{protocol.AgreementVoteTag, protocol.NetPrioResponseTag}) + bytes = marshallMessageOfInterest([]protocol.Tag{protocol.AgreementVoteTag, protocol.NetPrioResponseTag}) tags, err = unmarshallMessageOfInterest(bytes) require.NoError(t, err) require.Equal(t, tags[protocol.AgreementVoteTag], true) require.Equal(t, tags[protocol.NetPrioResponseTag], true) require.Equal(t, 2, len(tags)) - bytes = MarshallMessageOfInterest([]protocol.Tag{protocol.AgreementVoteTag, protocol.AgreementVoteTag}) + bytes = marshallMessageOfInterest([]protocol.Tag{protocol.AgreementVoteTag, protocol.AgreementVoteTag}) tags, err = unmarshallMessageOfInterest(bytes) require.NoError(t, err) require.Equal(t, tags[protocol.AgreementVoteTag], true) diff --git a/network/p2p/capabilities.go b/network/p2p/capabilities.go index 7a418767d1..6b79ad7d3e 100644 --- a/network/p2p/capabilities.go +++ b/network/p2p/capabilities.go @@ -79,7 +79,7 @@ func (c *CapabilitiesDiscovery) Host() host.Host { } // addPeer adds a given peer.AddrInfo to the Host's Peerstore, and the DHT's routing table -func (c *CapabilitiesDiscovery) addPeer(p peer.AddrInfo) (bool, error) { +func (c *CapabilitiesDiscovery) addPeer(p peer.AddrInfo) (bool, error) { //nolint:unused // TODO c.Host().Peerstore().AddAddrs(p.ID, p.Addrs, libpeerstore.AddressTTL) return c.dht.RoutingTable().TryAddPeer(p.ID, true, true) } diff --git a/network/wsNetwork.go b/network/wsNetwork.go index 5ab45e0406..1c5774aa6e 100644 --- a/network/wsNetwork.go +++ b/network/wsNetwork.go @@ -658,7 +658,7 @@ func (wn *WebsocketNetwork) Start() error { defer wn.messagesOfInterestMu.Unlock() wn.messagesOfInterestEncoded = true if wn.messagesOfInterest != nil { - wn.messagesOfInterestEnc = MarshallMessageOfInterestMap(wn.messagesOfInterest) + wn.messagesOfInterestEnc = marshallMessageOfInterestMap(wn.messagesOfInterest) } if wn.config.IsGossipServer() || wn.config.ForceRelayMessages { @@ -818,7 +818,7 @@ func (wn *WebsocketNetwork) RegisterHandlers(dispatch []TaggedMessageHandler) { // ClearHandlers deregisters all the existing message handlers. func (wn *WebsocketNetwork) ClearHandlers() { // exclude the internal handlers. These would get cleared out when Stop is called. - wn.handler.ClearHandlers([]Tag{protocol.PingTag, protocol.PingReplyTag, protocol.NetPrioResponseTag}) + wn.handler.ClearHandlers([]Tag{protocol.NetPrioResponseTag}) } // RegisterValidatorHandlers registers the set of given message handlers. @@ -2468,7 +2468,7 @@ func (wn *WebsocketNetwork) DeregisterMessageInterest(t protocol.Tag) { func (wn *WebsocketNetwork) updateMessagesOfInterestEnc() { // must run inside wn.messagesOfInterestMu.Lock - wn.messagesOfInterestEnc = MarshallMessageOfInterestMap(wn.messagesOfInterest) + wn.messagesOfInterestEnc = marshallMessageOfInterestMap(wn.messagesOfInterest) wn.messagesOfInterestEncoded = true wn.messagesOfInterestGeneration.Add(1) var peers []*wsPeer diff --git a/network/wsNetwork_test.go b/network/wsNetwork_test.go index 91983dfa20..1a355e5250 100644 --- a/network/wsNetwork_test.go +++ b/network/wsNetwork_test.go @@ -2904,7 +2904,7 @@ func TestWebsocketNetworkMessageOfInterest(t *testing.T) { partitiontest.PartitionTest(t) var ( ft1 = protocol.Tag("AV") - ft2 = protocol.Tag("pj") + ft2 = protocol.Tag("UE") ft3 = protocol.Tag("NI") ft4 = protocol.Tag("TX") @@ -2924,9 +2924,8 @@ func TestWebsocketNetworkMessageOfInterest(t *testing.T) { t.Logf("netA %s", addrA) netB.phonebook.ReplacePeerList([]string{addrA}, "default", phonebook.PhoneBookEntryRelayRole) - // have netB asking netA to send it ft2, deregister ping handler to make sure that we aren't exceeding the maximum MOI messagesize + // have netB asking netA to send it ft2. // Max MOI size is calculated by encoding all of the valid tags, since we are using a custom tag here we must deregister one in the default set. - netB.DeregisterMessageInterest(protocol.PingTag) netB.registerMessageInterest(ft2) netB.Start() @@ -3845,7 +3844,7 @@ func (t mockHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - bytes := MarshallMessageOfInterest([]protocol.Tag{protocol.AgreementVoteTag}) + bytes := marshallMessageOfInterest([]protocol.Tag{protocol.AgreementVoteTag}) msgBytes := append([]byte(protocol.MsgOfInterestTag), bytes...) _, err = wr.Write(msgBytes) if err != nil { diff --git a/network/wsPeer.go b/network/wsPeer.go index a6a982af59..2b30a17486 100644 --- a/network/wsPeer.go +++ b/network/wsPeer.go @@ -76,8 +76,6 @@ var defaultSendMessageTags = map[protocol.Tag]bool{ protocol.MsgDigestSkipTag: true, protocol.NetPrioResponseTag: true, protocol.NetIDVerificationTag: true, - protocol.PingTag: true, - protocol.PingReplyTag: true, protocol.ProposalPayloadTag: true, protocol.TopicMsgRespTag: true, protocol.MsgOfInterestTag: true, @@ -142,7 +140,6 @@ type disconnectReason string const disconnectReasonNone disconnectReason = "" const disconnectBadData disconnectReason = "BadData" -const disconnectTooSlow disconnectReason = "TooSlow" const disconnectReadError disconnectReason = "ReadError" const disconnectWriteError disconnectReason = "WriteError" const disconnectIdleConn disconnectReason = "IdleConnection" @@ -226,12 +223,6 @@ type wsPeer struct { processed chan struct{} - pingLock deadlock.Mutex - pingSent time.Time - pingData []byte - pingInFlight bool - lastPingRoundTripTime time.Duration - // Hint about position in wn.peers. Definitely valid if the peer // is present in wn.peers. peerIndex int @@ -684,8 +675,7 @@ func (wp *wsPeer) readLoop() { case protocol.ProposalPayloadTag: wp.ppMessageCount.Add(1) // the remaining valid tags: no special handling here - case protocol.NetPrioResponseTag, protocol.PingTag, protocol.PingReplyTag, - protocol.StateProofSigTag, protocol.UniEnsBlockReqTag, protocol.VoteBundleTag, protocol.NetIDVerificationTag: + case protocol.NetPrioResponseTag, protocol.StateProofSigTag, protocol.UniEnsBlockReqTag, protocol.VoteBundleTag, protocol.NetIDVerificationTag: default: // unrecognized tag unknownProtocolTagMessagesTotal.Inc(nil) wp.unkMessageCount.Add(1) @@ -951,40 +941,6 @@ func (wp *wsPeer) writeNonBlockMsgs(ctx context.Context, data [][]byte, highPrio // PingLength is the fixed length of ping message, exported to be used in the node.TestMaxSizesCorrect test const PingLength = 8 -const maxPingWait = 60 * time.Second - -// sendPing sends a ping block to the peer. -// return true if either a ping request was enqueued or there is already ping request in flight in the past maxPingWait time. -func (wp *wsPeer) sendPing() bool { - wp.pingLock.Lock() - defer wp.pingLock.Unlock() - now := time.Now() - if wp.pingInFlight && (now.Sub(wp.pingSent) < maxPingWait) { - return true - } - - tagBytes := []byte(protocol.PingTag) - mbytes := make([]byte, len(tagBytes)+PingLength) - copy(mbytes, tagBytes) - crypto.RandBytes(mbytes[len(tagBytes):]) - wp.pingData = mbytes[len(tagBytes):] - sent := wp.writeNonBlock(context.Background(), mbytes, false, crypto.Digest{}, time.Now()) - - if sent { - wp.pingInFlight = true - wp.pingSent = now - } - return sent -} - -// get some times out of the peer while observing the ping data lock -func (wp *wsPeer) pingTimes() (lastPingSent time.Time, lastPingRoundTripTime time.Duration) { - wp.pingLock.Lock() - defer wp.pingLock.Unlock() - lastPingSent = wp.pingSent - lastPingRoundTripTime = wp.lastPingRoundTripTime - return -} // called when the connection had an error or closed remotely func (wp *wsPeer) internalClose(reason disconnectReason) { diff --git a/network/wsPeer_test.go b/network/wsPeer_test.go index 973c027b16..ff1f9be7bc 100644 --- a/network/wsPeer_test.go +++ b/network/wsPeer_test.go @@ -241,21 +241,49 @@ func getProtocolTags(t *testing.T) []string { fset := token.NewFileSet() f, _ := parser.ParseFile(fset, file, nil, parser.ParseComments) + // get deprecated tags + deprecatedTags := make(map[string]bool) + for _, d := range f.Decls { + genDecl, ok := d.(*ast.GenDecl) + if !ok || genDecl.Tok != token.VAR { + continue + } + for _, spec := range genDecl.Specs { + if valueSpec, ok := spec.(*ast.ValueSpec); ok && len(valueSpec.Names) > 0 && + valueSpec.Names[0].Name == "DeprecatedTagList" { + for _, v := range valueSpec.Values { + cl, ok := v.(*ast.CompositeLit) + if !ok { + continue + } + for _, elt := range cl.Elts { + if ce, ok := elt.(*ast.Ident); ok { + deprecatedTags[ce.Name] = true + } + } + } + } + } + } + // look for const declarations in protocol/tags.go var declaredTags []string // Iterate through the declarations in the file for _, d := range f.Decls { genDecl, ok := d.(*ast.GenDecl) - // Check if the declaration is a constant and if not, continue + // Check if the declaration is a constant if !ok || genDecl.Tok != token.CONST { continue } // Iterate through the specs (specifications) in the declaration for _, spec := range genDecl.Specs { if valueSpec, ok := spec.(*ast.ValueSpec); ok { + if ident, isIdent := valueSpec.Type.(*ast.Ident); !isIdent || ident.Name != "Tag" { + continue // skip all but Tag constants + } for _, n := range valueSpec.Names { - if strings.HasSuffix(n.Name, "MaxSize") || n.Name == "TagLength" { - continue + if deprecatedTags[n.Name] { + continue // skip deprecated tags } declaredTags = append(declaredTags, n.Name) } @@ -263,7 +291,8 @@ func getProtocolTags(t *testing.T) []string { } } // assert these AST-discovered tags are complete (match the size of protocol.TagList) - require.Len(t, declaredTags, len(protocol.TagList)) + require.Len(t, protocol.TagList, len(declaredTags)) + require.Len(t, protocol.DeprecatedTagList, len(deprecatedTags)) return declaredTags } diff --git a/node/node_test.go b/node/node_test.go index d35ac43d98..387ea58aa8 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -798,10 +798,6 @@ func TestMaxSizesCorrect(t *testing.T) { require.Equal(t, npSize, protocol.NetPrioResponseTag.MaxMessageSize()) nsSize := uint64(network.IdentityVerificationMessageSignedMaxSize()) require.Equal(t, nsSize, protocol.NetIDVerificationTag.MaxMessageSize()) - piSize := uint64(network.PingLength) - require.Equal(t, piSize, protocol.PingTag.MaxMessageSize()) - pjSize := uint64(network.PingLength) - require.Equal(t, pjSize, protocol.PingReplyTag.MaxMessageSize()) ppSize := uint64(agreement.TransmittedPayloadMaxSize()) require.Equal(t, ppSize, protocol.ProposalPayloadTag.MaxMessageSize()) spSize := uint64(stateproof.SigFromAddrMaxSize()) diff --git a/protocol/tags.go b/protocol/tags.go index cdae9c6cdc..3a443c05cf 100644 --- a/protocol/tags.go +++ b/protocol/tags.go @@ -33,8 +33,8 @@ const ( MsgDigestSkipTag Tag = "MS" NetPrioResponseTag Tag = "NP" NetIDVerificationTag Tag = "NI" - PingTag Tag = "pi" - PingReplyTag Tag = "pj" + PingTag Tag = "pi" // was removed in 3.2.1 + PingReplyTag Tag = "pj" // was removed in 3.2.1 ProposalPayloadTag Tag = "PP" StateProofSigTag Tag = "SP" TopicMsgRespTag Tag = "TS" @@ -65,12 +65,6 @@ const NetPrioResponseTagMaxSize = 850 // NetIDVerificationTagMaxSize is the maximum size of a NetIDVerificationTag message const NetIDVerificationTagMaxSize = 215 -// PingTagMaxSize is the maximum size of a PingTag message -const PingTagMaxSize = 8 - -// PingReplyTagMaxSize is the maximum size of a PingReplyTag message -const PingReplyTagMaxSize = 8 - // ProposalPayloadTagMaxSize is the maximum size of a ProposalPayloadTag message // This value is dominated by the MaxTxnBytesPerBlock const ProposalPayloadTagMaxSize = 5250313 @@ -122,10 +116,6 @@ func (tag Tag) MaxMessageSize() uint64 { return NetPrioResponseTagMaxSize case NetIDVerificationTag: return NetIDVerificationTagMaxSize - case PingTag: - return PingTagMaxSize - case PingReplyTag: - return PingReplyTagMaxSize case ProposalPayloadTag: return ProposalPayloadTagMaxSize case StateProofSigTag: @@ -150,8 +140,6 @@ var TagList = []Tag{ MsgDigestSkipTag, NetIDVerificationTag, NetPrioResponseTag, - PingTag, - PingReplyTag, ProposalPayloadTag, StateProofSigTag, TopicMsgRespTag, @@ -160,12 +148,25 @@ var TagList = []Tag{ VoteBundleTag, } +// DeprecatedTagList contains tags that are no longer used, but may still show up in MsgOfInterest messages. +var DeprecatedTagList = []Tag{ + PingTag, + PingReplyTag, +} + // TagMap is a map of all currently used protocol tags. var TagMap map[Tag]struct{} +// DeprecatedTagMap is a map of all deprecated protocol tags. +var DeprecatedTagMap map[Tag]struct{} + func init() { TagMap = make(map[Tag]struct{}) for _, tag := range TagList { TagMap[tag] = struct{}{} } + DeprecatedTagMap = make(map[Tag]struct{}) + for _, tag := range DeprecatedTagList { + DeprecatedTagMap[tag] = struct{}{} + } } diff --git a/protocol/tags_test.go b/protocol/tags_test.go index 69c3146cf9..d4440a45cc 100644 --- a/protocol/tags_test.go +++ b/protocol/tags_test.go @@ -78,6 +78,37 @@ func getConstValues(t *testing.T, fileName string, typeName string, namesOnly bo return ret } +func getDeprecatedTags(t *testing.T) map[string]bool { + fset := token.NewFileSet() + f, _ := parser.ParseFile(fset, "tags.go", nil, 0) + + deprecatedTags := make(map[string]bool) + for _, d := range f.Decls { + genDecl, ok := d.(*ast.GenDecl) + if !ok || genDecl.Tok != token.VAR { + continue + } + for _, spec := range genDecl.Specs { + if valueSpec, ok := spec.(*ast.ValueSpec); ok && len(valueSpec.Names) > 0 && + valueSpec.Names[0].Name == "DeprecatedTagList" { + for _, v := range valueSpec.Values { + cl, ok := v.(*ast.CompositeLit) + if !ok { + continue + } + for _, elt := range cl.Elts { + if ce, ok := elt.(*ast.Ident); ok { + deprecatedTags[ce.Name] = true + } + } + } + } + } + } + + return deprecatedTags +} + // TestTagList checks that the TagList global variable contains // all the constant Tag variables declared in tags.go. func TestTagList(t *testing.T) { @@ -88,11 +119,16 @@ func TestTagList(t *testing.T) { // Verify that TagList is not empty and has the same length as constTags require.NotEmpty(t, TagList) - require.Len(t, TagList, len(constTags), "TagList is not complete") + require.Len(t, TagList, len(constTags)-len(DeprecatedTagMap), "TagList is not complete") tagListMap := make(map[Tag]bool) for _, tag := range TagList { tagListMap[tag] = true } + for tag := range DeprecatedTagMap { + // ensure deprecated tags are not in TagList + require.False(t, tagListMap[tag]) + tagListMap[tag] = true + } // Iterate through constTags and check that each element exists in tagListMap for _, constTag := range constTags { if tagListMap[Tag(constTag)] { @@ -168,11 +204,16 @@ func TestMaxSizesTested(t *testing.T) { } } + deprecatedTags := getDeprecatedTags(t) for _, tag := range constTags { if tag == "TxnTag" { // TxnTag is tested in a looser way in TestMaxSizesCorrect continue } + if deprecatedTags[tag] { + continue + } + require.Truef(t, tagsFound[tag], "Tag %s does not have a corresponding test in TestMaxSizesCorrect", tag) } } @@ -242,8 +283,6 @@ func TestLockdownTagList(t *testing.T) { MsgDigestSkipTag, NetIDVerificationTag, NetPrioResponseTag, - PingTag, - PingReplyTag, ProposalPayloadTag, StateProofSigTag, TopicMsgRespTag, diff --git a/shared/pingpong/accounts.go b/shared/pingpong/accounts.go index 99eb4b25bc..8ac9c44a87 100644 --- a/shared/pingpong/accounts.go +++ b/shared/pingpong/accounts.go @@ -958,7 +958,7 @@ func (pps *WorkerState) appFundFromSourceAccount(appID uint64, client *libgoal.C return nil } -func takeTopAccounts(allAccounts map[string]*pingPongAccount, numAccounts uint32, srcAccount string) (accounts map[string]*pingPongAccount) { +func takeTopAccounts(allAccounts map[string]*pingPongAccount, numAccounts uint32, srcAccount string) (accounts map[string]*pingPongAccount) { //nolint:unused // TODO allAddrs := make([]string, len(allAccounts)) var i int for addr := range allAccounts { diff --git a/util/metrics/service.go b/util/metrics/service.go index e579fd01a1..c7089470c6 100644 --- a/util/metrics/service.go +++ b/util/metrics/service.go @@ -22,7 +22,6 @@ import ( "errors" "os" "strconv" - "time" ) var ( @@ -34,13 +33,6 @@ var ( ErrMetricUnableToRegister = errors.New("Unable to register metric") ) -var ( - // the duration of which we'll keep a metric in-memory and keep reporting it. - // when a metric time expires, it would get removed. - // TODO: implement or remove - maxMetricRetensionDuration = time.Duration(5) * time.Minute -) - // MakeMetricService creates a new metrics server at the given endpoint. func MakeMetricService(config *ServiceConfig) *MetricService { server := &MetricService{