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

WIP: Jae/simulator improvements #2900

Merged
merged 9 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
66 changes: 38 additions & 28 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

[[override]]
name = "github.com/tendermint/iavl"
version = "=v0.11.1"
branch = "jae/reverseiterator"

[[override]]
name = "github.com/tendermint/tendermint"
version = "v0.26.1"
branch = "jae/reverseiterator"

## deps without releases:

Expand Down
24 changes: 16 additions & 8 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type BaseApp struct {
endBlocker sdk.EndBlocker // logic to run after all txs, and to determine valset changes
addrPeerFilter sdk.PeerFilter // filter peers by address and port
pubkeyPeerFilter sdk.PeerFilter // filter peers by public key
simulationMode bool // if true, MountStoresIAVL uses MountStoresDB for speed.

//--------------------
// Volatile
Expand Down Expand Up @@ -86,13 +87,14 @@ var _ abci.Application = (*BaseApp)(nil)
// Accepts variable number of option functions, which act on the BaseApp to set configuration choices
func NewBaseApp(name string, logger log.Logger, db dbm.DB, txDecoder sdk.TxDecoder, options ...func(*BaseApp)) *BaseApp {
app := &BaseApp{
Logger: logger,
name: name,
db: db,
cms: store.NewCommitMultiStore(db),
router: NewRouter(),
queryRouter: NewQueryRouter(),
txDecoder: txDecoder,
Logger: logger,
name: name,
db: db,
cms: store.NewCommitMultiStore(db),
router: NewRouter(),
queryRouter: NewQueryRouter(),
txDecoder: txDecoder,
simulationMode: false,
}
for _, option := range options {
option(app)
Expand All @@ -114,7 +116,13 @@ func (app *BaseApp) SetCommitMultiStoreTracer(w io.Writer) {
// Mount IAVL stores to the provided keys in the BaseApp multistore
func (app *BaseApp) MountStoresIAVL(keys ...*sdk.KVStoreKey) {
cwgoes marked this conversation as resolved.
Show resolved Hide resolved
for _, key := range keys {
app.MountStore(key, sdk.StoreTypeIAVL)
if !app.simulationMode {
app.MountStore(key, sdk.StoreTypeIAVL)
} else {
// StoreTypeDB doesn't do anything upon commit, and it doesn't
// retain history, but it's useful for faster simulation.
app.MountStore(key, sdk.StoreTypeDB)
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ func (app *BaseApp) SetPubKeyPeerFilter(pf sdk.PeerFilter) {
app.pubkeyPeerFilter = pf
}

func (app *BaseApp) SetSimulationMode() {
if app.sealed {
panic("SetSimulationMode() on sealed BaseApp")
}
app.simulationMode = true
}

//----------------------------------------
// TODO: move these out of this file?

func (app *BaseApp) Router() Router {
if app.sealed {
panic("Router() on sealed BaseApp")
Expand Down
21 changes: 12 additions & 9 deletions client/lcd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/log"
tmserver "github.com/tendermint/tendermint/rpc/lib/server"
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"

// Import statik for light client stuff
_ "github.com/cosmos/cosmos-sdk/client/lcd/statik"
Expand Down Expand Up @@ -87,9 +87,9 @@ func (rs *RestServer) Start(listenAddr string, sslHosts string,
"Insecure mode is temporarily disabled, please locally generate an " +
"SSL certificate to test. Support will be re-enabled soon!",
)
// listener, err = tmserver.StartHTTPServer(
// listener, err = rpcserver.StartHTTPServer(
// listenAddr, handler, logger,
// tmserver.Config{MaxOpenConnections: maxOpen},
// rpcserver.Config{MaxOpenConnections: maxOpen},
// )
// if err != nil {
// return
Expand Down Expand Up @@ -120,16 +120,19 @@ func (rs *RestServer) Start(listenAddr string, sslHosts string,
}()
}

rs.listener, err = tmserver.StartHTTPAndTLSServer(
listenAddr, rs.Mux,
certFile, keyFile,
rs.log,
tmserver.Config{MaxOpenConnections: maxOpen},
rs.listener, err = rpcserver.Listen(
listenAddr,
rpcserver.Config{MaxOpenConnections: maxOpen},
)
if err != nil {
return
}

go rpcserver.StartHTTPAndTLSServer(
rs.listener,
rs.Mux,
certFile, keyFile,
rs.log,
)
rs.log.Info(rs.fingerprint)
rs.log.Info("REST server started")
}
Expand Down
9 changes: 6 additions & 3 deletions client/lcd/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,16 @@ func startTM(
}

// startLCD starts the LCD.
//
// NOTE: This causes the thread to block.
func startLCD(logger log.Logger, listenAddr string, cdc *codec.Codec, t *testing.T) (net.Listener, error) {
rs := NewRestServer(cdc)
rs.setKeybase(GetTestKeyBase(t))
registerRoutes(rs)
return tmrpc.StartHTTPServer(listenAddr, rs.Mux, logger, tmrpc.Config{})
listener, err := tmrpc.Listen(listenAddr, tmrpc.Config{})
if err != nil {
return nil, err
}
go tmrpc.StartHTTPServer(listener, rs.Mux, logger)
return listener, nil
}

// NOTE: If making updates here also update cmd/gaia/cmd/gaiacli/main.go
Expand Down
8 changes: 7 additions & 1 deletion cmd/gaia/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,20 @@ func MakeCodec() *codec.Codec {

// application updates every end block
func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
tags := slashing.BeginBlocker(ctx, req, app.slashingKeeper)

// distribute rewards from previous block
distr.BeginBlocker(ctx, req, app.distrKeeper)

// mint new tokens for this new block
mint.BeginBlocker(ctx, app.mintKeeper)

// slash anyone who double signed.
// NOTE: This should happen after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool,
// so as to keep the CanWithdrawInvariant invariant.
// TODO: This should really happen at EndBlocker.
tags := slashing.BeginBlocker(ctx, req, app.slashingKeeper)
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved

return abci.ResponseBeginBlock{
Tags: tags.ToKVPairs(),
}
Expand Down
Loading