From 3703121f0905ef438779cc5be6b5718109a0f6f6 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Tue, 19 Sep 2017 20:16:04 -0400 Subject: [PATCH 01/15] Added IsValidNonnegative to coins module --- modules/coin/coin.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/coin/coin.go b/modules/coin/coin.go index 168b069259..b4b8fc9775 100644 --- a/modules/coin/coin.go +++ b/modules/coin/coin.go @@ -127,6 +127,11 @@ func (coins Coins) IsValid() bool { } } +// IsValidNonnegative tests is coins IsValid and IsNonnegative +func (coins Coins) IsValidNonnegative() bool { + return coins.IsValid() && coins.IsNonnegative() +} + // Plus combines to sets of coins // // TODO: handle empty coins! From 007fc330a41c562fbace49ce00ed9ce4c0025cc8 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Tue, 3 Oct 2017 03:47:26 -0400 Subject: [PATCH 02/15] ticker in the begin block logic --- app/app.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/app.go b/app/app.go index eebc816e8f..cda2ed8e3c 100644 --- a/app/app.go +++ b/app/app.go @@ -163,9 +163,28 @@ func (app *Basecoin) InitChain(req abci.RequestInitChain) { // } } +// Ticker - has the ticker function +type Ticker interface { + Tick(ctx sdk.Context, store sm.SimpleDB) ([]*abci.Validator, error) +} + // BeginBlock - ABCI func (app *Basecoin) BeginBlock(req abci.RequestBeginBlock) { app.height++ + + ticker, ok := app.handler.(Ticker) + if ok { + ctx := stack.NewContext( + app.GetChainID(), + app.height, + app.logger.With("call", "delivertx"), + ) + diff, err := ticker.Tick(ctx, app.state.Append()) + if err != nil { + panic(err) + } + app.addValChange(diff) + } // for _, plugin := range app.plugins.GetList() { // plugin.BeginBlock(app.state, hash, header) // } From 20e1b92ad4d1f237d47e108faa9e4360ea34da32 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Tue, 3 Oct 2017 16:42:01 -0400 Subject: [PATCH 03/15] remove ticker from begin block --- app/app.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/app/app.go b/app/app.go index cda2ed8e3c..79ed53b0c1 100644 --- a/app/app.go +++ b/app/app.go @@ -163,28 +163,10 @@ func (app *Basecoin) InitChain(req abci.RequestInitChain) { // } } -// Ticker - has the ticker function -type Ticker interface { - Tick(ctx sdk.Context, store sm.SimpleDB) ([]*abci.Validator, error) -} - // BeginBlock - ABCI func (app *Basecoin) BeginBlock(req abci.RequestBeginBlock) { app.height++ - ticker, ok := app.handler.(Ticker) - if ok { - ctx := stack.NewContext( - app.GetChainID(), - app.height, - app.logger.With("call", "delivertx"), - ) - diff, err := ticker.Tick(ctx, app.state.Append()) - if err != nil { - panic(err) - } - app.addValChange(diff) - } // for _, plugin := range app.plugins.GetList() { // plugin.BeginBlock(app.state, hash, header) // } From 6eb884017bf2d5a9e86406a64213e3c9aba99c74 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Tue, 3 Oct 2017 19:01:02 -0400 Subject: [PATCH 04/15] proper integration of tick functionality --- app/app.go | 23 ++++++++++++++++++++++ server/commands/start.go | 41 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/app/app.go b/app/app.go index 79ed53b0c1..0ff0908231 100644 --- a/app/app.go +++ b/app/app.go @@ -28,12 +28,16 @@ type Basecoin struct { state *Store handler sdk.Handler + tick Ticker pending []*abci.Validator height uint64 logger log.Logger } +// Ticker - tick function +type Ticker func(sm.SimpleDB) ([]*abci.Validator, error) + var _ abci.Application = &Basecoin{} // NewBasecoin - create a new instance of the basecoin application @@ -46,6 +50,17 @@ func NewBasecoin(handler sdk.Handler, store *Store, logger log.Logger) *Basecoin } } +// NewBasecoinTick - create a new instance of the basecoin application with tick functionality +func NewBasecoinTick(handler sdk.Handler, store *Store, logger log.Logger, tick Ticker) *Basecoin { + return &Basecoin{ + handler: handler, + info: sm.NewChainState(), + state: store, + logger: logger, + tick: tick, + } +} + // GetChainID returns the currently stored chain func (app *Basecoin) GetChainID() string { return app.info.GetChainID(app.state.Committed()) @@ -170,6 +185,14 @@ func (app *Basecoin) BeginBlock(req abci.RequestBeginBlock) { // for _, plugin := range app.plugins.GetList() { // plugin.BeginBlock(app.state, hash, header) // } + + if app.tick != nil { + diff, err := app.tick(app.state.Append()) + if err != nil { + panic(err) + } + app.addValChange(diff) + } } // EndBlock - ABCI diff --git a/server/commands/start.go b/server/commands/start.go index 949e57f068..8a5a56e6f2 100644 --- a/server/commands/start.go +++ b/server/commands/start.go @@ -9,8 +9,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - sdk "github.com/cosmos/cosmos-sdk" "github.com/tendermint/abci/server" + abci "github.com/tendermint/abci/types" "github.com/tendermint/tmlibs/cli" cmn "github.com/tendermint/tmlibs/common" @@ -19,6 +19,7 @@ import ( "github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk" "github.com/cosmos/cosmos-sdk/app" ) @@ -29,6 +30,15 @@ var StartCmd = &cobra.Command{ RunE: startCmd, } +// TickStartCmd - command to create a start command with tick +func TickStartCmd(tick app.Ticker) *cobra.Command { + return &cobra.Command{ + Use: "start", + Short: "Start this full node", + RunE: tickStartCmd(tick), + } +} + // nolint TODO: move to config file const EyesCacheSize = 10000 @@ -52,6 +62,26 @@ func init() { tcmd.AddNodeFlags(StartCmd) } +//returns the start command which uses the tick +func tickStartCmd(tick app.Ticker) func(cmd *cobra.Command, args []string) error { + return func(cmd *cobra.Command, args []string) error { + rootDir := viper.GetString(cli.HomeFlag) + + store, err := app.NewStore( + path.Join(rootDir, "data", "merkleeyes.db"), + EyesCacheSize, + logger.With("module", "store"), + ) + if err != nil { + return err + } + + // Create Basecoin app + basecoinApp := app.NewBasecoinTick(Handler, store, logger.With("module", "app"), tick) + return start(rootDir, store, basecoinApp) + } +} + func startCmd(cmd *cobra.Command, args []string) error { rootDir := viper.GetString(cli.HomeFlag) @@ -63,9 +93,12 @@ func startCmd(cmd *cobra.Command, args []string) error { if err != nil { return err } - // Create Basecoin app basecoinApp := app.NewBasecoin(Handler, store, logger.With("module", "app")) + return start(rootDir, store, basecoinApp) +} + +func start(rootDir string, store *app.Store, basecoinApp *app.Basecoin) error { // if chain_id has not been set yet, load the genesis. // else, assume it's been loaded @@ -93,7 +126,7 @@ func startCmd(cmd *cobra.Command, args []string) error { return startTendermint(rootDir, basecoinApp) } -func startBasecoinABCI(basecoinApp *app.Basecoin) error { +func startBasecoinABCI(basecoinApp abci.Application) error { // Start the ABCI listener addr := viper.GetString(FlagAddress) svr, err := server.NewServer(addr, "socket", basecoinApp) @@ -111,7 +144,7 @@ func startBasecoinABCI(basecoinApp *app.Basecoin) error { return nil } -func startTendermint(dir string, basecoinApp *app.Basecoin) error { +func startTendermint(dir string, basecoinApp abci.Application) error { cfg, err := tcmd.ParseConfig() if err != nil { return err From a11eb1eaa5657e382f1bc66abec657aedcb50ac7 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Thu, 5 Oct 2017 01:35:51 -0400 Subject: [PATCH 05/15] validPermission typo --- stack/context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stack/context.go b/stack/context.go index 18e76680f1..f923e89ad9 100644 --- a/stack/context.go +++ b/stack/context.go @@ -34,7 +34,7 @@ var _ sdk.Context = secureContext{} func (c secureContext) WithPermissions(perms ...sdk.Actor) sdk.Context { // the guard makes sure you only set permissions for the app you are inside for _, p := range perms { - if !c.validPermisison(p) { + if !c.validPermission(p) { err := errors.Errorf("Cannot set permission for %s/%s on (app=%s, ibc=%b)", p.ChainID, p.App, c.app, c.ibc) panic(err) @@ -48,7 +48,7 @@ func (c secureContext) WithPermissions(perms ...sdk.Actor) sdk.Context { } } -func (c secureContext) validPermisison(p sdk.Actor) bool { +func (c secureContext) validPermission(p sdk.Actor) bool { // if app is set, then it must match if c.app != "" && c.app != p.App { return false From 0e703d3f9ec0572e8283992ad37a0a69744c7c20 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Thu, 5 Oct 2017 15:09:12 -0400 Subject: [PATCH 06/15] Tick StartCmd now adds flags properly --- server/commands/start.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/commands/start.go b/server/commands/start.go index 8a5a56e6f2..1937840326 100644 --- a/server/commands/start.go +++ b/server/commands/start.go @@ -32,11 +32,13 @@ var StartCmd = &cobra.Command{ // TickStartCmd - command to create a start command with tick func TickStartCmd(tick app.Ticker) *cobra.Command { - return &cobra.Command{ + startCmd := &cobra.Command{ Use: "start", Short: "Start this full node", RunE: tickStartCmd(tick), } + addStartFlag(startCmd) + return startCmd } // nolint TODO: move to config file @@ -55,11 +57,15 @@ var ( ) func init() { - flags := StartCmd.Flags() + addStartFlag(StartCmd) +} + +func addStartFlag(startCmd *cobra.Command) { + flags := startCmd.Flags() flags.String(FlagAddress, "tcp://0.0.0.0:46658", "Listen address") flags.Bool(FlagWithoutTendermint, false, "Only run abci app, assume external tendermint process") // add all standard 'tendermint node' flags - tcmd.AddNodeFlags(StartCmd) + tcmd.AddNodeFlags(startCmd) } //returns the start command which uses the tick From c04200ceeb474c43dd7a18d1ef9f0c7500467f60 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Fri, 6 Oct 2017 15:43:15 -0400 Subject: [PATCH 07/15] start tick command choose command name --- server/commands/start.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/server/commands/start.go b/server/commands/start.go index 1937840326..da58520714 100644 --- a/server/commands/start.go +++ b/server/commands/start.go @@ -30,15 +30,10 @@ var StartCmd = &cobra.Command{ RunE: startCmd, } -// TickStartCmd - command to create a start command with tick -func TickStartCmd(tick app.Ticker) *cobra.Command { - startCmd := &cobra.Command{ - Use: "start", - Short: "Start this full node", - RunE: tickStartCmd(tick), - } - addStartFlag(startCmd) - return startCmd +// InitTickStartCmd - initialize a command as the start command with tick +func InitTickStartCmd(tick app.Ticker, cmd *cobra.Command) { + cmd.RunE = tickStartCmd(tick) + addStartFlag(cmd) } // nolint TODO: move to config file From 80ebfe9c0e60105f2e52e6597ef5343003a38fdc Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Sat, 7 Oct 2017 22:44:16 -0400 Subject: [PATCH 08/15] remove IsValidNonNegative --- modules/coin/coin.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/coin/coin.go b/modules/coin/coin.go index b4b8fc9775..168b069259 100644 --- a/modules/coin/coin.go +++ b/modules/coin/coin.go @@ -127,11 +127,6 @@ func (coins Coins) IsValid() bool { } } -// IsValidNonnegative tests is coins IsValid and IsNonnegative -func (coins Coins) IsValidNonnegative() bool { - return coins.IsValid() && coins.IsNonnegative() -} - // Plus combines to sets of coins // // TODO: handle empty coins! From 2ea45d8ec299f745fb4e78b85f750d62eaa47469 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Mon, 9 Oct 2017 01:14:16 -0400 Subject: [PATCH 09/15] mycoin -> strings --- app/app_test.go | 24 +++++++++++----------- app/genesis_test.go | 6 +++--- benchmarks/app_test.go | 10 ++++----- docs/architecture/API.md | 14 ++++++------- docs/basecoin-basics.rst | 14 ++++++------- docs/basecoin-plugins.rst | 4 ++-- docs/ibc.rst | 6 +++--- docs/roles-and-multi-sig.rst | 18 ++++++++-------- examples/basecoin/cmd/basecli/README.md | 2 +- examples/basecoin/cmd/basecoin/main.go | 4 ++-- examples/basecoin/cmd/baseserver/README.md | 6 +++--- examples/basecoin/tests/cli/basictx.sh | 14 ++++++------- examples/basecoin/tests/cli/ibc.sh | 10 ++++----- examples/basecoin/tests/cli/rest.sh | 6 +++--- examples/basecoin/tests/cli/restart.sh | 6 +++--- examples/basecoin/tests/cli/roles.sh | 8 ++++---- examples/counter/cmd/counter/main.go | 2 +- examples/counter/tests/cli/counter.sh | 14 ++++++------- modules/coin/bench_test.go | 4 ++-- modules/coin/coin_test.go | 2 +- modules/fee/commands/wrap.go | 2 +- server/commands/init.go | 4 ++-- server/commands/relay.go | 2 +- 23 files changed, 91 insertions(+), 91 deletions(-) diff --git a/app/app_test.go b/app/app_test.go index fca03e15ec..538a3b0d61 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -104,10 +104,10 @@ func (at *appTest) initAccount(acct *coin.AccountWithKey) { require.EqualValues(at.t, res, "Success") } -// reset the in and out accs to be one account each with 7mycoin +// reset the in and out accs to be one account each with 7strings func (at *appTest) reset() { - at.acctIn = coin.NewAccountWithKey(coin.Coins{{"mycoin", 7}}) - at.acctOut = coin.NewAccountWithKey(coin.Coins{{"mycoin", 7}}) + at.acctIn = coin.NewAccountWithKey(coin.Coins{{"strings", 7}}) + at.acctOut = coin.NewAccountWithKey(coin.Coins{{"strings", 7}}) // Note: switch logger if you want to get more info logger := log.TestingLogger() @@ -116,7 +116,7 @@ func (at *appTest) reset() { require.Nil(at.t, err, "%+v", err) at.app = NewBasecoin( - DefaultHandler("mycoin"), + DefaultHandler("strings"), store, logger.With("module", "app"), ) @@ -243,25 +243,25 @@ func TestTx(t *testing.T) { at := newAppTest(t) //Bad Balance - at.acctIn.Coins = coin.Coins{{"mycoin", 2}} + at.acctIn.Coins = coin.Coins{{"strings", 2}} at.initAccount(at.acctIn) at.app.Commit() - res, _, _ := at.exec(t, at.getTx(coin.Coins{{"mycoin", 5}}, 1), true) + res, _, _ := at.exec(t, at.getTx(coin.Coins{{"strings", 5}}, 1), true) assert.True(res.IsErr(), "ExecTx/Bad CheckTx: Expected error return from ExecTx, returned: %v", res) - res, diffIn, diffOut := at.exec(t, at.getTx(coin.Coins{{"mycoin", 5}}, 1), false) + res, diffIn, diffOut := at.exec(t, at.getTx(coin.Coins{{"strings", 5}}, 1), false) assert.True(res.IsErr(), "ExecTx/Bad DeliverTx: Expected error return from ExecTx, returned: %v", res) assert.True(diffIn.IsZero()) assert.True(diffOut.IsZero()) //Regular CheckTx at.reset() - res, _, _ = at.exec(t, at.getTx(coin.Coins{{"mycoin", 5}}, 1), true) + res, _, _ = at.exec(t, at.getTx(coin.Coins{{"strings", 5}}, 1), true) assert.True(res.IsOK(), "ExecTx/Good CheckTx: Expected OK return from ExecTx, Error: %v", res) //Regular DeliverTx at.reset() - amt := coin.Coins{{"mycoin", 3}} + amt := coin.Coins{{"strings", 3}} res, diffIn, diffOut = at.exec(t, at.getTx(amt, 1), false) assert.True(res.IsOK(), "ExecTx/Good DeliverTx: Expected OK return from ExecTx, Error: %v", res) assert.Equal(amt.Negative(), diffIn) @@ -269,8 +269,8 @@ func TestTx(t *testing.T) { //DeliverTx with fee.... 4 get to recipient, 1 extra taxed at.reset() - amt = coin.Coins{{"mycoin", 4}} - toll := coin.Coin{"mycoin", 1} + amt = coin.Coins{{"strings", 4}} + toll := coin.Coin{"strings", 1} res, diffIn, diffOut = at.exec(t, at.feeTx(amt, toll, 1), false) assert.True(res.IsOK(), "ExecTx/Good DeliverTx: Expected OK return from ExecTx, Error: %v", res) payment := amt.Plus(coin.Coins{toll}).Negative() @@ -283,7 +283,7 @@ func TestQuery(t *testing.T) { assert := assert.New(t) at := newAppTest(t) - res, _, _ := at.exec(t, at.getTx(coin.Coins{{"mycoin", 5}}, 1), false) + res, _, _ := at.exec(t, at.getTx(coin.Coins{{"strings", 5}}, 1), false) assert.True(res.IsOK(), "Commit, DeliverTx: Expected OK return from DeliverTx, Error: %v", res) resQueryPreCommit := at.app.Query(abci.RequestQuery{ diff --git a/app/genesis_test.go b/app/genesis_test.go index 2b76cd7f95..7b21f20b66 100644 --- a/app/genesis_test.go +++ b/app/genesis_test.go @@ -21,7 +21,7 @@ func TestLoadGenesisDoNotFailIfAppOptionsAreMissing(t *testing.T) { logger := log.TestingLogger() store, err := NewStore("", 0, logger) require.Nil(t, err, "%+v", err) - app := NewBasecoin(DefaultHandler("mycoin"), store, logger) + app := NewBasecoin(DefaultHandler("strings"), store, logger) err = app.LoadGenesis("./testdata/genesis3.json") require.Nil(t, err, "%+v", err) } @@ -33,7 +33,7 @@ func TestLoadGenesis(t *testing.T) { store, err := NewStore("", 0, logger) require.Nil(err, "%+v", err) - app := NewBasecoin(DefaultHandler("mycoin"), store, logger) + app := NewBasecoin(DefaultHandler("strings"), store, logger) err = app.LoadGenesis(genesisFilepath) require.Nil(err, "%+v", err) @@ -65,7 +65,7 @@ func TestLoadGenesisAccountAddress(t *testing.T) { store, err := NewStore("", 0, logger) require.Nil(err, "%+v", err) - app := NewBasecoin(DefaultHandler("mycoin"), store, logger) + app := NewBasecoin(DefaultHandler("strings"), store, logger) err = app.LoadGenesis(genesisAcctFilepath) require.Nil(err, "%+v", err) diff --git a/benchmarks/app_test.go b/benchmarks/app_test.go index acbf182f78..2e27e6281e 100644 --- a/benchmarks/app_test.go +++ b/benchmarks/app_test.go @@ -78,7 +78,7 @@ func NewBenchApp(h sdk.Handler, chainID string, n int, } // make keys - money := coin.Coins{{"mycoin", 1234567890}} + money := coin.Coins{{"strings", 1234567890}} accts := make([]*coin.AccountWithKey, n) for i := 0; i < n; i++ { accts[i] = coin.NewAccountWithKey(money) @@ -100,10 +100,10 @@ func (b BenchApp) makeTx(useFee bool) []byte { n := len(b.Accounts) sender := b.Accounts[cmn.RandInt()%n] recipient := b.Accounts[cmn.RandInt()%n] - amount := coin.Coins{{"mycoin", 123}} + amount := coin.Coins{{"strings", 123}} tx := coin.NewSendOneTx(sender.Actor(), recipient.Actor(), amount) if useFee { - toll := coin.Coin{"mycoin", 2} + toll := coin.Coin{"strings", 2} tx = fee.NewFee(tx, toll, sender.Actor()) } sequence := sender.NextSequence() @@ -116,7 +116,7 @@ func (b BenchApp) makeTx(useFee bool) []byte { } func BenchmarkMakeTx(b *testing.B) { - h := DefaultHandler("mycoin") + h := DefaultHandler("strings") app := NewBenchApp(h, "bench-chain", 10, false) b.ResetTimer() for i := 1; i <= b.N; i++ { @@ -192,7 +192,7 @@ func BenchmarkSimpleTransfer(b *testing.B) { prefix += "-memdb" } - h := DefaultHandler("mycoin") + h := DefaultHandler("strings") app := NewBenchApp(h, "bench-chain", bb.accounts, bb.toDisk) b.Run(prefix, func(sub *testing.B) { benchmarkTransfers(sub, app, bb.blockSize, bb.useFee) diff --git a/docs/architecture/API.md b/docs/architecture/API.md index ddabc8a8ce..ee8d36c32f 100644 --- a/docs/architecture/API.md +++ b/docs/architecture/API.md @@ -23,7 +23,7 @@ Input: { "to": {"app": "role", "addr": "62616E6B32" }, "from": {"app": "sigs", "addr": "BDADF167E6CF2CDF2D621E590FF1FED2787A40E0" }, - "amount": { "denom": "mycoin", "amount": 900000 }, + "amount": { "denom": "strings", "amount": 900000 }, "sequence": 1, "multi": true, } @@ -31,7 +31,7 @@ Input: Output (a json encoding of basecoin.Tx): -`basecli tx send --to=role:62616E6B32 --from=sigs:91C959ADE03D8973E8F2FBA9FD2EED327DCE2B0A --amount=900000mycoin --sequence=1 --multi --prepare=- --no-sign` +`basecli tx send --to=role:62616E6B32 --from=sigs:91C959ADE03D8973E8F2FBA9FD2EED327DCE2B0A --amount=900000strings --sequence=1 --multi --prepare=- --no-sign` ``` @@ -66,7 +66,7 @@ Output (a json encoding of basecoin.Tx): }, "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 900000 } ] @@ -81,7 +81,7 @@ Output (a json encoding of basecoin.Tx): }, "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 900000 } ] @@ -123,7 +123,7 @@ Input: Output: -`basecli tx send --to=role:62616E6B32 --from=sigs:91C959ADE03D8973E8F2FBA9FD2EED327DCE2B0A --amount=900000mycoin --sequence=1 --multi --no-sign --prepare=unsigned.json` +`basecli tx send --to=role:62616E6B32 --from=sigs:91C959ADE03D8973E8F2FBA9FD2EED327DCE2B0A --amount=900000strings --sequence=1 --multi --no-sign --prepare=unsigned.json` `echo 1234567890 | basecli tx --in=unsigned.json --prepare=- --name=matt` @@ -162,7 +162,7 @@ Signed tx as json, directly copy output of `/sign` Output: -`echo 1234567890 | basecli tx send --to=role:62616E6B32 --from=sigs:91C959ADE03D8973E8F2FBA9FD2EED327DCE2B0A --amount=900000mycoin --sequence=1 --multi --name=matt --prepare=signed.json` +`echo 1234567890 | basecli tx send --to=role:62616E6B32 --from=sigs:91C959ADE03D8973E8F2FBA9FD2EED327DCE2B0A --amount=900000strings --sequence=1 --multi --name=matt --prepare=signed.json` `basecli tx --in=signed.json --no-sign` @@ -193,7 +193,7 @@ Output: "data": { "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 12345 } ] diff --git a/docs/basecoin-basics.rst b/docs/basecoin-basics.rst index 099b4c4ec1..0d7d953766 100644 --- a/docs/basecoin-basics.rst +++ b/docs/basecoin-basics.rst @@ -28,7 +28,7 @@ #shelldown[6][0] #shelldown[6][1] RES=$(#shelldown[6][2] | jq '.data.coins[0].denom' | tr -d '"') - assertTrue "Line $LINENO: Expected to have mycoins, got $RES" '[[ $RES == mycoin ]]' + assertTrue "Line $LINENO: Expected to have stringss, got $RES" '[[ $RES == strings ]]' RES="$(#shelldown[6][3] 2>&1)" assertTrue "Line $LINENO: Expected to contain ERROR, got $RES" '[[ $RES == *ERROR* ]]' @@ -36,7 +36,7 @@ assertTrue "Line $LINENO: Expected 0 code deliver_tx, got $RES" '[[ $RES == 0 ]]' RES=$(#shelldown[8][-1] | jq '.data.coins[0].amount') - assertTrue "Line $LINENO: Expected to contain 1000 mycoin, got $RES" '[[ $RES == 1000 ]]' + assertTrue "Line $LINENO: Expected to contain 1000 strings, got $RES" '[[ $RES == 1000 ]]' RES=$((echo $KEYPASS) | #shelldown[9][-1] | jq '.deliver_tx.code') assertTrue "Line $LINENO: Expected 0 code deliver_tx, got $RES" '[[ $RES == 0 ]]' @@ -191,9 +191,9 @@ exist. Let's send funds from the first account to the second: :: - basecli tx send --name=cool --amount=1000mycoin --to=$YOU --sequence=1 + basecli tx send --name=cool --amount=1000strings --to=$YOU --sequence=1 -Now if we check the second account, it should have ``1000`` 'mycoin' +Now if we check the second account, it should have ``1000`` 'strings' coins! .. code:: shelldown[8] @@ -208,7 +208,7 @@ We can send some of these coins back like so: :: - basecli tx send --name=friend --amount=500mycoin --to=$ME --sequence=1 + basecli tx send --name=friend --amount=500strings --to=$ME --sequence=1 Note how we use the ``--name`` flag to select a different account to send from. @@ -219,7 +219,7 @@ If we try to send too much, we'll get an error: :: - basecli tx send --name=friend --amount=500000mycoin --to=$ME --sequence=2 + basecli tx send --name=friend --amount=500000strings --to=$ME --sequence=2 Let's send another transaction: @@ -227,7 +227,7 @@ Let's send another transaction: :: - basecli tx send --name=cool --amount=2345mycoin --to=$YOU --sequence=2 + basecli tx send --name=cool --amount=2345strings --to=$YOU --sequence=2 Note the ``hash`` value in the response - this is the hash of the transaction. We can query for the transaction by this hash: diff --git a/docs/basecoin-plugins.rst b/docs/basecoin-plugins.rst index 9f225ea396..7f0089f96f 100644 --- a/docs/basecoin-plugins.rst +++ b/docs/basecoin-plugins.rst @@ -113,7 +113,7 @@ initialize the light-client and send a transaction: countercli init --node=tcp://localhost:46657 --genesis=$HOME/.counter/genesis.json YOU=$(countercli keys get friend | awk '{print $2}') - countercli tx send --name=cool --amount=1000mycoin --to=$YOU --sequence=1 + countercli tx send --name=cool --amount=1000strings --to=$YOU --sequence=1 But the Counter has an additional command, ``countercli tx counter``, which crafts an ``AppTx`` specifically for this plugin: @@ -142,7 +142,7 @@ the counter) .. code:: shelldown[4] - countercli tx counter --name cool --countfee=2mycoin --sequence=2 --valid + countercli tx counter --name cool --countfee=2strings --sequence=2 --valid countercli query counter The Counter value should be 2, because we sent a second valid diff --git a/docs/ibc.rst b/docs/ibc.rst index f7f523ec69..ab5d981358 100644 --- a/docs/ibc.rst +++ b/docs/ibc.rst @@ -360,10 +360,10 @@ start the actual relay. RELAY_KEY=$BCHOME1_SERVER/key.json RELAY_ADDR=$(cat $RELAY_KEY | jq .address | tr -d \") - basecli1 tx send --amount=100000mycoin --sequence=1 --to=$RELAY_ADDR--name=money + basecli1 tx send --amount=100000strings --sequence=1 --to=$RELAY_ADDR--name=money basecli1 query account $RELAY_ADDR - basecli2 tx send --amount=100000mycoin --sequence=1 --to=$RELAY_ADDR --name=moremoney + basecli2 tx send --amount=100000strings --sequence=1 --to=$RELAY_ADDR --name=moremoney basecli2 query account $RELAY_ADDR Now we can start the relay process. @@ -398,7 +398,7 @@ labor... :: # Let's send some funds from test-chain-1 - basecli1 tx send --amount=12345mycoin --sequence=2 --to=test-chain-2/$BROKE --name=money + basecli1 tx send --amount=12345strings --sequence=2 --to=test-chain-2/$BROKE --name=money :: diff --git a/docs/roles-and-multi-sig.rst b/docs/roles-and-multi-sig.rst index 1681d76531..b1e8019dfd 100644 --- a/docs/roles-and-multi-sig.rst +++ b/docs/roles-and-multi-sig.rst @@ -32,7 +32,7 @@ has plenty of coins: "data": { "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 9007199254740992 } ], @@ -118,10 +118,10 @@ the second transaction being sent by rich, we need to increase :: - basecli tx send --fee=90mycoin --amount=10000mycoin --to=role:10CAFE4E --sequence=2 --name=rich + basecli tx send --fee=90strings --amount=10000strings --to=role:10CAFE4E --sequence=2 --name=rich We need to pay a transaction fee to the validators, in this case 90 -``mycoin`` to send 10000 ``mycoin`` Notice that for the ``--to`` flag, +``strings`` to send 10000 ``strings`` Notice that for the ``--to`` flag, to specify that we are sending to a role instead of an account, the ``role:`` prefix is added before the role. Because it's ``rich``'s second transaction, we've incremented the sequence. The output will be @@ -144,7 +144,7 @@ and this time you'll see the coins in the role's account: "data": { "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 10000 } ], @@ -157,7 +157,7 @@ role's account. First, it must be prepared like so: :: - basecli tx send --amount=6000mycoin --from=role:10CAFE4E --to=65D406E028319289A0706E294F3B764F44EBA3CF --sequence=1 --assume-role=10CAFE4E --name=poor --multi --prepare=tx.json + basecli tx send --amount=6000strings --from=role:10CAFE4E --to=65D406E028319289A0706E294F3B764F44EBA3CF --sequence=1 --assume-role=10CAFE4E --name=poor --multi --prepare=tx.json you'll be prompted for ``poor``'s password and there won't be any ``stdout`` to the terminal. Note that the address in the ``--to`` flag @@ -207,7 +207,7 @@ The ``tx.json`` file will look like this: }, "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 6000 } ] @@ -222,7 +222,7 @@ The ``tx.json`` file will look like this: }, "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 6000 } ] @@ -305,7 +305,7 @@ and get the result: "data": { "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 4000 } ], @@ -313,7 +313,7 @@ and get the result: } } -and see that ``poor`` now has 6000 ``mycoin``: +and see that ``poor`` now has 6000 ``strings``: :: diff --git a/examples/basecoin/cmd/basecli/README.md b/examples/basecoin/cmd/basecli/README.md index 2443c92ae5..97d6d65f4f 100644 --- a/examples/basecoin/cmd/basecli/README.md +++ b/examples/basecoin/cmd/basecli/README.md @@ -45,7 +45,7 @@ $ basecoin start ## Send the money ``` -% basecli tx send --name demo --amount 1000mycoin --sequence 1 --to $YOU +% basecli tx send --name demo --amount 1000strings --sequence 1 --to $YOU -> copy hash to HASH % basecli query tx $HASH % basecli query account $YOU diff --git a/examples/basecoin/cmd/basecoin/main.go b/examples/basecoin/cmd/basecoin/main.go index 2a96f76bd1..615db2ebf5 100644 --- a/examples/basecoin/cmd/basecoin/main.go +++ b/examples/basecoin/cmd/basecoin/main.go @@ -49,8 +49,8 @@ func BuildApp(feeDenom string) sdk.Handler { } func main() { - // require all fees in mycoin - change this in your app! - commands.Handler = BuildApp("mycoin") + // require all fees in strings - change this in your app! + commands.Handler = BuildApp("strings") RootCmd.AddCommand( commands.InitCmd, diff --git a/examples/basecoin/cmd/baseserver/README.md b/examples/basecoin/cmd/baseserver/README.md index a45e160b68..e3a6c55b53 100644 --- a/examples/basecoin/cmd/baseserver/README.md +++ b/examples/basecoin/cmd/baseserver/README.md @@ -59,7 +59,7 @@ $ curl -X POST $URL/sign --data '{ "tx": { "type": "sigs/multi", "data": { - "tx": {"type":"coin/send","data":{"inputs":[{"address":{"chain":"","app":"role","addr":"62616E6B32"},"coins":[{"denom":"mycoin","amount":900000}]}],"outputs":[{"address":{"chain":"","app":"sigs","addr":"BDADF167E6CF2CDF2D621E590FF1FED2787A40E0"},"coins":[{"denom":"mycoin","amount":900000}]}]}}, + "tx": {"type":"coin/send","data":{"inputs":[{"address":{"chain":"","app":"role","addr":"62616E6B32"},"coins":[{"denom":"strings","amount":900000}]}],"outputs":[{"address":{"chain":"","app":"sigs","addr":"BDADF167E6CF2CDF2D621E590FF1FED2787A40E0"},"coins":[{"denom":"strings","amount":900000}]}]}}, "signatures": null } } @@ -82,7 +82,7 @@ $ curl -X POST $URL/sign --data '{ }, "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 900000 } ] @@ -97,7 +97,7 @@ $ curl -X POST $URL/sign --data '{ }, "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 900000 } ] diff --git a/examples/basecoin/tests/cli/basictx.sh b/examples/basecoin/tests/cli/basictx.sh index 2ae46fce17..25e3c96470 100755 --- a/examples/basecoin/tests/cli/basictx.sh +++ b/examples/basecoin/tests/cli/basictx.sh @@ -33,9 +33,9 @@ test01SendTx() { SENDER=$(getAddr $RICH) RECV=$(getAddr $POOR) - assertFalse "line=${LINENO}, missing dest" "${CLIENT_EXE} tx send --amount=992mycoin --sequence=1" - assertFalse "line=${LINENO}, bad password" "echo foo | ${CLIENT_EXE} tx send --amount=992mycoin --sequence=1 --to=$RECV --name=$RICH" - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=992mycoin --sequence=1 --to=$RECV --name=$RICH) + assertFalse "line=${LINENO}, missing dest" "${CLIENT_EXE} tx send --amount=992strings --sequence=1" + assertFalse "line=${LINENO}, bad password" "echo foo | ${CLIENT_EXE} tx send --amount=992strings --sequence=1 --to=$RECV --name=$RICH" + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=992strings --sequence=1 --to=$RECV --name=$RICH) txSucceeded $? "$TX" "$RECV" HASH=$(echo $TX | jq .hash | tr -d \") TX_HEIGHT=$(echo $TX | jq .height) @@ -54,7 +54,7 @@ test02SendTxWithFee() { RECV=$(getAddr $POOR) # Test to see if the auto-sequencing works, the sequence here should be calculated to be 2 - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=90mycoin --fee=10mycoin --to=$RECV --name=$RICH) + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=90strings --fee=10strings --to=$RECV --name=$RICH) txSucceeded $? "$TX" "$RECV" HASH=$(echo $TX | jq .hash | tr -d \") TX_HEIGHT=$(echo $TX | jq .height) @@ -67,7 +67,7 @@ test02SendTxWithFee() { checkSendFeeTx $HASH $TX_HEIGHT $SENDER "90" "10" # assert replay protection - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=90mycoin --fee=10mycoin --sequence=2 --to=$RECV --name=$RICH 2>/dev/null) + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=90strings --fee=10strings --sequence=2 --to=$RECV --name=$RICH 2>/dev/null) assertFalse "line=${LINENO}, replay: $TX" $? # checking normally @@ -102,8 +102,8 @@ test03CreditTx() { RECV=$(getAddr $POOR) # make sure we are controlled by permissions (only rich can issue credit) - assertFalse "line=${LINENO}, bad password" "echo qwertyuiop | ${CLIENT_EXE} tx credit --amount=1000mycoin --sequence=1 --to=$RECV --name=$POOR" - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx credit --amount=1000mycoin --sequence=3 --to=$RECV --name=$RICH) + assertFalse "line=${LINENO}, bad password" "echo qwertyuiop | ${CLIENT_EXE} tx credit --amount=1000strings --sequence=1 --to=$RECV --name=$POOR" + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx credit --amount=1000strings --sequence=3 --to=$RECV --name=$RICH) txSucceeded $? "$TX" "$RECV" HASH=$(echo $TX | jq .hash | tr -d \") TX_HEIGHT=$(echo $TX | jq .height) diff --git a/examples/basecoin/tests/cli/ibc.sh b/examples/basecoin/tests/cli/ibc.sh index 45ab13b273..3e3fc654b3 100755 --- a/examples/basecoin/tests/cli/ibc.sh +++ b/examples/basecoin/tests/cli/ibc.sh @@ -174,7 +174,7 @@ test04SendIBCPacket() { SENDER=$(getAddr $RICH) RECV=$(BC_HOME=${CLIENT_2} getAddr $POOR) - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=20002mycoin \ + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=20002strings \ --to=${CHAIN_ID_2}::${RECV} --name=$RICH) txSucceeded $? "$TX" "${CHAIN_ID_2}::${RECV}" # quit early if there is no point in more tests @@ -209,7 +209,7 @@ test05ReceiveIBCPacket() { export BC_HOME=${CLIENT_2} # make some credit, so we can accept the packet - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx credit --amount=60006mycoin --to=$CHAIN_ID_1:: --name=$RICH) + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx credit --amount=60006strings --to=$CHAIN_ID_1:: --name=$RICH) txSucceeded $? "$TX" "${CHAIN_ID_1}::" checkAccount $CHAIN_ID_1:: "60006" @@ -269,7 +269,7 @@ assertNewHeight() { # RECV=$(BC_HOME=${CLIENT_2} getAddr $POOR) # export BC_HOME=${CLIENT_1} -# TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=20002mycoin \ +# TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=20002strings \ # --sequence=1 --to=${CHAIN_ID_2}/${RECV} --name=$RICH) # txSucceeded $? "$TX" "${CHAIN_ID_2}/${RECV}" # # an example to quit early if there is no point in more tests @@ -318,7 +318,7 @@ assertNewHeight() { # # Get paid on chain1 # export BC_HOME=${CLIENT_1} # SENDER=$(getAddr $RICH) -# RES=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=100000mycoin \ +# RES=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=100000strings \ # --sequence=$1 --to=$RELAY_ADDR --name=$RICH) # txSucceeded $? "$RES" "$RELAY_ADDR" # if [ $? != 0 ]; then echo "can't pay chain1!"; return 1; fi @@ -326,7 +326,7 @@ assertNewHeight() { # # Get paid on chain2 # export BC_HOME=${CLIENT_2} # SENDER=$(getAddr $RICH) -# RES=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=100000mycoin \ +# RES=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=100000strings \ # --sequence=$2 --to=$RELAY_ADDR --name=$RICH) # txSucceeded $? "$RES" "$RELAY_ADDR" # if [ $? != 0 ]; then echo "can't pay chain2!"; return 1; fi diff --git a/examples/basecoin/tests/cli/rest.sh b/examples/basecoin/tests/cli/rest.sh index 2d2c86de6a..7019ff369c 100755 --- a/examples/basecoin/tests/cli/rest.sh +++ b/examples/basecoin/tests/cli/rest.sh @@ -62,7 +62,7 @@ test01SendTx() { SENDER=$(restAddr $RICH) RECV=$(restAddr $POOR) - CMD="{\"from\": {\"app\": \"sigs\", \"addr\": \"$SENDER\"}, \"to\": {\"app\": \"sigs\", \"addr\": \"$RECV\"}, \"amount\": [{\"denom\": \"mycoin\", \"amount\": 992}], \"sequence\": 1}" + CMD="{\"from\": {\"app\": \"sigs\", \"addr\": \"$SENDER\"}, \"to\": {\"app\": \"sigs\", \"addr\": \"$RECV\"}, \"amount\": [{\"denom\": \"strings\", \"amount\": 992}], \"sequence\": 1}" UNSIGNED=$(curl -XPOST ${URL}/build/send -d "$CMD" 2>/dev/null) if [ -n "$DEBUG" ]; then echo $UNSIGNED; echo; fi @@ -120,7 +120,7 @@ test04CreateRoleInvalid() { # RECV=$(getAddr $POOR) # # Test to see if the auto-sequencing works, the sequence here should be calculated to be 2 -# TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=90mycoin --fee=10mycoin --to=$RECV --name=$RICH) +# TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=90strings --fee=10strings --to=$RECV --name=$RICH) # txSucceeded $? "$TX" "$RECV" # HASH=$(echo $TX | jq .hash | tr -d \") # TX_HEIGHT=$(echo $TX | jq .height) @@ -133,7 +133,7 @@ test04CreateRoleInvalid() { # checkSendFeeTx $HASH $TX_HEIGHT $SENDER "90" "10" # # assert replay protection -# TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=90mycoin --fee=10mycoin --sequence=2 --to=$RECV --name=$RICH 2>/dev/null) +# TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=90strings --fee=10strings --sequence=2 --to=$RECV --name=$RICH 2>/dev/null) # assertFalse "line=${LINENO}, replay: $TX" $? # checkAccount $SENDER "9007199254739900" # checkAccount $RECV "1082" diff --git a/examples/basecoin/tests/cli/restart.sh b/examples/basecoin/tests/cli/restart.sh index c091b32e7f..ab491dd979 100755 --- a/examples/basecoin/tests/cli/restart.sh +++ b/examples/basecoin/tests/cli/restart.sh @@ -21,7 +21,7 @@ test00PreRestart() { SENDER=$(getAddr $RICH) RECV=$(getAddr $POOR) - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=992mycoin --sequence=1 --to=$RECV --name=$RICH) + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=992strings --sequence=1 --to=$RECV --name=$RICH) txSucceeded $? "$TX" "$RECV" HASH=$(echo $TX | jq .hash | tr -d \") TX_HEIGHT=$(echo $TX | jq .height) @@ -38,7 +38,7 @@ test01OnRestart() { SENDER=$(getAddr $RICH) RECV=$(getAddr $POOR) - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=10000mycoin --sequence=2 --to=$RECV --name=$RICH) + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=10000strings --sequence=2 --to=$RECV --name=$RICH) txSucceeded $? "$TX" "$RECV" if [ $? != 0 ]; then echo "can't make tx!"; return 1; fi @@ -52,7 +52,7 @@ test01OnRestart() { echo "done waiting!" # last minute tx just at the block cut-off... - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=20000mycoin --sequence=3 --to=$RECV --name=$RICH) + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=20000strings --sequence=3 --to=$RECV --name=$RICH) txSucceeded $? "$TX" "$RECV" if [ $? != 0 ]; then echo "can't make second tx!"; return 1; fi diff --git a/examples/basecoin/tests/cli/roles.sh b/examples/basecoin/tests/cli/roles.sh index 1dece90ec9..b145d3dc91 100755 --- a/examples/basecoin/tests/cli/roles.sh +++ b/examples/basecoin/tests/cli/roles.sh @@ -45,7 +45,7 @@ test02SendTxToRole() { SENDER=$(getAddr $RICH) RECV=role:${ROLE} - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --fee=90mycoin --amount=10000mycoin --to=$RECV --sequence=2 --name=$RICH) + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --fee=90strings --amount=10000strings --to=$RECV --sequence=2 --name=$RICH) txSucceeded $? "$TX" "${ROLE}" HASH=$(echo $TX | jq .hash | tr -d \") TX_HEIGHT=$(echo $TX | jq .height) @@ -67,14 +67,14 @@ test03SendMultiFromRole() { assertFalse "line=${LINENO}, has no money yet" "${CLIENT_EXE} query account $TWO 2>/dev/null" # let's try to send money from the role directly without multisig - FAIL=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=6000mycoin --from=$BANK --to=$TWO --sequence=1 --name=$POOR 2>/dev/null) + FAIL=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=6000strings --from=$BANK --to=$TWO --sequence=1 --name=$POOR 2>/dev/null) assertFalse "need to assume role" $? - FAIL=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=6000mycoin --from=$BANK --to=$TWO --sequence=2 --assume-role=${ROLE} --name=$POOR 2>/dev/null) + FAIL=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=6000strings --from=$BANK --to=$TWO --sequence=2 --assume-role=${ROLE} --name=$POOR 2>/dev/null) assertFalse "need two signatures" $? # okay, begin a multisig transaction mr. poor... TX_FILE=$BASE_DIR/tx.json - echo qwertyuiop | ${CLIENT_EXE} tx send --amount=6000mycoin --from=$BANK --to=$TWO --sequence=1 --assume-role=${ROLE} --name=$POOR --multi --prepare=$TX_FILE + echo qwertyuiop | ${CLIENT_EXE} tx send --amount=6000strings --from=$BANK --to=$TWO --sequence=1 --assume-role=${ROLE} --name=$POOR --multi --prepare=$TX_FILE assertTrue "line=${LINENO}, successfully prepare tx" $? # and get some dude to sign it # FAIL=$(echo qwertyuiop | ${CLIENT_EXE} tx --in=$TX_FILE --name=$POOR 2>/dev/null) diff --git a/examples/counter/cmd/counter/main.go b/examples/counter/cmd/counter/main.go index b747e3be0d..ae6e39fbec 100644 --- a/examples/counter/cmd/counter/main.go +++ b/examples/counter/cmd/counter/main.go @@ -21,7 +21,7 @@ var RootCmd = &cobra.Command{ func main() { // TODO: register the counter here - commands.Handler = counter.NewHandler("mycoin") + commands.Handler = counter.NewHandler("strings") RootCmd.AddCommand( commands.InitCmd, diff --git a/examples/counter/tests/cli/counter.sh b/examples/counter/tests/cli/counter.sh index 53eebbe12f..0ef153d2c7 100755 --- a/examples/counter/tests/cli/counter.sh +++ b/examples/counter/tests/cli/counter.sh @@ -34,9 +34,9 @@ test01SendTx() { RECV=$(getAddr $POOR) # sequence should work well for first time also - assertFalse "Line=${LINENO}, missing dest" "${CLIENT_EXE} tx send --amount=992mycoin 2>/dev/null" - assertFalse "Line=${LINENO}, bad password" "echo foo | ${CLIENT_EXE} tx send --amount=992mycoin --to=$RECV --name=$RICH 2>/dev/null" - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=992mycoin --to=$RECV --name=$RICH) + assertFalse "Line=${LINENO}, missing dest" "${CLIENT_EXE} tx send --amount=992strings 2>/dev/null" + assertFalse "Line=${LINENO}, bad password" "echo foo | ${CLIENT_EXE} tx send --amount=992strings --to=$RECV --name=$RICH 2>/dev/null" + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=992strings --to=$RECV --name=$RICH) txSucceeded $? "$TX" "$RECV" HASH=$(echo $TX | jq .hash | tr -d \") TX_HEIGHT=$(echo $TX | jq .height) @@ -66,9 +66,9 @@ checkCounter() { test03AddCount() { SENDER=$(getAddr $RICH) - assertFalse "Line=${LINENO}, bad password" "echo hi | ${CLIENT_EXE} tx counter --countfee=100mycoin --sequence=2 --name=${RICH} 2>/dev/null" + assertFalse "Line=${LINENO}, bad password" "echo hi | ${CLIENT_EXE} tx counter --countfee=100strings --sequence=2 --name=${RICH} 2>/dev/null" - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx counter --countfee=10mycoin --sequence=2 --name=${RICH} --valid) + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx counter --countfee=10strings --sequence=2 --name=${RICH} --valid) txSucceeded $? "$TX" "counter" HASH=$(echo $TX | jq .hash | tr -d \") TX_HEIGHT=$(echo $TX | jq .height) @@ -94,7 +94,7 @@ test03AddCount() { fi # test again with fees... - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx counter --countfee=7mycoin --fee=4mycoin --sequence=3 --name=${RICH} --valid) + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx counter --countfee=7strings --fee=4strings --sequence=3 --name=${RICH} --valid) txSucceeded $? "$TX" "counter" # make sure the counter was updated, added 7 @@ -104,7 +104,7 @@ test03AddCount() { checkAccount $SENDER "9007199254739979" # make sure we cannot replay the counter, no state change - TX=$(echo qwertyuiop | ${CLIENT_EXE} tx counter --countfee=10mycoin --sequence=2 --name=${RICH} --valid 2>/dev/null) + TX=$(echo qwertyuiop | ${CLIENT_EXE} tx counter --countfee=10strings --sequence=2 --name=${RICH} --valid 2>/dev/null) assertFalse "line=${LINENO}, replay: $TX" $? checkCounter "2" "17" checkAccount $SENDER "9007199254739979" diff --git a/modules/coin/bench_test.go b/modules/coin/bench_test.go index 4fc5b8e8fd..19c0ccf6ee 100644 --- a/modules/coin/bench_test.go +++ b/modules/coin/bench_test.go @@ -27,7 +27,7 @@ func BenchmarkSimpleTransfer(b *testing.B) { logger := log.NewNopLogger() // set the initial account - acct := NewAccountWithKey(Coins{{"mycoin", 1234567890}}) + acct := NewAccountWithKey(Coins{{"strings", 1234567890}}) h.InitState(logger, store, NameCoin, "account", acct.MakeOption(), nil) sender := acct.Actor() receiver := sdk.Actor{App: "foo", Address: cmn.RandBytes(20)} @@ -35,7 +35,7 @@ func BenchmarkSimpleTransfer(b *testing.B) { // now, loop... for i := 1; i <= b.N; i++ { ctx := stack.MockContext("foo", 100).WithPermissions(sender) - tx := makeSimpleTx(sender, receiver, Coins{{"mycoin", 2}}) + tx := makeSimpleTx(sender, receiver, Coins{{"strings", 2}}) _, err := h.DeliverTx(ctx, store, tx, nil) // never should error if err != nil { diff --git a/modules/coin/coin_test.go b/modules/coin/coin_test.go index 0cb2b4f21b..7d2d48e1ea 100644 --- a/modules/coin/coin_test.go +++ b/modules/coin/coin_test.go @@ -69,7 +69,7 @@ func TestParse(t *testing.T) { {"98 bar , 1 foo ", true, Coins{{"bar", 98}, {"foo", 1}}}, {" 55\t \t bling\n", true, Coins{{"bling", 55}}}, {"2foo, 97 bar", true, Coins{{"bar", 97}, {"foo", 2}}}, - {"5 mycoin,", false, nil}, // no empty coins in a list + {"5 strings,", false, nil}, // no empty coins in a list {"2 3foo, 97 bar", false, nil}, // 3foo is invalid coin name {"11me coin, 12you coin", false, nil}, // no spaces in coin names {"1.2btc", false, nil}, // amount must be integer diff --git a/modules/fee/commands/wrap.go b/modules/fee/commands/wrap.go index 50ac91eb2a..b60f106352 100644 --- a/modules/fee/commands/wrap.go +++ b/modules/fee/commands/wrap.go @@ -46,7 +46,7 @@ func (FeeWrapper) Wrap(tx sdk.Tx) (res sdk.Tx, err error) { // Register adds the sequence flags to the cli func (FeeWrapper) Register(fs *pflag.FlagSet) { - fs.String(FlagFee, "0mycoin", "Coins for the transaction fee of the format ") + fs.String(FlagFee, "0strings", "Coins for the transaction fee of the format ") fs.String(FlagPayer, "", "Account to pay fee if not current signer (for multisig)") } diff --git a/server/commands/init.go b/server/commands/init.go index f913798d39..f5c089eb29 100644 --- a/server/commands/init.go +++ b/server/commands/init.go @@ -139,7 +139,7 @@ var PrivValJSON = `{ }` // GetGenesisJSON returns a new tendermint genesis with Basecoin app_options -// that grant a large amount of "mycoin" to a single address +// that grant a large amount of "strings" to a single address // TODO: A better UX for generating genesis files func GetGenesisJSON(chainID, addr string, options string) string { return fmt.Sprintf(`{ @@ -161,7 +161,7 @@ func GetGenesisJSON(chainID, addr string, options string) string { "address": "%s", "coins": [ { - "denom": "mycoin", + "denom": "strings", "amount": 9007199254740992 } ] diff --git a/server/commands/relay.go b/server/commands/relay.go index 9f9b714014..d2692b9667 100644 --- a/server/commands/relay.go +++ b/server/commands/relay.go @@ -253,7 +253,7 @@ package commands // ibc.IBCTx `json:"unwrap"` // }{ibcTx})) -// smallCoins := coin.Coin{"mycoin", 1} +// smallCoins := coin.Coin{"strings", 1} // input := types.NewTxInput(r.privKey.PubKey, coin.Coins{smallCoins}, sequence) // tx := &types.AppTx{ From 1cbb4094b173f00e2b4bff015888e0ca716d76af Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Mon, 9 Oct 2017 05:18:40 -0400 Subject: [PATCH 10/15] simplify tick start command --- server/commands/start.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/commands/start.go b/server/commands/start.go index da58520714..3804d13e48 100644 --- a/server/commands/start.go +++ b/server/commands/start.go @@ -31,9 +31,15 @@ var StartCmd = &cobra.Command{ } // InitTickStartCmd - initialize a command as the start command with tick -func InitTickStartCmd(tick app.Ticker, cmd *cobra.Command) { - cmd.RunE = tickStartCmd(tick) - addStartFlag(cmd) +func InitTickStartCmd(tick app.Ticker) *cobra.Command { + startCmd := &cobra.Command{ + Use: "start", + Short: "Start this full node", + RunE: startCmd, + } + startCmd.RunE = tickStartCmd(tick) + addStartFlag(startCmd) + return startCmd } // nolint TODO: move to config file From 5a7566a81a31f570981a951f26082f7e705191df Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Tue, 10 Oct 2017 01:50:10 -0400 Subject: [PATCH 11/15] init creates random priv_validator --- examples/eyes/cmd/eyes/init.go | 20 ++++++++++++++- server/commands/init.go | 45 ++++++++++++++-------------------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/examples/eyes/cmd/eyes/init.go b/examples/eyes/cmd/eyes/init.go index 0fbe5f51ca..c4c36cf3db 100644 --- a/examples/eyes/cmd/eyes/init.go +++ b/examples/eyes/cmd/eyes/init.go @@ -35,9 +35,27 @@ func initCmd(cmd *cobra.Command, args []string) error { } genesis := getGenesisJSON(viper.GetString(commands.FlagChainID)) - return commands.CreateGenesisValidatorFiles(cfg, genesis, cmd.Root().Name()) + return commands.CreateGenesisValidatorFiles(cfg, genesis, PrivValJSON, cmd.Root().Name()) } +// PrivValJSON - validator private key file contents in json +var PrivValJSON = `{ + "address": "7A956FADD20D3A5B2375042B2959F8AB172A058F", + "last_height": 0, + "last_round": 0, + "last_signature": null, + "last_signbytes": "", + "last_step": 0, + "priv_key": { + "type": "ed25519", + "data": "D07ABE82A8B15559A983B2DB5D4842B2B6E4D6AF58B080005662F424F17D68C17B90EA87E7DC0C7145C8C48C08992BE271C7234134343E8A8E8008E617DE7B30" + }, + "pub_key": { + "type": "ed25519", + "data": "7B90EA87E7DC0C7145C8C48C08992BE271C7234134343E8A8E8008E617DE7B30" + } +}` + // TODO: better, auto-generate validator... func getGenesisJSON(chainID string) string { return fmt.Sprintf(`{ diff --git a/server/commands/init.go b/server/commands/init.go index f5c089eb29..bfdc94430e 100644 --- a/server/commands/init.go +++ b/server/commands/init.go @@ -2,6 +2,7 @@ package commands import ( "encoding/hex" + "encoding/json" "fmt" "io/ioutil" "os" @@ -13,6 +14,7 @@ import ( tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" "github.com/tendermint/tendermint/config" + "github.com/tendermint/tendermint/types" cmn "github.com/tendermint/tmlibs/common" ) @@ -91,21 +93,30 @@ func initCmd(cmd *cobra.Command, args []string) error { optionsStr = sep + strings.Join(options[:], sep) } - genesis := GetGenesisJSON(viper.GetString(FlagChainID), userAddr, optionsStr) - return CreateGenesisValidatorFiles(cfg, genesis, cmd.Root().Name()) + privVal := types.GenPrivValidatorFS("") + privValHex := strings.ToUpper(hex.EncodeToString(privVal.PubKey.Bytes()[1:])) + genesis := GetGenesisJSON(privValHex, viper.GetString(FlagChainID), + userAddr, optionsStr) + + pvBytes, err := json.Marshal(privVal) + if err != nil { + return err + } + + return CreateGenesisValidatorFiles(cfg, genesis, string(pvBytes), cmd.Root().Name()) } // CreateGenesisValidatorFiles creates a genesis file with these // contents and a private validator file -func CreateGenesisValidatorFiles(cfg *config.Config, genesis, appName string) error { - genesisFile := cfg.GenesisFile() +func CreateGenesisValidatorFiles(cfg *config.Config, genesis, privVal, appName string) error { privValFile := cfg.PrivValidatorFile() + genesisFile := cfg.GenesisFile() mod1, err := setupFile(genesisFile, genesis, 0644) if err != nil { return err } - mod2, err := setupFile(privValFile, PrivValJSON, 0400) + mod2, err := setupFile(privValFile, privVal, 0400) if err != nil { return err } @@ -120,28 +131,10 @@ func CreateGenesisValidatorFiles(cfg *config.Config, genesis, appName string) er return nil } -// PrivValJSON - validator private key file contents in json -var PrivValJSON = `{ - "address": "7A956FADD20D3A5B2375042B2959F8AB172A058F", - "last_height": 0, - "last_round": 0, - "last_signature": null, - "last_signbytes": "", - "last_step": 0, - "priv_key": { - "type": "ed25519", - "data": "D07ABE82A8B15559A983B2DB5D4842B2B6E4D6AF58B080005662F424F17D68C17B90EA87E7DC0C7145C8C48C08992BE271C7234134343E8A8E8008E617DE7B30" - }, - "pub_key": { - "type": "ed25519", - "data": "7B90EA87E7DC0C7145C8C48C08992BE271C7234134343E8A8E8008E617DE7B30" - } -}` - // GetGenesisJSON returns a new tendermint genesis with Basecoin app_options // that grant a large amount of "strings" to a single address // TODO: A better UX for generating genesis files -func GetGenesisJSON(chainID, addr string, options string) string { +func GetGenesisJSON(pubkey, chainID, addr string, options string) string { return fmt.Sprintf(`{ "app_hash": "", "chain_id": "%s", @@ -152,7 +145,7 @@ func GetGenesisJSON(chainID, addr string, options string) string { "name": "", "pub_key": { "type": "ed25519", - "data": "7B90EA87E7DC0C7145C8C48C08992BE271C7234134343E8A8E8008E617DE7B30" + "data": "%s" } } ], @@ -170,5 +163,5 @@ func GetGenesisJSON(chainID, addr string, options string) string { "coin/issuer", {"app": "sigs", "addr": "%s"}%s ] } -}`, chainID, addr, addr, options) +}`, chainID, pubkey, addr, addr, options) } From d3b4d4245817fdb0d320846962af82daf4624356 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Tue, 10 Oct 2017 03:13:02 -0400 Subject: [PATCH 12/15] integrated init --static, fix tests --- examples/eyes/cmd/eyes/init.go | 20 +-------------- server/commands/init.go | 46 ++++++++++++++++++++++++++++------ tests/cli/common.sh | 2 +- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/examples/eyes/cmd/eyes/init.go b/examples/eyes/cmd/eyes/init.go index c4c36cf3db..29e682193b 100644 --- a/examples/eyes/cmd/eyes/init.go +++ b/examples/eyes/cmd/eyes/init.go @@ -35,27 +35,9 @@ func initCmd(cmd *cobra.Command, args []string) error { } genesis := getGenesisJSON(viper.GetString(commands.FlagChainID)) - return commands.CreateGenesisValidatorFiles(cfg, genesis, PrivValJSON, cmd.Root().Name()) + return commands.CreateGenesisValidatorFiles(cfg, genesis, commands.StaticPrivValJSON, cmd.Root().Name()) } -// PrivValJSON - validator private key file contents in json -var PrivValJSON = `{ - "address": "7A956FADD20D3A5B2375042B2959F8AB172A058F", - "last_height": 0, - "last_round": 0, - "last_signature": null, - "last_signbytes": "", - "last_step": 0, - "priv_key": { - "type": "ed25519", - "data": "D07ABE82A8B15559A983B2DB5D4842B2B6E4D6AF58B080005662F424F17D68C17B90EA87E7DC0C7145C8C48C08992BE271C7234134343E8A8E8008E617DE7B30" - }, - "pub_key": { - "type": "ed25519", - "data": "7B90EA87E7DC0C7145C8C48C08992BE271C7234134343E8A8E8008E617DE7B30" - } -}` - // TODO: better, auto-generate validator... func getGenesisJSON(chainID string) string { return fmt.Sprintf(`{ diff --git a/server/commands/init.go b/server/commands/init.go index bfdc94430e..5f28406f24 100644 --- a/server/commands/init.go +++ b/server/commands/init.go @@ -29,11 +29,13 @@ var InitCmd = &cobra.Command{ var ( FlagChainID = "chain-id" //TODO group with other flags or remove? is this already a flag here? FlagOption = "option" + FlagStatic = "static" ) func init() { InitCmd.Flags().String(FlagChainID, "test_chain_id", "Chain ID") InitCmd.Flags().StringSliceP(FlagOption, "p", []string{}, "Genesis option in the format /