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

R4R - Finish new docs v1 #5186

Merged
merged 11 commits into from
Oct 23, 2019
Merged

R4R - Finish new docs v1 #5186

merged 11 commits into from
Oct 23, 2019

Conversation

gamarin2
Copy link
Contributor

This PR contains the last core docs we need for "new docs v1"

  • 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.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md

  • Re-reviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@gamarin2 gamarin2 added the T:Docs Changes and features related to documentation. label Oct 11, 2019
@gamarin2 gamarin2 changed the title Finish docs v1 R4R - Finish new docs v1 Oct 11, 2019
@codecov
Copy link

codecov bot commented Oct 11, 2019

Codecov Report

Merging #5186 into master-docs will decrease coverage by 0.01%.
The diff coverage is n/a.

@@               Coverage Diff               @@
##           master-docs    #5186      +/-   ##
===============================================
- Coverage        54.85%   54.83%   -0.02%     
===============================================
  Files              305      305              
  Lines            18494    18494              
===============================================
- Hits             10144    10142       -2     
- Misses            7595     7597       +2     
  Partials           755      755

@fedekunze fedekunze added the R4R label Oct 11, 2019
}
```

The default implementation of `Keybase` of the Cosmos SDK is [`dbKeybase`](https://github.com/cosmos/cosmos-sdk/blob/master/crypto/keys/keybase.go). A few notes on the `Keybase` methods as implemented in `dbKeybase`:
Copy link
Member

Choose a reason for hiding this comment

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

if the doc is moved in the future will it break these links?

Copy link
Contributor Author

@gamarin2 gamarin2 Oct 14, 2019

Choose a reason for hiding this comment

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

well yes. We could use tags but the downside is that the link could become outdated instead of broken... Not sure one is better than the other (at least if it breaks we notice it)

Copy link
Member

Choose a reason for hiding this comment

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

but how will it affect releaes, i thought we will have versioned docs and this would break on some versions and not on others, and backporting shouldn't be something we do for docs, maybe a script on docs build for releases that changes master to a commit is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes that might be a good solution, would that be possible @fadeev?

Copy link
Contributor

@fadeev fadeev Oct 14, 2019

Choose a reason for hiding this comment

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

If the goal is to substitute master with something else when necessary, we specify a variable in config.js and interpolate it into the URL {{version}}.

Copy link
Collaborator

Choose a reason for hiding this comment

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

we should totally use permalinks here

Copy link
Collaborator

Choose a reason for hiding this comment

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

If the goal is to substitute master with something else when necessary, we specify a variable in config.js and interpolate it into the URL {{version}}.

this will only work for SDK links. Everything else should use a permalink

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we have permalinks for tendermint stuff, do we? @marbar3778

Copy link
Member

@tac0turtle tac0turtle Oct 16, 2019

Choose a reason for hiding this comment

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

Copy link
Member

@tac0turtle tac0turtle Oct 16, 2019

Choose a reason for hiding this comment

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

I don't think we need to worry about the repo disappearing case, there are bigger issues if that happens 🤣


`Addresses` and `PubKey`s are both public information that identify actors in the application. There are 3 main types of `Addresses`/`PubKeys` available by default in the Cosmos SDK:

- Addresses and Keys for **accounts**, which identify users (e.g. the sender of a `message`). They are derived using the **`secp256k1`** curve.
Copy link
Member

Choose a reason for hiding this comment

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

i believe with #5006 this isnt entirely true any more, you could use other keys, right @AdityaSripal ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

antedecorator will have a separate docs PR afaik. This pr should be based on this branch @AdityaSripal

## Events

`Event`s are implemented in the Cosmos SDK as an alias of the [ABCI `event` type](https://github.com/tendermint/tendermint/blob/master/abci/types/types.pb.go#L2661-L2667). They contain:
Copy link
Member

@tac0turtle tac0turtle Oct 12, 2019

Choose a reason for hiding this comment

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

we shouldnt use master branch here, these will be moving soon, can we use a commit/tag instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fadeev can we do the same thing with TM (i.e. variable interpolation via config.js)

A `Keybase` is an object that stores and manages accounts. In the Cosmos SDK, a `Keybase` implementation follows the [`Keybase` interface](https://github.com/cosmos/cosmos-sdk/blob/master/crypto/keys/types.go#L14-L60):

```go
type Keybase interface {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@alessio will this change with the keyring PR?

See an [example of `ExportGenesis` from the nameservice tutorial](https://github.com/cosmos/sdk-application-tutorial/blob/master/x/nameservice/genesis.go#L46-L57).
Copy link
Collaborator

Choose a reason for hiding this comment

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

use permalink

keeper.cdc.MustUnmarshalBinaryBare(bz, &object)
```

Copy link
Collaborator

Choose a reason for hiding this comment

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

typo uvarint


```go
tmNode, err := node.NewNode(
cfg,
Copy link
Collaborator

Choose a reason for hiding this comment

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

padding is off

```go
if err := tmNode.Start(); err != nil {
return nil, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

padding is off

- First, a [`codec`](./encoding.md) is instanciated for the application.
- Then, the [`config`](https://github.com/cosmos/cosmos-sdk/blob/master/types/config.go) is retrieved and config parameters are set. This mainly involves setting the bech32 prefixes for [addresses and pubkeys](../basics/accounts-fees-gas.md#addresses-and-pubkeys).
- Using [cobra](https://github.com/spf13/cobra), the root command of the full-node client is created. After that, all the custom commands of the application are added using the `AddCommand()` method of `rootCmd`.
- Add default server commands to `rootCmd` using the `server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators)` method. These commands are separated from the ones added above since they are standard and defined at SDK level. They should be shared by all SDK-based application. They include the most important command: the [`start` command](#start-command).
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
- Add default server commands to `rootCmd` using the `server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators)` method. These commands are separated from the ones added above since they are standard and defined at SDK level. They should be shared by all SDK-based application. They include the most important command: the [`start` command](#start-command).
- Add default server commands to `rootCmd` using the `server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators)` method. These commands are separated from the ones added above since they are standard and defined at SDK level. They should be shared by all SDK-based applications. They include the most important command: the [`start` command](#start-command).


## Introduction to SDK Stores

The Cosmos SDK comes with a large set of stores to persist the state of applications. By default, the main store of SDK applications is a multistore, i.e. a store of stores. Developers can add any number of key-value stores to the multistore, depending on their application needs. The multistore exists to support the modularity of the Cosmos SDK, as it lets each module declare and manage their own subset of the state. Key-value stores in the multistore can be accessed with a specific `key`, which is typically held in the [`keeper`](../building-modules/keeper.md) of the module that declared the store.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should mention that a StoreKey is really a capability key to access the store

Each Cosmos SDK application holds a multistore at its root to persist its state. The multistore is a store of `KVStores` that follows the `Multistore` interface:

```go
type MultiStore interface { //nolint
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
type MultiStore interface { //nolint
type MultiStore interface {

}
```

The default implementation of `Keybase` of the Cosmos SDK is [`dbKeybase`](https://github.com/cosmos/cosmos-sdk/blob/master/crypto/keys/keybase.go). A few notes on the `Keybase` methods as implemented in `dbKeybase`:
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the goal is to substitute master with something else when necessary, we specify a variable in config.js and interpolate it into the URL {{version}}.

this will only work for SDK links. Everything else should use a permalink

appd start
```

As a reminder, the full-node is composed of three conceptual layers: the networking layer, the consensus layer and the application layer. The first two are generally bundled together in an entity called the consensus engine, while the third is the state-machine defined with the help of the Cosmos SDK. Currently, the Cosmos SDK uses Tendermint as the default consensus engine, meaning the start command is implemented to boot up a Tendermint node.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
As a reminder, the full-node is composed of three conceptual layers: the networking layer, the consensus layer and the application layer. The first two are generally bundled together in an entity called the consensus engine, while the third is the state-machine defined with the help of the Cosmos SDK. Currently, the Cosmos SDK uses Tendermint as the default consensus engine, meaning the start command is implemented to boot up a Tendermint node.
As a reminder, the full-node is composed of three conceptual layers: the networking layer, the consensus layer and the application layer. The first two are generally bundled together in `Tendermint Core` while the third is the state-machine defined with the help of the Cosmos SDK.

Copy link
Contributor

Choose a reason for hiding this comment

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

"an entity call the consensus engine" is vaue, might want to specify Tendermint Core


As a reminder, the full-node is composed of three conceptual layers: the networking layer, the consensus layer and the application layer. The first two are generally bundled together in an entity called the consensus engine, while the third is the state-machine defined with the help of the Cosmos SDK. Currently, the Cosmos SDK uses Tendermint as the default consensus engine, meaning the start command is implemented to boot up a Tendermint node.

The flow of the `start` command is pretty straightforward. First, it retrieves the `config` from the `context` in order to open the `db`. This `db` contains the latest known state of the application (empty if the application is started from the first time).
Copy link
Contributor

Choose a reason for hiding this comment

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

the db is an instance of IAVL yes? maybe specify that? https://github.com/tendermint/iavl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nah it's a leveldb, I'll specify

@hschoenburg
Copy link
Contributor

a few minor changes

Copy link
Contributor

@hschoenburg hschoenburg left a comment

Choose a reason for hiding this comment

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

"Accounts Fees and Gas" is a heavily overloaded file. Why not split it into two? "Adresses and Accounts" & "Fees and Gas"

@gamarin2
Copy link
Contributor Author

@fedekunze @hschoenburg integrated your comments, please approve

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

I think at this point this pr is blocked on getting a ci process to replace master with commit hashes, or has this already happened?

Events: ctx.EventManager().Events(),
}
```

For a deeper look at `handler`s, see this [example implementation of a `handler` function](https://github.com/cosmos/sdk-application-tutorial/blob/master/x/nameservice/handler.go) from the nameservice tutorial.
Copy link
Member

Choose a reason for hiding this comment

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

this link will be broken in the coming days.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good job noticing that, I missed a few links. Added permalinks

Copy link
Member

Choose a reason for hiding this comment

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

should this be done for the sdk links as well? just thinking in terms of versioning

@fadeev
Copy link
Contributor

fadeev commented Oct 23, 2019

@marbar3778 if you mean CI process of cosmos.network, then no, it's not blocking, we can merge into master safely.

https://allinbits.slack.com/archives/GDDLSDFPT/p1571509059077500

@gamarin2
Copy link
Contributor Author

Added permalinks, and no the CI process should not block this PR as denis said. If nothing else please approve 🙏

@tac0turtle
Copy link
Member

tac0turtle commented Oct 23, 2019

ah I didn't mean that @fadeev meant a script to replace cosmos-sdk/blob/master with cosmos-sdk/blob/<commit_hash>

I think this script would have to be run on releases only though

@gamarin2 gamarin2 merged commit 6d67876 into master-docs Oct 23, 2019
@gamarin2 gamarin2 deleted the gamarin/finish-docs branch October 23, 2019 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T:Docs Changes and features related to documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants