Skip to content

Commit

Permalink
Merge branch 'main' into john/#13099-decouple-simapp
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Aug 30, 2022
2 parents 5ea07c7 + 797bd12 commit 60be640
Show file tree
Hide file tree
Showing 61 changed files with 6,481 additions and 5,123 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/legacy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ jobs:
with:
name: "${{ github.sha }}-${{ matrix.part }}-coverage"
path: ./${{ matrix.part }}profile.out
env:
# Here we don't use the go.work for ensuring that the modules are correctly tagged and tidy-ed.
GOWORK: off

sims-notify-success:
needs: [tests]
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ jobs:
with:
name: "${{ github.sha }}-${{ matrix.part }}-coverage"
path: ./${{ matrix.part }}profile.out
env:
# Here we don't use the go.work for ensuring that the modules are correctly tagged and tidy-ed.
GOWORK: off

upload-coverage-report:
runs-on: buildjet-4vcpu-ubuntu-2004
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ buf-stamp
artifacts

# Go
go.work
go.work.sum

# Data - ideally these don't exist
Expand Down
5,128 changes: 2,564 additions & 2,564 deletions CHANGELOG.md

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [Requesting Reviews](#requesting-reviews)
* [Updating Documentation](#updating-documentation)
* [Dependencies](#dependencies)
* [`go.work`](#gowork)
* [Protobuf](#protobuf)
* [Branching Model and Release](#branching-model-and-release)
* [PR Targeting](#pr-targeting)
Expand Down Expand Up @@ -65,7 +66,7 @@ To synchronize we have few major meetings:
* Cosmos Community SDK Development Call on the last Wednesday of every month at 17:00 UTC.
* Cosmos Roadmap Prioritization every 4 weeks on Tuesday at 15:00 UTC (limited participation).

If you would like to join one of those calls, then please contact us on [Discord](https://discord.com/invite/cosmosnetwork) or reach out directly to Cory Levinson from Regen Network (cory@regen.network).
If you would like to join one of those calls, then please contact us on [Discord](https://discord.com/invite/cosmosnetwork) or reach out directly to Marko (@marbar3778).

## Architecture Decision Records (ADR)

Expand Down Expand Up @@ -176,6 +177,13 @@ get away with telling people they can just `go get` our software.
Since some dependencies are not under our control, a third party may break our
build, in which case we can fall back on `go mod tidy -v`.

### `go.work`

The Cosmos SDK is a multi-module repo, for this reason, the use of a `go.work` file is handy.
We provide a [`go.work.example`](./go.work.example) that contains all the modules used in the SDK.
Do note that contributions modifying multiple Go modules should be submitted as separate PRs, this allows us to tag the changes and avoid `replace`s.
For consistency between our CI and the local tests, `GOWORK=off` is set in the `Makefile`. This means that the `go.work` file is not used when using `make test` or any other `make` command.

## Protobuf

We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use in Cosmos SDK.
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ DOCS_DOMAIN=docs.cosmos.network
# RocksDB is a native dependency, so we don't assume the library is installed.
# Instead, it must be explicitly enabled and we warn when it is not.
ENABLE_ROCKSDB ?= false

export GO111MODULE = on
GOWORK = off # we disable the `go.work` for consistency with our CI

# process build tags

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
Expand Down
45 changes: 45 additions & 0 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package baseapp

import (
"encoding/json"
"os"
"testing"

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
"github.com/cosmos/cosmos-sdk/snapshots"
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func defaultLogger() log.Logger {
return log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
}

func TestGetBlockRentionHeight(t *testing.T) {
logger := defaultLogger()
db := dbm.NewMemDB()
Expand Down Expand Up @@ -164,3 +172,40 @@ func TestBaseAppCreateQueryContext(t *testing.T) {
})
}
}

type paramStore struct {
db *dbm.MemDB
}

func (ps *paramStore) Set(_ sdk.Context, key []byte, value interface{}) {
bz, err := json.Marshal(value)
if err != nil {
panic(err)
}

ps.db.Set(key, bz)
}

func (ps *paramStore) Has(_ sdk.Context, key []byte) bool {
ok, err := ps.db.Has(key)
if err != nil {
panic(err)
}

return ok
}

func (ps *paramStore) Get(_ sdk.Context, key []byte, ptr interface{}) {
bz, err := ps.db.Get(key)
if err != nil {
panic(err)
}

if len(bz) == 0 {
return
}

if err := json.Unmarshal(bz, ptr); err != nil {
panic(err)
}
}
28 changes: 0 additions & 28 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
)

const (
Expand Down Expand Up @@ -49,7 +48,6 @@ type BaseApp struct { //nolint: maligned
db dbm.DB // common DB backend
cms sdk.CommitMultiStore // Main (uncached) state
storeLoader StoreLoader // function to handle store loading, may be overridden with SetStoreLoader()
router sdk.Router // handle any kind of legacy message
queryRouter sdk.QueryRouter // router for redirecting query calls
grpcQueryRouter *GRPCQueryRouter // router for redirecting gRPC query calls
msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages
Expand Down Expand Up @@ -149,7 +147,6 @@ func NewBaseApp(
db: db,
cms: store.NewCommitMultiStore(db),
storeLoader: DefaultStoreLoader,
router: NewRouter(),
queryRouter: NewQueryRouter(),
grpcQueryRouter: NewGRPCQueryRouter(),
msgServiceRouter: NewMsgServiceRouter(),
Expand Down Expand Up @@ -367,17 +364,6 @@ func (app *BaseApp) setIndexEvents(ie []string) {
}
}

// Router returns the legacy router of the BaseApp.
func (app *BaseApp) Router() sdk.Router {
if app.sealed {
// We cannot return a Router when the app is sealed because we can't have
// any routes modified which would cause unexpected routing behavior.
panic("Router() on sealed BaseApp")
}

return app.router
}

// QueryRouter returns the QueryRouter of a BaseApp.
func (app *BaseApp) QueryRouter() sdk.QueryRouter { return app.queryRouter }

Expand Down Expand Up @@ -749,20 +735,6 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*s
// ADR 031 request type routing
msgResult, err = handler(ctx, msg)
eventMsgName = sdk.MsgTypeURL(msg)
} else if legacyMsg, ok := msg.(legacytx.LegacyMsg); ok {
// legacy sdk.Msg routing
// Assuming that the app developer has migrated all their Msgs to
// proto messages and has registered all `Msg services`, then this
// path should never be called, because all those Msgs should be
// registered within the `msgServiceRouter` already.
msgRoute := legacyMsg.Route()
eventMsgName = legacyMsg.Type()
handler := app.router.Route(ctx, msgRoute)
if handler == nil {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s; message index: %d", msgRoute, i)
}

msgResult, err = handler(ctx, msg)
} else {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "can't route message %+v", msg)
}
Expand Down
Loading

0 comments on commit 60be640

Please sign in to comment.