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 is not added to erc20 benchmark #1137

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 15 additions & 1 deletion app/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"testing"

sdkmath "cosmossdk.io/math"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/testutil/mock"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
memiavlstore "github.com/crypto-org-chain/cronos/store"
"github.com/crypto-org-chain/cronos/v2/x/cronos/types"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
Expand All @@ -36,14 +38,26 @@ func BenchmarkERC20Transfer(b *testing.B) {
require.NoError(b, err)
benchmarkERC20Transfer(b, db)
})
b.Run("memiavl", func(b *testing.B) {
benchmarkERC20Transfer(b, nil)
})
}

// pass `nil` to db to use memiavl
func benchmarkERC20Transfer(b *testing.B, db dbm.DB) {
txsPerBlock := 1000
gasPrice := big.NewInt(100000000000)

var appOpts servertypes.AppOptions = EmptyAppOptions{}
if db == nil {
appOpts = AppOptionsMap(map[string]interface{}{
memiavlstore.FlagMemIAVL: true,
})
}

encodingConfig := MakeEncodingConfig()
app := New(log.NewNopLogger(), db, nil, true, true, map[int64]bool{}, DefaultNodeHome, 0, encodingConfig, EmptyAppOptions{})
app := New(log.NewNopLogger(), db, nil, true, true, map[int64]bool{}, b.TempDir(), 0, encodingConfig, appOpts)
defer app.Close()
yihuang marked this conversation as resolved.
Show resolved Hide resolved

priv, err := ethsecp256k1.GenerateKey()
address := common.BytesToAddress(priv.PubKey().Address().Bytes())
Expand Down
12 changes: 12 additions & 0 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,18 @@ func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) {
return &ed25519.PubKey{Key: pkBytes}
}

// AppOptionsMap is a stub implementing AppOptions which can get data from a map
type AppOptionsMap map[string]interface{}

func (m AppOptionsMap) Get(key string) interface{} {
v, ok := m[key]
if !ok {
return interface{}(nil)
}

return v
}

// EmptyAppOptions is a stub implementing AppOptions
type EmptyAppOptions struct{}

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,6 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk=
github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis=
github.com/cosmos/cosmos-proto v1.0.0-beta.1 h1:iDL5qh++NoXxG8hSy93FdYJut4XfgbShIocllGaXx/0=
github.com/cosmos/cosmos-proto v1.0.0-beta.1/go.mod h1:8k2GNZghi5sDRFw/scPL8gMSowT1vDA+5ouxL8GjaUE=
github.com/cosmos/cosmos-sdk v0.46.15-0.20230807090309-16d52690792e h1:vxDKg/iXN/qJHt/iqdCzGdTOU7lhn+1LEdloLSrZKFo=
github.com/cosmos/cosmos-sdk v0.46.15-0.20230807090309-16d52690792e/go.mod h1:9MRixWsgoJ2UmVsCRRePtENFPP3cM+gTC5azEpxgllo=
github.com/cosmos/cosmos-sdk v0.46.15-0.20230807104542-537257060180 h1:JgSAZEKce5UOGOykTVEcgJcUAL5kvpV0+RMfDnOna78=
github.com/cosmos/cosmos-sdk v0.46.15-0.20230807104542-537257060180/go.mod h1:9MRixWsgoJ2UmVsCRRePtENFPP3cM+gTC5azEpxgllo=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
Expand Down
Loading