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

feat: migrate to docusaurus #13471

Merged
merged 25 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
versionning
  • Loading branch information
julienrbrt committed Oct 10, 2022
commit 164dd6e83bf42a83eb08084bbe102eb364e902b7
19 changes: 2 additions & 17 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,8 @@ The [README.md](./README.md) is both the README for the repository and the confi
**NOTE:** Strongly consider the existing links - both within this directory
and to the website docs - when moving or deleting files.

Absolute links should be used nearly everywhere, having discovered and weighed the following:

### Relative

Where is the other file, relative to the current one?

* works both on GitHub and for the Docusaurus build
* confusing / annoying to have things like: `../../../../myfile.md`
* requires more updates when files are re-shuffled

### Absolute

Where is the other file, given the root of the repo?

* works on GitHub, works in Docusaurus
* this is much nicer: `/docs/hereitis/myfile.md`
* if you move that file around, the links inside of it are preserved
Relative links should be used nearly everywhere, due to versionning.
Note that in case of page reshufling, you must update all links references.

### Full

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/basics/00-app-anatomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ The `EncodingConfig` structure is the last important part of the `app.go` file.
Here are descriptions of what each of the four fields means:

* `InterfaceRegistry`: The `InterfaceRegistry` is used by the Protobuf codec to handle interfaces that are encoded and decoded (we also say "unpacked") using [`google.protobuf.Any`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). `Any` could be thought as a struct that contains a `type_url` (name of a concrete type implementing the interface) and a `value` (its encoded bytes). `InterfaceRegistry` provides a mechanism for registering interfaces and implementations that can be safely unpacked from `Any`. Each of the application's modules implements the `RegisterInterfaces` method that can be used to register the module's own interfaces and implementations.
* You can read more about Any in [ADR-19](../architecture/adr-019-protobuf-state-05-encoding.md#usage-of-any-to-encode-interfaces).
* To go more into details, the Cosmos SDK uses an implementation of the Protobuf specification called [`gogoprotobuf`](https://github.com/cosmos/gogoproto). By default, the [gogo protobuf implementation of `Any`](https://pkg.go.dev/github.com/cosmos/gogoproto/types) uses [global type registration](https://github.com/cosmos/gogoproto/blob/master/proto/properties.go#L540) to decode values packed in `Any` into concrete Go types. This introduces a vulnerability where any malicious module in the dependency tree could register a type with the global protobuf registry and cause it to be loaded and unmarshaled by a transaction that referenced it in the `type_url` field. For more information, please refer to [ADR-019](../architecture/adr-019-protobuf-state-05-encoding.md).
* You can read more about Any in [ADR-19](../architecture/adr-019-protobuf-state-encoding.md).
* To go more into details, the Cosmos SDK uses an implementation of the Protobuf specification called [`gogoprotobuf`](https://github.com/cosmos/gogoproto). By default, the [gogo protobuf implementation of `Any`](https://pkg.go.dev/github.com/cosmos/gogoproto/types) uses [global type registration](https://github.com/cosmos/gogoproto/blob/master/proto/properties.go#L540) to decode values packed in `Any` into concrete Go types. This introduces a vulnerability where any malicious module in the dependency tree could register a type with the global protobuf registry and cause it to be loaded and unmarshaled by a transaction that referenced it in the `type_url` field. For more information, please refer to [ADR-019](../architecture/adr-019-protobuf-state-encoding.md).
* `Codec`: the default codec used throughout the Cosmos SDK. It is composed of a `BinaryCodec` used to encode and decode state, and a `JSONCodec` used to output data to the users (for example in the [CLI](#cli)). By default, the SDK uses Protobuf as `Codec`.
* `TxConfig`: `TxConfig` defines an interface a client can utilize to generate an application-defined concrete transaction type. Currently, the SDK handles two transaction types: `SIGN_MODE_DIRECT` (which uses Protobuf binary as over-the-wire encoding) and `SIGN_MODE_LEGACY_AMINO_JSON` (which depends on Amino). Read more about transactions [here](../core/01-transactions.md).
* `Amino`: Some legacy parts of the Cosmos SDK still use Amino for backwards-compatibility. Each module exposes a `RegisterLegacyAmino` method to register the module's specific types within Amino. This `Amino` codec should not be used by app developers anymore, and will be removed in future releases.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/basics/03-accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ The default implementation of `Keyring` comes from the third-party [`99designs/k

A few notes on the `Keyring` methods:

* `Sign(uid string, msg []byte) ([]byte, types.PubKey, error)` strictly deals with the signature of the `msg` bytes. You must prepare and encode the transaction into a canonical `[]byte` form. Because protobuf is not deterministic, it has been decided in [ADR-020](../architecture/adr-020-protobuf-transaction-05-encoding.md) that the canonical `payload` to sign is the `SignDoc` struct, deterministically encoded using [ADR-027](../architecture/adr-027-deterministic-protobuf-serialization.md). Note that signature verification is not implemented in the Cosmos SDK by default, it is deferred to the [`anteHandler`](../core/00-baseapp.md#antehandler).
* `Sign(uid string, msg []byte) ([]byte, types.PubKey, error)` strictly deals with the signature of the `msg` bytes. You must prepare and encode the transaction into a canonical `[]byte` form. Because protobuf is not deterministic, it has been decided in [ADR-020](../architecture/adr-020-protobuf-transaction-encoding.md) that the canonical `payload` to sign is the `SignDoc` struct, deterministically encoded using [ADR-027](../architecture/adr-027-deterministic-protobuf-serialization.md). Note that signature verification is not implemented in the Cosmos SDK by default, it is deferred to the [`anteHandler`](../core/00-baseapp.md#antehandler).
+++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/proto/cosmos/tx/v1beta1/tx.proto#L48-L65

* `NewAccount(uid, mnemonic, bip39Passphrase, hdPath string, algo SignatureAlgo) (*Record, 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. The `PrivKey` is **never stored unencrypted**, instead it is [encrypted with a passphrase](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/crypto/armor.go) before being persisted. In the context of this method, the key type and sequence number refer to the segment of the BIP44 derivation path (for example, `0`, `1`, `2`, ...) that is used to derive a private and a public key from the mnemonic. Using the same mnemonic and derivation path, the same `PrivKey`, `PubKey` and `Address` is generated. The following keys are supported by the keyring:
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/core/05-encoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ A standard implementation of both these objects can be found in the [`auth` modu

+++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/auth/tx/encoder.go

See [ADR-020](../architecture/adr-020-protobuf-transaction-05-encoding.md) for details of how a transaction is encoded.
See [ADR-020](../architecture/adr-020-protobuf-transaction-encoding.md) for details of how a transaction is encoded.

### Interface Encoding and Usage of `Any`

Expand All @@ -148,7 +148,7 @@ In this `Profile` example, we hardcoded `account` as a `BaseAccount`. However, t

+++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/auth/types/account.go#L301-L324

In [ADR-019](../architecture/adr-019-protobuf-state-05-encoding.md), it has been decided to use [`Any`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto)s to encode interfaces in protobuf. An `Any` contains an arbitrary serialized message as bytes, along with a URL that acts as a globally unique identifier for and resolves to that message's type. This strategy allows us to pack arbitrary Go types inside protobuf messages. Our new `Profile` then looks like:
In [ADR-019](../architecture/adr-019-protobuf-state-encoding.md), it has been decided to use [`Any`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto)s to encode interfaces in protobuf. An `Any` contains an arbitrary serialized message as bytes, along with a URL that acts as a globally unique identifier for and resolves to that message's type. This strategy allows us to pack arbitrary Go types inside protobuf messages. Our new `Profile` then looks like:

```protobuf
message Profile {
Expand Down Expand Up @@ -217,7 +217,7 @@ func (p *Profile) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {

The `UnpackInterfaces` gets called recursively on all structs implementing this method, to allow all `Any`s to have their `GetCachedValue()` correctly populated.

For more information about interface encoding, and especially on `UnpackInterfaces` and how the `Any`'s `type_url` gets resolved using the `InterfaceRegistry`, please refer to [ADR-019](../architecture/adr-019-protobuf-state-05-encoding.md).
For more information about interface encoding, and especially on `UnpackInterfaces` and how the `Any`'s `type_url` gets resolved using the `InterfaceRegistry`, please refer to [ADR-019](../architecture/adr-019-protobuf-state-encoding.md).

#### `Any` Encoding in the Cosmos SDK

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/run-node/03-txs.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ At this point, `TxBuilder`'s underlying transaction is ready to be signed.

### Signing a Transaction

We set encoding config to use Protobuf, which will use `SIGN_MODE_DIRECT` by default. As per [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-020-protobuf-transaction-05-encoding.md), each signer needs to sign the `SignerInfo`s of all other signers. This means that we need to perform two steps sequentially:
We set encoding config to use Protobuf, which will use `SIGN_MODE_DIRECT` by default. As per [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-020-protobuf-transaction-encoding.md), each signer needs to sign the `SignerInfo`s of all other signers. This means that we need to perform two steps sequentially:

* for each signer, populate the signer's `SignerInfo` inside `TxBuilder`,
* once all `SignerInfo`s are populated, for each signer, sign the `SignDoc` (the payload to be signed).
Expand Down
31 changes: 26 additions & 5 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");

const lastVersion = "v0.47";

/** @type {import('@docusaurus/types').Config} */
const config = {
title: "Cosmos SDK",
Expand Down Expand Up @@ -38,6 +40,17 @@ const config = {
sidebarPath: require.resolve("./sidebars.js"),
routeBasePath: "/",
editUrl: "https://github.com/cosmos/cosmos-sdk/tree/main/",
lastVersion: lastVersion,
versions: {
current: {
path: "main",
},
"v0.47": {
label: "v0.47",
path: "v0.47",
banner: "none",
},
},
},
theme: {
customCss: require.resolve("./src/css/custom.css"),
Expand Down Expand Up @@ -71,16 +84,24 @@ const config = {
`,
position: "right",
},
{
type: "docsVersionDropdown",
position: "left",
dropdownActiveClassDisabled: true,
// versions not yet migrated to docusaurus
dropdownItemsAfter: [
{ to: "/v0.46", label: "v0.46" },
{ to: "/v0.45", label: "v0.45" },
],
},
],
},
footer: {
links: [
{
items: [
{
html: `
<a href="https://cosmos.network"><img src="/img/logo-bw.svg" alt="Cosmos Logo"></a>
`,
html: `<a href="https://cosmos.network"><img src="/img/logo-bw.svg" alt="Cosmos Logo"></a>`,
},
],
},
Expand Down Expand Up @@ -185,8 +206,8 @@ const config = {
toExtensions: ["html"],
redirects: [
{
from: "/main/",
to: `/`,
from: "/",
to: "/" + lastVersion,
},
],
},
Expand Down
3 changes: 2 additions & 1 deletion docs/post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ rm -rf docs/modules
rm -rf docs/run-node/06-cosmovisor.md
rm -rf docs/building-apps/01-depinject.md
rm -rf docs/architecture
rm -rf docs/spec
rm -rf docs/spec
rm -rf versioned_docs versioned_sidebars versions.json