Skip to content

Commit 2c69346

Browse files
S1nusConnor O'HaraManav-Aggarwal
authored
use go-ds-badger4 (#1419)
closes #1389 ## Overview @Wondertan fixed a memory leak in Badger. Ensure Rollkit has the fix by upgrading to Celestia's [go-ds-badger4](https://github.com/celestiaorg/go-ds-badger4) ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [x] New and updated code has appropriate documentation - [x] New and updated code has new and/or updated testing - [x] Required CI checks are passing - [x] Visual proof for any user facing features like CLI or documentation updates - [x] Linked issues closed with keywords <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated the storage backend to a newer version for enhanced performance and stability. - **Documentation** - Updated documentation to reflect changes in storage backend usage and configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Connor O'Hara <[email protected]> Co-authored-by: Manav Aggarwal <[email protected]>
1 parent 0d865b5 commit 2c69346

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

go.mod

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,22 @@ go 1.21.1
55
toolchain go1.21.4
66

77
require (
8-
github.com/celestiaorg/go-header v0.4.1
98
github.com/celestiaorg/utils v0.1.0
109
github.com/cometbft/cometbft v0.38.0-rc3
1110
github.com/cosmos/gogoproto v1.4.11
12-
github.com/dgraph-io/badger/v3 v3.2103.5
1311
github.com/go-kit/kit v0.13.0
1412
github.com/gogo/protobuf v1.3.2
1513
github.com/gorilla/rpc v1.2.1
1614
github.com/gorilla/websocket v1.5.1
1715
github.com/ipfs/go-datastore v0.6.0
18-
github.com/ipfs/go-ds-badger3 v0.0.2
1916
github.com/ipfs/go-log v1.0.5
2017
github.com/libp2p/go-libp2p v0.30.0
2118
github.com/libp2p/go-libp2p-kad-dht v0.23.0
2219
github.com/libp2p/go-libp2p-pubsub v0.9.3
2320
github.com/multiformats/go-multiaddr v0.12.0
2421
github.com/pkg/errors v0.9.1
2522
github.com/prometheus/client_golang v1.18.0
26-
github.com/rollkit/go-da v0.0.0-20231117151938-ee3b613d7a3a
23+
github.com/rollkit/go-da v0.0.0-20231207150926-93600f28d67d
2724
github.com/rs/cors v1.10.1
2825
github.com/spf13/cobra v1.8.0
2926
github.com/spf13/viper v1.18.2
@@ -35,6 +32,11 @@ require (
3532
google.golang.org/protobuf v1.32.0
3633
)
3734

35+
require (
36+
github.com/celestiaorg/go-header v0.5.1
37+
github.com/ipfs/go-ds-badger4 v0.1.5
38+
)
39+
3840
require (
3941
github.com/benbjohnson/clock v1.3.5 // indirect
4042
github.com/beorn7/perks v1.0.1 // indirect
@@ -50,6 +52,7 @@ require (
5052
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
5153
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
5254
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
55+
github.com/dgraph-io/badger/v4 v4.2.1-0.20231013074411-fb1b00959581 // indirect
5356
github.com/dgraph-io/ristretto v0.1.1 // indirect
5457
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
5558
github.com/docker/go-units v0.5.0 // indirect
@@ -177,5 +180,3 @@ require (
177180
gopkg.in/yaml.v3 v3.0.1 // indirect
178181
lukechampine.com/blake3 v1.2.1 // indirect
179182
)
180-
181-
replace github.com/rollkit/go-da => github.com/rollkit/go-da v0.0.0-20231207150926-93600f28d67d

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7
186186
github.com/butuzov/ireturn v0.1.1/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacMsOEFPoc=
187187
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
188188
github.com/casbin/casbin/v2 v2.37.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg=
189-
github.com/celestiaorg/go-header v0.4.1 h1:bjbUcKDnhrJJ9EoE7vtPpgleNLVjc2S+cB4/qe8nQmo=
190-
github.com/celestiaorg/go-header v0.4.1/go.mod h1:H8xhnDLDLbkpwmWPhCaZyTnIV3dlVxBHPnxNXS2Qu6c=
189+
github.com/celestiaorg/go-header v0.5.1 h1:1s1lw4fcCHalNK0qw/0a3cxg3ezx3Hl020znIxPZvtk=
190+
github.com/celestiaorg/go-header v0.5.1/go.mod h1:H8xhnDLDLbkpwmWPhCaZyTnIV3dlVxBHPnxNXS2Qu6c=
191191
github.com/celestiaorg/go-libp2p-messenger v0.2.0 h1:/0MuPDcFamQMbw9xTZ73yImqgTO3jHV7wKHvWD/Irao=
192192
github.com/celestiaorg/go-libp2p-messenger v0.2.0/go.mod h1:s9PIhMi7ApOauIsfBcQwbr7m+HBzmVfDIS+QLdgzDSo=
193193
github.com/celestiaorg/utils v0.1.0 h1:WsP3O8jF7jKRgLNFmlDCwdThwOFMFxg0MnqhkLFVxPo=
@@ -291,8 +291,8 @@ github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrV
291291
github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE=
292292
github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o=
293293
github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk=
294-
github.com/dgraph-io/badger/v3 v3.2103.5 h1:ylPa6qzbjYRQMU6jokoj4wzcaweHylt//CH0AKt0akg=
295-
github.com/dgraph-io/badger/v3 v3.2103.5/go.mod h1:4MPiseMeDQ3FNCYwRbbcBOGJLf5jsE0PPFzRiKjtcdw=
294+
github.com/dgraph-io/badger/v4 v4.2.1-0.20231013074411-fb1b00959581 h1:yy45brf1ktmnkTCZlHynP1gRlVwZ9g19oz5D9wG81v4=
295+
github.com/dgraph-io/badger/v4 v4.2.1-0.20231013074411-fb1b00959581/go.mod h1:T/uWAYxrXdaXw64ihI++9RMbKTCpKd/yE9+saARew7k=
296296
github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
297297
github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
298298
github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8=
@@ -707,8 +707,8 @@ github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8
707707
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
708708
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
709709
github.com/ipfs/go-ds-badger v0.3.0/go.mod h1:1ke6mXNqeV8K3y5Ak2bAA0osoTfmxUdupVCGm4QUIek=
710-
github.com/ipfs/go-ds-badger3 v0.0.2 h1:+pME0YfRnbUKhvySnakNMuCMsUUhmGfwIsH/nnHZ7QY=
711-
github.com/ipfs/go-ds-badger3 v0.0.2/go.mod h1:6/yjF1KaOU+IpCaqMV43yoWIdxHqOAJlO9EhWLnZSkI=
710+
github.com/ipfs/go-ds-badger4 v0.1.5 h1:MwrTsIUJIqH/ChuDdUOzxwxMxHx/Li1ECoSCKsCUxiA=
711+
github.com/ipfs/go-ds-badger4 v0.1.5/go.mod h1:LUU2FbhNdmhAbJmMeoahVRbe4GsduAODSJHWJJh2Vo4=
712712
github.com/ipfs/go-ds-leveldb v0.5.0/go.mod h1:d3XG9RUDzQ6V4SHi8+Xgj9j1XuEk1z82lquxrVbml/Q=
713713
github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
714714
github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8=

store/kv.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ import (
88
"path/filepath"
99
"time"
1010

11-
"github.com/dgraph-io/badger/v3"
1211
ds "github.com/ipfs/go-datastore"
1312
dsq "github.com/ipfs/go-datastore/query"
14-
badger3 "github.com/ipfs/go-ds-badger3"
13+
14+
badger4 "github.com/ipfs/go-ds-badger4"
1515
)
1616

1717
// NewDefaultInMemoryKVStore builds KVStore that works in-memory (without accessing disk).
1818
func NewDefaultInMemoryKVStore() (ds.TxnDatastore, error) {
19-
inMemoryOptions := &badger3.Options{
19+
inMemoryOptions := &badger4.Options{
2020
GcDiscardRatio: 0.2,
2121
GcInterval: 15 * time.Minute,
2222
GcSleep: 10 * time.Second,
23-
Options: badger.DefaultOptions("").WithInMemory(true),
23+
Options: badger4.DefaultOptions.WithInMemory(true),
2424
}
25-
return badger3.NewDatastore("", inMemoryOptions)
25+
return badger4.NewDatastore("", inMemoryOptions)
2626
}
2727

2828
// NewDefaultKVStore creates instance of default key-value store.
2929
func NewDefaultKVStore(rootDir, dbPath, dbName string) (ds.TxnDatastore, error) {
3030
path := filepath.Join(rootify(rootDir, dbPath), dbName)
31-
return badger3.NewDatastore(path, nil)
31+
return badger4.NewDatastore(path, nil)
3232
}
3333

3434
// PrefixEntries retrieves all entries in the datastore whose keys have the supplied prefix

0 commit comments

Comments
 (0)