From d1bab1f98a4fca18860472c6d52bd4a3582bb3f5 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Tue, 3 Dec 2024 09:56:59 +0700 Subject: [PATCH 1/4] save --- erigon-lib/go.mod | 10 +++++----- erigon-lib/go.sum | 4 ++-- go.mod | 13 +++++++------ go.sum | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/erigon-lib/go.mod b/erigon-lib/go.mod index cb61837a06e..3005a5f5aa8 100644 --- a/erigon-lib/go.mod +++ b/erigon-lib/go.mod @@ -2,6 +2,11 @@ module github.com/erigontech/erigon-lib go 1.22.0 +replace ( + github.com/anacrolix/torrent => github.com/erigontech/torrent v1.54.2-alpha-38 + github.com/holiman/bloomfilter/v2 => github.com/AskAlexSharov/bloomfilter/v2 v2.0.9 +) + require ( github.com/erigontech/erigon-snapshot v1.3.1-0.20241023024258-f64407a77e8e github.com/erigontech/interfaces v0.0.0-20241116035842-5d396f10468e @@ -154,8 +159,3 @@ require ( rsc.io/tmplfunc v0.0.3 // indirect zombiezen.com/go/sqlite v0.13.1 // indirect ) - -replace ( - github.com/anacrolix/torrent => github.com/erigontech/torrent v1.54.2-alpha-38 - github.com/holiman/bloomfilter/v2 => github.com/AskAlexSharov/bloomfilter/v2 v2.0.8 -) diff --git a/erigon-lib/go.sum b/erigon-lib/go.sum index 63af7e40d9e..dee4ab325e5 100644 --- a/erigon-lib/go.sum +++ b/erigon-lib/go.sum @@ -4,8 +4,8 @@ crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797/go.mod h1:sXBiorCo8c46JlQV3oX crawshaw.io/sqlite v0.3.2/go.mod h1:igAO5JulrQ1DbdZdtVq48mnZUBAPOeFzer7VhDWNtW4= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= -github.com/AskAlexSharov/bloomfilter/v2 v2.0.8 h1:eRExAhnCcGHKC4/s8bpbYHJTQfOtn/urU/CYXNx2Q+8= -github.com/AskAlexSharov/bloomfilter/v2 v2.0.8/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/AskAlexSharov/bloomfilter/v2 v2.0.9 h1:BuZqNjRlYmcXJIsI7nrIkejYMz9mgFi7ZsNFCbSPpaI= +github.com/AskAlexSharov/bloomfilter/v2 v2.0.9/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= diff --git a/go.mod b/go.mod index 62ee556903d..a959270dd5a 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,13 @@ module github.com/erigontech/erigon go 1.22.5 +replace github.com/erigontech/erigon-lib => ./erigon-lib + +replace ( + github.com/anacrolix/torrent => github.com/erigontech/torrent v1.54.2-alpha-38 + github.com/holiman/bloomfilter/v2 => github.com/AskAlexSharov/bloomfilter/v2 v2.0.9 +) + require ( github.com/erigontech/erigonwatch v0.0.0-20240718131902-b6576bde1116 github.com/erigontech/mdbx-go v0.38.4 @@ -9,7 +16,6 @@ require ( github.com/erigontech/silkworm-go v0.18.0 ) -replace github.com/erigontech/erigon-lib => ./erigon-lib require ( gfx.cafe/util/go/generic v0.0.0-20230721185457-c559e86c829c @@ -287,8 +293,3 @@ require ( rsc.io/tmplfunc v0.0.3 // indirect zombiezen.com/go/sqlite v0.13.1 // indirect ) - -replace ( - github.com/anacrolix/torrent => github.com/erigontech/torrent v1.54.2-alpha-38 - github.com/holiman/bloomfilter/v2 => github.com/AskAlexSharov/bloomfilter/v2 v2.0.8 -) diff --git a/go.sum b/go.sum index 46fde5c4bf0..c8c6309c587 100644 --- a/go.sum +++ b/go.sum @@ -51,8 +51,8 @@ gfx.cafe/util/go/generic v0.0.0-20230721185457-c559e86c829c/go.mod h1:WvSX4JsCRB git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/99designs/gqlgen v0.17.56 h1:+J42ARAHvnysH6klO9Wq+tCsGF32cpAgU3SyF0VRJtI= github.com/99designs/gqlgen v0.17.56/go.mod h1:rmB6vLvtL8uf9F9w0/irJ5alBkD8DJvj35ET31BKbtY= -github.com/AskAlexSharov/bloomfilter/v2 v2.0.8 h1:eRExAhnCcGHKC4/s8bpbYHJTQfOtn/urU/CYXNx2Q+8= -github.com/AskAlexSharov/bloomfilter/v2 v2.0.8/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/AskAlexSharov/bloomfilter/v2 v2.0.9 h1:BuZqNjRlYmcXJIsI7nrIkejYMz9mgFi7ZsNFCbSPpaI= +github.com/AskAlexSharov/bloomfilter/v2 v2.0.9/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Giulio2002/bls v0.0.0-20241116091023-2ddcc8954ec0 h1:6DVEDL29nd7f2GoHZIA9rjpW90gYeNE3x5aUadOgTB4= From a09be2ff992cd650854ba8ec594baf6065d516ab Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Tue, 3 Dec 2024 10:00:58 +0700 Subject: [PATCH 2/4] save --- erigon-lib/state/existence_filter.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/erigon-lib/state/existence_filter.go b/erigon-lib/state/existence_filter.go index f0ed98c8f3a..f7ac75c5f02 100644 --- a/erigon-lib/state/existence_filter.go +++ b/erigon-lib/state/existence_filter.go @@ -17,6 +17,7 @@ package state import ( + "bufio" "fmt" "hash" "os" @@ -157,12 +158,23 @@ func OpenExistenceFilter(filePath string) (exFilder *ExistenceFilter, err error) idx.empty = stat.Size() == 0 } - if !idx.empty { - var err error - idx.filter, _, err = bloomfilter.ReadFile(filePath) - if err != nil { - return nil, fmt.Errorf("OpenExistenceFilter: %w, %s", err, fileName) - } + if idx.empty { + return idx, nil + } + + f, err := os.Open(filePath) + if err != nil { + return nil, err + } + defer f.Close() + filter := new(bloomfilter.Filter) + _, err = filter.UnmarshalFromReaderNoVerify(bufio.NewReaderSize(f, 1*1024*1024)) + if err != nil { + return nil, fmt.Errorf("OpenExistenceFilter: %w, %s", err, fileName) + } + idx.filter = filter + if err != nil { + return nil, fmt.Errorf("OpenExistenceFilter: %w, %s", err, fileName) } return idx, nil } From 9e796a8f17bb08a6a1ec4b31a787726c1fc3880f Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Tue, 3 Dec 2024 10:01:58 +0700 Subject: [PATCH 3/4] save --- erigon-lib/state/existence_filter.go | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/erigon-lib/state/existence_filter.go b/erigon-lib/state/existence_filter.go index f7ac75c5f02..4d82cfea4c5 100644 --- a/erigon-lib/state/existence_filter.go +++ b/erigon-lib/state/existence_filter.go @@ -145,37 +145,27 @@ func OpenExistenceFilter(filePath string) (exFilder *ExistenceFilter, err error) if !exists { return nil, fmt.Errorf("file doesn't exists: %s", fileName) } - { - ff, err := os.Open(filePath) - if err != nil { - return nil, err - } - defer ff.Close() - stat, err := ff.Stat() - if err != nil { - return nil, err - } - idx.empty = stat.Size() == 0 - } - - if idx.empty { - return idx, nil - } f, err := os.Open(filePath) if err != nil { return nil, err } defer f.Close() + stat, err := f.Stat() + if err != nil { + return nil, err + } + idx.empty = stat.Size() == 0 + if idx.empty { + return idx, nil + } + filter := new(bloomfilter.Filter) _, err = filter.UnmarshalFromReaderNoVerify(bufio.NewReaderSize(f, 1*1024*1024)) if err != nil { return nil, fmt.Errorf("OpenExistenceFilter: %w, %s", err, fileName) } idx.filter = filter - if err != nil { - return nil, fmt.Errorf("OpenExistenceFilter: %w, %s", err, fileName) - } return idx, nil } func (b *ExistenceFilter) Close() { From 21e94db039f961d732adb72ebe0a61c58d8eb33d Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Tue, 3 Dec 2024 10:55:33 +0700 Subject: [PATCH 4/4] save --- go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/go.mod b/go.mod index a959270dd5a..f63e23ac8b3 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( github.com/erigontech/silkworm-go v0.18.0 ) - require ( gfx.cafe/util/go/generic v0.0.0-20230721185457-c559e86c829c github.com/99designs/gqlgen v0.17.56