Skip to content

Commit

Permalink
Recsplit: collision typed error (#2925)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Nov 7, 2021
1 parent ed83d29 commit 49ff8ff
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
38 changes: 28 additions & 10 deletions cmd/hack/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -2718,14 +2718,32 @@ func reducedict(name string) error {
return nil
}
func recsplitWholeChain(chaindata string) error {
blocksPerFile := 500_000
blockTotal = &blocksPerFile
for i := 0; i < 13_500_000; i += *blockTotal {
database := mdbx.MustOpen(chaindata)
defer database.Close()
var last uint64
if err := database.View(context.Background(), func(tx kv.Tx) error {
c, err := tx.Cursor(kv.BlockBody)
if err != nil {
return err
}
k, _, err := c.Last()
if err != nil {
return err
}
last = binary.BigEndian.Uint64(k)
return nil
}); err != nil {
return err
}
database.Close()

blocksPerFile := uint64(500_000)
last = last - last%blocksPerFile
for i := uint64(*block); i < last; i += blocksPerFile {
*name = fmt.Sprintf("bodies%d-%dm", i/1_000_000, i%1_000_000/100_000)
log.Info("Creating", "file", *name)

block = &i
if err := dumpTxs(chaindata, uint64(*block), *blockTotal, *name); err != nil {
if err := dumpTxs(chaindata, i, int(i)+*blockTotal, *name); err != nil {
return err
}
if err := compress1(chaindata, *name); err != nil {
Expand Down Expand Up @@ -2890,14 +2908,14 @@ RETRY:
log.Info("Building recsplit...")

if err = rs.Build(); err != nil {
if errors.Is(err, recsplit.ErrCollision) {
log.Info("Building recsplit. Collision happened. It's ok. Restarting...")
rs.ResetNextSalt()
goto RETRY
}
return err
}

if rs.Collision() {
log.Info("Building recsplit. Collision happened. It's ok. Restarting...")
rs.ResetNextSalt()
goto RETRY
}
return nil
}
func decompress(name string) error {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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-20211107020730-8bf610171cf6
github.com/ledgerwatch/erigon-lib v0.0.0-20211107024620-98f80aa89ffd
github.com/ledgerwatch/log/v3 v3.4.0
github.com/ledgerwatch/secp256k1 v1.0.0
github.com/logrusorgru/aurora/v3 v3.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,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-20211107020730-8bf610171cf6 h1:uDjCJqjTFg2dI+AjPon7kcD5vC/QO0toPt+DknREE98=
github.com/ledgerwatch/erigon-lib v0.0.0-20211107020730-8bf610171cf6/go.mod h1:CuEZROm43MykZT5CjCj02jw0FOwaDl8Nh+PZkTEGopg=
github.com/ledgerwatch/erigon-lib v0.0.0-20211107024620-98f80aa89ffd h1:F0/S8NSvXijZIdVjFzFFRMaalN6Y3AxLQvQMY1hS4Ik=
github.com/ledgerwatch/erigon-lib v0.0.0-20211107024620-98f80aa89ffd/go.mod h1:CuEZROm43MykZT5CjCj02jw0FOwaDl8Nh+PZkTEGopg=
github.com/ledgerwatch/log/v3 v3.4.0 h1:SEIOcv5a2zkG3PmoT5jeTU9m/0nEUv0BJS5bzsjwKCI=
github.com/ledgerwatch/log/v3 v3.4.0/go.mod h1:VXcz6Ssn6XEeU92dCMc39/g1F0OYAjw1Mt+dGP5DjXY=
github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ=
Expand Down

0 comments on commit 49ff8ff

Please sign in to comment.