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

R4R Module/Genesis Generalization #4159

Merged
merged 120 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
fc3343b
first commit
rigelrozanski Apr 3, 2019
2ed7ec3
gaia cleanup
rigelrozanski Apr 4, 2019
fa8d51b
...
rigelrozanski Apr 4, 2019
78beb8b
Merge 'origin/develop' and working on module manager
rigelrozanski Apr 4, 2019
f3c84d2
Merge remote-tracking branch 'origin/develop' into rigel/genesis-gene…
rigelrozanski Apr 8, 2019
31e268a
staking multihooks
rigelrozanski Apr 8, 2019
f04fd65
missing module function return args
rigelrozanski Apr 8, 2019
b9fea80
bank module name constant
rigelrozanski Apr 8, 2019
53096ec
working, module interface for x/
rigelrozanski Apr 9, 2019
f89b67b
got this thing compiling
rigelrozanski Apr 9, 2019
fc2c20a
Merge remote-tracking branch 'origin/develop' into rigel/genesis-gene…
rigelrozanski Apr 9, 2019
f026bec
make test compiles and passes
rigelrozanski Apr 9, 2019
45d82f9
remove expanded simulation invariants
rigelrozanski Apr 9, 2019
3f4d0cf
genesis issue
rigelrozanski Apr 10, 2019
050317d
continued
rigelrozanski Apr 10, 2019
69a543e
continued
rigelrozanski Apr 10, 2019
95236c4
Merge remote-tracking branch 'origin/develop' into rigel/genesis-gene…
rigelrozanski Apr 10, 2019
03328ee
Merge remote-tracking branch 'origin/develop' into rigel/genesis-gene…
rigelrozanski Apr 10, 2019
9031e9d
register crisis routes thought mm
rigelrozanski Apr 10, 2019
480c10e
begin blocker to mm
rigelrozanski Apr 10, 2019
ef5ec28
end blocker to mm
rigelrozanski Apr 10, 2019
3c681a6
empty routes not initialized
rigelrozanski Apr 10, 2019
4ad51d2
move gaia initChainer sanity check to baseapp
rigelrozanski Apr 10, 2019
3620b2e
remove codecs from module manager
rigelrozanski Apr 10, 2019
62342b2
reorging genesis stuff
rigelrozanski Apr 10, 2019
6ce6260
Merge remote-tracking branch 'origin/develop' into rigel/genesis-gene…
rigelrozanski Apr 15, 2019
c8c3a08
module manager passed by reference/bugfixes from working last commit
rigelrozanski Apr 15, 2019
cd4d68f
move invariant checks from gaia to crisis
rigelrozanski Apr 15, 2019
2d95c57
typo
rigelrozanski Apr 15, 2019
a22a9f7
basic refactors cmd/gaia/init
rigelrozanski Apr 16, 2019
75a9a15
working
rigelrozanski Apr 16, 2019
631298e
MultiStakingHooks from types to x/staking/types
rigelrozanski Apr 17, 2019
a2cd3dc
default module manager order of operations from input modules
rigelrozanski Apr 17, 2019
26dae66
Merge branch 'rigel/genesis-generalization' into rigel/genesis-genera…
rigelrozanski Apr 17, 2019
1b805dd
working
rigelrozanski Apr 17, 2019
022498e
typo
rigelrozanski Apr 17, 2019
8e8345c
Merge branch 'rigel/genesis-generalization' into rigel/genesis-genera…
rigelrozanski Apr 17, 2019
2573df8
add AppModuleBasic
rigelrozanski Apr 17, 2019
9386263
moduleBasicManager / non-test code compiles
rigelrozanski Apr 17, 2019
a21406e
working attempting to get tests passing
rigelrozanski Apr 17, 2019
cf671d4
make test passes
rigelrozanski Apr 17, 2019
a2c8c28
sim random genesis fix
rigelrozanski Apr 18, 2019
c8a86bd
export bug
rigelrozanski Apr 18, 2019
cceb887
...
rigelrozanski Apr 18, 2019
a93c56a
genutil module
rigelrozanski Apr 19, 2019
da0a5f9
genutil working
rigelrozanski Apr 19, 2019
092aab3
Merge remote-tracking branch 'origin/develop' into rigel/genesis-gene…
rigelrozanski Apr 22, 2019
d2de398
Merge branch 'rigel/genesis-generalization' into rigel/genesis-genera…
rigelrozanski Apr 22, 2019
ec35f4d
Merge branch 'rigel/genesis-generalization2' into rigel/genesis-gener…
rigelrozanski Apr 22, 2019
4d36066
refactored - happy with non-testing code in cmd/
rigelrozanski Apr 23, 2019
add17c4
...
rigelrozanski Apr 23, 2019
93fa001
lint fixes
rigelrozanski Apr 23, 2019
c7fcefd
Merge branch 'rigel/genesis-generalization2' into rigel/genesis-gener…
rigelrozanski Apr 23, 2019
7977e7e
Merge remote-tracking branch 'origin/develop' into rigel/genesis-gene…
rigelrozanski Apr 26, 2019
62a2b69
Merge branch 'rigel/genesis-generalization' into rigel/genesis-genera…
rigelrozanski Apr 26, 2019
e2b257d
Merge branch 'rigel/genesis-generalization2' into rigel/genesis-gener…
rigelrozanski Apr 26, 2019
87ed491
comment improvement
rigelrozanski Apr 26, 2019
84a0167
Merge branch 'rigel/genesis-generalization' into rigel/genesis-genera…
rigelrozanski Apr 26, 2019
8054543
Merge branch 'rigel/genesis-generalization2' into rigel/genesis-gener…
rigelrozanski Apr 26, 2019
988da1b
cli test fix
rigelrozanski Apr 26, 2019
8fafc42
Merge branch 'rigel/genesis-generalization2' into rigel/genesis-gener…
rigelrozanski Apr 26, 2019
c8ed8ca
compile housing
rigelrozanski Apr 26, 2019
7e7fc06
working through compile errors
rigelrozanski Apr 27, 2019
b15175f
working gettin' compilin'
rigelrozanski Apr 28, 2019
1806ce1
non-test code compiles
rigelrozanski Apr 28, 2019
13840bd
Merge branch 'origin/master' into rigel/genesis-generalization
rigelrozanski Apr 29, 2019
f387889
Merge branch 'rigel/genesis-generalization' into rigel/genesis-genera…
rigelrozanski Apr 29, 2019
0c6d7e4
Merge branch 'rigel/genesis-generalization2' into rigel/genesis-gener…
rigelrozanski Apr 29, 2019
dca8f25
move testnet to its own module
rigelrozanski Apr 30, 2019
7e52f2d
reworking tests
rigelrozanski Apr 30, 2019
8008e48
bez staging PR 1 comments
rigelrozanski May 1, 2019
19e9edb
Merge branch 'rigel/genesis-generalization' into rigel/genesis-genera…
rigelrozanski May 1, 2019
d58b14d
Merge branch 'rigel/genesis-generalization2' into rigel/genesis-gener…
rigelrozanski May 1, 2019
1bd95b5
concise module function-of names
rigelrozanski May 1, 2019
bad6c13
Merge remote-tracking branch 'origin/master' into rigel/genesis-gener…
rigelrozanski May 1, 2019
62c7941
Merge remote-tracking branch 'origin/master' into rigel/genesis-gener…
rigelrozanski May 2, 2019
bfdc03a
moved all tests from genesis_test.go to other genutil tests
rigelrozanski May 2, 2019
5dc633b
genaccounts package, add genutil and genaccounts to app.go
rigelrozanski May 2, 2019
2b94f53
docs for genutil genaccounts
rigelrozanski May 2, 2019
b5bb13a
genaccounts iterate fn
rigelrozanski May 2, 2019
5a4cadf
non-test code with genaccounts/ now compiles
rigelrozanski May 2, 2019
0784d6a
working test compiling
rigelrozanski May 2, 2019
bc53079
Merge remote-tracking branch 'origin/master' into rigel/genesis-gener…
rigelrozanski May 3, 2019
56316cc
debugging tests
rigelrozanski May 4, 2019
b86f595
resolved all make test compile errors
rigelrozanski May 4, 2019
94fd81e
test debuggin
rigelrozanski May 6, 2019
1c4f39f
resolved all unit tests, introduced param module
rigelrozanski May 6, 2019
0f934a4
Merge remote-tracking branch 'origin/master' into rigel/genesis-gener…
rigelrozanski May 6, 2019
54b1dd3
cli-test compile fixes
rigelrozanski May 6, 2019
e051eca
staking initialization bug
rigelrozanski May 6, 2019
f760f46
Merge remote-tracking branch 'origin/master' into rigel/genesis-gener…
rigelrozanski May 8, 2019
1a8340b
code comment improvements, changelog entries
rigelrozanski May 8, 2019
8948d80
BasicGaiaApp -> ModuleBasics
rigelrozanski May 8, 2019
2053b83
highlevel explanation in types/module.go
rigelrozanski May 8, 2019
ebc7af9
Merge remote-tracking branch 'origin/master' into rigel/genesis-gener…
rigelrozanski May 8, 2019
44ff940
@alexanderbez comment revisions
rigelrozanski May 9, 2019
47d4817
@fedekunze PR comments
rigelrozanski May 9, 2019
aaed9ac
@alexanderbez PR comments (x2)
rigelrozanski May 9, 2019
1c2c4df
@cwgoes comments (minor updates)
rigelrozanski May 10, 2019
5a622b5
@fedekunze suggestions
rigelrozanski May 10, 2019
4196712
Merge remote-tracking branch 'origin/master' into rigel/genesis-gener…
rigelrozanski May 10, 2019
7e2b0d8
Merge remote-tracking branch 'origin/master' into rigel/genesis-gener…
rigelrozanski May 13, 2019
eb5f7a5
panic on init with multiple validator updates from different modules
rigelrozanski May 13, 2019
5c0aa05
initchain panic makes validate genesis fail
rigelrozanski May 13, 2019
a45a6f3
AppModuleGenesis seperation
rigelrozanski May 13, 2019
7563a16
test
rigelrozanski May 13, 2019
36a37a8
remove init panic logic in validate genesis replaced with TODO
rigelrozanski May 14, 2019
5c428b8
Merge remote-tracking branch 'origin/master' into rigel/genesis-gener…
rigelrozanski May 15, 2019
4528cf3
set maxprocs to match system's GOMAXPROCS
alessio May 15, 2019
5349379
Update circleci
alessio May 15, 2019
50dde98
Cap maxprocs in CI to 4
alessio May 15, 2019
2bc901b
@alexanderbez recent comments addressed
rigelrozanski May 15, 2019
dc320a3
less blocks in twouble sims
rigelrozanski May 15, 2019
9bea7ee
runsim error output flag
rigelrozanski May 15, 2019
74a0042
-e on import_export as well
rigelrozanski May 15, 2019
e7f9c5a
error out
rigelrozanski May 15, 2019
6d9ddf1
Try to fix failures
alessio May 15, 2019
9187c71
runsim
rigelrozanski May 16, 2019
7cee51a
Merge remote-tracking branch 'origin/alessio/runsim-default-maxprocs'…
rigelrozanski May 16, 2019
85be41a
Merge remote-tracking branch 'origin/master' into rigel/genesis-gener…
rigelrozanski May 16, 2019
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
1 change: 1 addition & 0 deletions .pending/breaking/gaia/4159-use-module-patt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4159 use module pattern and module manager for initialization
1 change: 1 addition & 0 deletions .pending/breaking/sdk/4159-create-the-defa
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4159 create the default module patterns and module manager
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ test_sim_gaia_fast:

