From 3ac390e95e6e6f0d41cdc8fd91faea6723030e67 Mon Sep 17 00:00:00 2001
From: yihuang <huang@crypto.com>
Date: Thu, 22 Sep 2022 16:16:17 +0800
Subject: [PATCH] Problem: new iavl indexes migration is slow and not optional
 (#714)

* Problem: new iavl indexes migration is slow and not optional

Closes: #712
Solution:
- Integrate the option introduced in cosmos-sdk

* Update CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

Signed-off-by: yihuang <huang@crypto.com>
---
 CHANGELOG.md            | 4 ++++
 cmd/cronosd/cmd/root.go | 6 ++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d3928cfab3..b8fad708d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@
 
 - [cronos#719](https://github.com/crypto-org-chain/cronos/pull/719) Fix `eth_call` for legacy blocks (backport #713).
 
+### Improvements
+
+- [cronos#714](https://github.com/crypto-org-chain/cronos/pull/714) Add option `iavl-disable-fastnode` to disable iavl fastnode indexing migration.
+
 *Sep 20, 2022*
 
 ## v0.9.0-beta3
diff --git a/cmd/cronosd/cmd/root.go b/cmd/cronosd/cmd/root.go
index 1066ae8bbe..7a38867f15 100644
--- a/cmd/cronosd/cmd/root.go
+++ b/cmd/cronosd/cmd/root.go
@@ -211,9 +211,6 @@ type appCreator struct {
 	encCfg params.EncodingConfig
 }
 
-// missing flag from cosmos-sdk
-const flagIAVLCacheSize = "iavl-cache-size"
-
 // newApp is an AppCreator
 func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
 	var cache sdk.MultiStorePersistentCache
@@ -269,7 +266,8 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a
 		baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
 		baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
 		baseapp.SetSnapshot(snapshotStore, snapshotOptions),
-		baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(flagIAVLCacheSize))),
+		baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))),
+		baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagIAVLFastNode))),
 	)
 }