Skip to content

Commit

Permalink
use tm-db v0.6.7 to avoid replacing goleveldb
Browse files Browse the repository at this point in the history
  • Loading branch information
adu-web3 committed Feb 25, 2022
1 parent 9d5033b commit fefb5ca
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require (
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15
github.com/tendermint/go-amino v0.16.0
github.com/tendermint/tendermint v0.35.1
github.com/tendermint/tm-db v0.6.6
github.com/tendermint/tm-db v0.6.7
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa
google.golang.org/grpc v1.44.0
Expand All @@ -68,11 +68,13 @@ require (
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/ledger-go v0.9.2 // indirect
github.com/danieljoos/wincred v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/badger/v3 v3.2103.2 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
Expand All @@ -87,6 +89,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/flatbuffers v2.0.0+incompatible // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
Expand Down Expand Up @@ -152,4 +155,4 @@ replace github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
replace github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0

replace github.com/cosmos/cosmos-sdk/db => ./db
replace github.com/cosmos/cosmos-sdk/db => ./db
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.2/go.mod h1:Gi7pzVRnvZ1N16JAXpLA
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y=
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y=
github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w=
Expand Down Expand Up @@ -324,6 +325,7 @@ github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFM
github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE=
github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o=
github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk=
github.com/dgraph-io/badger/v3 v3.2103.2 h1:dpyM5eCJAtQCBcMCZcT4UBZchuTJgCywerHHgmxfxM8=
github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M=
github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
github.com/dgraph-io/ristretto v0.0.3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
Expand Down Expand Up @@ -538,6 +540,7 @@ github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB
github.com/google/certificate-transparency-go v1.1.1/go.mod h1:FDKqPvSXawb2ecErVRrD+nfy23RCzyl7eqVCEmlT1Zs=
github.com/google/flatbuffers v1.11.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/flatbuffers v2.0.0+incompatible h1:dicJ2oXwypfwUGnB2/TYWYEKiuk9eYQlQO/AnOHl5mI=
github.com/google/flatbuffers v2.0.0+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
Expand Down Expand Up @@ -1257,6 +1260,8 @@ github.com/tendermint/tendermint v0.35.1/go.mod h1:6qVMoP3Wa3Vo8M4Cx8HkViNg9xw+2
github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw=
github.com/tendermint/tm-db v0.6.6 h1:EzhaOfR0bdKyATqcd5PNeyeq8r+V4bRPHBfyFdD9kGM=
github.com/tendermint/tm-db v0.6.6/go.mod h1:wP8d49A85B7/erz/r4YbKssKw6ylsO/hKtFk7E1aWZI=
github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8=
github.com/tendermint/tm-db v0.6.7/go.mod h1:byQDzFkZV1syXr/ReXS808NxA2xvyuuVgXOJ/088L6I=
github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0=
github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY=
github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8=
Expand Down
38 changes: 18 additions & 20 deletions store/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,32 +201,22 @@ func runDeterministicOperations(b *testing.B, s store, values [][]byte, c counts
}
}

func RunRvert(b *testing.B, version int, dbType tmdb.BackendType, committedValues [][]byte, uncommittedValues [][]byte) {
dir := fmt.Sprintf("testdbs/v%d", version)
dbName := fmt.Sprintf("reverttest-%s", dbType)
db, err := newDB(version, dbName, tmdb.RocksDBBackend, dir)
require.NoError(b, err)
s, err := newStore(version, db, nil, cacheSize)
require.NoError(b, err)
for i, v := range committedValues {
s.Set(createKey(i), v)
}
_ = s.Commit()

b.ResetTimer()
func RunRvert(b *testing.B, s store, db interface{}, uncommittedValues [][]byte) {
for i := 0; i < b.N; i++ {
// Key, value pairs changed but not committed
for i, v := range uncommittedValues {
s.Set(createKey(i), v)
}

b.ResetTimer()
switch t := s.(type) {
case *storev1.Store:
s, err = newStore(1, db, nil, cacheSize) // This shall revert to the last commitID
_, err := newStore(1, db, nil, cacheSize) // This shall revert to the last commitID
require.NoError(b, err)
case *storeV2:
require.NoError(b, t.Close())
s, err = newStore(2, db, nil, 0) // This shall revert to the last commitID
_, err := newStore(2, db, nil, 0) // This shall revert to the last commitID
require.NoError(b, err)
default:
panic("not supported store type")
}
Expand Down Expand Up @@ -307,12 +297,19 @@ func newStore(version int, dbBackend interface{}, cID *types.CommitID, cacheSize
return nil, fmt.Errorf("unsupported version")
}

func prepareStore(s store, values [][]byte) (store, types.CommitID) {
for i, v := range values {
func prepareStore(b *testing.B, version int, dbType tmdb.BackendType, committedValues [][]byte) (store, interface{}) {
dir := fmt.Sprintf("testdbs/v%d", version)
dbName := fmt.Sprintf("reverttest-%s", dbType)
db, err := newDB(version, dbName, dbType, dir)
require.NoError(b, err)
s, err := newStore(version, db, nil, cacheSize)
require.NoError(b, err)
for i, v := range committedValues {
s.Set(createKey(i), v)
}
cID := s.Commit()
return s, cID
_ = s.Commit()

return s, db
}

func runSuite(b *testing.B, version int, dbBackendTypes []tmdb.BackendType, dir string) {
Expand Down Expand Up @@ -348,8 +345,9 @@ func runSuite(b *testing.B, version int, dbBackendTypes []tmdb.BackendType, dir
committedValues := prepareValues()
uncommittedValues := prepareValues()
for _, dbType := range dbBackendTypes {
s, db := prepareStore(b, version, dbType, committedValues)
b.Run(fmt.Sprintf("v%d-%s-revert", version, dbType), func(sub *testing.B) {
RunRvert(sub, version, dbType, committedValues, uncommittedValues)
RunRvert(sub, s, db, uncommittedValues)
})
}
}
Expand Down

0 comments on commit fefb5ca

Please sign in to comment.