test_sim_gaia_import_export: runsim
@echo "Running Gaia import/export simulation. This may take several minutes..."
$(BINDIR)/runsim 50 5 TestGaiaImportExport
$(BINDIR)/runsim -e 25 5 TestGaiaImportExport

test_sim_gaia_simulation_after_import: runsim
@echo "Running Gaia simulation-after-import. This may take several minutes..."
$(BINDIR)/runsim 50 5 TestGaiaSimulationAfterImport
$(BINDIR)/runsim -e 25 5 TestGaiaSimulationAfterImport

test_sim_gaia_custom_genesis_multi_seed: runsim
@echo "Running multi-seed custom genesis simulation..."
Expand Down
25 changes: 21 additions & 4 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"reflect"
"runtime/debug"
"sort"
"strings"

"errors"
Expand Down Expand Up @@ -47,8 +48,8 @@ type BaseApp struct {
name string // application name from abci.Info
db dbm.DB // common DB backend
cms sdk.CommitMultiStore // Main (uncached) state
router Router // handle any kind of message
queryRouter QueryRouter // router for redirecting query calls
router sdk.Router // handle any kind of message
queryRouter sdk.QueryRouter // router for redirecting query calls
txDecoder sdk.TxDecoder // unmarshal []byte into sdk.Tx

// set upon LoadVersion or LoadLatestVersion.
Expand Down Expand Up @@ -246,7 +247,7 @@ func (app *BaseApp) setHaltHeight(height uint64) {
}

// Router returns the router of the BaseApp.
func (app *BaseApp) Router() Router {
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.
Expand All @@ -256,7 +257,7 @@ func (app *BaseApp) Router() Router {
}

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

// Seal seals a BaseApp. It prohibits any further modifications to a BaseApp.
func (app *BaseApp) Seal() { app.sealed = true }
Expand Down Expand Up @@ -368,6 +369,22 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC

res = app.initChainer(app.deliverState.ctx, req)

// sanity check
if len(req.Validators) > 0 {
if len(req.Validators) != len(res.Validators) {
panic(fmt.Errorf(
"len(RequestInitChain.Validators) != len(validators) (%d != %d)",
len(req.Validators), len(res.Validators)))
}
sort.Sort(abci.ValidatorUpdates(req.Validators))
sort.Sort(abci.ValidatorUpdates(res.Validators))
for i, val := range res.Validators {
if !val.Equal(req.Validators[i]) {
panic(fmt.Errorf("validators[%d] != req.Validators[%d] ", i, i))
}
}
}

// NOTE: We don't commit, but BeginBlock for block 1 starts from this
// deliverState.
return
Expand Down
10 changes: 3 additions & 7 deletions baseapp/queryrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// QueryRouter provides queryables for each query path.
type QueryRouter interface {
AddRoute(r string, h sdk.Querier) (rtr QueryRouter)
Route(path string) (h sdk.Querier)
}

type queryRouter struct {
routes map[string]sdk.Querier
}

var _ sdk.QueryRouter = NewQueryRouter()

// NewQueryRouter returns a reference to a new queryRouter.
//
// TODO: Either make the function private or make return type (queryRouter) public.
Expand All @@ -27,7 +23,7 @@ func NewQueryRouter() *queryRouter { // nolint: golint

// AddRoute adds a query path to the router with a given Querier. It will panic
// if a duplicate route is given. The route must be alphanumeric.
func (qrt *queryRouter) AddRoute(path string, q sdk.Querier) QueryRouter {
func (qrt *queryRouter) AddRoute(path string, q sdk.Querier) sdk.QueryRouter {
if !isAlphaNumeric(path) {
panic("route expressions can only contain alphanumeric characters")
}
Expand Down
10 changes: 3 additions & 7 deletions baseapp/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// Router provides handlers for each transaction type.
type Router interface {
AddRoute(r string, h sdk.Handler) (rtr Router)
Route(path string) (h sdk.Handler)
}

type router struct {
routes map[string]sdk.Handler
}

var _ sdk.Router = NewRouter()

// NewRouter returns a reference to a new router.
//
// TODO: Either make the function private or make return type (router) public.
Expand All @@ -27,7 +23,7 @@ func NewRouter() *router { // nolint: golint

// AddRoute adds a route path to the router with a given handler. The route must
// be alphanumeric.
func (rtr *router) AddRoute(path string, h sdk.Handler) Router {
func (rtr *router) AddRoute(path string, h sdk.Handler) sdk.Router {
if !isAlphaNumeric(path) {
panic("route expressions can only contain alphanumeric characters")
}
Expand Down
Loading