chore: reduce external dependencies by removing 13 packages#518
Open
chore: reduce external dependencies by removing 13 packages#518
Conversation
Remove direct dependency on ordishs/go-utils, libsv/go-p2p, and 11 other external packages by replacing them with stdlib equivalents or small internal implementations.
Contributor
|
🤖 Claude Code Review Status: Complete Current Review: This PR successfully reduces 13 external dependencies by internalizing simple utilities and using stdlib replacements. The internalized code quality is good with proper cleanup patterns. Unresolved Issue:
Previously Fixed (verified):
|
Add Stop() method and use time.NewTicker with a select loop to prevent goroutine leaks from the background cleanup routine.
Call Stop() on every ExpiringMap during service shutdown and test cleanup to prevent goroutine leaks from background ticker routines. Production code: added to S3.Close(), SyncManager.Stop(), SubtreeValidation.Stop(), BlockValidation (new StopCaches method), Orphanage (new Stop method), UTXOSetCache, ExpiringConcurrentCache. Test code: added defer/t.Cleanup Stop() calls at all creation sites.
- Remove rpcCallCache.Stop() from RPCServer.Stop() since the cache is a package-level global whose lifetime outlives individual servers. Calling Stop() twice on ttlcache deadlocks. - Add nil guards for orphanage and invalidSubtreeDeDuplicateMap in subtreevalidation Server.Stop() since tests may not initialize them.
|
freemans13
approved these changes
Feb 19, 2026
ordishs
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Reduce the external dependency footprint by removing 13 packages from go.mod (473 → 460 lines, go.sum 1395 → 1361 lines). All replacements use either Go stdlib, existing dependencies already in the project, or small internalized implementations.
Motivation
The primary driver was ordishs/go-utils, which was imported in 43 files but pulled in heavy transitive dependencies:
InitGlobalTracer)sync/atomicsince Go 1.19The go-utils library itself only provided a handful of simple utility functions (
ReverseAndHexEncodeSlice,SafeSend,ExpiringMap) that are trivial to implement locally. Internalizing these eliminated the entire jaeger/uber dependency chain.libsv/go-p2p was only used for test fixture constants (
TX1Raw,TX1RawBytes) in 4 test files — inlined as local constants.Changes by category
Stdlib replacements (zero-risk)
kpango/fastimetime.Now().UnixMilli()golang.org/x/exp/randcrypto/randgolang.org/x/exp/constraints+ custommaxfuncmax(Go 1.21+)golang.org/x/exp/slicesslicesgo.uber.org/atomicsync/atomicjson-iterator/goencoding/jsongocarina/gocsvencoding/csvConsolidation (removed duplicates)
patrickmn/go-cachejellydator/ttlcache/v3(already in deps)cespare/xxhashv1cespare/xxhash/v2(already in deps)Internalized from ordishs/go-utils
expiringmap.ExpiringMaputil/expiringmap/safemap.Safemaputil/safemap/ReverseAndHexEncodeSlice,DecodeAndReverseHexString,ReverseSliceutil/reverse_hex.goSafeSend[T]util/safe_send.goFormatComma(replaceddustin/go-humanize)util/format_comma.goLoggerinterfaceulogger.LoggerTest fixture inlining
libsv/go-p2ptest.TX1Raw,TX1Hash,TX2RawBytesetc. inlined as local constantsjoho/godotenvloadEnvFile()Dependencies fully removed from go.mod
Direct:
kpango/fastime,cespare/xxhashv1,gocarina/gocsv,ordishs/go-utils,libsv/go-p2p,patrickmn/go-cacheIndirect (no longer needed):
uber/jaeger-client-go,uber/jaeger-lib,go.uber.org/atomic,golang.org/x/exp,joho/godotenv,dustin/go-humanize,json-iterator/goTest plan
go build ./...passesmake lintpasses (0 issues)make testpasses (pre-existingTestImprovedCache_OverfillGenerationStatsfailure fixed — bound was too tight for hash distribution variance)go mod tidyis cleangrep -r 'ordishs/go-utils\|libsv/go-p2p' --include='*.go'returns nothing