Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate API Server #6426

Merged
merged 23 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
client/lcd/swagger-ui/* linguist-vendored
client/docs/swagger-ui/* linguist-vendored
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Client Breaking

* (api) [\#6426](https://github.com/cosmos/cosmos-sdk/pull/6426) The ability to start an out-of-process API REST server has now been removed. Instead, the API server is now started in-process along with the application and Tendermint. Configuration options have been added to `app.toml` to enable/disable the API server along with additional HTTP server options.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* (api) [\#6426](https://github.com/cosmos/cosmos-sdk/pull/6426) The ability to start an out-of-process API REST server has now been removed. Instead, the API server is now started in-process along with the application and Tendermint. Configuration options have been added to `app.toml` to enable/disable the API server along with additional HTTP server options.
* (api) [\#6426](https://github.com/cosmos/cosmos-sdk/pull/6426) The ability to start an out-of-process API REST server has now been removed. Instead, the API server is now started in-process along with the application and Tendermint. Configuration options, i.e legacy flags, have been migrated to `app.toml` to enable/disable the API server along with additional HTTP server options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legacy flags? What legacy flags?

* (baseapp) [\#6384](https://github.com/cosmos/cosmos-sdk/pull/6384) The `Result.Data` is now a Protocol Buffer encoded binary blob of type `TxData`. The `TxData` contains `Data` which contains a list of Protocol Buffer encoded message data and the corresponding message type.
* (x/gov) [#6295](https://github.com/cosmos/cosmos-sdk/pull/6295) Fix typo in querying governance params.
* (x/auth) [\#6054](https://github.com/cosmos/cosmos-sdk/pull/6054) Remove custom JSON marshaling for base accounts as multsigs cannot be bech32 decoded.
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ lint:
.PHONY: lint

format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs goimports -w -local github.com/cosmos/cosmos-sdk
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs goimports -w -local github.com/cosmos/cosmos-sdk
.PHONY: format

###############################################################################
Expand Down
18 changes: 14 additions & 4 deletions client/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// Context implements a typical context created in SDK modules for
// transaction handling and queries.
// Context implements a typical context created in SDK modules for transaction
// handling and queries.
type Context struct {
FromAddress sdk.AccAddress
Client rpcclient.Client
Expand All @@ -34,10 +34,8 @@ type Context struct {
OutputFormat string
Height int64
HomeDir string
NodeURI string
From string
BroadcastMode string
Verifier tmlite.Verifier
FromName string
TrustNode bool
UseLedger bool
Expand All @@ -49,6 +47,12 @@ type Context struct {
TxGenerator TxGenerator
AccountRetriever AccountRetriever

// TODO: API and CLI interfaces are migrating to a single binary (i.e be part of
// the same process of the application). We need to groom through these fields
// and remove any that no longer make sense.
NodeURI string
Verifier tmlite.Verifier

// TODO: Deprecated (remove).
Codec *codec.Codec
}
Expand Down Expand Up @@ -267,6 +271,12 @@ func (ctx Context) WithChainID(chainID string) Context {
return ctx
}

// WithHomeDir returns a copy of the Context with HomeDir set.
func (ctx Context) WithHomeDir(dir string) Context {
ctx.HomeDir = dir
return ctx
}

// WithGenerateOnly returns a copy of the context with updated GenerateOnly value
func (ctx Context) WithGenerateOnly(generateOnly bool) Context {
ctx.GenerateOnly = generateOnly
Expand Down
2 changes: 1 addition & 1 deletion client/lcd/statik/init.go → client/docs/statik/init.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package statik

//This just for fixing the error in importing empty github.com/cosmos/cosmos-sdk/client/lcd/statik
//This just for fixing the error in importing empty github.com/cosmos/cosmos-sdk/client/docs/statik
File renamed without changes.
File renamed without changes.
File renamed without changes.
69 changes: 25 additions & 44 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,31 @@ const (

// List of CLI flags
const (
FlagHome = tmcli.HomeFlag
FlagUseLedger = "ledger"
FlagChainID = "chain-id"
FlagNode = "node"
FlagHeight = "height"
FlagGasAdjustment = "gas-adjustment"
FlagTrustNode = "trust-node"
FlagFrom = "from"
FlagName = "name"
FlagAccountNumber = "account-number"
FlagSequence = "sequence"
FlagMemo = "memo"
FlagFees = "fees"
FlagGasPrices = "gas-prices"
FlagBroadcastMode = "broadcast-mode"
FlagDryRun = "dry-run"
FlagGenerateOnly = "generate-only"
FlagOffline = "offline"
FlagIndentResponse = "indent"
FlagListenAddr = "laddr"
FlagMaxOpenConnections = "max-open"
FlagRPCReadTimeout = "read-timeout"
FlagRPCWriteTimeout = "write-timeout"
FlagRPCMaxBodyBytes = "max-body-bytes"
FlagOutputDocument = "output-document" // inspired by wget -O
FlagSkipConfirmation = "yes"
FlagProve = "prove"
FlagKeyringBackend = "keyring-backend"
FlagPage = "page"
FlagLimit = "limit"
FlagUnsafeCORS = "unsafe-cors"
FlagHome = tmcli.HomeFlag
FlagUseLedger = "ledger"
FlagChainID = "chain-id"
FlagNode = "node"
FlagHeight = "height"
FlagGasAdjustment = "gas-adjustment"
FlagTrustNode = "trust-node"
FlagFrom = "from"
FlagName = "name"
FlagAccountNumber = "account-number"
FlagSequence = "sequence"
FlagMemo = "memo"
FlagFees = "fees"
FlagGasPrices = "gas-prices"
FlagBroadcastMode = "broadcast-mode"
FlagDryRun = "dry-run"
FlagGenerateOnly = "generate-only"
FlagOffline = "offline"
FlagIndentResponse = "indent"
FlagOutputDocument = "output-document" // inspired by wget -O
FlagSkipConfirmation = "yes"
FlagProve = "prove"
FlagKeyringBackend = "keyring-backend"
FlagPage = "page"
FlagLimit = "limit"
)

// LineBreak can be included in a command list to provide a blank line
Expand Down Expand Up @@ -141,19 +135,6 @@ func PostCommands(cmds ...*cobra.Command) []*cobra.Command {
return cmds
}

// RegisterRestServerFlags registers the flags required for rest server
func RegisterRestServerFlags(cmd *cobra.Command) *cobra.Command {
cmd = GetCommands(cmd)[0]
cmd.Flags().String(FlagListenAddr, "tcp://localhost:1317", "The address for the server to listen on")
cmd.Flags().Uint(FlagMaxOpenConnections, 1000, "The number of maximum open connections")
cmd.Flags().Uint(FlagRPCReadTimeout, 10, "The RPC read timeout (in seconds)")
cmd.Flags().Uint(FlagRPCWriteTimeout, 10, "The RPC write timeout (in seconds)")
cmd.Flags().Uint(FlagRPCMaxBodyBytes, 1000000, "The RPC max body bytes")
cmd.Flags().Bool(FlagUnsafeCORS, false, "Allows CORS requests from all domains. For development purposes only, use it at your own risk.")

return cmd
}

// Gas flag parsing functions

// GasSetting encapsulates the possible values passed through the --gas flag.
Expand Down
128 changes: 0 additions & 128 deletions client/lcd/root.go

This file was deleted.

4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
image: "cosmos-sdk/simappnode"
ports:
- "26656-26657:26656-26657"
- "1317:1317"
environment:
- ID=0
- LOG=${LOG:-simd.log}
Expand All @@ -20,6 +21,7 @@ services:
image: "cosmos-sdk/simappnode"
ports:
- "26659-26660:26656-26657"
- "1318:1317"
environment:
- ID=1
- LOG=${LOG:-simd.log}
Expand All @@ -37,6 +39,7 @@ services:
- LOG=${LOG:-simd.log}
ports:
- "26661-26662:26656-26657"
- "1319:1317"
volumes:
- ./build:/simd:Z
networks:
Expand All @@ -51,6 +54,7 @@ services:
- LOG=${LOG:-simd.log}
ports:
- "26663-26664:26656-26657"
- "1320:1317"
volumes:
- ./build:/simd:Z
networks:
Expand Down
2 changes: 1 addition & 1 deletion networks/local/simappnode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN apt-get update && \

VOLUME [ /simd ]
WORKDIR /simd
EXPOSE 26656 26657
EXPOSE 26656 26657 1317
ENTRYPOINT ["/usr/bin/wrapper.sh"]
CMD ["start"]
STOPSIGNAL SIGTERM
Expand Down
Loading