Rename gaia{d,cli} to wasm{d,cli}, GaiaApp->WasmApp

This commit is contained in:
Ethan Frey
2019-11-19 22:20:03 +01:00
parent d6dfa141e2
commit 4307d9a50a
12 changed files with 75 additions and 75 deletions

View File

@@ -48,9 +48,9 @@ build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
# process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=gaia \
-X github.com/cosmos/cosmos-sdk/version.ServerName=gaiad \
-X github.com/cosmos/cosmos-sdk/version.ClientName=gaiacli \
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=wasm \
-X github.com/cosmos/cosmos-sdk/version.ServerName=wasmd \
-X github.com/cosmos/cosmos-sdk/version.ClientName=wasmcli \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
@@ -70,11 +70,11 @@ all: install lint test
build: go.sum
ifeq ($(OS),Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o build/gaiad.exe ./cmd/gaiad
go build -mod=readonly $(BUILD_FLAGS) -o build/gaiacli.exe ./cmd/gaiacli
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmd.exe ./cmd/wasmd
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmcli.exe ./cmd/wasmcli
else
go build -mod=readonly $(BUILD_FLAGS) -o build/gaiad ./cmd/gaiad
go build -mod=readonly $(BUILD_FLAGS) -o build/gaiacli ./cmd/gaiacli
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmd ./cmd/wasmd
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmcli ./cmd/wasmcli
endif
build-linux: go.sum
@@ -88,8 +88,8 @@ else
endif
install: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/gaiad
go install -mod=readonly $(BUILD_FLAGS) ./cmd/gaiacli
go install -mod=readonly $(BUILD_FLAGS) ./cmd/wasmd
go install -mod=readonly $(BUILD_FLAGS) ./cmd/wasmcli
########################################
### Tools & dependencies

View File

@@ -31,14 +31,14 @@ import (
"github.com/cosmos/cosmos-sdk/x/supply"
)
const appName = "GaiaApp"
const appName = "WasmApp"
var (
// DefaultCLIHome default home directories for gaiacli
DefaultCLIHome = os.ExpandEnv("$HOME/.gaiacli")
// DefaultCLIHome default home directories for wasmcli
DefaultCLIHome = os.ExpandEnv("$HOME/.wasmcli")
// DefaultNodeHome default home directories for gaiad
DefaultNodeHome = os.ExpandEnv("$HOME/.gaiad")
// DefaultNodeHome default home directories for wasmd
DefaultNodeHome = os.ExpandEnv("$HOME/.wasmd")
// ModuleBasics The module BasicManager is in charge of setting up basic,
// non-dependant module elements, such as codec registration
@@ -83,8 +83,8 @@ func MakeCodec() *codec.Codec {
return cdc.Seal()
}
// GaiaApp extended ABCI application
type GaiaApp struct {
// WasmApp extended ABCI application
type WasmApp struct {
*bam.BaseApp
cdc *codec.Codec
@@ -114,11 +114,11 @@ type GaiaApp struct {
sm *module.SimulationManager
}
// NewGaiaApp returns a reference to an initialized GaiaApp.
func NewGaiaApp(
// NewWasmApp returns a reference to an initialized WasmApp.
func NewWasmApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
invCheckPeriod uint, baseAppOptions ...func(*bam.BaseApp),
) *GaiaApp {
) *WasmApp {
cdc := MakeCodec()
@@ -133,7 +133,7 @@ func NewGaiaApp(
)
tKeys := sdk.NewTransientStoreKeys(staking.TStoreKey, params.TStoreKey)
app := &GaiaApp{
app := &WasmApp{
BaseApp: bApp,
cdc: cdc,
invCheckPeriod: invCheckPeriod,
@@ -264,17 +264,17 @@ func NewGaiaApp(
}
// application updates every begin block
func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
func (app *WasmApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
return app.mm.BeginBlock(ctx, req)
}
// application updates every end block
func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
func (app *WasmApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
return app.mm.EndBlock(ctx, req)
}
// application update at chain initialization
func (app *GaiaApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
func (app *WasmApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
var genesisState simapp.GenesisState
app.cdc.MustUnmarshalJSON(req.AppStateBytes, &genesisState)
@@ -282,12 +282,12 @@ func (app *GaiaApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci
}
// load a particular height
func (app *GaiaApp) LoadHeight(height int64) error {
func (app *WasmApp) LoadHeight(height int64) error {
return app.LoadVersion(height, app.keys[bam.MainStoreKey])
}
// ModuleAccountAddrs returns all the app's module account addresses.
func (app *GaiaApp) ModuleAccountAddrs() map[string]bool {
func (app *WasmApp) ModuleAccountAddrs() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range maccPerms {
modAccAddrs[supply.NewModuleAddress(acc).String()] = true
@@ -297,7 +297,7 @@ func (app *GaiaApp) ModuleAccountAddrs() map[string]bool {
}
// Codec returns the application's sealed codec.
func (app *GaiaApp) Codec() *codec.Codec {
func (app *WasmApp) Codec() *codec.Codec {
return app.cdc
}

View File

@@ -14,14 +14,14 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
)
func TestGaiadExport(t *testing.T) {
func TestWasmddExport(t *testing.T) {
db := db.NewMemDB()
gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
gapp := NewWasmdApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
err := setGenesis(gapp)
require.NoError(t, err)
// Making a new app object with the db, so that initchain hasn't been called
newGapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
newGapp := NewWasmdApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
_, _, err = newGapp.ExportAppStateAndValidators(false, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
}
@@ -29,14 +29,14 @@ func TestGaiadExport(t *testing.T) {
// ensure that black listed addresses are properly set in bank keeper
func TestBlackListedAddrs(t *testing.T) {
db := db.NewMemDB()
gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
gapp := NewWasmdApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
for acc := range maccPerms {
require.True(t, gapp.bankKeeper.BlacklistedAddr(gapp.supplyKeeper.GetModuleAddress(acc)))
}
}
func setGenesis(gapp *GaiaApp) error {
func setGenesis(gapp *WasmApp) error {
genesisState := simapp.NewDefaultGenesisState()
stateBytes, err := codec.MarshalJSONIndent(gapp.cdc, genesisState)
if err != nil {

View File

@@ -14,7 +14,7 @@ import (
)
// ExportAppStateAndValidators export the state of gaia for a genesis file
func (app *GaiaApp) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []string,
func (app *WasmApp) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []string,
) (appState json.RawMessage, validators []tmtypes.GenesisValidator, err error) {
// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, abci.Header{Height: app.LastBlockHeight()})
@@ -35,7 +35,7 @@ func (app *GaiaApp) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteLis
// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favour of export at a block height
func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []string) {
func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []string) {
applyWhiteList := false
//Check if there is a whitelist

View File

@@ -38,7 +38,7 @@ func init() {
simapp.GetSimulatorFlags()
}
func testAndRunTxs(app *GaiaApp, config simulation.Config) []simulation.WeightedOperation {
func testAndRunTxs(app *WasmApp, config simulation.Config) []simulation.WeightedOperation {
ap := make(simulation.AppParams)
paramChanges := app.sm.GenerateParamChanges(config.Seed)
@@ -246,7 +246,7 @@ func interBlockCacheOpt() func(*baseapp.BaseApp) {
}
// Profile with:
// /usr/local/go/bin/go test -benchmem -run=^$ github.com/cosmos/cosmos-sdk/GaiaApp -bench ^BenchmarkFullAppSimulation$ -Commit=true -cpuprofile cpu.out
// /usr/local/go/bin/go test -benchmem -run=^$ github.com/cosmos/cosmos-sdk/WasmApp -bench ^BenchmarkFullAppSimulation$ -Commit=true -cpuprofile cpu.out
func BenchmarkFullAppSimulation(b *testing.B) {
logger := log.NewNopLogger()
config := simapp.NewConfigFromFlags()
@@ -267,7 +267,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
_ = os.RemoveAll(dir)
}()
gapp := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, interBlockCacheOpt())
gapp := NewWasmApp(logger, db, nil, true, simapp.FlagPeriodValue, interBlockCacheOpt())
// Run randomized simulation
// TODO: parameterize numbers, save for a later PR
@@ -328,8 +328,8 @@ func TestFullAppSimulation(t *testing.T) {
_ = os.RemoveAll(dir)
}()
gapp := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
require.Equal(t, "GaiaApp", gapp.Name())
gapp := NewWasmApp(logger, db, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
require.Equal(t, "WasmApp", gapp.Name())
// Run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(
@@ -384,7 +384,7 @@ func TestAppImportExport(t *testing.T) {
_ = os.RemoveAll(dir)
}()
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
app := NewWasmApp(logger, db, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
require.Equal(t, "SimApp", app.Name())
// Run randomized simulation
@@ -430,7 +430,7 @@ func TestAppImportExport(t *testing.T) {
_ = os.RemoveAll(newDir)
}()
newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
require.Equal(t, "SimApp", newApp.Name())
var genesisState simapp.GenesisState
@@ -504,8 +504,8 @@ func TestAppSimulationAfterImport(t *testing.T) {
_ = os.RemoveAll(dir)
}()
gapp := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
require.Equal(t, "GaiaApp", gapp.Name())
gapp := NewWasmApp(logger, db, nil, true, simapp.FlagPeriodValue, fauxMerkleModeOpt)
require.Equal(t, "WasmApp", gapp.Name())
// Run randomized simulation
// Run randomized simulation
@@ -560,8 +560,8 @@ func TestAppSimulationAfterImport(t *testing.T) {
_ = os.RemoveAll(newDir)
}()
newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, true, 0, fauxMerkleModeOpt)
require.Equal(t, "GaiaApp", newApp.Name())
newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, 0, fauxMerkleModeOpt)
require.Equal(t, "WasmApp", newApp.Name())
newApp.InitChain(abci.RequestInitChain{
AppStateBytes: appState,
@@ -599,7 +599,7 @@ func TestAppStateDeterminism(t *testing.T) {
for j := 0; j < numTimesToRunPerSeed; j++ {
logger := log.NewNopLogger()
db := dbm.NewMemDB()
app := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, interBlockCacheOpt())
app := NewWasmApp(logger, db, nil, true, simapp.FlagPeriodValue, interBlockCacheOpt())
fmt.Printf(
"running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",
@@ -647,7 +647,7 @@ func BenchmarkInvariants(b *testing.B) {
os.RemoveAll(dir)
}()
gapp := NewGaiaApp(logger, db, nil, true, simapp.FlagPeriodValue, interBlockCacheOpt())
gapp := NewWasmApp(logger, db, nil, true, simapp.FlagPeriodValue, interBlockCacheOpt())
// 2. Run parameterized simulation (w/o invariants)
_, simParams, simErr := simulation.SimulateFromSeed(

View File

@@ -16,7 +16,7 @@ import (
)
// ExportStateToJSON util function to export the app state to JSON
func ExportStateToJSON(app *GaiaApp, path string) error {
func ExportStateToJSON(app *WasmApp, path string) error {
fmt.Println("exporting app state...")
appState, _, err := app.ExportAppStateAndValidators(false, nil)
if err != nil {
@@ -26,13 +26,13 @@ func ExportStateToJSON(app *GaiaApp, path string) error {
return ioutil.WriteFile(path, []byte(appState), 0644)
}
// NewGaiaAppUNSAFE is used for debugging purposes only.
// NewWasmAppUNSAFE is used for debugging purposes only.
//
// NOTE: to not use this function with non-test code
func NewGaiaAppUNSAFE(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
func NewWasmAppUNSAFE(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
invCheckPeriod uint, baseAppOptions ...func(*baseapp.BaseApp),
) (gapp *GaiaApp, keyMain, keyStaking *sdk.KVStoreKey, stakingKeeper staking.Keeper) {
) (gapp *WasmApp, keyMain, keyStaking *sdk.KVStoreKey, stakingKeeper staking.Keeper) {
gapp = NewGaiaApp(logger, db, traceStore, loadLatest, invCheckPeriod, baseAppOptions...)
gapp = NewWasmApp(logger, db, traceStore, loadLatest, invCheckPeriod, baseAppOptions...)
return gapp, gapp.keys[bam.MainStoreKey], gapp.keys[staking.StoreKey], gapp.stakingKeeper
}

View File

@@ -23,7 +23,7 @@ import (
"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/gaia/app"
"github.com/cosmwasm/wasmd/app"
)
func main() {
@@ -38,7 +38,7 @@ func main() {
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
config.SetKeyringServiceName("gaia")
config.SetKeyringServiceName("wasmd")
config.Seal()
// TODO: setup keybase, viper object, etc. to be passed into
@@ -46,8 +46,8 @@ func main() {
// with the cdc
rootCmd := &cobra.Command{
Use: "gaiacli",
Short: "Command line interface for interacting with gaiad",
Use: "wasmcli",
Short: "Command line interface for interacting with wasmd",
}
// Add --chain-id to persistent flags and mark it required
@@ -71,8 +71,8 @@ func main() {
client.NewCompletionCmd(rootCmd, true),
)
// Add flags and prefix all env exposed with GA
executor := cli.PrepareMainCmd(rootCmd, "GA", app.DefaultCLIHome)
// Add flags and prefix all env exposed with WM
executor := cli.PrepareMainCmd(rootCmd, "WM", app.DefaultCLIHome)
err := executor.Execute()
if err != nil {

View File

@@ -13,7 +13,7 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
"github.com/cosmos/gaia/app"
"github.com/cosmwasm/wasmd/app"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
@@ -37,14 +37,14 @@ func main() {
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
config.SetKeyringServiceName("gaia")
config.SetKeyringServiceName("wasmd")
config.Seal()
ctx := server.NewDefaultContext()
cobra.EnableCommandSorting = false
rootCmd := &cobra.Command{
Use: "gaiad",
Short: "Gaia Daemon (server)",
Use: "wasmd",
Short: "Wasm Daemon (server)",
PersistentPreRunE: server.PersistentPreRunEFn(ctx),
}
@@ -67,7 +67,7 @@ func main() {
server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators)
// prepare and add flags
executor := cli.PrepareBaseCmd(rootCmd, "GA", app.DefaultNodeHome)
executor := cli.PrepareBaseCmd(rootCmd, "WM", app.DefaultNodeHome)
rootCmd.PersistentFlags().UintVar(&invCheckPeriod, flagInvCheckPeriod,
0, "Assert registered invariants every N blocks")
err := executor.Execute()
@@ -83,7 +83,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application
cache = store.NewCommitKVStoreCacheManager()
}
return app.NewGaiaApp(
return app.NewWasmApp(
logger, db, traceStore, true, invCheckPeriod,
baseapp.SetPruning(store.NewPruningOptionsFromString(viper.GetString("pruning"))),
baseapp.SetMinGasPrices(viper.GetString(server.FlagMinGasPrices)),
@@ -98,7 +98,7 @@ func exportAppStateAndTMValidators(
) (json.RawMessage, []tmtypes.GenesisValidator, error) {
if height != -1 {
gapp := app.NewGaiaApp(logger, db, traceStore, false, uint(1))
gapp := app.NewWasmApp(logger, db, traceStore, false, uint(1))
err := gapp.LoadHeight(height)
if err != nil {
return nil, nil, err
@@ -106,6 +106,6 @@ func exportAppStateAndTMValidators(
return gapp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
}
gapp := app.NewGaiaApp(logger, db, traceStore, true, uint(1))
gapp := app.NewWasmApp(logger, db, traceStore, true, uint(1))
return gapp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
}

View File

@@ -17,7 +17,7 @@ import (
tmstore "github.com/tendermint/tendermint/store"
tm "github.com/tendermint/tendermint/types"
"github.com/cosmos/gaia/app"
"github.com/cosmwasm/wasmd/app"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/server"
@@ -92,7 +92,7 @@ func replayTxs(rootDir string) error {
// Application
fmt.Fprintln(os.Stderr, "Creating application")
gapp := app.NewGaiaApp(
gapp := app.NewWasmApp(
ctx.Logger, appDB, traceStoreWriter, true, uint(1),
baseapp.SetPruning(store.PruneEverything), // nothing
)

View File

@@ -48,7 +48,7 @@ func testnetCmd(ctx *server.Context, cdc *codec.Codec,
cmd := &cobra.Command{
Use: "testnet",
Short: "Initialize files for a Gaiad testnet",
Short: "Initialize files for a Wasmd testnet",
Long: `testnet will create "v" number of directories and populate each with
necessary files (private validator, genesis, config, etc.).
@@ -80,9 +80,9 @@ Example:
"Directory to store initialization data for the testnet")
cmd.Flags().String(flagNodeDirPrefix, "node",
"Prefix the directory name for each node with (node results in node0, node1, ...)")
cmd.Flags().String(flagNodeDaemonHome, "gaiad",
cmd.Flags().String(flagNodeDaemonHome, "wasmd",
"Home directory of the node's daemon configuration")
cmd.Flags().String(flagNodeCLIHome, "gaiacli",
cmd.Flags().String(flagNodeCLIHome, "wasmcli",
"Home directory of the node's cli configuration")
cmd.Flags().String(flagStartingIPAddress, "192.168.0.1",
"Starting IP address (192.168.0.1 results in persistent peers list ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)")
@@ -110,8 +110,8 @@ func InitTestnet(cmd *cobra.Command, config *tmconfig.Config, cdc *codec.Codec,
nodeIDs := make([]string, numValidators)
valPubKeys := make([]crypto.PubKey, numValidators)
gaiaConfig := srvconfig.DefaultConfig()
gaiaConfig.MinGasPrices = minGasPrices
wasmConfig := srvconfig.DefaultConfig()
wasmConfig.MinGasPrices = minGasPrices
//nolint:prealloc
var (
@@ -223,8 +223,8 @@ func InitTestnet(cmd *cobra.Command, config *tmconfig.Config, cdc *codec.Codec,
// TODO: Rename config file to server.toml as it's not particular to Gaia
// (REF: https://github.com/cosmos/cosmos-sdk/issues/4125).
gaiaConfigFilePath := filepath.Join(nodeDir, "config/gaiad.toml")
srvconfig.WriteConfigFile(gaiaConfigFilePath, gaiaConfig)
wasmConfigFilePath := filepath.Join(nodeDir, "config/gaiad.toml")
srvconfig.WriteConfigFile(wasmConfigFilePath, wasmConfig)
}
if err := initGenFiles(cdc, mbm, chainID, genAccounts, genFiles, numValidators); err != nil {

2
go.mod
View File

@@ -1,4 +1,4 @@
module github.com/cosmos/gaia
module github.com/cosmwasm/wasmd
go 1.13