Skip to content

Commit

Permalink
fix(hotfix): v0.17.2 (#1448)
Browse files Browse the repository at this point in the history
* feat(templates/cmd): upgrade spm to add 'config' cmd (#1417)

* feat(templates/cmd): upgrade spm to add 'config' cmd

to appd.

* also make $HOME/config/client.toml configurable through 'init.client'
section of chain's Starport config.yml.

* default to test

* fix

* fix

* updated changelog

* fix config application order

* fix

Co-authored-by: Denis Fadeev <[email protected]>

* fix(services/chain): detecting keyring (#1449)

* fix(services/chain): detecting keyring

when client.toml > keyring-backend used.

* fix

* fix

* default to test kb

* fix

* fix(services/chain): default home dir for app (#1457)

* fix(services/chain): support 0.43.x based chains (#1455)

* Apply suggestions from code review

* Apply suggestions from code review

* feat(pkg/chaincmd/runner): support YAML encoded CLI response (#1468)

* feat(pkg/chaincmd/runner): support YAML encoded CLI response

* Apply suggestions from code review

* fix

* fix

* fix

* fix

Co-authored-by: Denis Fadeev <[email protected]>
  • Loading branch information
ilgooz and fadeev authored Aug 17, 2021
1 parent b071eed commit d534217
Show file tree
Hide file tree
Showing 16 changed files with 296 additions and 179 deletions.
18 changes: 17 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# Changelog

## v0.17
## `v0.17.2`

### Features

- `client.toml` is initialized and used by node's CLI, can be configured through `config.yml` with the `init.client` property
- Support serving Cosmos SDK `v0.43.x` based chains.

## `v0.17.1`

### Fixes:

- Set visibility to `public` on Gitpod's port 7575 to enable peer discovery for SPN
- Fixed GitHub action that releases blockchain node's binary
- Fixed an error in chain scaffolding due to "unknown revision"
- Fixed an error in `starport chain serve` by limiting the scope where proto files are searched for

## `v0.17`

### Features:

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ require (
github.com/docker/docker v20.10.7+incompatible
github.com/emicklei/proto v1.9.0
github.com/fatih/color v1.10.0
github.com/ghodss/yaml v1.0.0
github.com/go-git/go-git/v5 v5.1.0
github.com/gobuffalo/genny v0.6.0
github.com/gobuffalo/logger v1.0.3
github.com/gobuffalo/packd v1.0.0
github.com/gobuffalo/plush v3.8.3+incompatible
github.com/gobuffalo/plushgen v0.1.2
github.com/goccy/go-yaml v1.8.0
github.com/goccy/go-yaml v1.9.2
github.com/google/go-github/v37 v37.0.0
github.com/gookit/color v1.2.7
github.com/gorilla/mux v1.8.0
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXt
github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/gertd/go-pluralize v0.1.7/go.mod h1:O4eNeeIf91MHh1GJ2I47DNtaesm66NYvjYgAahcqSDQ=
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
Expand Down Expand Up @@ -491,10 +492,13 @@ github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL9
github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
Expand Down Expand Up @@ -532,8 +536,9 @@ github.com/gobuffalo/uuid v2.0.5+incompatible h1:c5uWRuEnYggYCrT9AJm0U2v1QTG7OVD
github.com/gobuffalo/uuid v2.0.5+incompatible/go.mod h1:ErhIzkRhm0FtRuiE/PeORqcw4cVi1RtSpnwYrxuvkfE=
github.com/gobuffalo/validate v2.0.3+incompatible h1:6f4JCEz11Zi6iIlexMv7Jz10RBPvgI795AOaubtCwTE=
github.com/gobuffalo/validate v2.0.3+incompatible/go.mod h1:N+EtDe0J8252BgfzQUChBgfd6L93m9weay53EWFVsMM=
github.com/goccy/go-yaml v1.8.0 h1:WCe9sBiI0oZb6EC6f3kq3dv0+aEiNdstT7b4xxq4MJQ=
github.com/goccy/go-yaml v1.8.0/go.mod h1:wS4gNoLalDSJxo/SpngzPQ2BN4uuZVLCmbM4S3vd4+Y=
github.com/goccy/go-yaml v1.9.2 h1:2Njwzw+0+pjU2gb805ZC1B/uBuAs2VcZ3K+ZgHwDs7w=
github.com/goccy/go-yaml v1.9.2/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
Expand Down Expand Up @@ -1713,7 +1718,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v9 v9.30.0 h1:Wk0Z37oBmKj9/n+tPyBHZmeL19LaCoK3Qq48VwYENss=
gopkg.in/go-playground/validator.v9 v9.30.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
Expand Down
182 changes: 94 additions & 88 deletions integration/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,100 +47,106 @@ func TestGetTxViaGRPCGateway(t *testing.T) {
// 1- list accounts
// 2- send tokens from one to other.
// 3- verify tx by using gRPC Gateway API.
steps := step.NewSteps(step.New(
step.Exec(
appname+"d",
"keys",
"list",
"--keyring-backend", "test",
"--output", "json",
steps := step.NewSteps(
step.New(
step.Exec(
appname+"d",
"config",
"output", "json",
),
step.PreExec(func() error {
return env.IsAppServed(ctx, host)
}),
),
step.PreExec(func() error {
output.Reset()
return env.IsAppServed(ctx, host)
}),
step.PostExec(func(execErr error) error {
if execErr != nil {
return execErr
}

addresses := []string{}

// collect addresses of alice and bob.
accounts := []struct {
Name string `json:"name"`
Address string `json:"address"`
}{}
if err := json.NewDecoder(output).Decode(&accounts); err != nil {
return err
}
for _, account := range accounts {
if account.Name == "alice" || account.Name == "bob" {
addresses = append(addresses, account.Address)
step.New(
step.Exec(
appname+"d",
"keys",
"list",
"--keyring-backend", "test",
),
step.PostExec(func(execErr error) error {
if execErr != nil {
return execErr
}
}
if len(addresses) != 2 {
return errors.New("expected alice and bob accounts to be created")
}

// send some tokens from alice to bob and confirm the corresponding tx via gRPC gateway
// endpoint by asserting denom and amount.
return cmdrunner.New().Run(ctx, step.New(
step.Exec(
appname+"d",
"tx",
"bank",
"send",
addresses[0],
addresses[1],
"10token",
"--keyring-backend", "test",
"--chain-id", appname,
"--node", xurl.TCP(host.RPC),
"--yes",
),
step.PreExec(func() error {
output.Reset()
return nil
}),
step.PostExec(func(execErr error) error {
if execErr != nil {
return execErr
}

tx := struct {
Hash string `json:"txHash"`
}{}
if err := json.NewDecoder(output).Decode(&tx); err != nil {
return err
}

addr := fmt.Sprintf("%s/cosmos/tx/v1beta1/txs/%s", xurl.HTTP(host.API), tx.Hash)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, addr, nil)
if err != nil {
return errors.Wrap(err, "call to get tx via gRPC gateway")
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
addresses := []string{}

// Send error if the request failed
if resp.StatusCode != http.StatusOK {
return errors.New(resp.Status)
// collect addresses of alice and bob.
accounts := []struct {
Name string `json:"name"`
Address string `json:"address"`
}{}
if err := json.NewDecoder(output).Decode(&accounts); err != nil {
return err
}
for _, account := range accounts {
if account.Name == "alice" || account.Name == "bob" {
addresses = append(addresses, account.Address)
}
}
if len(addresses) != 2 {
return errors.New("expected alice and bob accounts to be created")
}

if err := json.NewDecoder(resp.Body).Decode(&txBody); err != nil {
return err
}
return nil
}),
step.Stdout(output),
))
}),
step.Stdout(output),
))
// send some tokens from alice to bob and confirm the corresponding tx via gRPC gateway
// endpoint by asserting denom and amount.
return cmdrunner.New().Run(ctx, step.New(
step.Exec(
appname+"d",
"tx",
"bank",
"send",
addresses[0],
addresses[1],
"10token",
"--keyring-backend", "test",
"--chain-id", appname,
"--node", xurl.TCP(host.RPC),
"--yes",
),
step.PreExec(func() error {
output.Reset()
return nil
}),
step.PostExec(func(execErr error) error {
if execErr != nil {
return execErr
}

tx := struct {
Hash string `json:"txHash"`
}{}
if err := json.NewDecoder(output).Decode(&tx); err != nil {
return err
}

addr := fmt.Sprintf("%s/cosmos/tx/v1beta1/txs/%s", xurl.HTTP(host.API), tx.Hash)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, addr, nil)
if err != nil {
return errors.Wrap(err, "call to get tx via gRPC gateway")
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()

// Send error if the request failed
if resp.StatusCode != http.StatusOK {
return errors.New(resp.Status)
}

if err := json.NewDecoder(resp.Body).Decode(&txBody); err != nil {
return err
}
return nil
}),
step.Stdout(output),
))
}),
step.Stdout(output),
))

go func() {
defer cancel()
Expand Down
3 changes: 3 additions & 0 deletions starport/chainconf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ type Init struct {
// App overwrites appd's config/app.toml configs.
App map[string]interface{} `yaml:"app"`

// Client overwrites appd's config/client.toml configs.
Client map[string]interface{} `yaml:"client"`

// Config overwrites appd's config/config.toml configs.
Config map[string]interface{} `yaml:"config"`

Expand Down
2 changes: 0 additions & 2 deletions starport/cmd/chain_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package starportcmd

import (
"github.com/spf13/cobra"
"github.com/tendermint/starport/starport/pkg/chaincmd"
"github.com/tendermint/starport/starport/services/chain"
)

Expand Down Expand Up @@ -40,7 +39,6 @@ func chainServeHandler(cmd *cobra.Command, args []string) error {

chainOption := []chain.Option{
chain.LogLevel(logLevel(cmd)),
chain.KeyringBackend(chaincmd.KeyringBackendTest),
}

if isRebuildProtoOnce {
Expand Down
19 changes: 15 additions & 4 deletions starport/pkg/chaincmd/runner/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,22 @@ var (
// returns with an error if the operation went unsuccessful or an account with the provided name
// already exists.
func (r Runner) AddAccount(ctx context.Context, name, mnemonic string) (Account, error) {
b := &bytes.Buffer{}
b := newBuffer()

// check if account already exists.
var accounts []Account
if err := r.run(ctx, runOptions{stdout: b}, r.chainCmd.ListKeysCommand()); err != nil {
return Account{}, err
}
if err := json.NewDecoder(b).Decode(&accounts); err != nil {

data, err := b.JSONEnsuredBytes()
if err != nil {
return Account{}, err
}
if err := json.Unmarshal(data, &accounts); err != nil {
return Account{}, err
}

for _, account := range accounts {
if account.Name == name {
return Account{}, ErrAccountAlreadyExists
Expand Down Expand Up @@ -67,12 +73,17 @@ func (r Runner) AddAccount(ctx context.Context, name, mnemonic string) (Account,
} else {
if err := r.run(ctx, runOptions{
stdout: b,
stderr: os.Stderr,
stderr: b,
stdin: os.Stdin,
}, r.chainCmd.AddKeyCommand(name)); err != nil {
return Account{}, err
}
if err := json.NewDecoder(b).Decode(&account); err != nil {

data, err := b.JSONEnsuredBytes()
if err != nil {
return Account{}, err
}
if err := json.Unmarshal(data, &account); err != nil {
return Account{}, err
}

Expand Down
Loading

0 comments on commit d534217

Please sign in to comment.