From c47cf1fd490301063d3187b1dcf80c3d75015af8 Mon Sep 17 00:00:00 2001
From: ledgerwatch <akhounov@gmail.com>
Date: Fri, 18 Mar 2022 09:55:38 +0000
Subject: [PATCH] [erigon2] Optimise Huffman decoding (#3727)

* Update to erigon-lib

* Fix for block number

* Update

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
---
 cmd/state/commands/erigon2.go | 2 +-
 go.mod                        | 2 +-
 go.sum                        | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/state/commands/erigon2.go b/cmd/state/commands/erigon2.go
index f92e2322b2..81145d8a45 100644
--- a/cmd/state/commands/erigon2.go
+++ b/cmd/state/commands/erigon2.go
@@ -195,7 +195,7 @@ func Erigon2(genesis *core.Genesis, chainConfig *params.ChainConfig, logger log.
 			return err
 		}
 
-		if blockNum < block {
+		if blockNum <= block {
 			_, _, txAmount := rawdb.ReadBody(historyTx, blockHash, blockNum)
 
 			// Skip that block, but increase txNum
diff --git a/go.mod b/go.mod
index 8608ba6dd4..c66e3e696b 100644
--- a/go.mod
+++ b/go.mod
@@ -40,7 +40,7 @@ require (
 	github.com/json-iterator/go v1.1.12
 	github.com/julienschmidt/httprouter v1.3.0
 	github.com/kevinburke/go-bindata v3.21.0+incompatible
-	github.com/ledgerwatch/erigon-lib v0.0.0-20220318074446-776f04ec3d9b
+	github.com/ledgerwatch/erigon-lib v0.0.0-20220318091018-f93ea948d0ae
 	github.com/ledgerwatch/log/v3 v3.4.1
 	github.com/ledgerwatch/secp256k1 v1.0.0
 	github.com/magiconair/properties v1.8.6 // indirect
diff --git a/go.sum b/go.sum
index f23adf4cf9..27e9d797c7 100644
--- a/go.sum
+++ b/go.sum
@@ -615,8 +615,8 @@ github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3P
 github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
 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-20220318074446-776f04ec3d9b h1:jUiLOWQrmlZD+7+kD4KIrG/p5iyxNxrxxzWyrQU9KNY=
-github.com/ledgerwatch/erigon-lib v0.0.0-20220318074446-776f04ec3d9b/go.mod h1:DOOU7AueOIleumnEzs21bwDaOMu5lJAzZtuxBoTrgm4=
+github.com/ledgerwatch/erigon-lib v0.0.0-20220318091018-f93ea948d0ae h1:A+1WvlyWy97z7boHaqhH5zGoF7OqB00KNNHu4gX9dCc=
+github.com/ledgerwatch/erigon-lib v0.0.0-20220318091018-f93ea948d0ae/go.mod h1:DOOU7AueOIleumnEzs21bwDaOMu5lJAzZtuxBoTrgm4=
 github.com/ledgerwatch/log/v3 v3.4.1 h1:/xGwlVulXnsO9Uq+tzaExc8OWmXXHU0dnLalpbnY5Bc=
 github.com/ledgerwatch/log/v3 v3.4.1/go.mod h1:VXcz6Ssn6XEeU92dCMc39/g1F0OYAjw1Mt+dGP5DjXY=
 github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ=
-- 
GitLab