Skip to content

Commit

Permalink
update baseapp options
Browse files Browse the repository at this point in the history
  • Loading branch information
vuong177 committed Apr 4, 2023
1 parent a884aa5 commit 8fe338f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 65 deletions.
19 changes: 7 additions & 12 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package app

import (
"fmt"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -253,13 +252,10 @@ func NewBanksyApp(
bApp.SetVersion(Version)
bApp.SetInterfaceRegistry(interfaceRegistry)

fmt.Println("base app dcm", bApp)

keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, icqtypes.StoreKey, capabilitytypes.StoreKey, consensusparamtypes.StoreKey,

evidencetypes.StoreKey, ibctransfertypes.StoreKey, icqtypes.StoreKey, capabilitytypes.StoreKey, consensusparamtypes.StoreKey, wasmtypes.StoreKey,
crisistypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
Expand Down Expand Up @@ -294,25 +290,25 @@ func NewBanksyApp(

// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec, keys[authtypes.StoreKey], authtypes.ProtoBaseAccount, maccPerms, AccountAddressPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(), // TODO: Fix
appCodec, keys[authtypes.StoreKey], authtypes.ProtoBaseAccount, maccPerms, AccountAddressPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.BlacklistedModuleAccountAddrs(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), // TODO: Fix
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.BlacklistedModuleAccountAddrs(), authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.StakingKeeper = *stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), // TODO: Fix
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.AccountKeeper, app.BankKeeper,
app.StakingKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), // TODO: Fix
app.StakingKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, encodingConfig.Amino, keys[slashingtypes.StoreKey], app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), // TODO: Fix
appCodec, encodingConfig.Amino, keys[slashingtypes.StoreKey], app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.CrisisKeeper = crisiskeeper.NewKeeper(appCodec, keys[crisistypes.StoreKey],
invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), // TODO: fix
invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
Expand Down Expand Up @@ -722,7 +718,6 @@ func (app *BanksyApp) RegisterTendermintService(clientCtx client.Context) {

// RegisterNodeService registers the node gRPC Query service.
func (app *BanksyApp) RegisterNodeService(clientCtx client.Context) {
// TODO: implement!
nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter())
}

Expand Down
47 changes: 4 additions & 43 deletions cmd/banksyd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ import (
"fmt"
"io"
"os"
"path/filepath"

"github.com/cosmos/cosmos-sdk/snapshots"

dbm "github.com/cometbft/cometbft-db"
tmcli "github.com/cometbft/cometbft/libs/cli"
"github.com/cometbft/cometbft/libs/log"
"github.com/spf13/cast"
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
config "github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/debug"
Expand All @@ -25,8 +21,6 @@ import (
"github.com/cosmos/cosmos-sdk/server"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -197,6 +191,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) {
txCommand(),
keys.Commands(app.DefaultNodeHome),
)

}

func addModuleInitFlags(startCmd *cobra.Command) {
Expand Down Expand Up @@ -252,7 +247,6 @@ func txCommand() *cobra.Command {

app.ModuleBasics.AddTxCommands(cmd)
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")

return cmd
}

Expand All @@ -262,11 +256,6 @@ type appCreator struct {

// 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

if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
cache = store.NewCommitKVStoreCacheManager()
}

skipUpgradeHeights := make(map[int64]bool)
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
Expand All @@ -277,25 +266,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a
skipUpgradeHeights[h_] = true
}

pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts)
if err != nil {
panic(err)
}

snapshotDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots")
snapshotDB, err := dbm.NewDB("metadata", dbm.GoLevelDBBackend, snapshotDir)
if err != nil {
panic(err)
}
snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir)
if err != nil {
panic(err)
}

snapshotOptions := snapshottypes.NewSnapshotOptions(
cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval)),
cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)),
)
baseappOptions := server.DefaultBaseappOptions(appOpts)

newApp := app.NewBanksyApp(
logger, db, traceStore, true, skipUpgradeHeights,
Expand All @@ -304,19 +275,9 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a
a.encCfg,
// this line is used by starport scaffolding # stargate/root/appArgument
appOpts,
baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))),
baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))),
baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))),
baseapp.SetInterBlockCache(cache),
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(server.FlagIAVLCacheSize))),
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))),
baseapp.SetChainID("test-1"),
baseappOptions...,
)

