You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/learn/beginner/00-app-anatomy.md
+29-18
Original file line number
Diff line number
Diff line change
@@ -12,22 +12,31 @@ This document describes the core parts of a Cosmos SDK application, represented
12
12
13
13
The Daemon, or [Full-Node Client](../advanced/03-node.md), is the core process of a Cosmos SDK-based blockchain. Participants in the network run this process to initialize their state-machine, connect with other full-nodes, and update their state-machine as new blocks come in.
14
14
15
-
```text
16
-
^ +-------------------------------+ ^
17
-
| | | |
18
-
| | State-machine = Application | |
19
-
| | | | Built with Cosmos SDK
20
-
| | ^ + | |
21
-
| +----------- | ABCI | ----------+ v
22
-
| | + v | ^
23
-
| | | |
24
-
Blockchain Node | | Consensus | |
25
-
| | | |
26
-
| +-------------------------------+ | CometBFT
27
-
| | | |
28
-
| | Networking | |
29
-
| | | |
30
-
v +-------------------------------+ v
15
+
```mermaid
16
+
flowchart TD
17
+
subgraph Blockchain_Node[Blockchain Node]
18
+
subgraph SM[State-machine = Application]
19
+
direction TB
20
+
SM1[Cosmos SDK]
21
+
end
22
+
subgraph ABCI[ABCI]
23
+
direction TB
24
+
end
25
+
subgraph Consensus[Consensus]
26
+
direction TB
27
+
end
28
+
subgraph Networking[Networking]
29
+
direction TB
30
+
end
31
+
end
32
+
33
+
SM <--> ABCI
34
+
ABCI <--> Consensus
35
+
Consensus <--> Networking
36
+
37
+
Blockchain_Node -->|Includes| SM
38
+
Blockchain_Node -->|Includes| Consensus
39
+
Blockchain_Node -->|Includes| Networking
31
40
```
32
41
33
42
The blockchain full-node presents itself as a binary, generally suffixed by `-d` for "daemon" (e.g. `appd` for `app` or `gaiad` for `gaia`). This binary is built by running a simple [`main.go`](../advanced/03-node.md#main-function) function placed in `./cmd/appd/`. This operation usually happens through the [Makefile](#dependencies-and-makefile).
Copy file name to clipboardexpand all lines: docs/learn/beginner/01-tx-lifecycle.md
+7-40
Original file line number
Diff line number
Diff line change
@@ -163,46 +163,13 @@ that receive a block proposal from the correct proposer execute the transactions
163
163
As mentioned throughout the documentation `BeginBlock`, `ExecuteTx` and `EndBlock` are called within FinalizeBlock.
164
164
Although every full-node operates individually and locally, the outcome is always consistent and unequivocal. This is because the state changes brought about by the messages are predictable, and the transactions are specifically sequenced in the proposed block.
Copy file name to clipboardexpand all lines: docs/learn/beginner/03-accounts.md
+15-38
Original file line number
Diff line number
Diff line change
@@ -21,44 +21,21 @@ In the Cosmos SDK, an _account_ designates a pair of _public key_ `PubKey` and _
21
21
22
22
For HD key derivation the Cosmos SDK uses a standard called [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki). The BIP32 allows users to create an HD wallet (as specified in [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)) - a set of accounts derived from an initial secret seed. A seed is usually created from a 12- or 24-word mnemonic. A single seed can derive any number of `PrivKey`s using a one-way cryptographic function. Then, a `PubKey` can be derived from the `PrivKey`. Naturally, the mnemonic is the most sensitive information, as private keys can always be re-generated if the mnemonic is preserved.
Copy file name to clipboardexpand all lines: docs/learn/intro/01-why-app-specific.md
+22-14
Original file line number
Diff line number
Diff line change
@@ -12,20 +12,28 @@ This document explains what application-specific blockchains are, and why develo
12
12
13
13
Application-specific blockchains are blockchains customized to operate a single application. Instead of building a decentralized application on top of an underlying blockchain like Ethereum, developers build their own blockchain from the ground up. This means building a full-node client, a light-client, and all the necessary interfaces (CLI, REST, ...) to interact with the nodes.
Copy file name to clipboardexpand all lines: docs/learn/intro/02-sdk-app-architecture.md
+29-26
Original file line number
Diff line number
Diff line change
@@ -12,22 +12,20 @@ A state machine is a computer science concept whereby a machine can have multipl
12
12
13
13
Given a state S and a transaction T, the state machine will return a new state S'.
14
14
15
-
```text
16
-
+--------+ +--------+
17
-
| | | |
18
-
| S +---------------->+ S' |
19
-
| | apply(T) | |
20
-
+--------+ +--------+
15
+
```mermaid
16
+
flowchart LR
17
+
A[S]
18
+
B[S']
19
+
A -->|"apply(T)"| B
21
20
```
22
21
23
22
In practice, the transactions are bundled in blocks to make the process more efficient. Given a state S and a block of transactions B, the state machine will return a new state S'.
24
23
25
-
```text
26
-
+--------+ +--------+
27
-
| | | |
28
-
| S +----------------------------> | S' |
29
-
| | For each T in B: apply(T) | |
30
-
+--------+ +--------+
24
+
```mermaid
25
+
flowchart LR
26
+
A[S]
27
+
B[S']
28
+
A -->|"For each T in B: apply(T)"| B
31
29
```
32
30
33
31
In a blockchain context, the state machine is deterministic. This means that if a node is started at a given state and replays the same sequence of transactions, it will always end up with the same final state.
@@ -38,20 +36,25 @@ The Cosmos SDK gives developers maximum flexibility to define the state of their
38
36
39
37
Thanks to the Cosmos SDK, developers just have to define the state machine, and [*CometBFT*](https://docs.cometbft.com/v1.0/explanation/introduction/) will handle replication over the network for them.
40
38
41
-
```text
42
-
^ +-------------------------------+ ^
43
-
| | | | Built with Cosmos SDK
44
-
| | State-machine = Application | |
45
-
| | | v
46
-
| +-------------------------------+
47
-
| | | ^
48
-
Blockchain node | | Consensus | |
49
-
| | | |
50
-
| +-------------------------------+ | CometBFT
51
-
| | | |
52
-
| | Networking | |
53
-
| | | |
54
-
v +-------------------------------+ v
39
+
```mermaid
40
+
flowchart TD
41
+
subgraph Blockchain_Node[Blockchain Node]
42
+
subgraph SM[State-machine]
43
+
direction TB
44
+
SM1[Cosmos SDK]
45
+
end
46
+
subgraph CometBFT[CometBFT]
47
+
direction TB
48
+
Consensus
49
+
Networking
50
+
end
51
+
end
52
+
53
+
SM <--> CometBFT
54
+
55
+
56
+
Blockchain_Node -->|Includes| SM
57
+
Blockchain_Node -->|Includes| CometBFT
55
58
```
56
59
57
60
[CometBFT](https://docs.cometbft.com/v1.0/explanation/introduction/) is an application-agnostic engine that is responsible for handling the *networking* and *consensus* layers of a blockchain. In practice, this means that CometBFT is responsible for propagating and ordering transaction bytes. CometBFT relies on an eponymous Byzantine-Fault-Tolerant (BFT) algorithm to reach consensus on the order of transactions.
A[Transaction relayed from the full-node's CometBFT engine to the node's application via DeliverTx] --> B[APPLICATION]
45
+
B -->|"Using baseapp's methods: Decode the Tx, extract and route the message(s)"| C[Message routed to the correct module to be processed]
46
+
C --> D1[AUTH MODULE]
47
+
C --> D2[BANK MODULE]
48
+
C --> D3[STAKING MODULE]
49
+
C --> D4[GOV MODULE]
50
+
D1 -->|Handle message, Update state| E["Return result to CometBFT (0=Ok, 1=Err)"]
51
+
D2 -->|Handle message, Update state| E["Return result to CometBFT (0=Ok, 1=Err)"]
52
+
D3 -->|Handle message, Update state| E["Return result to CometBFT (0=Ok, 1=Err)"]
53
+
D4 -->|Handle message, Update state| E["Return result to CometBFT (0=Ok, 1=Err)"]
85
54
```
86
55
87
56
Each module can be seen as a little state-machine. Developers need to define the subset of the state handled by the module, as well as custom message types that modify the state (*Note:*`messages` are extracted from `transactions` by `baseapp`). In general, each module declares its own `KVStore` in the `multistore` to persist the subset of the state it defines. Most developers will need to access other 3rd party modules when building their own modules. Given that the Cosmos SDK is an open framework, some of the modules may be malicious, which means there is a need for security principles to reason about inter-module interactions. These principles are based on [object-capabilities](../advanced/10-ocap.md). In practice, this means that instead of having each module keep an access control list for other modules, each module implements special objects called `keepers` that can be passed to other modules to grant a pre-defined set of capabilities.
0 commit comments