Skip to content

Commit

Permalink
Merge PR cosmos#4691: Add baseapp concept doc
Browse files Browse the repository at this point in the history
* consolidate intro

* start anatomy of sdk app

* wokring

* working

* querier

* working

* workiiiing

* finish

* add dep and makefile

* Apply suggestions from code review

Co-Authored-By: Alessio Treglia <[email protected]>

* typo

* typo

* Apply suggestions from code review

Co-Authored-By: Alexander Bezobchuk <[email protected]>
Co-Authored-By: Federico Kunze <[email protected]>
Co-Authored-By: Alessio Treglia <[email protected]>
Co-Authored-By: frog power 4000 <[email protected]>

* refactor for new module interface

* karoly review

* Apply suggestions from code review

Co-Authored-By: Karoly Albert Szabo <[email protected]>
Co-Authored-By: Federico Kunze <[email protected]>

* encoding

* working on baseapp doc

* baseapp work

* reorg

* almost there

* finish first draft

* remove old files

* hans review'

* jack review + clarification on ABCI methods
  • Loading branch information
gamarin2 authored and jackzampolin committed Jul 17, 2019
1 parent 8c7ed19 commit ae77f00
Show file tree
Hide file tree
Showing 52 changed files with 362 additions and 10 deletions.
File renamed without changes.
15 changes: 15 additions & 0 deletions docs/basics/accounts-fees-gas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Accounts, Fees and Gas

## Accounts

## AnteHandler

## Signatures

## Fees

## Gas

## Gas Meter

## Block Gas Meter
4 changes: 2 additions & 2 deletions docs/concepts/app-anatomy.md → docs/basics/app-anatomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ The SDK offers developers the possibility to implement automatic execution of co

In general, the `BeginBlocker` and `EndBlocker` functions are mostly composed of the `BeginBlock` and `EndBlock` functions of each of the application's modules. This is done by calling the `BeginBlock` and `EndBlock` functions of the module manager, which in turn will call the `BeginBLock` and `EndBlock` functions of each of the modules it contains. Note that the order in which the modules' `BegingBlock` and `EndBlock` functions must be called has to be set in the module manager using the `SetOrderBeginBlock` and `SetOrderEndBlock` methods respectively. This is done in the [application's constructor](#application-constructor), and the `SetOrderBeginBlock` and `SetOrderEndBlock` methods have to be called before the `SetBeginBlocker` and `SetEndBlocker` functions.

As a sidenote, it is important to remember that application-specific blockchains are deterministic. Developers must be careful not to introduce non-determinism in `BeginBlocker` or `EndBlocker`, and must also be careful not to make them too computationally expensive, as [gas](./fees-signature.md/gas) does not constrain the cost of `BeginBlocker` and `EndBlocker` execution.
As a sidenote, it is important to remember that application-specific blockchains are deterministic. Developers must be careful not to introduce non-determinism in `BeginBlocker` or `EndBlocker`, and must also be careful not to make them too computationally expensive, as [gas](./accounts-fees-gas.md/gas) does not constrain the cost of `BeginBlocker` and `EndBlocker` execution.

You can see an example of `BeginBlocker` and `EndBlocker` functions [here](https://github.com/cosmos/gaia/blob/master/app/app.go#L224-L232).

Expand Down Expand Up @@ -155,7 +155,7 @@ To learn more about the application module interface, [click here](./modules.md#
A message is a custom type defined by each module that implements the [`message`](https://github.com/cosmos/cosmos-sdk/blob/master/types/tx_msg.go#L8-L29) interface. Each `transaction` contains one or multiple `messages`. When a valid block of transactions is received by the full-node, Tendermint relays each one to the application via [`DeliverTx`](https://tendermint.com/docs/app-dev/abci-spec.html#delivertx). Then, the application handles the transaction:

1. Upon receiving the transaction, the application first unmarshalls it from `[]bytes`.
2. Then, it verifies a few things about the transaction like [fee payment and signatures](#fees-signature.md) before extracting the message(s) contained in the transaction.
2. Then, it verifies a few things about the transaction like [fee payment and signatures](#accounts-fees-gas.md) before extracting the message(s) contained in the transaction.
3. With the [`Type()`](https://github.com/cosmos/cosmos-sdk/blob/master/types/tx_msg.go#L16) method, `baseapp` is able to know which modules defines the message. It is then able to route it to the appropriate module's [handler](#handler) in order for the message to be processed.
4. If the message is successfully processed, the state is updated.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions docs/concepts/fees-signature.md

This file was deleted.

331 changes: 331 additions & 0 deletions docs/core/baseapp.md

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions docs/core/store.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Store

## Commit Multi Store

## Database

## Main Store

5 changes: 5 additions & 0 deletions docs/core/tx-msgs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Transactions and Messages

## Transactions

## Messages
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/intro/sdk-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Here is a simplified view of how a transaction is processed by the application o
v
```

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` using `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](./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.
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` using `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](../coore/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.

SDK modules are defined in the `x/` folder of the SDK. Some core modules include:

Expand Down

0 comments on commit ae77f00

Please sign in to comment.