fmt.Println("new app", newApp.BaseApp)
return newApp
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ replace (
// dragonberry replkace line per: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.9
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0

github.com/cosmos/ibc-go/v7 v7.1.0 => github.com/notional-labs/ibc-go/v7 v7.0.0-rc0.0.20230321185643-9020cfed6545
github.com/cosmos/ibc-go/v7 v7.1.0 => github.com/strangelove-ventures/ibc-go/v7 v7.0.0-20230327161923-eae575bf57cc
// use cosmos-flavored protobufs
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,6 @@ github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OS
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/notional-labs/async-icq/v7 v7.0.0 h1:lvkpZGiHQ+4cTmbzvxn0fU+ADQOPbuWwEBLPaTxIPj4=
github.com/notional-labs/async-icq/v7 v7.0.0/go.mod h1:quyRN5K9evUbruyCLUvoOkbODAXJt5IUqVu+PmSg8Fc=
github.com/notional-labs/ibc-go/v7 v7.0.0-rc0.0.20230321185643-9020cfed6545 h1:Lzot2Zk+fT4ks8IQ+hq9BbtXGY9g0PPUeflzYfxJe1k=
github.com/notional-labs/ibc-go/v7 v7.0.0-rc0.0.20230321185643-9020cfed6545/go.mod h1:WPyGyrrMYsIwWLKjOY5DzfUlbiGkCfJNnItCPnBKV/s=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
Expand Down Expand Up @@ -869,6 +867,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU=
github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA=
github.com/strangelove-ventures/ibc-go/v7 v7.0.0-20230327161923-eae575bf57cc h1:1vDhd5IjP1kdglSQ12DpOhUkwmUXBiE9NMwCj4yuVW8=
github.com/strangelove-ventures/ibc-go/v7 v7.0.0-20230327161923-eae575bf57cc/go.mod h1:ISHo/Qitjtvj2svGmttaZv03zVXmS+uqvUyF9kFqlI0=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
Expand Down
15 changes: 8 additions & 7 deletions testnode.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
KEY="mykey"
CHAINID="test-1"
CHAINID="banksy-testnet-1"
MONIKER="localtestnet"
KEYALGO="secp256k1"
KEYRING="test"
Expand All @@ -18,15 +18,15 @@ banksyd config keyring-backend $KEYRING
banksyd config chain-id $CHAINID

# if $KEY exists it should be deleted
echo "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry" | banksyd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO --recover
echo "taste shoot adapt slow truly grape gift need suggest midnight burger horn whisper hat vast aspect exit scorpion jewel axis great area awful blind" | banksyd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO --recover

banksyd init $MONIKER --chain-id $CHAINID

# Allocate genesis accounts (cosmos formatted addresses)
banksyd add-genesis-account $KEY 100000000000000000000000000stake --keyring-backend $KEYRING

# Sign genesis transaction
banksyd gentx $KEY 1000000000000000000000stake --keyring-backend $KEYRING --chain-id $CHAINID
banksyd add-genesis-account $KEY 10000000000upicax --keyring-backend $KEYRING
banksyd add-genesis-account banksy1594tdya20hxz7kjenkn5w09jljyvdfk8kx5rd6 1000000000000000upicax --keyring-backend $KEYRING
# Sign genesis transaction banksy1594tdya20hxz7kjenkn5w09jljyvdfk8kx5rd6
banksyd gentx $KEY 10000000000upicax --keyring-backend $KEYRING --chain-id $CHAINID

# Collect genesis tx
banksyd collect-gentxs
Expand All @@ -41,6 +41,7 @@ fi
# update request max size so that we can upload the light client
# '' -e is a must have params on mac, if use linux please delete before run
sed -i'' -e 's/max_body_bytes = /max_body_bytes = 1/g' ~/.banksy/config/config.toml
cat $HOME/.banksy/config/genesis.json | jq '.app_state["gov"]["voting_params"]["voting_period"]="45s"' > $HOME/.banksy/config/tmp_genesis.json && mv $HOME/.banksy/config/tmp_genesis.json $HOME/.banksy/config/genesis.json

# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
banksyd start --pruning=nothing --minimum-gas-prices=0.0001stake
# banksyd start --pruning=nothing --minimum-gas-prices=0.0001stake

0 comments on commit 8fe338f

Please sign in to comment.