Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test out the new iavl store that only stores in memory #1232

Merged
merged 37 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
05fe115
test out the hack iavl store
mattkanwisher Jun 15, 2019
c85946c
update gopkg toml with hacked iavl store
mattkanwisher Jun 15, 2019
e528b08
update to new iavl and make it compile
mattkanwisher Jun 15, 2019
158b205
update iavl hash
mattkanwisher Jun 15, 2019
7c1019d
fix broken test
mattkanwisher Jun 16, 2019
6bed507
use the new saveversion mem function
mattkanwisher Jun 16, 2019
14a78f0
add iavl persistence interval
mattkanwisher Jun 16, 2019
b0248bc
updating iavl test build
mattkanwisher Jun 16, 2019
9661161
bump iavl and tendermint
mattkanwisher Jun 16, 2019
c6e0c51
refactored iavl flushing to be handled by the app
mattkanwisher Jun 16, 2019
dd3311a
fix test compilations
mattkanwisher Jun 16, 2019
a9a1b20
turn on flushing by default
mattkanwisher Jun 16, 2019
96c6ab1
bump iavl version
mattkanwisher Jun 16, 2019
33c7cee
bump iavl version again
mattkanwisher Jun 16, 2019
5c07b17
unit tests
Sriep Jun 18, 2019
0dabdee
touch
Sriep Jun 18, 2019
bbd1f3d
Merge remote-tracking branch 'remotes/origin/master' into iavl-hack
Sriep Jun 19, 2019
1a029d8
go-loom revision
Sriep Jun 19, 2019
9ac3c41
unit test
Sriep Jun 21, 2019
f38a8f5
unit test
Sriep Jun 21, 2019
cb58e1c
point to new iavl commit
Sriep Jun 21, 2019
846ff2d
unit test
Sriep Jun 21, 2019
f922768
skip benchmarks
Sriep Jun 21, 2019
e03d20b
chain iavl revision
Sriep Jun 24, 2019
311a07e
default flushinterval to zero until we have tested in production for …
mattkanwisher Jul 2, 2019
89000fe
use updated IAVL version
mattkanwisher Jul 2, 2019
ca631e9
use updated IAVL version
mattkanwisher Jul 2, 2019
0ab00ae
use tmreal on iavl and use HEAD for go-loom
mattkanwisher Jul 2, 2019
a2772db
use tmreal on iavl and use HEAD for go-loom
mattkanwisher Jul 2, 2019
618636d
use tmreal on iavl and use HEAD for go-loom
mattkanwisher Jul 2, 2019
6f4e90f
Merge branch 'master' into iavl-hack
mattkanwisher Jul 2, 2019
e3f6991
remove unit test dependant on nil range
Sriep Jul 3, 2019
f7d6dbe
lock
Sriep Jul 3, 2019
13529c4
Merge branch 'iavl-hack' of https://github.com/loomnetwork/loomchain …
Sriep Jul 3, 2019
e0986db
Merge branch 'master' into iavl-hack
mattkanwisher Jul 5, 2019
19dcc49
new iavl branch
Sriep Jul 5, 2019
408e002
Merge remote-tracking branch 'remotes/origin/master' into iavl-hack
Sriep Jul 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ignored = [
"github.com/go-kit/kit*",
"github.com/grpc-ecosystem/go-grpc-prometheus*",
"github.com/prometheus/client_golang/prometheus*",
"github.com/loomnetwork/transfer-gateway*",
"github.com/certusone/yubihsm-go*",
"github.com/jmhodges/levigo*", # can only build it with the right c packages
"github.com/btcsuite/btcd*"
Expand All @@ -59,8 +60,8 @@ ignored = [
[[override]]
name = "github.com/tendermint/tendermint"
source = "https://github.com/loomnetwork/tendermint.git"
revision = "29bb7b1ad483bec3c797ce24a5135465fccfa5f6"

branch = "loomchain"
[[constraint]]
name = "github.com/gomodule/redigo"
version = "2.0.0"
Expand All @@ -76,8 +77,8 @@ ignored = [

[[override]]
name = "github.com/tendermint/iavl"
source = "https://github.com/enlight/iavl.git"
branch = "multi-mutex-nodedb"
source = "https://github.com/loomnetwork/iavl.git"
branch = "tmreal2"

[[override]]
name = "github.com/tendermint/go-amino"
Expand All @@ -94,7 +95,7 @@ ignored = [
[[constraint]]
name = "github.com/btcsuite/btcutil"
revision = "9e5f4b9a998d263e3ce9c56664a7816001ac8000"

[prune]
go-tests = true
unused-packages = true
2 changes: 1 addition & 1 deletion builtin/plugins/karma/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func MockStateWithKarmaAndCoinB(b *testing.B, karmaInit *ktypes.KarmaInitRequest
}

func MockStateWithKarmaAndCoin(karmaInit *ktypes.KarmaInitRequest, coinInit *ctypes.InitRequest, appDb db.DB) (loomchain.State, registry.Registry, vm.VM, error) {
appStore, err := store.NewIAVLStore(appDb, 0, 0)
appStore, err := store.NewIAVLStore(appDb, 0, 0, 0)
if err != nil {
return nil, nil, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/loom/db/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func newGetAppHeightCommand() *cobra.Command {
}
defer db.Close()

iavlStore, err := store.NewIAVLStore(db, 0, 0)
iavlStore, err := store.NewIAVLStore(db, 0, 0, 0)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/loom/db/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func newDumpEVMStateCommand() *cobra.Command {
if err != nil {
return err
}
appStore, err := store.NewIAVLStore(db, 0, appHeight)
appStore, err := store.NewIAVLStore(db, 0, appHeight, 0)
if err != nil {
return err
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func newDumpEVMStateMultiWriterAppStoreCommand() *cobra.Command {
if err != nil {
return err
}
iavlStore, err := store.NewIAVLStore(db, 0, appHeight)
iavlStore, err := store.NewIAVLStore(db, 0, appHeight, 0)
if err != nil {
return err
}
Expand Down
13 changes: 7 additions & 6 deletions cmd/loom/loom.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,17 +578,18 @@ func loadAppStore(cfg *config.Config, logger *loom.Logger, targetVersion int64)
if cfg.AppStore.PruneInterval > int64(0) {
logger.Info("Loading Pruning IAVL Store")
appStore, err = store.NewPruningIAVLStore(db, store.PruningIAVLStoreConfig{
MaxVersions: cfg.AppStore.MaxVersions,
BatchSize: cfg.AppStore.PruneBatchSize,
Interval: time.Duration(cfg.AppStore.PruneInterval) * time.Second,
Logger: logger,
MaxVersions: cfg.AppStore.MaxVersions,
BatchSize: cfg.AppStore.PruneBatchSize,
Interval: time.Duration(cfg.AppStore.PruneInterval) * time.Second,
Logger: logger,
FlushInterval: cfg.AppStore.IAVLFlushInterval,
})
if err != nil {
return nil, err
}
} else {
logger.Info("Loading IAVL Store")
appStore, err = store.NewIAVLStore(db, cfg.AppStore.MaxVersions, targetVersion)
appStore, err = store.NewIAVLStore(db, cfg.AppStore.MaxVersions, targetVersion, cfg.AppStore.IAVLFlushInterval)
if err != nil {
return nil, err
}
Expand All @@ -608,7 +609,7 @@ func loadAppStore(cfg *config.Config, logger *loom.Logger, targetVersion int64)
}
} else if cfg.AppStore.Version == 3 {
logger.Info("Loading Multi-Writer App Store")
iavlStore, err := store.NewIAVLStore(db, cfg.AppStore.MaxVersions, targetVersion)
iavlStore, err := store.NewIAVLStore(db, cfg.AppStore.MaxVersions, targetVersion, cfg.AppStore.IAVLFlushInterval)
if err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions store/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type AppStoreConfig struct {
// If true the app store will write EVM state to both IAVLStore and EvmStore
// This config works with AppStore Version 3 (MultiWriterAppStore) only
SaveEVMStateToIAVL bool

IAVLFlushInterval int64
}

func DefaultConfig() *AppStoreConfig {
Expand All @@ -42,6 +44,7 @@ func DefaultConfig() *AppStoreConfig {
NodeCacheSize: 10000,
SnapshotVersion: MultiReaderIAVLStoreSnapshotV1,
SaveEVMStateToIAVL: false,
IAVLFlushInterval: 0, //default to zero until we know its ready
}
}

Expand Down
28 changes: 22 additions & 6 deletions store/iavlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ func init() {
}

type IAVLStore struct {
tree *iavl.MutableTree
maxVersions int64 // maximum number of versions to keep when pruning
tree *iavl.MutableTree
maxVersions int64 // maximum number of versions to keep when pruning
flushInterval int64 // how often we persist to disk
}

func (s *IAVLStore) Delete(key []byte) {
Expand Down Expand Up @@ -135,7 +136,21 @@ func (s *IAVLStore) SaveVersion() ([]byte, int64, error) {
}(time.Now())

oldVersion := s.Version()
hash, version, err := s.tree.SaveVersion()

var version int64
var hash []byte
//Every X versions we should persist to disk
if s.flushInterval == 0 || ((oldVersion+1)%s.flushInterval == 0) {
if s.flushInterval != 0 {
log.Error(fmt.Sprintf("Flushing mem to disk at version %d\n", oldVersion+1))
hash, version, err = s.tree.FlushMemVersionDisk()
} else {
hash, version, err = s.tree.SaveVersion()
}
} else {
hash, version, err = s.tree.SaveVersionMem()
}

if err != nil {
return nil, 0, errors.Wrapf(err, "failed to save tree version %d", oldVersion+1)
}
Expand Down Expand Up @@ -180,7 +195,7 @@ func (s *IAVLStore) GetSnapshot() Snapshot {
// old versions will never been deleted.
// targetVersion can be used to load any previously saved version of the store, if set to zero then
// the last version that was saved will be loaded.
func NewIAVLStore(db dbm.DB, maxVersions, targetVersion int64) (*IAVLStore, error) {
func NewIAVLStore(db dbm.DB, maxVersions, targetVersion, flushInterval int64) (*IAVLStore, error) {
tree := iavl.NewMutableTree(db, 10000)
_, err := tree.LoadVersion(targetVersion)
if err != nil {
Expand All @@ -193,8 +208,9 @@ func NewIAVLStore(db dbm.DB, maxVersions, targetVersion int64) (*IAVLStore, erro
}

return &IAVLStore{
tree: tree,
maxVersions: maxVersions,
tree: tree,
maxVersions: maxVersions,
flushInterval: flushInterval,
}, nil
}

Expand Down
Loading