-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: memiavl configs are not defined in app.toml (#1028)
* Problem: memiavl configs are not defined in app.toml Solution: - integrate custom configs into app.toml * Update CHANGELOG.md Signed-off-by: yihuang <huang@crypto.com> * better memiavl setup code * fix integration test --------- Signed-off-by: yihuang <huang@crypto.com>
- Loading branch information
Showing
9 changed files
with
89 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package config | ||
|
||
import "github.com/evmos/ethermint/server/config" | ||
|
||
type Config struct { | ||
config.Config | ||
|
||
MemIAVL MemIAVLConfig `mapstructure:"memiavl"` | ||
} | ||
|
||
type MemIAVLConfig struct { | ||
// Enable defines if the memiavl should be enabled. | ||
Enable bool `mapstructure:"enable"` | ||
// ZeroCopy defines if the memiavl should return slices pointing to mmap-ed buffers directly (zero-copy), | ||
// the zero-copied slices must not be retained beyond current block's execution. | ||
ZeroCopy bool `mapstructure:"zero-copy"` | ||
// AsyncCommit defines if the memiavl should commit asynchronously, this greatly improve block catching-up performance. | ||
AsyncCommit bool `mapstructure:"async-commit"` | ||
} | ||
|
||
func DefaultMemIAVLConfig() MemIAVLConfig { | ||
return MemIAVLConfig{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package config | ||
|
||
// DefaultConfigTemplate defines the configuration template for the EVM RPC configuration | ||
const DefaultConfigTemplate = ` | ||
############################################################################### | ||
### Cronos Configuration ### | ||
############################################################################### | ||
[memiavl] | ||
# Enable defines if the memiavl should be enabled. | ||
enable = {{ .MemIAVL.Enable }} | ||
# ZeroCopy defines if the memiavl should return slices pointing to mmap-ed buffers directly (zero-copy), | ||
# the zero-copied slices must not be retained beyond current block's execution. | ||
zero-copy = {{ .MemIAVL.ZeroCopy }} | ||
# AsyncCommit defines if the memiavl should commit asynchronously, this greatly improve block catching-up performance. | ||
async-commit = {{ .MemIAVL.AsyncCommit }} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package app | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/spf13/cast" | ||
"github.com/tendermint/tendermint/libs/log" | ||
|
||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
servertypes "github.com/cosmos/cosmos-sdk/server/types" | ||
|
||
"github.com/crypto-org-chain/cronos/store/rootmulti" | ||
) | ||
|
||
const ( | ||
FlagMemIAVL = "memiavl.enable" | ||
FlagAsyncCommit = "memiavl.async-commit" | ||
FlagZeroCopy = "memiavl.zero-copy" | ||
) | ||
|
||
func SetupMemIAVL(logger log.Logger, homePath string, appOpts servertypes.AppOptions, baseAppOptions []func(*baseapp.BaseApp)) []func(*baseapp.BaseApp) { | ||
if cast.ToBool(appOpts.Get(FlagMemIAVL)) { | ||
// cms must be overridden before the other options, because they may use the cms, | ||
// make sure the cms aren't be overridden by the other options later on. | ||
cms := rootmulti.NewStore(filepath.Join(homePath, "data", "memiavl.db"), logger) | ||
cms.SetAsyncWAL(cast.ToBool(appOpts.Get(FlagAsyncCommit))) | ||
cms.SetZeroCopy(cast.ToBool(appOpts.Get(FlagZeroCopy))) | ||
baseAppOptions = append([]func(*baseapp.BaseApp){setCMS(cms)}, baseAppOptions...) | ||
} | ||
|
||
return baseAppOptions | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters