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

Minimal v0.44 app, without deleting unupgraded packages #1029

Merged
merged 56 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
bdabd2c
remove migrations
rhuairahrighairidh Oct 19, 2021
038d711
remove incentive module
rhuairahrighairidh Oct 19, 2021
e92cc43
remove swap module
rhuairahrighairidh Oct 19, 2021
1450f06
remove committee module
rhuairahrighairidh Oct 19, 2021
63c9326
remove hard module
rhuairahrighairidh Oct 19, 2021
deb4e1e
remove bep3 module
rhuairahrighairidh Oct 19, 2021
03aa355
remove kavadist module
rhuairahrighairidh Oct 19, 2021
45b3833
remove cdp module
rhuairahrighairidh Oct 19, 2021
a797d65
remove issuance module
rhuairahrighairidh Oct 19, 2021
3fc21ac
remove auction module
rhuairahrighairidh Oct 19, 2021
65dce3a
remove pricefeed module
rhuairahrighairidh Oct 19, 2021
fb02168
remove validator-vesting module
rhuairahrighairidh Oct 19, 2021
b47c320
remove unused rest test spike
rhuairahrighairidh Oct 19, 2021
e742d84
remove missed module imports from antehandler
rhuairahrighairidh Oct 19, 2021
deaf002
app - remove alias from imports
rhuairahrighairidh Oct 19, 2021
e7f61bf
update cosmos-sdk version in go.mod
rhuairahrighairidh Oct 19, 2021
d01d1c1
app - replace supply module
rhuairahrighairidh Oct 19, 2021
a6d34dd
app - add vesting modulea
rhuairahrighairidh Oct 19, 2021
0a8b4d1
app - replace codec
rhuairahrighairidh Oct 19, 2021
94a9707
app - remove upgrade, remove antehandler
rhuairahrighairidh Oct 19, 2021
b7eba95
app - remove features until NewApp runs
rhuairahrighairidh Oct 20, 2021
09722ea
delete cmd, cli_test, migration cmd
rhuairahrighairidh Oct 20, 2021
e3c72ca
add new app binary
rhuairahrighairidh Oct 20, 2021
36e22f9
add rough copy of gaia cmds
rhuairahrighairidh Oct 20, 2021
5986f07
read from flags/config and create new app
rhuairahrighairidh Oct 20, 2021
e04a790
remove out of date contrib files
rhuairahrighairidh Oct 20, 2021
7ab71e9
add sdk config and other tweaks to get app running
rhuairahrighairidh Oct 20, 2021
49f2727
code tidying and checks against old kava and gaia
rhuairahrighairidh Oct 20, 2021
c829030
add modules packages back in
rhuairahrighairidh Oct 21, 2021
0cc924f
set go mod to ignore modules
rhuairahrighairidh Oct 21, 2021
8aea9c4
add ante package back in
rhuairahrighairidh Oct 21, 2021
e7119b9
set go mod to ignore ante
rhuairahrighairidh Oct 21, 2021
e5724e3
add cmd packages back in
rhuairahrighairidh Oct 21, 2021
6594432
set go mod to ignore cmd
rhuairahrighairidh Oct 21, 2021
6d66008
add migrate package back in
rhuairahrighairidh Oct 21, 2021
73a3d4c
set go mod to ignore migrate
rhuairahrighairidh Oct 21, 2021
a5df7f5
add app files back in, but ignored
rhuairahrighairidh Oct 21, 2021
1a1e978
revert commented out params file
rhuairahrighairidh Oct 21, 2021
567b7e9
add cli_test package back in
rhuairahrighairidh Oct 21, 2021
17d2107
set go mod to ignore cli_test
rhuairahrighairidh Oct 21, 2021
453ed88
remove unused makefile entry
rhuairahrighairidh Oct 21, 2021
b2635a9
add upgrade todo to go.mod
rhuairahrighairidh Oct 21, 2021
c05e705
update to go 1.16
rhuairahrighairidh Oct 21, 2021
e5494b8
fix CI
rhuairahrighairidh Oct 21, 2021
ad913f2
update replace directive for v0.44.x and run go mod tidy; removes
nddeluca Oct 21, 2021
4aa5df1
add ldflag for tendermint version, as tendermint now sets the version at
nddeluca Oct 22, 2021
313ee8c
add todo for settings version map in upgrade keeper
nddeluca Oct 22, 2021
9d938fc
upgrade antehandler package
rhuairahrighairidh Oct 25, 2021
94e8877
upgrade TestApp, add antehandler to app
rhuairahrighairidh Oct 25, 2021
0d6d145
register rest and grpc gateway routes
rhuairahrighairidh Oct 26, 2021
8898199
resolve TODO about funding community pool
rhuairahrighairidh Oct 26, 2021
8645874
move test methods to TestApp
rhuairahrighairidh Oct 26, 2021
dd6a95b
decouple default data dir configuration from app
rhuairahrighairidh Oct 26, 2021
b777597
refactor NewTestApp
rhuairahrighairidh Oct 26, 2021
b2e3fcb
remove ineffective cmd formatting
rhuairahrighairidh Oct 26, 2021
18a2266
move test helper for more accesibility
rhuairahrighairidh Oct 27, 2021
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
Prev Previous commit
Next Next commit
add sdk config and other tweaks to get app running
  • Loading branch information
rhuairahrighairidh committed Oct 20, 2021
commit 7ab71e9e30f79e276b980849abc504b0529182ff
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ all: install

build: go.sum
ifeq ($(OS), Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o build/$(shell go env GOOS)/kvd.exe ./cmd/kvd
go build -mod=readonly $(BUILD_FLAGS) -o build/$(shell go env GOOS)/kvd.exe ./cmd/kvd
go build -mod=readonly $(BUILD_FLAGS) -o build/$(shell go env GOOS)/kvcli.exe ./cmd/kvcli
else
go build -mod=readonly $(BUILD_FLAGS) -o build/$(shell go env GOOS)/kvd ./cmd/kvd
Expand Down Expand Up @@ -131,6 +131,11 @@ localnet-start: build-linux localnet-stop
localnet-stop:
docker-compose down

# Launch a new single validator chain
start:
./contrib/devnet/init-new-chain.sh
kava start

########################################
### Testing

Expand Down
44 changes: 22 additions & 22 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package app
import (
"fmt"
"io"
"log"
"os"
"path/filepath"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -54,23 +56,21 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmlog "github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

kavaappparams "github.com/kava-labs/kava/app/params"
)

const (
appName = "kava"
Bech32MainPrefix = "kava"
Bip44CoinType = 459 // see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
appName = "kava" // TODO what is this used for?

)

var (
// default home directories for expected binaries
DefaultCLIHome = os.ExpandEnv("$HOME/.kvcli") // TODO
DefaultNodeHome = os.ExpandEnv("$HOME/.kvd")
DefaultNodeHome string

// ModuleBasics manages simple versions of full app modules. It's used for things such as codec registration and genesis file verification.
ModuleBasics = module.NewBasicManager(
Expand Down Expand Up @@ -110,6 +110,14 @@ var (
}
)

func init() { // TODO why is this in app?
userHomeDir, err := os.UserHomeDir()
if err != nil {
log.Println("Failed to get home dir %2", err) // TODO bug?
}
DefaultNodeHome = filepath.Join(userHomeDir, ".kava") // TODO use appName, or version.AppName?
}

// Verify app interface at compile time
// var _ simapp.App = (*App)(nil) // TODO
var _ servertypes.Application = (*App)(nil)
Expand Down Expand Up @@ -158,7 +166,7 @@ type App struct {
}

// NewApp returns a reference to an initialized App.
func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, encodingConfig kavaappparams.EncodingConfig, options Options, baseAppOptions ...func(*baseapp.BaseApp)) *App {
func NewApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer, encodingConfig kavaappparams.EncodingConfig, options Options, baseAppOptions ...func(*baseapp.BaseApp)) *App {

appCodec := encodingConfig.Marshaler
legacyAmino := encodingConfig.Amino
Expand Down Expand Up @@ -202,6 +210,10 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, encodingConfig k
govSubspace := app.paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
crisisSubspace := app.paramsKeeper.Subspace(crisistypes.ModuleName)

bApp.SetParamStore(
app.paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()),
)

// add keepers
app.accountKeeper = authkeeper.NewAccountKeeper(
appCodec,
Expand Down Expand Up @@ -386,18 +398,6 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, encodingConfig k
// return cdc.Seal()
// }

// SetBech32AddressPrefixes sets the global prefix to be used when serializing addresses to bech32 strings.
func SetBech32AddressPrefixes(config *sdk.Config) {
config.SetBech32PrefixForAccount(Bech32MainPrefix, Bech32MainPrefix+sdk.PrefixPublic)
config.SetBech32PrefixForValidator(Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixOperator, Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixOperator+sdk.PrefixPublic)
config.SetBech32PrefixForConsensusNode(Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixConsensus, Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixConsensus+sdk.PrefixPublic)
}

// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets.
func SetBip44CoinType(config *sdk.Config) {
config.SetCoinType(Bip44CoinType)
}

// application updates every end block
func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
return app.mm.BeginBlock(ctx, req)
Expand Down Expand Up @@ -476,17 +476,17 @@ func (app *App) SimulationManager() *module.SimulationManager {
// RegisterAPIRoutes registers all application module routes with the provided
// API server.
func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
panic("TODO")
// TODO
}

// RegisterTxService implements the Application.RegisterTxService method.
func (app *App) RegisterTxService(clientCtx client.Context) {
panic("TODO")
// TODO
}

// RegisterTendermintService implements the Application.RegisterTendermintService method.
func (app *App) RegisterTendermintService(clientCtx client.Context) {
panic("TODO")
// TODO
}

// GetMaccPerms returns a mapping of the application's module account permissions.
Expand Down
41 changes: 41 additions & 0 deletions app/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package app

import sdk "github.com/cosmos/cosmos-sdk/types"

const (
// Bech32MainPrefix defines the Bech32 prefix for account addresses
Bech32MainPrefix = "kava"
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
Bech32PrefixAccPub = Bech32MainPrefix + "pub"
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
Bech32PrefixValAddr = Bech32MainPrefix + "val" + "oper"
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
Bech32PrefixValPub = Bech32MainPrefix + "val" + "oper" + "pub"
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
Bech32PrefixConsAddr = Bech32MainPrefix + "val" + "cons"
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
Bech32PrefixConsPub = Bech32MainPrefix + "val" + "cons" + "pub"

Bip44CoinType = 459 // see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
)

// SetSDKConfig configures the global config with kava app specific parameters.
// It does not seal the config to allow modification in tests.
func SetSDKConfig() *sdk.Config {
config := sdk.GetConfig()
SetBech32AddressPrefixes(config)
SetBip44CoinType(config)
return config
}

// SetBech32AddressPrefixes sets the global prefix to be used when serializing addresses to bech32 strings.
func SetBech32AddressPrefixes(config *sdk.Config) {
config.SetBech32PrefixForAccount(Bech32MainPrefix, Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
}

// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets.
func SetBip44CoinType(config *sdk.Config) {
config.SetCoinType(Bip44CoinType)
}
9 changes: 5 additions & 4 deletions cmd/kava/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/server"
simdcmd "github.com/cosmos/cosmos-sdk/simapp/simd/cmd"
"github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
Expand All @@ -19,10 +20,10 @@ import (
"github.com/kava-labs/kava/app/params"
)

// TODO set sdk config somewhere

// NewRootCmd creates a new root command for kava.
func NewRootCmd() *cobra.Command {
app.SetSDKConfig().Seal()

encodingConfig := app.MakeEncodingConfig()

initClientCtx := client.Context{}.
Expand Down Expand Up @@ -65,8 +66,8 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
// app.MigrateGenesisCmd(), // TODO
genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome),
genutilcli.ValidateGenesisCmd(app.ModuleBasics),
// AddGenesisAccountCmd(app.DefaultNodeHome), // TODO
tmcli.NewCompletionCmd(rootCmd, true), // TODO add other shells
simdcmd.AddGenesisAccountCmd(app.DefaultNodeHome), // TODO use own version with vesting accounts
tmcli.NewCompletionCmd(rootCmd, true), // TODO add other shells
// testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}), // TODO
debug.Cmd(),
config.Cmd(),
Expand Down
46 changes: 46 additions & 0 deletions contrib/devnet/init-new-chain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#! /bin/bash
set -e




validatorMnemonic="equip town gesture square tomorrow volume nephew minute witness beef rich gadget actress egg sing secret pole winter alarm law today check violin uncover"
# kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c
faucetMnemonic="crash sort dwarf disease change advice attract clump avoid mobile clump right junior axis book fresh mask tube front require until face effort vault"
# kava1adkm6svtzjsxxvg7g6rshg6kj9qwej8gwqadqd

DATA=~/.kava
# remove any old state and config
rm -rf $DATA

BINARY=kava

# Create new data directory, overwriting any that alread existed
chainID="kava-localnet"
$BINARY init validator --chain-id $chainID

# hacky enable of rest api
sed -in-place='' 's/enable = false/enable = true/g' $DATA/config/app.toml

# avoid having to use password for keys
$BINARY config keyring-backend test

# Create validator keys and add account to genesis
validatorKeyName="validator"
printf "$validatorMnemonic\n" | $BINARY keys add $validatorKeyName --recover
$BINARY add-genesis-account $validatorKeyName 2000000000ukava,100000000000bnb

# Create faucet keys and add account to genesis
faucetKeyName="faucet"
printf "$faucetMnemonic\n" | $BINARY keys add $faucetKeyName --recover
$BINARY add-genesis-account $faucetKeyName 1000000000ukava,100000000000bnb

# Create a delegation tx for the validator and add to genesis
$BINARY gentx $validatorKeyName 1000000000ukava --keyring-backend test --chain-id $chainID
$BINARY collect-gentxs

# Replace stake with ukava
sed -in-place='' 's/stake/ukava/g' $DATA/config/genesis.json

# Zero out the total supply so it gets recalculated during InitGenesis
jq '.app_state.bank.supply = []' $DATA/config/genesis.json|sponge $DATA/config/genesis.json