From 68374f2e2eebb30fa7b1db05989abf706d8a94cf Mon Sep 17 00:00:00 2001 From: ucwong Date: Tue, 30 May 2023 19:00:12 +0800 Subject: [PATCH] deps --- go.mod | 8 ++--- go.sum | 16 ++++----- .../torrent/peer_protocol/decoder.go | 35 ++++++++++++------- .../anacrolix/torrent/peer_protocol/msg.go | 2 +- vendor/github.com/anacrolix/torrent/pex.go | 9 +++-- .../github.com/anacrolix/torrent/pexconn.go | 8 +++++ .../github.com/cockroachdb/pebble/ingest.go | 4 +++ .../github.com/cockroachdb/pebble/metrics.go | 8 +++++ vendor/modules.txt | 8 ++--- 9 files changed, 67 insertions(+), 31 deletions(-) diff --git a/go.mod b/go.mod index 1a8a19610a..8fa50d4689 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1 github.com/CortexFoundation/inference v1.0.2-0.20230307032835-9197d586a4e8 github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 - github.com/CortexFoundation/torrentfs v1.0.43-0.20230528102152-5155a84ffaed + github.com/CortexFoundation/torrentfs v1.0.43-0.20230530100627-7bfe09a114cf github.com/VictoriaMetrics/fastcache v1.12.1 github.com/arsham/figurine v1.3.0 github.com/aws/aws-sdk-go-v2 v1.17.7 @@ -17,7 +17,7 @@ require ( github.com/cespare/cp v1.1.1 github.com/charmbracelet/bubbletea v0.23.2 github.com/cloudflare/cloudflare-go v0.57.1 - github.com/cockroachdb/pebble v0.0.0-20230527012508-ac69476c46ff + github.com/cockroachdb/pebble v0.0.0-20230529170040-f235f568816e github.com/consensys/gnark-crypto v0.10.0 github.com/crate-crypto/go-kzg-4844 v0.2.0 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc @@ -99,7 +99,7 @@ require ( github.com/anacrolix/multiless v0.3.1-0.20221221005021-2d12701f83f7 // indirect github.com/anacrolix/stm v0.5.0 // indirect github.com/anacrolix/sync v0.4.0 // indirect - github.com/anacrolix/torrent v1.51.4-0.20230528035322-5efb4dd9410e // indirect + github.com/anacrolix/torrent v1.52.1-0.20230529090101-ac086bb3bd3b // indirect github.com/anacrolix/upnp v0.1.3-0.20220123035249-922794e51c96 // indirect github.com/anacrolix/utp v0.2.0 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect @@ -210,7 +210,7 @@ require ( github.com/tklauser/numcpus v0.6.0 // indirect github.com/ucwong/filecache v1.0.6-0.20230405163841-810d53ced4bd // indirect github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb // indirect - github.com/ucwong/golang-kv v1.0.20-0.20230527092737-7031c7fd276d // indirect + github.com/ucwong/golang-kv v1.0.20-0.20230529202344-2e8d2e5c7a38 // indirect github.com/ucwong/shard v1.0.1-0.20230505153952-911e99b5f0c2 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/xujiajun/mmap-go v1.0.1 // indirect diff --git a/go.sum b/go.sum index 9cde5599f2..c93cf41a18 100644 --- a/go.sum +++ b/go.sum @@ -67,8 +67,8 @@ github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66/go.mod h1: github.com/CortexFoundation/torrentfs v1.0.13-0.20200623060705-ce027f43f2f8/go.mod h1:Ma+tGhPPvz4CEZHaqEJQMOEGOfHeQBiAoNd1zyc/w3Q= github.com/CortexFoundation/torrentfs v1.0.14-0.20200703071639-3fcabcabf274/go.mod h1:qnb3YlIJmuetVBtC6Lsejr0Xru+1DNmDCdTqnwy7lhk= github.com/CortexFoundation/torrentfs v1.0.20-0.20200810031954-d36d26f82fcc/go.mod h1:N5BsicP5ynjXIi/Npl/SRzlJ630n1PJV2sRj0Z0t2HA= -github.com/CortexFoundation/torrentfs v1.0.43-0.20230528102152-5155a84ffaed h1:VMOrIETsezrRuguj59X5IOssvge6ulB6641rrICL5/4= -github.com/CortexFoundation/torrentfs v1.0.43-0.20230528102152-5155a84ffaed/go.mod h1:u9AYrTvM43uAc4cxOXGvwBw9HRtTT9VBXFdMQZSHIm0= +github.com/CortexFoundation/torrentfs v1.0.43-0.20230530100627-7bfe09a114cf h1:KuU/V2mIKg+55MI++3SgugOSW03jQnPuPBe4uhjLi6Y= +github.com/CortexFoundation/torrentfs v1.0.43-0.20230530100627-7bfe09a114cf/go.mod h1:WdGkOFfYRVTyOqjyDx2ubMD/Lnq3WeQpFPdzGQurlD0= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= @@ -211,8 +211,8 @@ github.com/anacrolix/torrent v1.15.0/go.mod h1:MFc6KcbpAyfwGqOyRkdarUK9QnKA/FkVg github.com/anacrolix/torrent v1.15.1-0.20200504230043-cc5d2abe18e5/go.mod h1:QlOfgrCz5kbvhOz8M58dUwHY5SfZ9VbIvReZ0z0MdIk= github.com/anacrolix/torrent v1.15.1-0.20200619022403-dd51e99b88cc/go.mod h1:wuopQPC5+/M+zHYvhcA2vp5UCTm9rUc+VqjyBa882Q8= github.com/anacrolix/torrent v1.15.1-0.20200715061614-dd906f8fa72e/go.mod h1:XWo/fJN1oKgcjgxM+pUZpvalHfqHDs27BY5mBZjIQWo= -github.com/anacrolix/torrent v1.51.4-0.20230528035322-5efb4dd9410e h1:rrdRJi0ALM/mRux5k8lZcjqd9PqfEAJybCgpInni1MU= -github.com/anacrolix/torrent v1.51.4-0.20230528035322-5efb4dd9410e/go.mod h1:+XzcWXQU97PPEWSvpC85MJyqzP1vz47M5BYGno4vIHg= +github.com/anacrolix/torrent v1.52.1-0.20230529090101-ac086bb3bd3b h1:8GauwzI1T02k+9Iw5wj9iaQTNLKycjtwlD8QzE+uXww= +github.com/anacrolix/torrent v1.52.1-0.20230529090101-ac086bb3bd3b/go.mod h1:+XzcWXQU97PPEWSvpC85MJyqzP1vz47M5BYGno4vIHg= github.com/anacrolix/upnp v0.1.1/go.mod h1:LXsbsp5h+WGN7YR+0A7iVXm5BL1LYryDev1zuJMWYQo= github.com/anacrolix/upnp v0.1.2-0.20200416075019-5e9378ed1425/go.mod h1:Pz94W3kl8rf+wxH3IbCa9Sq+DTJr8OSbV2Q3/y51vYs= github.com/anacrolix/upnp v0.1.3-0.20220123035249-922794e51c96 h1:QAVZ3pN/J4/UziniAhJR2OZ9Ox5kOY2053tBbbqUPYA= @@ -351,8 +351,8 @@ github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZO github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230527012508-ac69476c46ff h1:/F1VgP7wxZCRj8PzresPo2NbAdgPwmU7pi+CgZ8sBZw= -github.com/cockroachdb/pebble v0.0.0-20230527012508-ac69476c46ff/go.mod h1:TkdVsGYRqtULUppt2RbC+YaKtTHnHoWa2apfFrSKABw= +github.com/cockroachdb/pebble v0.0.0-20230529170040-f235f568816e h1:iB7Z/maVDYLJo034mHHO8PJz46bXxmbZQJcpCKLyxpg= +github.com/cockroachdb/pebble v0.0.0-20230529170040-f235f568816e/go.mod h1:TkdVsGYRqtULUppt2RbC+YaKtTHnHoWa2apfFrSKABw= github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/redact v1.1.4 h1:Y0XrVI2FAyofNyGveodTN//qdpPtFKcKTeCBsK3AHAQ= github.com/cockroachdb/redact v1.1.4/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= @@ -1271,8 +1271,8 @@ github.com/ucwong/filecache v1.0.6-0.20230405163841-810d53ced4bd h1:gBtlvLAsgLk+ github.com/ucwong/filecache v1.0.6-0.20230405163841-810d53ced4bd/go.mod h1:ddwX+NCjMZPdpzcGh1fcEbNTUTCtKgt2hC2rqvmLKgA= github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb h1:dVZH3AH9f7zB3VBmsjn25B7lfcAyMP4QxdFYTrfj7tg= github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb/go.mod h1:3yswsBsVuwsOjDvFfC5Na9XSEf4HC7mj3W3g6jvSY/s= -github.com/ucwong/golang-kv v1.0.20-0.20230527092737-7031c7fd276d h1:ruuTtbFDRcEhnpgCTdpIHvKtscwB4/lK+sXUKdEJl8Y= -github.com/ucwong/golang-kv v1.0.20-0.20230527092737-7031c7fd276d/go.mod h1:lOZr0fLPrtejGy6k8JLvoPYBNs+FjBUdjodRGucBfCs= +github.com/ucwong/golang-kv v1.0.20-0.20230529202344-2e8d2e5c7a38 h1:UDCioFG6fVbPJEwj0beG63hRbdFG/dVJlj0Ykg3WgFk= +github.com/ucwong/golang-kv v1.0.20-0.20230529202344-2e8d2e5c7a38/go.mod h1:9dobGnLPEHP1EJt9+8i1T12W0qTzaofbj41nfJtWbCY= github.com/ucwong/golang-set v1.8.1-0.20200419153428-d7b0b1ac2d43/go.mod h1:xu0FaiQFGbBcFZj2o7udZ5rbA8jRTsv47hkPoG5qQNM= github.com/ucwong/goleveldb v1.0.3-0.20200508074755-578cba616f37/go.mod h1:dgJUTtDxq/ne6/JzZhHzF24OL/uqILz9IWk8HmT4V2g= github.com/ucwong/goleveldb v1.0.3-0.20200618184106-f1c6bc3a428b/go.mod h1:7Sq6w7AfEZuB/a6mrlvHCSXCSkqojCMMrM3Ei12QAT0= diff --git a/vendor/github.com/anacrolix/torrent/peer_protocol/decoder.go b/vendor/github.com/anacrolix/torrent/peer_protocol/decoder.go index f4432f64d6..9dfe125b1a 100644 --- a/vendor/github.com/anacrolix/torrent/peer_protocol/decoder.go +++ b/vendor/github.com/anacrolix/torrent/peer_protocol/decoder.go @@ -11,7 +11,10 @@ import ( ) type Decoder struct { - R *bufio.Reader + R *bufio.Reader + // This must return *[]byte where the slices can fit data for piece messages. I think we store + // *[]byte in the pool to avoid an extra allocation every time we put the slice back into the + // pool. The chunk size should not change for the life of the decoder. Pool *sync.Pool MaxLength Integer // TODO: Should this include the length header or not? } @@ -35,11 +38,18 @@ func (d *Decoder) Decode(msg *Message) (err error) { length-- return d.R.ReadByte() } + // From this point onwards, EOF is unexpected + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() c, err := readByte() if err != nil { return } msg.Type = MessageType(c) + // Can return directly in cases when err is not nil, or length is known to be zero. switch msg.Type { case Choke, Unchoke, Interested, NotInterested, HaveAll, HaveNone: case Have, AllowedFast, Suggest: @@ -58,6 +68,7 @@ func (d *Decoder) Decode(msg *Message) (err error) { _, err = io.ReadFull(r, b) length = 0 msg.Bitfield = unmarshalBitfield(b) + return case Piece: for _, pi := range []*Integer{&msg.Index, &msg.Begin} { err := pi.Read(r) @@ -67,16 +78,18 @@ func (d *Decoder) Decode(msg *Message) (err error) { } length -= 8 dataLen := int64(length) - msg.Piece = *d.Pool.Get().(*[]byte) - if int64(cap(msg.Piece)) < dataLen { - return errors.New("piece data longer than expected") - } - msg.Piece = msg.Piece[:dataLen] - _, err := io.ReadFull(r, msg.Piece) - if err != nil { - return fmt.Errorf("reading piece data: %w", err) + if d.Pool == nil { + msg.Piece = make([]byte, dataLen) + } else { + msg.Piece = *d.Pool.Get().(*[]byte) + if int64(cap(msg.Piece)) < dataLen { + return errors.New("piece data longer than expected") + } + msg.Piece = msg.Piece[:dataLen] } + _, err = io.ReadFull(r, msg.Piece) length = 0 + return case Extended: var b byte b, err = readByte() @@ -86,10 +99,8 @@ func (d *Decoder) Decode(msg *Message) (err error) { msg.ExtendedID = ExtensionNumber(b) msg.ExtendedPayload = make([]byte, length) _, err = io.ReadFull(r, msg.ExtendedPayload) - if err == io.EOF { - err = io.ErrUnexpectedEOF - } length = 0 + return case Port: err = binary.Read(r, binary.BigEndian, &msg.Port) length -= 2 diff --git a/vendor/github.com/anacrolix/torrent/peer_protocol/msg.go b/vendor/github.com/anacrolix/torrent/peer_protocol/msg.go index 23710e6339..f1b1f10e83 100644 --- a/vendor/github.com/anacrolix/torrent/peer_protocol/msg.go +++ b/vendor/github.com/anacrolix/torrent/peer_protocol/msg.go @@ -66,7 +66,7 @@ func (msg Message) MarshalBinary() (data []byte, err error) { } switch msg.Type { case Choke, Unchoke, Interested, NotInterested, HaveAll, HaveNone: - case Have: + case Have, AllowedFast, Suggest: err = binary.Write(&buf, binary.BigEndian, msg.Index) case Request, Cancel, Reject: for _, i := range []Integer{msg.Index, msg.Begin, msg.Length} { diff --git a/vendor/github.com/anacrolix/torrent/pex.go b/vendor/github.com/anacrolix/torrent/pex.go index 4770f3d3bb..a0a5f49f5b 100644 --- a/vendor/github.com/anacrolix/torrent/pex.go +++ b/vendor/github.com/anacrolix/torrent/pex.go @@ -4,6 +4,7 @@ import ( "net" "net/netip" "sync" + "time" pp "github.com/anacrolix/torrent/peer_protocol" ) @@ -144,8 +145,11 @@ func (me *pexMsgFactory) PexMsg() *pp.PexMsg { // Per-torrent PEX state type pexState struct { sync.RWMutex - tail *pexEvent // event feed list - hold []pexEvent // delayed drops + tail *pexEvent // event feed list + hold []pexEvent // delayed drops + // Torrent-wide cooldown deadline on inbound. This exists to prevent PEX from drowning out other + // peer address sources, until that is fixed. + rest time.Time nc int // net number of alive conns msg0 pexMsgFactory // initial message } @@ -157,6 +161,7 @@ func (s *pexState) Reset() { s.tail = nil s.hold = nil s.nc = 0 + s.rest = time.Time{} s.msg0 = pexMsgFactory{} } diff --git a/vendor/github.com/anacrolix/torrent/pexconn.go b/vendor/github.com/anacrolix/torrent/pexconn.go index 2f7e7df08d..9254f5e187 100644 --- a/vendor/github.com/anacrolix/torrent/pexconn.go +++ b/vendor/github.com/anacrolix/torrent/pexconn.go @@ -143,9 +143,17 @@ func (s *pexConnState) Recv(payload []byte) error { var peers peerInfos peers.AppendFromPex(rx.Added6, rx.Added6Flags) peers.AppendFromPex(rx.Added, rx.AddedFlags) + if time.Now().Before(s.torrent.pex.rest) { + s.dbg.Printf("in cooldown period, incoming PEX discarded") + return nil + } added := s.torrent.addPeers(peers) s.dbg.Printf("got %v peers over pex, added %v", len(peers), added) + if len(peers) > 0 { + s.torrent.pex.rest = time.Now().Add(pexInterval) + } + // one day we may also want to: // - handle drops somehow // - detect malicious peers diff --git a/vendor/github.com/cockroachdb/pebble/ingest.go b/vendor/github.com/cockroachdb/pebble/ingest.go index 617c8b268f..aaf9ddbbcb 100644 --- a/vendor/github.com/cockroachdb/pebble/ingest.go +++ b/vendor/github.com/cockroachdb/pebble/ingest.go @@ -816,6 +816,7 @@ func (d *DB) ingest( if err != nil { return IngestOperationStats{}, err } + if len(meta) == 0 { // All of the sstables to be ingested were empty. Nothing to do. return IngestOperationStats{}, nil @@ -1106,6 +1107,9 @@ func (d *DB) ingestApply( }); err != nil { return nil, err } + + d.mu.versions.metrics.Ingest.Count++ + d.updateReadStateLocked(d.opts.DebugCheck) d.updateTableStatsLocked(ve.NewFiles) // The ingestion may have pushed a level over the threshold for compaction, diff --git a/vendor/github.com/cockroachdb/pebble/metrics.go b/vendor/github.com/cockroachdb/pebble/metrics.go index cd90d03515..b030de9120 100644 --- a/vendor/github.com/cockroachdb/pebble/metrics.go +++ b/vendor/github.com/cockroachdb/pebble/metrics.go @@ -184,6 +184,11 @@ type Metrics struct { Duration time.Duration } + Ingest struct { + // The total number of ingestions + Count uint64 + } + Flush struct { // The total number of flushes. Count int64 @@ -504,6 +509,9 @@ func (m *Metrics) SafeFormat(w redact.SafePrinter, _ rune) { notApplicable, notApplicable, redact.Safe(hitRate(m.Filter.Hits, m.Filter.Misses))) + w.Printf(" ingest %9d\n", + redact.Safe(m.Ingest.Count), + ) } func hitRate(hits, misses int64) float64 { diff --git a/vendor/modules.txt b/vendor/modules.txt index 7a9a026e00..bd627ba7bd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -45,7 +45,7 @@ github.com/CortexFoundation/merkletree # github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 ## explicit; go 1.16 github.com/CortexFoundation/statik -# github.com/CortexFoundation/torrentfs v1.0.43-0.20230528102152-5155a84ffaed +# github.com/CortexFoundation/torrentfs v1.0.43-0.20230530100627-7bfe09a114cf ## explicit; go 1.20 github.com/CortexFoundation/torrentfs github.com/CortexFoundation/torrentfs/backend @@ -137,7 +137,7 @@ github.com/anacrolix/stm/stmutil # github.com/anacrolix/sync v0.4.0 ## explicit; go 1.13 github.com/anacrolix/sync -# github.com/anacrolix/torrent v1.51.4-0.20230528035322-5efb4dd9410e +# github.com/anacrolix/torrent v1.52.1-0.20230529090101-ac086bb3bd3b ## explicit; go 1.20 github.com/anacrolix/torrent github.com/anacrolix/torrent/analysis @@ -335,7 +335,7 @@ github.com/cockroachdb/errors/withstack # github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b ## explicit; go 1.16 github.com/cockroachdb/logtags -# github.com/cockroachdb/pebble v0.0.0-20230527012508-ac69476c46ff +# github.com/cockroachdb/pebble v0.0.0-20230529170040-f235f568816e ## explicit; go 1.19 github.com/cockroachdb/pebble github.com/cockroachdb/pebble/bloom @@ -938,7 +938,7 @@ github.com/ucwong/filecache # github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb ## explicit; go 1.19 github.com/ucwong/go-ttlmap -# github.com/ucwong/golang-kv v1.0.20-0.20230527092737-7031c7fd276d +# github.com/ucwong/golang-kv v1.0.20-0.20230529202344-2e8d2e5c7a38 ## explicit; go 1.20 github.com/ucwong/golang-kv github.com/ucwong/golang-kv/badger