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

Add baseapp concept doc #4691

Merged
merged 29 commits into from
Jul 17, 2019
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Prev Previous commit
Next Next commit
Merge branch 'master' into gamarin/baseapp
  • Loading branch information
gamarin2 committed Jul 5, 2019
commit 9aedc16280e58005607092024fdace75531cdd6b
19 changes: 0 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,6 @@ jobs:
- bin
- profiles

lint:
<<: *linux_defaults
parallelism: 1
steps:
- attach_workspace:
at: /tmp/workspace
- checkout
- restore_cache:
keys:
- go-mod-v1-{{ checksum "go.sum" }}
- run:
name: Lint source
command: |
export PATH=/tmp/workspace/bin:$PATH
make ci-lint

test_sim_app_nondeterminism:
<<: *linux_defaults
parallelism: 1
Expand Down Expand Up @@ -284,9 +268,6 @@ workflows:
tags:
only:
- /^v.*/
- lint:
requires:
- setup_dependencies
- test_sim_app_nondeterminism:
requires:
- setup_dependencies
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ mytestnet
# Testing
coverage.txt
profile.out
sim_log_file

# Vagrant
.vagrant/
Expand Down
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ linters:
- unconvert
- misspell
- govet
- unused
- deadcode
- goconst
- gosec
- staticcheck
linters-settings:
gocyclo:
min-complexity: 11
Expand Down
11 changes: 11 additions & 0 deletions .pending/breaking/sdk/3972-supply
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#4255 Add supply module that passively tracks the supplies of a chain
- Renamed `x/distribution` `ModuleName`
- Genesis JSON and CLI now use `distribution` instead of `distr`
- Introduce `ModuleAccount` type, which tracks the flow of coins held within a module
- Replaced `FeeCollectorKeeper` for a `ModuleAccount`
- Replaced the staking `Pool`, which coins are now held by the `BondedPool` and `NotBonded` module accounts
- The `NotBonded` module account now only keeps track of the not bonded tokens within staking, instead of the whole chain
- #3628 Replaced governance's burn and deposit accounts for a `ModuleAccount`
- Added a `ModuleAccount` for the distribution module
- Added a `ModuleAccount` for the mint module
#4472 validation for crisis genesis
1 change: 1 addition & 0 deletions .pending/breaking/sdk/3985-ValidatorPowerR
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3985 `ValidatorPowerRank` uses potential consensus power instead of tendermint power
15 changes: 15 additions & 0 deletions .pending/breaking/sdk/4387-Refactor-the-us
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#4387 Refactor the usage of tags (now called events) to reflect the
new ABCI events semantics:

- Move `x/{module}/tags/tags.go` => `x/{module}/types/events.go`
- Update `docs/specs`
- Refactor tags in favor of new `Event(s)` type(s)
- Update `Context` to use new `EventManager`
- (Begin|End)Blocker no longer return tags, but rather uses new `EventManager`
- Message handlers no longer return tags, but rather uses new `EventManager`

Any component (e.g. BeginBlocker, message handler, etc...) wishing to emit an event must do so
through `ctx.EventManger().EmitEvent(s)`.

To reset or wipe emitted events: `ctx = ctx.WithEventManager(sdk.NewEventManager())`
To get all emitted events: `events := ctx.EventManager().Events()`
1 change: 1 addition & 0 deletions .pending/breaking/sdk/4437-bytes-gov-keys
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4437 Replace governance module store keys to use `[]byte` instead of `string`.
5 changes: 5 additions & 0 deletions .pending/breaking/sdk/4451-Improve-modular
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#4451 Improve modularization of clients and modules:
* Module directory structure improved and standardized
* Aliases autogenerated
* Auth and bank related commands are now mounted under the respective moduels
* Client initialization and mounting standardized
2 changes: 2 additions & 0 deletions .pending/breaking/sdk/4479-Remove-codec-ar
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4479 Remove codec argument redundency in client usage where
the CLIContext's codec should be used instead.
2 changes: 2 additions & 0 deletions .pending/breaking/sdk/4488-client-s-tx-res
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4488 Decouple client tx, REST, and ultil packages from auth. These packages have
been restructured and retrofitted into the `x/auth` module.
1 change: 1 addition & 0 deletions .pending/breaking/sdk/4521-Flatten-x-bank-
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4521 Flatten x/bank structure by hiding module internals.
1 change: 1 addition & 0 deletions .pending/breaking/sdk/4525-Remove---cors-f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4525 Remove --cors flag, the feature is long gone.
2 changes: 2 additions & 0 deletions .pending/breaking/sdk/4536-The-auth-accoun
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4536 The `/auth/accounts/{address}` now returns a `height` in the response.
The account is now nested under `account`.
2 changes: 2 additions & 0 deletions .pending/breaking/sdk/4543-Account-getters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4543 Account getters are no longer part of client.CLIContext() and have now moved
to reside in the auth-specific AccountRetriever.
6 changes: 6 additions & 0 deletions .pending/breaking/sdk/4588-Context-does-no
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#4588 Context does not depend on x/auth anymore. client/context is stripped out of the following features:
- GetAccountDecoder()
- CLIContext.WithAccountDecoder()
- CLIContext.WithAccountStore()

