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

docs: Update "Basics" section #7416

Merged
merged 26 commits into from
Oct 12, 2020
Merged

docs: Update "Basics" section #7416

merged 26 commits into from
Oct 12, 2020

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Sep 30, 2020

Description

ref: #6953

rendered

Main changes:

  • Be clear on Amino vs Protobuf in MakeCodecs
  • Replace legacy KeyBase with new Keyring
  • Update code snippets to latest version, and use simapp instead of gaia
  • appcli -> appd

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@codecov
Copy link

codecov bot commented Sep 30, 2020

Codecov Report

Merging #7416 into master will not change coverage.
The diff coverage is 80.00%.

@@           Coverage Diff           @@
##           master    #7416   +/-   ##
=======================================
  Coverage   56.01%   56.01%           
=======================================
  Files         592      592           
  Lines       37244    37244           
=======================================
  Hits        20864    20864           
  Misses      14262    14262           
  Partials     2118     2118           

Copy link
Contributor Author

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

my main concern for merging this right now is that we reference gaia's code as an example, but it hasn't been updated to use protobuf yet.

I can add a note in #6953 to update these snippets once gaia is ready.

`lazyKeybase` is simple wrapper around `dbKeybase` which locks the database only when operations are to be performed and unlocks it immediately after. With the `lazyKeybase`, it is possible for the [command-line interface](../interfaces/cli.md) to create a new account while the [rest server](../interfaces/rest.md) is running. It is also possible to pipe multiple CLI commands.
- `Sign(uid string, msg []byte) ([]byte, tmcrypto.PubKey, error)` strictly deals with the signature of the `message` bytes. Some preliminary work should be done beforehand to prepare and encode the `message` into a canonical `[]byte` form. See an example of `message` preparation from the `x/bank` module. Note that signature verification is not implemented in the SDK by default. It is deferred to the [`anteHandler`](#antehandler).
+++ https://github.com/cosmos/cosmos-sdk/blob/d9175200920e96bfa4182b5c8bc46d91b17a28a1/x/bank/types/msgs.go#L51-L54
- `NewAccount(uid, mnemonic, bip39Passwd, hdPath string, algo SignatureAlgo) (Info, error)` creates a new account based on the [`bip44 path`](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) and persists it on disk (note that the `PrivKey` is [encrypted with a passphrase before being persisted](https://github.com/cosmos/cosmos-sdk/blob/d9175200920e96bfa4182b5c8bc46d91b17a28a1/crypto/keys/mintkey/mintkey.go), it is **never stored unencrypted**). In the context of this method, the `account` and `address` parameters refer to the segment of the BIP44 derivation path (e.g. `0`, `1`, `2`, ...) used to derive the `PrivKey` and `PubKey` from the mnemonic (note that given the same mnemonic and `account`, the same `PrivKey` will be generated, and given the same `account` and `address`, the same `PubKey` and `Address` will be generated). Finally, note that the `NewAccount` method derives keys and addresses using `secp256k1` as implemented in the [SDK's `crypto/keys/secp256k1` package](https://github.com/cosmos/cosmos-sdk/blob/d9175200920e96bfa4182b5c8bc46d91b17a28a1/crypto/keys/secp256k1/secp256k1.go). As a result, it only works for creating account keys and addresses, not consensus keys. See [`Addresses`](#addresses) for more.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that we switched to use 99designs/keyring, does anyone know if this section is still relevant?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it makes sense, adding a note on how to export private keys would be valuable imho, i.e key -> armored privkey -> raw priv key

docs/basics/accounts.md Show resolved Hide resolved
docs/basics/app-anatomy.md Outdated Show resolved Hide resolved
docs/basics/app-anatomy.md Outdated Show resolved Hide resolved
@amaury1093 amaury1093 marked this pull request as ready for review September 30, 2020 11:41
@amaury1093 amaury1093 marked this pull request as draft September 30, 2020 16:10
@amaury1093 amaury1093 marked this pull request as ready for review October 1, 2020 11:26
@amaury1093 amaury1093 added A:automerge Automatically merge PR once all prerequisites pass. T:Docs Changes and features related to documentation. labels Oct 2, 2020
Copy link
Contributor

@blushi blushi left a comment

Choose a reason for hiding this comment

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

Pre-approving, just some small nits/questions.
Also not sure re: #7416 (comment)

docs/basics/accounts.md Outdated Show resolved Hide resolved
docs/basics/app-anatomy.md Show resolved Hide resolved
docs/basics/app-anatomy.md Outdated Show resolved Hide resolved
docs/basics/accounts.md Outdated Show resolved Hide resolved
`lazyKeybase` is simple wrapper around `dbKeybase` which locks the database only when operations are to be performed and unlocks it immediately after. With the `lazyKeybase`, it is possible for the [command-line interface](../interfaces/cli.md) to create a new account while the [rest server](../interfaces/rest.md) is running. It is also possible to pipe multiple CLI commands.
- `Sign(uid string, msg []byte) ([]byte, tmcrypto.PubKey, error)` strictly deals with the signature of the `message` bytes. Some preliminary work should be done beforehand to prepare and encode the `message` into a canonical `[]byte` form. See an example of `message` preparation from the `x/bank` module. Note that signature verification is not implemented in the SDK by default. It is deferred to the [`anteHandler`](#antehandler).
+++ https://github.com/cosmos/cosmos-sdk/blob/d9175200920e96bfa4182b5c8bc46d91b17a28a1/x/bank/types/msgs.go#L51-L54
- `NewAccount(uid, mnemonic, bip39Passwd, hdPath string, algo SignatureAlgo) (Info, error)` creates a new account based on the [`bip44 path`](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) and persists it on disk (note that the `PrivKey` is [encrypted with a passphrase before being persisted](https://github.com/cosmos/cosmos-sdk/blob/d9175200920e96bfa4182b5c8bc46d91b17a28a1/crypto/keys/mintkey/mintkey.go), it is **never stored unencrypted**). In the context of this method, the `account` and `address` parameters refer to the segment of the BIP44 derivation path (e.g. `0`, `1`, `2`, ...) used to derive the `PrivKey` and `PubKey` from the mnemonic (note that given the same mnemonic and `account`, the same `PrivKey` will be generated, and given the same `account` and `address`, the same `PubKey` and `Address` will be generated). Finally, note that the `NewAccount` method derives keys and addresses using `secp256k1` as implemented in the [SDK's `crypto/keys/secp256k1` package](https://github.com/cosmos/cosmos-sdk/blob/d9175200920e96bfa4182b5c8bc46d91b17a28a1/crypto/keys/secp256k1/secp256k1.go). As a result, it only works for creating account keys and addresses, not consensus keys. See [`Addresses`](#addresses) for more.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it makes sense, adding a note on how to export private keys would be valuable imho, i.e key -> armored privkey -> raw priv key

docs/basics/accounts.md Outdated Show resolved Hide resolved
docs/basics/accounts.md Outdated Show resolved Hide resolved
docs/basics/app-anatomy.md Outdated Show resolved Hide resolved
docs/basics/app-anatomy.md Outdated Show resolved Hide resolved
docs/basics/app-anatomy.md Show resolved Hide resolved
docs/basics/app-anatomy.md Outdated Show resolved Hide resolved
docs/basics/app-anatomy.md Outdated Show resolved Hide resolved
docs/basics/tx-lifecycle.md Show resolved Hide resolved
@amaury1093
Copy link
Contributor Author

Thanks @fedekunze, your review was very helpful. I believe I addressed all your comments.

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

docs/basics/accounts.md Outdated Show resolved Hide resolved
@mergify mergify bot merged commit 647ad0d into master Oct 12, 2020
@mergify mergify bot deleted the am-6953-basic branch October 12, 2020 15:31
clevinson pushed a commit that referenced this pull request Oct 19, 2020
* Prettier

* docs: Update "Basics" section

* appcli -> appd

* Better wording

* Fix to appCodec

* Add gRPC mention

* Add grpc

* Reference simapp code

* Update docs/basics/accounts.md

Co-authored-by: Marie Gauthier <[email protected]>

* Add section about gRPC query services

* Optional LegacyQuerierHandler

* Clearer docs

* Update docs/basics/app-anatomy.md

Co-authored-by: Marie Gauthier <[email protected]>

* Update docs/basics/app-anatomy.md

Co-authored-by: Federico Kunze <[email protected]>

* Address comments

* Address comments

* Update docs/basics/accounts.md

Co-authored-by: Marie Gauthier <[email protected]>
Co-authored-by: Federico Kunze <[email protected]>
@clevinson clevinson mentioned this pull request Oct 19, 2020
31 tasks
clevinson added a commit that referenced this pull request Oct 19, 2020
* Update Encoding Doc for 0.40 (#7430)

* Remove deprecated docs and add first guidelines to protobuf migration

* Add conventions

* Reorder and add more FAQ doc

* Update guidelines for pb msg definitions

* Use commit hash in github links

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* docs: Update "Basics" section (#7416)

* Prettier

* docs: Update "Basics" section

* appcli -> appd

* Better wording

* Fix to appCodec

* Add gRPC mention

* Add grpc

* Reference simapp code

* Update docs/basics/accounts.md

Co-authored-by: Marie Gauthier <[email protected]>

* Add section about gRPC query services

* Optional LegacyQuerierHandler

* Clearer docs

* Update docs/basics/app-anatomy.md

Co-authored-by: Marie Gauthier <[email protected]>

* Update docs/basics/app-anatomy.md

Co-authored-by: Federico Kunze <[email protected]>

* Address comments

* Address comments

* Update docs/basics/accounts.md

Co-authored-by: Marie Gauthier <[email protected]>
Co-authored-by: Federico Kunze <[email protected]>

* Fix misbehaviour handling for solo machine (#7515)

* add timestamp to SignatureAndData

Add timestamp field to signature and data. Add ValidateBasic check for timestamp. Add ValidateBasic test. Update misbehaviour handler to use supplied timestamp.

* fix typo

* add timestamp check

* fix lint

Co-authored-by: Federico Kunze <[email protected]>

* update solo machine specs (#7512)

* update solo machine specs

* update concepts

* self review fixes

* Apply suggestions from code review

* add note on upgarding solo machines

Co-authored-by: Federico Kunze <[email protected]>

* Corrected 'unsafe-reset-all' help text (#7504)

* Merge PR #7415: Return empty store tree on non-existing version

* tendermint: update sdk to rc5 (#7527)

* update sdk to rc5

* Update baseapp/params.go

Co-authored-by: Aleksandr Bezobchuk <[email protected]>

* Bump github.com/spf13/cobra from 1.0.0 to 1.1.0 (#7553)

Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Changelog](https://github.com/spf13/cobra/blob/master/CHANGELOG.md)
- [Commits](spf13/cobra@v1.0.0...v1.1.0)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* remove test_utils.go in tm client (#7522)

* remove test_utils from tm client

* fix build

* fix lint?

* fix lint?

* apply @fedekunze review suggestion

* add tests as per @alessio suggestion

* fix typo

* ibc: cleanup channel types test (#7521)

* Update Building Modules documentation (#7473)

* Update module-manager.md

* Update modules #messages doc

* Fix typo

* Update message implementation example link

* Update messages-and-queries.md#queries doc

* Update querier.md

* Update handler.md

* Update links in beginblock-endblock.md

* Update keeper.md

* Update invariants.md

* Update genesis.md

* Update module-interfaces.md#transaction-commands

* Update module-interfaces.md#query-commands

* Update module-interfaces.md#flags

* Update module-interfaces.md#rest

* Update structure.md

* Update module-interfaces.md#grpc

* Update errors.md

* Update module-interfaces.md#grpc-gateway-rest

* Add more info on swagger

* Address comments

* Fix go.sum

* Fix app-anatomy.md

* Update docs/building-modules/module-interfaces.md

Co-authored-by: Federico Kunze <[email protected]>

* Update docs/building-modules/querier.md

Co-authored-by: Federico Kunze <[email protected]>

* Update docs/building-modules/querier.md

Co-authored-by: Federico Kunze <[email protected]>

* Update docs/building-modules/module-interfaces.md

Co-authored-by: Federico Kunze <[email protected]>

* Update docs/building-modules/module-interfaces.md

Co-authored-by: Federico Kunze <[email protected]>

* Address part of review comments

* Update old ref of RegisterQueryService

* Add example code for Manager

* Update queriers.md to query-services.md and refs

* Add new query-services.md

* Revert "Update old ref of RegisterQueryService"

This reverts commit 1ea1ea8.

* Update keeper.md

* Update handler.md

* Update handler.md

* Update messages-and-queries.md

* Update docs/basics/app-anatomy.md

Co-authored-by: Amaury Martiny <[email protected]>

* Update docs/building-modules/intro.md

Co-authored-by: Amaury Martiny <[email protected]>

* Fix typo

Co-authored-by: Federico Kunze <[email protected]>
Co-authored-by: Amaury Martiny <[email protected]>

* client: add GetAccount and GetAccountWithHeight to AccountRetriever (#7558)

* client: add GetAccount and GetAccountWithHeight to AccountRetriever

* update ADR

* address comments from review

* Add the option of emitting amino encoded json from the CLI (#7221)

* Add the option of emitting amino encoded json

* Update AMINO JSON serialization with ConvertTxToStdTx

* Make the Amino flag more self documenting by serializing the BroadcastRequest type instead of StdTx

* Handle amino encoding error

* Update x/auth/client/cli/tx_multisign.go

Co-authored-by: Alessio Treglia <[email protected]>

* Update x/auth/client/cli/tx_sign.go

Co-authored-by: Alessio Treglia <[email protected]>

* Apply suggestions from code review

Co-authored-by: Alessio Treglia <[email protected]>

* Fix go format

Co-authored-by: Federico Kunze <[email protected]>
Co-authored-by: Alessio Treglia <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* ibc: update solo machine client command (#7579)

Co-authored-by: Federico Kunze <[email protected]>

* docs: Revert SPEC-SPEC and update x/{auth,bank,evidence,slashing} (#7407)

* Revert some changes from #7404

* Update x/slashing

* Address review comments

* Small tweak

Co-authored-by: Federico Kunze <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* remove id in localhost (#7577)

Co-authored-by: Federico Kunze <[email protected]>
Co-authored-by: Christopher Goes <[email protected]>

* update changelog

* Update CHANGELOG.md

Co-authored-by: Aleksandr Bezobchuk <[email protected]>

* Fix solomachine cmds (#7581)

* fix solo machine cli cmds

* polish

Co-authored-by: Federico Kunze <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* simapp: use tmjson on InitChainer (#7514)

Co-authored-by: Alessio Treglia <[email protected]>

* [IAVL]: Bump to v0.15.0-rc4 (#7549)

* iavl 0.15.0-rc4 version bump

* update comments on error modes for store.LoadStore

* update CONFIO_URL in makefile

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Handle nil *Any in UnpackAny and add panic handler for tx decoding (#7594)

* Handle nil any in UnpackAny

* Add test

* Add flag back

* Update runTx signature

* Update Simulate signature

* Update calls to Simulate

* Add txEncoder in baseapp

* Fix TestTxWithoutPublicKey

* Wrap errors

* Use amino in baseapp tests

* Add txEncoder arg to Check & Deliver

* Fix gas in test

* Fix remaining base app tests

* Rename to amionTxEncoder

* Update codec/types/interface_registry.go

Co-authored-by: Aaron Craelius <[email protected]>

* golangci-lint fix

Co-authored-by: Amaury Martiny <[email protected]>
Co-authored-by: Aaron Craelius <[email protected]>
Co-authored-by: Cory Levinson <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

Co-authored-by: Marie Gauthier <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Amaury Martiny <[email protected]>
Co-authored-by: Federico Kunze <[email protected]>
Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Neeraj Murarka <[email protected]>
Co-authored-by: Riccardo Montagnin <[email protected]>
Co-authored-by: Marko <[email protected]>
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Zaki Manian <[email protected]>
Co-authored-by: Alessio Treglia <[email protected]>
Co-authored-by: Christopher Goes <[email protected]>
Co-authored-by: Aaron Craelius <[email protected]>
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
* Prettier

* docs: Update "Basics" section

* appcli -> appd

* Better wording

* Fix to appCodec

* Add gRPC mention

* Add grpc

* Reference simapp code

* Update docs/basics/accounts.md

Co-authored-by: Marie Gauthier <[email protected]>

* Add section about gRPC query services

* Optional LegacyQuerierHandler

* Clearer docs

* Update docs/basics/app-anatomy.md

Co-authored-by: Marie Gauthier <[email protected]>

* Update docs/basics/app-anatomy.md

Co-authored-by: Federico Kunze <[email protected]>

* Address comments

* Address comments

* Update docs/basics/accounts.md

Co-authored-by: Marie Gauthier <[email protected]>
Co-authored-by: Federico Kunze <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. T:Docs Changes and features related to documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants