Skip to content

Commit

Permalink
Rename gaia{d,cli} to wasm{d,cli}, GaiaApp->WasmApp
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Nov 19, 2019
1 parent d6dfa14 commit 4307d9a
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 75 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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
Expand All @@ -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
Expand Down
34 changes: 17 additions & 17 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()

Expand All @@ -133,7 +133,7 @@ func NewGaiaApp(
)
tKeys := sdk.NewTransientStoreKeys(staking.TStoreKey, params.TStoreKey)

app := &GaiaApp{
app := &WasmApp{
BaseApp: bApp,
cdc: cdc,
invCheckPeriod: invCheckPeriod,
Expand Down Expand Up @@ -264,30 +264,30 @@ 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)

return app.mm.InitGenesis(ctx, genesisState)
}

// 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
Expand All @@ -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
}

Expand Down
10 changes: 5 additions & 5 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ 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")
}

// 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 {
Expand Down
4 changes: 2 additions & 2 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()})
Expand All @@ -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
Expand Down
26 changes: 13 additions & 13 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions app/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
12 changes: 6 additions & 6 deletions cmd/gaiacli/main.go → cmd/wasmcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -38,16 +38,16 @@ 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
// the below functions and eliminate global vars, like we do
// 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
Expand All @@ -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 {
Expand Down
File renamed without changes.
Loading

0 comments on commit 4307d9a

Please sign in to comment.