From edb83d1ed962fa3793c35193cd9e031effc37307 Mon Sep 17 00:00:00 2001
From: Alex Sharov <AskAlexSharov@gmail.com>
Date: Wed, 1 Sep 2021 12:09:04 +0700
Subject: [PATCH] Roaring bitmap lib version up (#2606)

---
 eth/stagedsync/stage_indexes_test.go | 12 ++++++++++++
 go.mod                               |  4 ++--
 go.sum                               | 10 ++++++----
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/eth/stagedsync/stage_indexes_test.go b/eth/stagedsync/stage_indexes_test.go
index cfb077dc04..e1d50484ba 100644
--- a/eth/stagedsync/stage_indexes_test.go
+++ b/eth/stagedsync/stage_indexes_test.go
@@ -10,6 +10,7 @@ import (
 	"testing"
 	"time"
 
+	"github.com/RoaringBitmap/roaring/roaring64"
 	"github.com/ledgerwatch/erigon-lib/kv"
 	kv2 "github.com/ledgerwatch/erigon-lib/kv/memdb"
 	"github.com/ledgerwatch/erigon/common"
@@ -286,3 +287,14 @@ func generateAddrs(numOfAddrs int, isPlain bool) ([][]byte, error) {
 	}
 	return addrs, nil
 }
+
+func TestRoaringCanParseRealDBValue(t *testing.T) {
+	v := common.FromHex("0100000000000000000000003a30000001000000c700c00310000000c02c092e162e55315a315b315c310932103214321d321f32223226322d323c325a325b326132623267326c327332753278327f32853287329932ab32af32bb32c332c732c832cf32d232d732d832db32e232e532e932f032f632fe320f331333173325332e3333333433363344334e33583369336e337d338a3391339933a733ab33b033b533c133cb33d133ff3301340c34143421342e3434343a345f346734733476347d348734893497349a34a134a534b834ce34d534dc34df34eb34ed34f334f634023505350c3513353e3546354a354f355a356235713576357a358d35913598359e35a535bf3501361c362036243625362c3634363c36453648365636643665366b367036713679367c3682369f36a336b336be36cc36d436db3609370f37433759375d3766378337983799379c37a837a937af37b137b837bb37c037c337c737d537db37e037f3371c38263828382d3832383c383e3846384d3852386f3875387b388138843889388b389038b438c038c338ce38d738de38e638f8380e39273933393d394d39793981398639a839b639c039c339e039f239043a0f3a1f3a243a273a2a3a2b3a453a563a663a693a793a7d3a833a8b3ac43add3af63a033b0e3b283b2f3b413b443b5c3b803b8e3ba03bae3bc73bd03be03b0c3c133c1d3c1e3c333c3c3c3f3c4f3c693c7c3c933cbe3cca3cd93cdd3ce13ce93cf53c063d0b3d173d1d3d233d283d3d3d423d453d4d3d513d563d5e3d6a3d6e3d943dc43dd63de03df43df73d273e7c3ea13ea63edd3ee33ef23e423f4f3fcf40d340d940e440ed40f24000410b4116411a414f41694172417f4188418a41a041aa41c541cc41d241d841e541f341fc410e4214421e4224422a423042454258427f4281429042b742bf42c642d742e642eb42f042f642024310431443184323432b433043354338433e4343434f4355435943614366436e43704373437a437d438143854387438f4392439e43a843b843c643ce43d343dd43f043fb430d44124419441e44214425442e442f4433443b44584460446844744478447a448c449244a444a844b744c344cf44d944e744ec4407451145264541454c4576458545a045ad45b345bd45e145ea45f34505460c46114614461946494654465d4668466f4675467a467e4687469446ae46ba46c146c646c846d446da46de46ec46fb4602470b4716471f4727472a473147384771479e47c147d347d947ff487449824987498949c049c449d949eb49ff49094a0b4a0d4a8a4b934b974bb54bbc4bc04bc14bc64bc74bca4bd14bd54bdf4be24be34be74bee4bf04bf54b014c064c0a4c174c1e4c224c294c354c394c3e4c404c454c504c554c5b4c5d4c5e4c754c7f4c814c844c894c904c9b4ca44cab4cae4cb24cb44cc64cc84ccb4ccd4cd14cd64ceb4ced4cf84cfe4c054d0c4d124d154d194d224d2b4d334d3c4d4d4d574d5d4d604d674d704d734d794d804d864d954d984d9e4da14dac4dbb4dc14dc44dcc4dcf4dd54ddd4deb4dec4df04df74d094e114e144e294e2f4e364e394e404e484e514e594e5d4e684e6c4e704e754e774e814e8d4e954ea34ea94eaa4ead4eb34eb54ebb4ec54ec94ed14ed74ee04ee44ee94eeb4ef44efe4e014f054f124f1e4f304f334f374f394f3a4f4a4f5a4f604f674f6b4f754f774f7f4f8f4f954f9a4f9c4fa34fbf4fc84fe64ff04ffe4f06501f502d50305036503f504750525056505c50645068506a506e5073507b5088508a5094509a50a050a250af50b250b650cf50d650eb50f650f750fd50035105511451175119511c5125512a512c5135513d514351455153515a515f517651775178517b518051835186518b519151a251ad51b851bc51ca51cc51df51e251e651e851ed51ee51ef51fc51075224522952335234523d5248524c524f52505255525c526c5273527c528552aa52bb52c952d552db52e152e852f1520d533f5343534a535a5363536d5374537a53835386538b5396539e53a453ad539e54fe5448566656a558f6583f597f599b59b559dd59055a1e5a9b5afa5a045b0e5b175b2c5b315b335b395bf65b145c465c525c5d5c615c6b5c875c8d5cb45cba5cec5cf25cf75c055d585ea15ee55ebc5fee5f016019603a60426059605b609760a860d36015613c617061bc61c661d461e561ed61f36152626762a262bc62c162c562d462de62076330633c635f638063826388638d63cf63f363fa6311642e64cb64ea641765216538653e655365ba65bd65c965cf65d465d865d965dc65de65e565ea65ed65f465f965fc6500660c660f661a662b66366645664b664d6655667066776682668b66906692669366ad66b366b766b966d266d566fb66ff6604670867186723673767436749674d67526757676467af67e56716681e6825682c6835683c683e684e6855685c685d6867686f6873687a68e068236b4c6b8a6bcc6bdc6bde6bed6c1d6f236f596f6e6fbc6f8c708f7093709b70a27021714b71eb731b75377548755c7581759d75a575ab75b175237648764c765b76697682769376c176d6762c7740775f776d778777c977d477ef77f277ff7707780e78207821782e7833783b783f784d784f7853785a78717872787f7883788d7894789d78a078a378c578c978d078d378d778e678e878ea78f278f77809790c79")
+	m := roaring64.New()
+	err := m.UnmarshalBinary(v)
+	require.NoError(t, err)
+	require.Equal(t, uint64(961), m.GetCardinality())
+	encoded, err := m.MarshalBinary()
+	require.NoError(t, err)
+	require.Equal(t, encoded, v)
+}
diff --git a/go.mod b/go.mod
index 62a79e8542..342e72c6ef 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
 go 1.16
 
 require (
-	github.com/RoaringBitmap/roaring v0.6.0
+	github.com/RoaringBitmap/roaring v0.9.4
 	github.com/VictoriaMetrics/fastcache v1.5.7
 	github.com/VictoriaMetrics/metrics v1.17.3
 	github.com/anacrolix/log v0.8.0
@@ -37,7 +37,7 @@ require (
 	github.com/julienschmidt/httprouter v1.3.0
 	github.com/kevinburke/go-bindata v3.21.0+incompatible
 	github.com/kylelemons/godebug v1.1.0 // indirect
-	github.com/ledgerwatch/erigon-lib v0.0.0-20210831141709-6c5a46a28e8f
+	github.com/ledgerwatch/erigon-lib v0.0.0-20210901012021-3e96e721954d
 	github.com/ledgerwatch/log/v3 v3.3.0
 	github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d
 	github.com/logrusorgru/aurora/v3 v3.0.0
diff --git a/go.sum b/go.sum
index a4008092b8..41aee62c44 100644
--- a/go.sum
+++ b/go.sum
@@ -59,8 +59,8 @@ github.com/RoaringBitmap/roaring v0.4.18/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrX
 github.com/RoaringBitmap/roaring v0.4.21/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo=
 github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo=
 github.com/RoaringBitmap/roaring v0.5.5/go.mod h1:puNo5VdzwbaIQxSiDIwfXl4Hnc+fbovcX4IW/dSTtUk=
-github.com/RoaringBitmap/roaring v0.6.0 h1:tZcn2nJpUrZf+xQY8x+9QY7BxSETMjkdNG4Ts5zahyU=
-github.com/RoaringBitmap/roaring v0.6.0/go.mod h1:WZ83fjBF/7uBHi6QoFyfGL4+xuV4Qn+xFkm4+vSzrhE=
+github.com/RoaringBitmap/roaring v0.9.4 h1:ckvZSX5gwCRaJYBNe7syNawCU5oruY9gQmjXlp4riwo=
+github.com/RoaringBitmap/roaring v0.9.4/go.mod h1:icnadbWcNyfEHlYdr+tDlOTih1Bf/h+rzPpv4sbomAA=
 github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
 github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
 github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
@@ -174,6 +174,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
 github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
 github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
+github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA=
+github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
 github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
 github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
 github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
@@ -490,8 +492,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
 github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
 github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
-github.com/ledgerwatch/erigon-lib v0.0.0-20210831141709-6c5a46a28e8f h1:DJUxUjsGSN2gTYWu3SmEajEtGxhMcm+Te9FbvmFYB/Q=
-github.com/ledgerwatch/erigon-lib v0.0.0-20210831141709-6c5a46a28e8f/go.mod h1:mer12uv2+HWhB+3cE1rAbD2+b/JVwCnIbG2Gyv9rmhA=
+github.com/ledgerwatch/erigon-lib v0.0.0-20210901012021-3e96e721954d h1:dx55mJky8jsApiMNSFoMBvl891KvvfCShK+DTiu6Ks4=
+github.com/ledgerwatch/erigon-lib v0.0.0-20210901012021-3e96e721954d/go.mod h1:q+AQKX1ij+xDBKKPwI3XgV09dwPpukXR1fE22ResK0M=
 github.com/ledgerwatch/log/v3 v3.3.0 h1:k8N/3NQLILr8CKCMyza261vLFKU7VA+nMNNb0wVyQSc=
 github.com/ledgerwatch/log/v3 v3.3.0/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0=
 github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d h1:/IKMrJdfRsoYNc36PXqP4xMH3vhW/8IQyBKGQbKZUno=
-- 
GitLab