x/auth.AccountDecoder is unnecessary and consequently removed.
1 change: 1 addition & 0 deletions .pending/breaking/sdk/4602-client-input-Bu
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4602 client/input.{Buffer,Override}Stdin() functions are removed. Thanks to cobra's new release they are now redundant.
2 changes: 2 additions & 0 deletions .pending/breaking/sdk/4633-Update-old-Tx-s
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4633 Update old Tx search by tags APIs to use new Events
nomenclature.
1 change: 1 addition & 0 deletions .pending/breaking/sdk/4649-Refactor-x-cris
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4649 Refactor x/crisis as per modules new specs.
2 changes: 2 additions & 0 deletions .pending/breaking/sdk/refactor-bank-keeper
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4663 Refactor bank keeper by removing private functions
- `InputOutputCoins`, `SetCoins`, `SubtractCoins` and `AddCoins` are now part of the `SendKeeper` instead of the `Keeper` interface
1 change: 1 addition & 0 deletions .pending/bugfixes/sdk/1351-https-github-co
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[\#1351](https://github.com/cosmos/cosmos-sdk/issues/1351) Stable AppHash allows no_empty_blocks
1 change: 1 addition & 0 deletions .pending/bugfixes/sdk/4455-Print-null-whil
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4455 Use `QueryWithData()` to query unbonding delegations.
2 changes: 2 additions & 0 deletions .pending/bugfixes/sdk/4493-Fix-validator-o
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4493 Fix validator-outstanding-rewards command. It now takes as an argument
a validator address.
1 change: 1 addition & 0 deletions .pending/bugfixes/sdk/4598-fix-check-bond-
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4598 Fix redelegation and undelegation txs that were not checking for the correct bond denomination.
2 changes: 2 additions & 0 deletions .pending/bugfixes/sdk/4619-Close-iterators
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4619 Close iterators in `GetAllMatureValidatorQueue` and `UnbondAllMatureValidatorQueue`
methods.
1 change: 1 addition & 0 deletions .pending/bugfixes/sdk/4654-validator-slash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4654 validator slash event stored by period and height
2 changes: 2 additions & 0 deletions .pending/bugfixes/sdk/4681-mint-check
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4681 panic on invalid amount on `MintCoins` and `BurnCoins`
- skip minting if inflation is set to zero
3 changes: 3 additions & 0 deletions .pending/features/sdk/4409-migration-scrip
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#4409 Implement a command that migrates exported state from one version to the next.
The `migrate` command currently supports migrating from v0.34 to v0.36 by implementing
necessary types for both versions.
1 change: 1 addition & 0 deletions .pending/features/sdk/4570-Move-bank-balan
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4570 Move /bank/balances/{address} REST handler to x/bank/client/rest. The exposed interface is unchanged.
1 change: 1 addition & 0 deletions .pending/improvements/sdk/3512-Implement-Logge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3512 Implement Logger method on each module's keeper.
2 changes: 2 additions & 0 deletions .pending/improvements/sdk/3928-remove-types-staking
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#3928 remove staking references from types package
#1528 define local module interfaces instead of /types
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4439-add-governance-
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4439 Implement governance module iterators.
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4465-Unknown-subcomm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4465 Unknown subcommands print relevant error message
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4466-Commission-vali
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4466 Commission validation added to validate basic of MsgCreateValidator by changing CommissionMsg to CommissionRates
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4501-Support-height-
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4501 Support height queriers in rest client
2 changes: 2 additions & 0 deletions .pending/improvements/sdk/4535-improve-sim-err
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4535 Improve import-export simulation errors by decoding the `KVPair.Value` into its
respective type
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4536-cli-context-que
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4536 cli context queries return query height and accounts are returned with query height
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4553 undelegate max entries check first
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4556-Added-IsValid-f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4556 Added IsValid function to Coin
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4564-Allow-empty-ans
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4564 client/input.GetConfirmation()'s default is changed to No.
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4573-adds-height-in-
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4573 Returns height in response for query endpoints.
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4580-remove-block-he
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4580 Update `Context#BlockHeight` to properly set the block height via `WithBlockHeader`.
2 changes: 2 additions & 0 deletions .pending/improvements/sdk/4584-Update-bank-Kee
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4584 Update bank Keeper to use expected keeper interface of the AccountKeeper.
#4584 Move `Account` and `VestingAccount` interface types to `x/auth/exported`.
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4595-supply-queriers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4082 supply module queriers for CLI and REST endpoints
2 changes: 2 additions & 0 deletions .pending/improvements/sdk/4601-Implement-gener
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4601 Implement generic pangination helper function to be used in
REST handlers and queriers.
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4629-Added-event-that-get
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4629 Added warning event that gets emitted if validator misses a block.
1 change: 1 addition & 0 deletions .pending/improvements/sdk/4676-expose-simapp-f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4674 Export `Simapp` genState generators and util functions by making them public
1 change: 1 addition & 0 deletions .pending/improvements/sdk/Remove---print-respo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove `--print-response` flag as it is no longer used.
1 change: 1 addition & 0 deletions .pending/improvements/sdk/Revert-2284-https-gi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Revert (#2284)[https://github.com/cosmos/cosmos-sdk/pull/2284] to allow create_empty_blocks in the config
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
SIMAPP = github.com/cosmos/cosmos-sdk/simapp
MOCKS_DIR = $(CURDIR)/tests/mocks

export GO111MODULE = on

Expand All @@ -33,6 +34,12 @@ dist:
@bash publish/dist.sh
@bash publish/publish.sh

mocks: $(MOCKS_DIR)
mockgen -source=x/auth/types/account_retriever.go -package mocks -destination tests/mocks/account_retriever.go

$(MOCKS_DIR):
mkdir -p $(MOCKS_DIR)

########################################
### Tools & dependencies

Expand All @@ -43,6 +50,7 @@ go-mod-cache: go.sum
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify
@go mod tidy

clean:
rm -rf snapcraft-local.yaml build/
Expand Down Expand Up @@ -118,8 +126,9 @@ test_sim_benchmark_invariants:

# Don't move it into tools - this will be gone once gaia has moved into the new repo
runsim: $(BINDIR)/runsim
$(BINDIR)/runsim: contrib/runsim/main.go
go install github.com/cosmos/cosmos-sdk/contrib/runsim
$(BINDIR)/runsim:
go get github.com/cosmos/tools/cmd/runsim/
go mod tidy

SIM_NUM_BLOCKS ?= 500
SIM_BLOCK_SIZE ?= 200
Expand All @@ -138,8 +147,7 @@ test_sim_app_profile:
test_cover:
@export VERSION=$(VERSION); bash -x tests/test_cover.sh

lint: tools ci-lint
ci-lint:
lint: golangci-lint
golangci-lint run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
go mod verify
Expand Down Expand Up @@ -186,7 +194,7 @@ snapcraft-local.yaml: snapcraft-local.yaml.in
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: build dist clean test test_unit test_cover lint \
.PHONY: build dist clean test test_unit test_cover lint mocks \
benchmark devdoc_init devdoc devdoc_save devdoc_update runsim \
format test_sim_app_nondeterminism test_sim_modules test_sim_app_fast \
test_sim_app_custom_genesis_fast test_sim_app_custom_genesis_multi_seed \
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Cosmos SDK
![banner](docs/cosmos-sdk-image.png)
![banner](docs/cosmos-sdk-image.jpg)

[![version](https://img.shields.io/github/tag/cosmos/cosmos-sdk.svg)](https://github.com/cosmos/cosmos-sdk/releases/latest)
[![CircleCI](https://circleci.com/gh/cosmos/cosmos-sdk/tree/master.svg?style=shield)](https://circleci.com/gh/cosmos/cosmos-sdk/tree/master)
[![Snap Status](https://build.snapcraft.io/badge/cosmos/cosmos-sdk.svg)](https://build.snapcraft.io/user/cosmos/cosmos-sdk)
[![codecov](https://codecov.io/gh/cosmos/cosmos-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/cosmos/cosmos-sdk)
[![Go Report Card](https://goreportcard.com/badge/github.com/cosmos/cosmos-sdk)](https://goreportcard.com/report/github.com/cosmos/cosmos-sdk)
[![license](https://img.shields.io/github/license/cosmos/cosmos-sdk.svg)](https://github.com/cosmos/cosmos-sdk/blob/master/LICENSE)
Expand Down
41 changes: 23 additions & 18 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,14 +627,14 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
// the route match to see whether a handler exists.
//
// NOTE:CheckTx does not run the actual Msg handler function(s).
func (app *BaseApp) CheckTx(txBytes []byte) (res abci.ResponseCheckTx) {
func (app *BaseApp) CheckTx(req abci.RequestCheckTx) (res abci.ResponseCheckTx) {
var result sdk.Result

tx, err := app.txDecoder(txBytes)
tx, err := app.txDecoder(req.Tx)
if err != nil {
result = err.Result()
} else {
result = app.runTx(runTxModeCheck, txBytes, tx)
result = app.runTx(runTxModeCheck, req.Tx, tx)
}

return abci.ResponseCheckTx{
Expand All @@ -643,19 +643,19 @@ func (app *BaseApp) CheckTx(txBytes []byte) (res abci.ResponseCheckTx) {
Log: result.Log,
GasWanted: int64(result.GasWanted), // TODO: Should type accept unsigned ints?
GasUsed: int64(result.GasUsed), // TODO: Should type accept unsigned ints?
Tags: result.Tags,
Events: result.Events.ToABCIEvents(),
}
}

// DeliverTx implements the ABCI interface.
func (app *BaseApp) DeliverTx(txBytes []byte) (res abci.ResponseDeliverTx) {
func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliverTx) {
var result sdk.Result

tx, err := app.txDecoder(txBytes)
tx, err := app.txDecoder(req.Tx)
if err != nil {
result = err.Result()
} else {
result = app.runTx(runTxModeDeliver, txBytes, tx)
result = app.runTx(runTxModeDeliver, req.Tx, tx)
}

return abci.ResponseDeliverTx{
Expand All @@ -665,7 +665,7 @@ func (app *BaseApp) DeliverTx(txBytes []byte) (res abci.ResponseDeliverTx) {
Log: result.Log,
GasWanted: int64(result.GasWanted), // TODO: Should type accept unsigned ints?
GasUsed: int64(result.GasUsed), // TODO: Should type accept unsigned ints?
Tags: result.Tags,
Events: result.Events.ToABCIEvents(),
}
}

Expand Down Expand Up @@ -705,11 +705,15 @@ func (app *BaseApp) getContextForTx(mode runTxMode, txBytes []byte) (ctx sdk.Con
func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (result sdk.Result) {
idxLogs := make([]sdk.ABCIMessageLog, 0, len(msgs)) // a list of JSON-encoded logs with msg index

var data []byte // NOTE: we just append them all (?!)
var tags sdk.Tags // also just append them all
var code sdk.CodeType
var codespace sdk.CodespaceType
var (
data []byte
code sdk.CodeType
codespace sdk.CodespaceType
)

events := sdk.EmptyEvents()

// NOTE: GasWanted is determined by ante handler and GasUsed by the GasMeter.
for msgIdx, msg := range msgs {
// match message route
msgRoute := msg.Route()
Expand All @@ -725,12 +729,13 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (re
msgResult = handler(ctx, msg)
}

// NOTE: GasWanted is determined by ante handler and GasUsed by the GasMeter.

// Result.Data must be length prefixed in order to separate each result
// Each message result's Data must be length prefixed in order to separate
// each result.
data = append(data, msgResult.Data...)
tags = append(tags, sdk.MakeTag(sdk.TagAction, msg.Type()))
tags = append(tags, msgResult.Tags...)

// append events from the message's execution and a message action event
events = events.AppendEvent(sdk.NewEvent(sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyAction, msg.Type())))
events = events.AppendEvents(msgResult.Events)

idxLog := sdk.ABCIMessageLog{MsgIndex: uint16(msgIdx), Log: msgResult.Log}

Expand All @@ -755,7 +760,7 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (re
Data: data,
Log: strings.TrimSpace(string(logJSON)),
GasUsed: ctx.GasMeter().GasConsumed(),
Tags: tags,
Events: events,
}

return result
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.