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

Problem: memiavl setup code is not reusable #1082

Merged
merged 5 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
- [#1050](https://github.com/crypto-org-chain/cronos/pull/1050) nativebyteorder mode will check endianness on startup, binaries are built with nativebyteorder by default.
- [#1064](https://github.com/crypto-org-chain/cronos/pull/1064) Simplify memiavl snapshot switching.
- [#1067](https://github.com/crypto-org-chain/cronos/pull/1067) memiavl: only export state-sync snapshots on an exist snapshot
- [#]() Make memiavl setup code reusable.
yihuang marked this conversation as resolved.
Show resolved Hide resolved

*April 13, 2023*

Expand Down
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ import (

// this line is used by starport scaffolding # stargate/app/moduleImport

memiavlstore "github.com/crypto-org-chain/cronos/store"
memiavlrootmulti "github.com/crypto-org-chain/cronos/store/rootmulti"
"github.com/crypto-org-chain/cronos/v2/x/cronos"
cronosclient "github.com/crypto-org-chain/cronos/v2/x/cronos/client"
Expand Down Expand Up @@ -343,7 +344,7 @@ func New(
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry

baseAppOptions = SetupMemIAVL(logger, homePath, appOpts, baseAppOptions)
baseAppOptions = memiavlstore.SetupMemIAVL(logger, homePath, appOpts, baseAppOptions)
bApp := baseapp.NewBaseApp(Name, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...)

bApp.SetCommitMultiStoreTracer(traceStore)
Expand Down
15 changes: 12 additions & 3 deletions cmd/cronosd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import (
servercfg "github.com/evmos/ethermint/server/config"
ethermint "github.com/evmos/ethermint/types"

memiavlcfg "github.com/crypto-org-chain/cronos/store/config"
"github.com/crypto-org-chain/cronos/v2/app"
cronoscfg "github.com/crypto-org-chain/cronos/v2/app/config"
"github.com/crypto-org-chain/cronos/v2/cmd/cronosd/opendb"
"github.com/crypto-org-chain/cronos/v2/x/cronos"
// this line is used by starport scaffolding # stargate/root/import
Expand Down Expand Up @@ -213,11 +213,20 @@ func txCommand() *cobra.Command {
// initAppConfig helps to override default appConfig template and configs.
// return "", nil if no custom configuration is required for the application.
func initAppConfig() (string, interface{}) {
type CustomAppConfig struct {
servercfg.Config

MemIAVL memiavlcfg.MemIAVLConfig `mapstructure:"memiavl"`
}

tpl, cfg := servercfg.AppConfig(ethermint.AttoPhoton)
return tpl + cronoscfg.DefaultConfigTemplate, cronoscfg.Config{

customAppConfig := CustomAppConfig{
Config: cfg.(servercfg.Config),
MemIAVL: cronoscfg.DefaultMemIAVLConfig(),
MemIAVL: memiavlcfg.DefaultMemIAVLConfig(),
}

return tpl + memiavlcfg.DefaultConfigTemplate, customAppConfig
}

type appCreator struct {
Expand Down
11 changes: 1 addition & 10 deletions app/config/config.go → store/config/config.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
package config

import (
"github.com/crypto-org-chain/cronos/memiavl"
"github.com/evmos/ethermint/server/config"
)
import "github.com/crypto-org-chain/cronos/memiavl"

const DefaultCacheSize = 1000

type Config struct {
config.Config

MemIAVL MemIAVLConfig `mapstructure:"memiavl"`
}

type MemIAVLConfig struct {
// Enable defines if the memiavl should be enabled.
Enable bool `mapstructure:"enable"`
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion app/memiavl.go → store/setup.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app
package store

import (
"path/filepath"
Expand Down