diff --git a/go.mod b/go.mod index baed450ff..c7df6d383 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0 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.69-0.20241204160300-7085a7256ea1 + github.com/CortexFoundation/torrentfs v1.0.69-0.20241209112125-47a204623d40 github.com/VictoriaMetrics/fastcache v1.12.2 github.com/arsham/figurine v1.3.0 github.com/aws/aws-sdk-go-v2 v1.32.6 @@ -38,7 +38,7 @@ require ( github.com/gorilla/websocket v1.5.3 github.com/hashicorp/golang-lru v1.0.2 github.com/holiman/bloomfilter/v2 v2.0.3 - github.com/holiman/uint256 v1.3.1 + github.com/holiman/uint256 v1.3.2 github.com/huin/goupnp v1.3.0 github.com/influxdata/influxdb-client-go/v2 v2.14.0 github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c @@ -121,7 +121,7 @@ require ( github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/benbjohnson/immutable v0.4.3 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bits-and-blooms/bitset v1.17.0 // indirect + github.com/bits-and-blooms/bitset v1.18.0 // indirect github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect github.com/bwmarrin/snowflake v0.3.0 // indirect github.com/cespare/xxhash v1.1.0 // indirect @@ -138,7 +138,7 @@ require ( github.com/consensys/bavard v0.1.22 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect - github.com/dgraph-io/badger/v4 v4.5.1-0.20241202092052-28fb51daf2e1 // indirect + github.com/dgraph-io/badger/v4 v4.5.1-0.20241205031432-6027e2f549b8 // indirect github.com/dgraph-io/ristretto/v2 v2.0.0 // indirect github.com/dlclark/regexp2 v1.11.4 // indirect github.com/dustin/go-humanize v1.0.1 // indirect @@ -225,7 +225,7 @@ require ( github.com/tklauser/numcpus v0.9.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.24-0.20241204155516-b95d1a27ab32 // indirect + github.com/ucwong/golang-kv v1.0.24-0.20241207143212-a23845651f1b // indirect github.com/ucwong/shard v1.0.1-0.20240327124306-59a521744cae // indirect github.com/wlynxg/anet v0.0.5 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect diff --git a/go.sum b/go.sum index aff259e1a..f233b2ba1 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,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.69-0.20241204160300-7085a7256ea1 h1:cwClxy38evmrduG3qWpAR5UF27PJANBguFQypKiGLig= -github.com/CortexFoundation/torrentfs v1.0.69-0.20241204160300-7085a7256ea1/go.mod h1:SoKBW0AQ95TvPQsEoM5whh7aKLu9R4JLaN65TqZYqDw= +github.com/CortexFoundation/torrentfs v1.0.69-0.20241209112125-47a204623d40 h1:yxVrps9hbOaLmGu8OkluLfeff2ylOpJ9TdCN1aJR3h0= +github.com/CortexFoundation/torrentfs v1.0.69-0.20241209112125-47a204623d40/go.mod h1:pSVkZci7kFMpvus52MITMIra9O9FK5hO1ALFt9Kfsak= github.com/CortexFoundation/wormhole v0.0.2-0.20241128010855-a23c88842cfa h1:46VAGWxOwpoLlPNcR9etAhK0NtT215skO9Wl4i14r4o= github.com/CortexFoundation/wormhole v0.0.2-0.20241128010855-a23c88842cfa/go.mod h1:ipzmPabDgzYKUbXkGVe2gTkBEp+MsDx6pXGiuYzmP6s= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= @@ -304,8 +304,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bitly/go-simplejson v0.5.1-0.20200416141419-39a59b1b2866/go.mod h1:bXegrmTNBg3jTbSwV0BSBcSSfHHctupCgavZr/gX5fo= github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= -github.com/bits-and-blooms/bitset v1.17.0 h1:1X2TS7aHz1ELcC0yU1y2stUs/0ig5oMU6STFZGrhvHI= -github.com/bits-and-blooms/bitset v1.17.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.18.0 h1:eCa5BU3k9TtC6GP0r+bER6Si5ow7O0S+EXahjgwpLLs= +github.com/bits-and-blooms/bitset v1.18.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= @@ -412,8 +412,8 @@ github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5il github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/dgraph-io/badger/v4 v4.5.1-0.20241202092052-28fb51daf2e1 h1:a4WwdT/mHIqzaqrG6A86/JFXjjw3102QfCI/vVVWCS8= -github.com/dgraph-io/badger/v4 v4.5.1-0.20241202092052-28fb51daf2e1/go.mod h1:ysgYmIeG8dS/E8kwxT7xHyc7MkmwNYLRoYnFbr7387A= +github.com/dgraph-io/badger/v4 v4.5.1-0.20241205031432-6027e2f549b8 h1:X8Uami00qamSAle5raVIyA4+XVVSj02FC6Yv6DYNco0= +github.com/dgraph-io/badger/v4 v4.5.1-0.20241205031432-6027e2f549b8/go.mod h1:XjA53MAnqnIJZR55zKv3agaCukWIZRnnESksjrXUidw= github.com/dgraph-io/ristretto/v2 v2.0.0 h1:l0yiSOtlJvc0otkqyMaDNysg8E9/F/TYZwMbxscNOAQ= github.com/dgraph-io/ristretto/v2 v2.0.0/go.mod h1:FVFokF2dRqXyPyeMnK1YDy8Fc6aTe0IKgbcd03CYeEk= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -692,8 +692,8 @@ github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZ github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.1.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= -github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= -github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/holiman/uint256 v1.3.2 h1:a9EgMPSC1AAaj1SZL5zIQD3WbwTuHrMGOerLjGmM/TA= +github.com/holiman/uint256 v1.3.2/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= @@ -1248,8 +1248,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.24-0.20241204155516-b95d1a27ab32 h1:ueDi/pL+ODKhPKydBTiv4nP++zR+m6Ke0IiVNJhowJQ= -github.com/ucwong/golang-kv v1.0.24-0.20241204155516-b95d1a27ab32/go.mod h1:yifrX4N6b+sil+Kfezib57vAxUzuX80V4pg7+akI7lM= +github.com/ucwong/golang-kv v1.0.24-0.20241207143212-a23845651f1b h1:VcZVV8FVFzA+B1dLRi9JOn4+Mc9NiKjMTt4Vo91tDCU= +github.com/ucwong/golang-kv v1.0.24-0.20241207143212-a23845651f1b/go.mod h1:3yp1cEOQtSrAhJchLSFINJfifWlctqwhP10LxEKoHuU= 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/bits-and-blooms/bitset/README.md b/vendor/github.com/bits-and-blooms/bitset/README.md index f48d52a1d..c53bcf802 100644 --- a/vendor/github.com/bits-and-blooms/bitset/README.md +++ b/vendor/github.com/bits-and-blooms/bitset/README.md @@ -12,7 +12,7 @@ This library is part of the [awesome go collection](https://github.com/avelino/a * [beego](https://github.com/beego/beego) * [CubeFS](https://github.com/cubefs/cubefs) * [Amazon EKS Distro](https://github.com/aws/eks-distro) -* [sourcegraph](https://github.com/sourcegraph/sourcegraph) +* [sourcegraph](https://github.com/sourcegraph/sourcegraph-public-snapshot) * [torrent](https://github.com/anacrolix/torrent) @@ -125,7 +125,7 @@ E.g., ## Memory Usage -The memory usage of a bitset using `N` bits is at least `N/8` bytes. The number of bits in a bitset is at least as large as one plus the greatest bit index you have accessed. Thus it is possible to run out of memory while using a bitset. If you have lots of bits, you might prefer compressed bitsets, like the [Roaring bitmaps](http://roaringbitmap.org) and its [Go implementation](https://github.com/RoaringBitmap/roaring). +The memory usage of a bitset using `N` bits is at least `N/8` bytes. The number of bits in a bitset is at least as large as one plus the greatest bit index you have accessed. Thus it is possible to run out of memory while using a bitset. If you have lots of bits, you might prefer compressed bitsets, like the [Roaring bitmaps](https://roaringbitmap.org) and its [Go implementation](https://github.com/RoaringBitmap/roaring). The `roaring` library allows you to go back and forth between compressed Roaring bitmaps and the conventional bitset instances: ```Go diff --git a/vendor/github.com/bits-and-blooms/bitset/bitset.go b/vendor/github.com/bits-and-blooms/bitset/bitset.go index 334367dd9..cf11581a3 100644 --- a/vendor/github.com/bits-and-blooms/bitset/bitset.go +++ b/vendor/github.com/bits-and-blooms/bitset/bitset.go @@ -44,6 +44,7 @@ import ( "errors" "fmt" "io" + "math/bits" "strconv" ) @@ -491,7 +492,7 @@ func (b *BitSet) NextSet(i uint) (uint, bool) { w := b.set[x] w = w >> wordsIndex(i) if w != 0 { - return i + trailingZeroes64(w), true + return i + uint(bits.TrailingZeros64(w)), true } x++ // bounds check elimination in the loop @@ -500,7 +501,7 @@ func (b *BitSet) NextSet(i uint) (uint, bool) { } for x < len(b.set) { if b.set[x] != 0 { - return uint(x)*wordSize + trailingZeroes64(b.set[x]), true + return uint(x)*wordSize + uint(bits.TrailingZeros64(b.set[x])), true } x++ @@ -541,7 +542,7 @@ func (b *BitSet) NextSetMany(i uint, buffer []uint) (uint, []uint) { myanswer = myanswer[:capacity] size := int(0) for word != 0 { - r := trailingZeroes64(word) + r := uint(bits.TrailingZeros64(word)) t := word & ((^word) + 1) myanswer[size] = r + i size++ @@ -553,7 +554,7 @@ func (b *BitSet) NextSetMany(i uint, buffer []uint) (uint, []uint) { x++ for idx, word := range b.set[x:] { for word != 0 { - r := trailingZeroes64(word) + r := uint(bits.TrailingZeros64(word)) t := word & ((^word) + 1) myanswer[size] = r + (uint(x+idx) << 6) size++ @@ -581,7 +582,7 @@ func (b *BitSet) NextClear(i uint) (uint, bool) { w := b.set[x] w = w >> wordsIndex(i) wA := allBits >> wordsIndex(i) - index := i + trailingZeroes64(^w) + index := i + uint(bits.TrailingZeros64(^w)) if w != wA && index < b.length { return index, true } @@ -592,7 +593,7 @@ func (b *BitSet) NextClear(i uint) (uint, bool) { } for x < len(b.set) { if b.set[x] != allBits { - index = uint(x)*wordSize + trailingZeroes64(^b.set[x]) + index = uint(x)*wordSize + uint(bits.TrailingZeros64(^b.set[x])) if index < b.length { return index, true } @@ -614,12 +615,12 @@ func (b *BitSet) PreviousSet(i uint) (uint, bool) { // Clear the bits above the index w = w & ((1 << (wordsIndex(i) + 1)) - 1) if w != 0 { - return uint(x<= 0; x-- { w = b.set[x] if w != 0 { - return uint(x<= 0; x-- { w = b.set[x] w = ^w if w != 0 { - return uint(x<>6])) if leftover != 0 { - answer += uint(popcount(b.set[(index+1)>>6] << (64 - leftover))) + answer += uint(bits.OnesCount64(b.set[(index+1)>>6] << (64 - leftover))) } return answer } @@ -1302,7 +1303,7 @@ func (b *BitSet) Rank(index uint) uint { func (b *BitSet) Select(index uint) uint { leftover := index for idx, word := range b.set { - w := uint(popcount(word)) + w := uint(bits.OnesCount64(word)) if w > leftover { return uint(idx)*64 + select64(word, leftover) } @@ -1324,7 +1325,7 @@ func (b *BitSet) top() (uint, bool) { return 0, false } - return uint(idx)*wordSize + len64(b.set[idx]) - 1, true + return uint(idx)*wordSize + uint(bits.Len64(b.set[idx])) - 1, true } // ShiftLeft shifts the bitset like << operation would do. diff --git a/vendor/github.com/bits-and-blooms/bitset/leading_zeros_18.go b/vendor/github.com/bits-and-blooms/bitset/leading_zeros_18.go deleted file mode 100644 index 72af1d6fc..000000000 --- a/vendor/github.com/bits-and-blooms/bitset/leading_zeros_18.go +++ /dev/null @@ -1,43 +0,0 @@ -//go:build !go1.9 -// +build !go1.9 - -package bitset - -var len8tab = "" + - "\x00\x01\x02\x02\x03\x03\x03\x03\x04\x04\x04\x04\x04\x04\x04\x04" + - "\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05" + - "\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06" + - "\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06" + - "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + - "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + - "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + - "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" - -// len64 returns the minimum number of bits required to represent x; the result is 0 for x == 0. -func len64(x uint64) (n uint) { - if x >= 1<<32 { - x >>= 32 - n = 32 - } - if x >= 1<<16 { - x >>= 16 - n += 16 - } - if x >= 1<<8 { - x >>= 8 - n += 8 - } - return n + uint(len8tab[x]) -} - -func leadingZeroes64(v uint64) uint { - return 64 - len64(v) -} diff --git a/vendor/github.com/bits-and-blooms/bitset/leading_zeros_19.go b/vendor/github.com/bits-and-blooms/bitset/leading_zeros_19.go deleted file mode 100644 index 74a794241..000000000 --- a/vendor/github.com/bits-and-blooms/bitset/leading_zeros_19.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build go1.9 -// +build go1.9 - -package bitset - -import "math/bits" - -func len64(v uint64) uint { - return uint(bits.Len64(v)) -} - -func leadingZeroes64(v uint64) uint { - return uint(bits.LeadingZeros64(v)) -} diff --git a/vendor/github.com/bits-and-blooms/bitset/popcnt.go b/vendor/github.com/bits-and-blooms/bitset/popcnt.go index 76577a838..93492390b 100644 --- a/vendor/github.com/bits-and-blooms/bitset/popcnt.go +++ b/vendor/github.com/bits-and-blooms/bitset/popcnt.go @@ -1,53 +1,59 @@ package bitset -// bit population count, take from -// https://code.google.com/p/go/issues/detail?id=4988#c11 -// credit: https://code.google.com/u/arnehormann/ -func popcount(x uint64) (n uint64) { - x -= (x >> 1) & 0x5555555555555555 - x = (x>>2)&0x3333333333333333 + x&0x3333333333333333 - x += x >> 4 - x &= 0x0f0f0f0f0f0f0f0f - x *= 0x0101010101010101 - return x >> 56 -} +import "math/bits" -func popcntSliceGo(s []uint64) uint64 { - cnt := uint64(0) +func popcntSlice(s []uint64) uint64 { + var cnt int for _, x := range s { - cnt += popcount(x) + cnt += bits.OnesCount64(x) } - return cnt + return uint64(cnt) } -func popcntMaskSliceGo(s, m []uint64) uint64 { - cnt := uint64(0) +func popcntMaskSlice(s, m []uint64) uint64 { + var cnt int + // this explicit check eliminates a bounds check in the loop + if len(m) < len(s) { + panic("mask slice is too short") + } for i := range s { - cnt += popcount(s[i] &^ m[i]) + cnt += bits.OnesCount64(s[i] &^ m[i]) } - return cnt + return uint64(cnt) } -func popcntAndSliceGo(s, m []uint64) uint64 { - cnt := uint64(0) +func popcntAndSlice(s, m []uint64) uint64 { + var cnt int + // this explicit check eliminates a bounds check in the loop + if len(m) < len(s) { + panic("mask slice is too short") + } for i := range s { - cnt += popcount(s[i] & m[i]) + cnt += bits.OnesCount64(s[i] & m[i]) } - return cnt + return uint64(cnt) } -func popcntOrSliceGo(s, m []uint64) uint64 { - cnt := uint64(0) +func popcntOrSlice(s, m []uint64) uint64 { + var cnt int + // this explicit check eliminates a bounds check in the loop + if len(m) < len(s) { + panic("mask slice is too short") + } for i := range s { - cnt += popcount(s[i] | m[i]) + cnt += bits.OnesCount64(s[i] | m[i]) } - return cnt + return uint64(cnt) } -func popcntXorSliceGo(s, m []uint64) uint64 { - cnt := uint64(0) +func popcntXorSlice(s, m []uint64) uint64 { + var cnt int + // this explicit check eliminates a bounds check in the loop + if len(m) < len(s) { + panic("mask slice is too short") + } for i := range s { - cnt += popcount(s[i] ^ m[i]) + cnt += bits.OnesCount64(s[i] ^ m[i]) } - return cnt + return uint64(cnt) } diff --git a/vendor/github.com/bits-and-blooms/bitset/popcnt_19.go b/vendor/github.com/bits-and-blooms/bitset/popcnt_19.go deleted file mode 100644 index 7855c04b5..000000000 --- a/vendor/github.com/bits-and-blooms/bitset/popcnt_19.go +++ /dev/null @@ -1,62 +0,0 @@ -//go:build go1.9 -// +build go1.9 - -package bitset - -import "math/bits" - -func popcntSlice(s []uint64) uint64 { - var cnt int - for _, x := range s { - cnt += bits.OnesCount64(x) - } - return uint64(cnt) -} - -func popcntMaskSlice(s, m []uint64) uint64 { - var cnt int - // this explicit check eliminates a bounds check in the loop - if len(m) < len(s) { - panic("mask slice is too short") - } - for i := range s { - cnt += bits.OnesCount64(s[i] &^ m[i]) - } - return uint64(cnt) -} - -func popcntAndSlice(s, m []uint64) uint64 { - var cnt int - // this explicit check eliminates a bounds check in the loop - if len(m) < len(s) { - panic("mask slice is too short") - } - for i := range s { - cnt += bits.OnesCount64(s[i] & m[i]) - } - return uint64(cnt) -} - -func popcntOrSlice(s, m []uint64) uint64 { - var cnt int - // this explicit check eliminates a bounds check in the loop - if len(m) < len(s) { - panic("mask slice is too short") - } - for i := range s { - cnt += bits.OnesCount64(s[i] | m[i]) - } - return uint64(cnt) -} - -func popcntXorSlice(s, m []uint64) uint64 { - var cnt int - // this explicit check eliminates a bounds check in the loop - if len(m) < len(s) { - panic("mask slice is too short") - } - for i := range s { - cnt += bits.OnesCount64(s[i] ^ m[i]) - } - return uint64(cnt) -} diff --git a/vendor/github.com/bits-and-blooms/bitset/popcnt_amd64.go b/vendor/github.com/bits-and-blooms/bitset/popcnt_amd64.go deleted file mode 100644 index 116e04440..000000000 --- a/vendor/github.com/bits-and-blooms/bitset/popcnt_amd64.go +++ /dev/null @@ -1,68 +0,0 @@ -//go:build !go1.9 && amd64 && !appengine -// +build !go1.9,amd64,!appengine - -package bitset - -// *** the following functions are defined in popcnt_amd64.s - -//go:noescape - -func hasAsm() bool - -// useAsm is a flag used to select the GO or ASM implementation of the popcnt function -var useAsm = hasAsm() - -//go:noescape - -func popcntSliceAsm(s []uint64) uint64 - -//go:noescape - -func popcntMaskSliceAsm(s, m []uint64) uint64 - -//go:noescape - -func popcntAndSliceAsm(s, m []uint64) uint64 - -//go:noescape - -func popcntOrSliceAsm(s, m []uint64) uint64 - -//go:noescape - -func popcntXorSliceAsm(s, m []uint64) uint64 - -func popcntSlice(s []uint64) uint64 { - if useAsm { - return popcntSliceAsm(s) - } - return popcntSliceGo(s) -} - -func popcntMaskSlice(s, m []uint64) uint64 { - if useAsm { - return popcntMaskSliceAsm(s, m) - } - return popcntMaskSliceGo(s, m) -} - -func popcntAndSlice(s, m []uint64) uint64 { - if useAsm { - return popcntAndSliceAsm(s, m) - } - return popcntAndSliceGo(s, m) -} - -func popcntOrSlice(s, m []uint64) uint64 { - if useAsm { - return popcntOrSliceAsm(s, m) - } - return popcntOrSliceGo(s, m) -} - -func popcntXorSlice(s, m []uint64) uint64 { - if useAsm { - return popcntXorSliceAsm(s, m) - } - return popcntXorSliceGo(s, m) -} diff --git a/vendor/github.com/bits-and-blooms/bitset/popcnt_amd64.s b/vendor/github.com/bits-and-blooms/bitset/popcnt_amd64.s deleted file mode 100644 index 666c0dcc1..000000000 --- a/vendor/github.com/bits-and-blooms/bitset/popcnt_amd64.s +++ /dev/null @@ -1,104 +0,0 @@ -// +build !go1.9 -// +build amd64,!appengine - -TEXT ·hasAsm(SB),4,$0-1 -MOVQ $1, AX -CPUID -SHRQ $23, CX -ANDQ $1, CX -MOVB CX, ret+0(FP) -RET - -#define POPCNTQ_DX_DX BYTE $0xf3; BYTE $0x48; BYTE $0x0f; BYTE $0xb8; BYTE $0xd2 - -TEXT ·popcntSliceAsm(SB),4,$0-32 -XORQ AX, AX -MOVQ s+0(FP), SI -MOVQ s_len+8(FP), CX -TESTQ CX, CX -JZ popcntSliceEnd -popcntSliceLoop: -BYTE $0xf3; BYTE $0x48; BYTE $0x0f; BYTE $0xb8; BYTE $0x16 // POPCNTQ (SI), DX -ADDQ DX, AX -ADDQ $8, SI -LOOP popcntSliceLoop -popcntSliceEnd: -MOVQ AX, ret+24(FP) -RET - -TEXT ·popcntMaskSliceAsm(SB),4,$0-56 -XORQ AX, AX -MOVQ s+0(FP), SI -MOVQ s_len+8(FP), CX -TESTQ CX, CX -JZ popcntMaskSliceEnd -MOVQ m+24(FP), DI -popcntMaskSliceLoop: -MOVQ (DI), DX -NOTQ DX -ANDQ (SI), DX -POPCNTQ_DX_DX -ADDQ DX, AX -ADDQ $8, SI -ADDQ $8, DI -LOOP popcntMaskSliceLoop -popcntMaskSliceEnd: -MOVQ AX, ret+48(FP) -RET - -TEXT ·popcntAndSliceAsm(SB),4,$0-56 -XORQ AX, AX -MOVQ s+0(FP), SI -MOVQ s_len+8(FP), CX -TESTQ CX, CX -JZ popcntAndSliceEnd -MOVQ m+24(FP), DI -popcntAndSliceLoop: -MOVQ (DI), DX -ANDQ (SI), DX -POPCNTQ_DX_DX -ADDQ DX, AX -ADDQ $8, SI -ADDQ $8, DI -LOOP popcntAndSliceLoop -popcntAndSliceEnd: -MOVQ AX, ret+48(FP) -RET - -TEXT ·popcntOrSliceAsm(SB),4,$0-56 -XORQ AX, AX -MOVQ s+0(FP), SI -MOVQ s_len+8(FP), CX -TESTQ CX, CX -JZ popcntOrSliceEnd -MOVQ m+24(FP), DI -popcntOrSliceLoop: -MOVQ (DI), DX -ORQ (SI), DX -POPCNTQ_DX_DX -ADDQ DX, AX -ADDQ $8, SI -ADDQ $8, DI -LOOP popcntOrSliceLoop -popcntOrSliceEnd: -MOVQ AX, ret+48(FP) -RET - -TEXT ·popcntXorSliceAsm(SB),4,$0-56 -XORQ AX, AX -MOVQ s+0(FP), SI -MOVQ s_len+8(FP), CX -TESTQ CX, CX -JZ popcntXorSliceEnd -MOVQ m+24(FP), DI -popcntXorSliceLoop: -MOVQ (DI), DX -XORQ (SI), DX -POPCNTQ_DX_DX -ADDQ DX, AX -ADDQ $8, SI -ADDQ $8, DI -LOOP popcntXorSliceLoop -popcntXorSliceEnd: -MOVQ AX, ret+48(FP) -RET diff --git a/vendor/github.com/bits-and-blooms/bitset/popcnt_generic.go b/vendor/github.com/bits-and-blooms/bitset/popcnt_generic.go deleted file mode 100644 index 9e0ad464e..000000000 --- a/vendor/github.com/bits-and-blooms/bitset/popcnt_generic.go +++ /dev/null @@ -1,25 +0,0 @@ -//go:build !go1.9 && (!amd64 || appengine) -// +build !go1.9 -// +build !amd64 appengine - -package bitset - -func popcntSlice(s []uint64) uint64 { - return popcntSliceGo(s) -} - -func popcntMaskSlice(s, m []uint64) uint64 { - return popcntMaskSliceGo(s, m) -} - -func popcntAndSlice(s, m []uint64) uint64 { - return popcntAndSliceGo(s, m) -} - -func popcntOrSlice(s, m []uint64) uint64 { - return popcntOrSliceGo(s, m) -} - -func popcntXorSlice(s, m []uint64) uint64 { - return popcntXorSliceGo(s, m) -} diff --git a/vendor/github.com/bits-and-blooms/bitset/select.go b/vendor/github.com/bits-and-blooms/bitset/select.go index f15e74a2c..a43c6bd6a 100644 --- a/vendor/github.com/bits-and-blooms/bitset/select.go +++ b/vendor/github.com/bits-and-blooms/bitset/select.go @@ -1,10 +1,12 @@ package bitset +import "math/bits" + func select64(w uint64, j uint) uint { seen := 0 // Divide 64bit part := w & 0xFFFFFFFF - n := uint(popcount(part)) + n := uint(bits.OnesCount64(part)) if n <= j { part = w >> 32 seen += 32 @@ -15,7 +17,7 @@ func select64(w uint64, j uint) uint { // Divide 32bit part = ww & 0xFFFF - n = uint(popcount(part)) + n = uint(bits.OnesCount64(part)) if n <= j { part = ww >> 16 seen += 16 @@ -25,7 +27,7 @@ func select64(w uint64, j uint) uint { // Divide 16bit part = ww & 0xFF - n = uint(popcount(part)) + n = uint(bits.OnesCount64(part)) if n <= j { part = ww >> 8 seen += 8 diff --git a/vendor/github.com/bits-and-blooms/bitset/trailing_zeros_18.go b/vendor/github.com/bits-and-blooms/bitset/trailing_zeros_18.go deleted file mode 100644 index 12336e76a..000000000 --- a/vendor/github.com/bits-and-blooms/bitset/trailing_zeros_18.go +++ /dev/null @@ -1,15 +0,0 @@ -//go:build !go1.9 -// +build !go1.9 - -package bitset - -var deBruijn = [...]byte{ - 0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, - 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, - 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, - 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6, -} - -func trailingZeroes64(v uint64) uint { - return uint(deBruijn[((v&-v)*0x03f79d71b4ca8b09)>>58]) -} diff --git a/vendor/github.com/bits-and-blooms/bitset/trailing_zeros_19.go b/vendor/github.com/bits-and-blooms/bitset/trailing_zeros_19.go deleted file mode 100644 index cfb0a8409..000000000 --- a/vendor/github.com/bits-and-blooms/bitset/trailing_zeros_19.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build go1.9 -// +build go1.9 - -package bitset - -import "math/bits" - -func trailingZeroes64(v uint64) uint { - return uint(bits.TrailingZeros64(v)) -} diff --git a/vendor/github.com/holiman/uint256/circle.yml b/vendor/github.com/holiman/uint256/circle.yml index 48243cb09..3b0b6d1c6 100644 --- a/vendor/github.com/holiman/uint256/circle.yml +++ b/vendor/github.com/holiman/uint256/circle.yml @@ -19,14 +19,14 @@ commands: jobs: - go122: + go123: docker: - - image: cimg/go:1.22 + - image: cimg/go:1.23 steps: - run: name: "Install tools" command: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.58.0 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0 - checkout - run: name: "Lint" @@ -82,6 +82,13 @@ jobs: name: "Test (PPC64 emulation)" command: qemu-ppc64-static uint256.test.ppc64 -test.v + go122: + docker: + - image: cimg/go:1.22 + steps: + - checkout + - test + go121: docker: - image: cimg/go:1.21 @@ -112,9 +119,10 @@ workflows: - go119 - go120 - go121 - - go122: + - go122 + - go123: requires: - - go121 + - go122 - bigendian: requires: - - go122 + - go123 diff --git a/vendor/github.com/holiman/uint256/conversion.go b/vendor/github.com/holiman/uint256/conversion.go index 50c527673..640197c76 100644 --- a/vendor/github.com/holiman/uint256/conversion.go +++ b/vendor/github.com/holiman/uint256/conversion.go @@ -236,7 +236,7 @@ func (z *Int) UnmarshalText(input []byte) error { if len(input) >= 2 && input[0] == '0' && (input[1] == 'x' || input[1] == 'X') { return z.fromHex(string(input)) } - return z.fromDecimal(string(input)) + return z.SetFromDecimal(string(input)) } // SetFromBig converts a big.Int to Int and sets the value to z. @@ -712,7 +712,7 @@ func (z *Int) MarshalJSON() ([]byte, error) { func (z *Int) UnmarshalJSON(input []byte) error { if len(input) < 2 || input[0] != '"' || input[len(input)-1] != '"' { // if not quoted, it must be decimal - return z.fromDecimal(string(input)) + return z.SetFromDecimal(string(input)) } return z.UnmarshalText(input[1 : len(input)-1]) } diff --git a/vendor/github.com/holiman/uint256/decimal.go b/vendor/github.com/holiman/uint256/decimal.go index 0a268f3c8..564ae12c8 100644 --- a/vendor/github.com/holiman/uint256/decimal.go +++ b/vendor/github.com/holiman/uint256/decimal.go @@ -177,6 +177,8 @@ var multipliers = [5]*Int{ // fromDecimal is a helper function to only ever be called via SetFromDecimal // this function takes a string and chunks it up, calling ParseUint on it up to 5 times // these chunks are then multiplied by the proper power of 10, then added together. +// Note: this method assumes that some basic validity-checks have already been performed +// on the input 'bs'. See SetFromDecimal. func (z *Int) fromDecimal(bs string) error { // first clear the input z.Clear() diff --git a/vendor/github.com/holiman/uint256/uint256.go b/vendor/github.com/holiman/uint256/uint256.go index 9033594a5..043b8ed82 100644 --- a/vendor/github.com/holiman/uint256/uint256.go +++ b/vendor/github.com/holiman/uint256/uint256.go @@ -144,18 +144,35 @@ func (z *Int) WriteToSlice(dest []byte) { } } +// PutUint256 writes all 32 bytes of z to the destination slice, including zero-bytes. +// If dest is larger than 32 bytes, z will fill the first parts, and leave +// the end untouched. +// Note: The dest slice must be at least 32 bytes large, otherwise this +// method will panic. The method WriteToSlice, which is slower, should be used +// if the destination slice is smaller or of unknown size. +func (z *Int) PutUint256(dest []byte) { + _ = dest[31] + binary.BigEndian.PutUint64(dest[0:8], z[3]) + binary.BigEndian.PutUint64(dest[8:16], z[2]) + binary.BigEndian.PutUint64(dest[16:24], z[1]) + binary.BigEndian.PutUint64(dest[24:32], z[0]) +} + // WriteToArray32 writes all 32 bytes of z to the destination array, including zero-bytes func (z *Int) WriteToArray32(dest *[32]byte) { - for i := 0; i < 32; i++ { - dest[31-i] = byte(z[i/8] >> uint64(8*(i%8))) - } + // The PutUint64()s are inlined and we get 4x (load, bswap, store) instructions. + binary.BigEndian.PutUint64(dest[0:8], z[3]) + binary.BigEndian.PutUint64(dest[8:16], z[2]) + binary.BigEndian.PutUint64(dest[16:24], z[1]) + binary.BigEndian.PutUint64(dest[24:32], z[0]) } // WriteToArray20 writes the last 20 bytes of z to the destination array, including zero-bytes func (z *Int) WriteToArray20(dest *[20]byte) { - for i := 0; i < 20; i++ { - dest[19-i] = byte(z[i/8] >> uint64(8*(i%8))) - } + // The PutUint*()s are inlined and we get 3x (load, bswap, store) instructions. + binary.BigEndian.PutUint32(dest[0:4], uint32(z[2])) + binary.BigEndian.PutUint64(dest[4:12], z[1]) + binary.BigEndian.PutUint64(dest[12:20], z[0]) } // Uint64 returns the lower 64-bits of z @@ -1182,12 +1199,18 @@ func (z *Int) Byte(n *Int) *Int { // Exp sets z = base**exponent mod 2**256, and returns z. func (z *Int) Exp(base, exponent *Int) *Int { - res := Int{1, 0, 0, 0} - multiplier := *base - expBitLen := exponent.BitLen() + var ( + res = Int{1, 0, 0, 0} + multiplier = *base + expBitLen = exponent.BitLen() + curBit = 0 + word = exponent[0] + even = base[0]&1 == 0 + ) + if even && expBitLen > 8 { + return z.Clear() + } - curBit := 0 - word := exponent[0] for ; curBit < expBitLen && curBit < 64; curBit++ { if word&1 == 1 { res.Mul(&res, &multiplier) @@ -1195,6 +1218,9 @@ func (z *Int) Exp(base, exponent *Int) *Int { multiplier.squared() word >>= 1 } + if even { // If the base was even, we are finished now + return z.Set(&res) + } word = exponent[1] for ; curBit < expBitLen && curBit < 128; curBit++ { diff --git a/vendor/modules.txt b/vendor/modules.txt index a89fe5880..950b1c7df 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -61,7 +61,7 @@ github.com/CortexFoundation/robot/backend # github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 ## explicit; go 1.16 github.com/CortexFoundation/statik -# github.com/CortexFoundation/torrentfs v1.0.69-0.20241204160300-7085a7256ea1 +# github.com/CortexFoundation/torrentfs v1.0.69-0.20241209112125-47a204623d40 ## explicit; go 1.23.0 github.com/CortexFoundation/torrentfs github.com/CortexFoundation/torrentfs/backend @@ -326,7 +326,7 @@ github.com/benbjohnson/immutable # github.com/beorn7/perks v1.0.1 ## explicit; go 1.11 github.com/beorn7/perks/quantile -# github.com/bits-and-blooms/bitset v1.17.0 +# github.com/bits-and-blooms/bitset v1.18.0 ## explicit; go 1.16 github.com/bits-and-blooms/bitset # github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 @@ -490,7 +490,7 @@ github.com/deckarep/golang-set/v2 ## explicit; go 1.17 github.com/decred/dcrd/dcrec/secp256k1/v4 github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa -# github.com/dgraph-io/badger/v4 v4.5.1-0.20241202092052-28fb51daf2e1 +# github.com/dgraph-io/badger/v4 v4.5.1-0.20241205031432-6027e2f549b8 ## explicit; go 1.21 github.com/dgraph-io/badger/v4 github.com/dgraph-io/badger/v4/fb @@ -651,7 +651,7 @@ github.com/hashicorp/golang-lru/v2/simplelru # github.com/holiman/bloomfilter/v2 v2.0.3 ## explicit; go 1.15 github.com/holiman/bloomfilter/v2 -# github.com/holiman/uint256 v1.3.1 +# github.com/holiman/uint256 v1.3.2 ## explicit; go 1.19 github.com/holiman/uint256 # github.com/huandu/xstrings v1.5.0 @@ -1037,7 +1037,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.24-0.20241204155516-b95d1a27ab32 +# github.com/ucwong/golang-kv v1.0.24-0.20241207143212-a23845651f1b ## explicit; go 1.23 github.com/ucwong/golang-kv github.com/ucwong/golang-kv/badger