Prathamesh Musale
debfb82205
All checks were successful
SDK Tests / sdk_tests (push) Successful in 10m32s
SDK Tests / sdk_tests_auctions (push) Successful in 14m45s
Integration Tests / test-integration (push) Successful in 2m55s
E2E Tests / test-e2e (push) Successful in 4m7s
Unit Tests / test-unit (push) Successful in 2m48s
Publish on release / Run docker build and publish (release) Successful in 3m11s
SDK Tests / sdk_tests_nameservice_expiry (push) Successful in 9m33s
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675) Add `slashing` module for penalizing / jailing offline validators Reference: https://docs.cosmos.network/main/build/modules/slashing#liveness-tracking Note: Breaking change, an existing chain cannot be run with the updated binary Reviewed-on: #53 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
223 lines
7.0 KiB
Go
223 lines
7.0 KiB
Go
package app
|
|
|
|
import (
|
|
_ "embed"
|
|
"io"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
dbm "github.com/cosmos/cosmos-db"
|
|
|
|
"cosmossdk.io/core/appconfig"
|
|
"cosmossdk.io/depinject"
|
|
"cosmossdk.io/log"
|
|
storetypes "cosmossdk.io/store/types"
|
|
|
|
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
|
bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper"
|
|
onboardingkeeper "git.vdb.to/cerc-io/laconicd/x/onboarding/keeper"
|
|
registrykeeper "git.vdb.to/cerc-io/laconicd/x/registry/keeper"
|
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
"github.com/cosmos/cosmos-sdk/runtime"
|
|
"github.com/cosmos/cosmos-sdk/server"
|
|
"github.com/cosmos/cosmos-sdk/server/api"
|
|
"github.com/cosmos/cosmos-sdk/server/config"
|
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
|
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
|
|
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
|
|
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
|
"github.com/cosmos/cosmos-sdk/x/genutil"
|
|
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
|
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
|
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
|
|
|
_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
|
|
_ "git.vdb.to/cerc-io/laconicd/x/auction/module" // import for side-effects
|
|
_ "git.vdb.to/cerc-io/laconicd/x/bond/module" // import for side-effects
|
|
_ "git.vdb.to/cerc-io/laconicd/x/onboarding/module" // import for side-effects
|
|
_ "git.vdb.to/cerc-io/laconicd/x/registry/module" // import for side-effects
|
|
_ "github.com/cosmos/cosmos-sdk/x/auth" // import for side-effects
|
|
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects
|
|
_ "github.com/cosmos/cosmos-sdk/x/bank" // import for side-effects
|
|
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects
|
|
_ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects
|
|
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects
|
|
_ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects
|
|
_ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects
|
|
_ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects
|
|
)
|
|
|
|
// DefaultNodeHome default home directories for the application daemon
|
|
var DefaultNodeHome string
|
|
|
|
//go:embed app.yaml
|
|
var AppConfigYAML []byte
|
|
|
|
var (
|
|
_ runtime.AppI = (*LaconicApp)(nil)
|
|
_ servertypes.Application = (*LaconicApp)(nil)
|
|
)
|
|
|
|
// LaconicApp extends an ABCI application, but with most of its parameters exported.
|
|
// They are exported for convenience in creating helper functions, as object
|
|
// capabilities aren't needed for testing.
|
|
type LaconicApp struct {
|
|
*runtime.App
|
|
legacyAmino *codec.LegacyAmino
|
|
appCodec codec.Codec
|
|
txConfig client.TxConfig
|
|
interfaceRegistry codectypes.InterfaceRegistry
|
|
|
|
// keepers
|
|
AccountKeeper authkeeper.AccountKeeper
|
|
BankKeeper bankkeeper.Keeper
|
|
StakingKeeper *stakingkeeper.Keeper
|
|
SlashingKeeper slashingkeeper.Keeper
|
|
DistrKeeper distrkeeper.Keeper
|
|
CrisisKeeper *crisiskeeper.Keeper
|
|
ConsensusParamsKeeper consensuskeeper.Keeper
|
|
|
|
// laconic keepers
|
|
AuctionKeeper *auctionkeeper.Keeper // (Use * as per ProvideModule implementation)
|
|
BondKeeper *bondkeeper.Keeper
|
|
RegistryKeeper registrykeeper.Keeper
|
|
OnboardingKeeper *onboardingkeeper.Keeper
|
|
|
|
// simulation manager
|
|
sm *module.SimulationManager
|
|
}
|
|
|
|
func init() {
|
|
userHomeDir, err := os.UserHomeDir()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
DefaultNodeHome = filepath.Join(userHomeDir, ".laconicd")
|
|
}
|
|
|
|
// AppConfig returns the default app config.
|
|
func AppConfig() depinject.Config {
|
|
return depinject.Configs(
|
|
appconfig.LoadYAML(AppConfigYAML),
|
|
depinject.Supply(
|
|
// supply custom module basics
|
|
map[string]module.AppModuleBasic{
|
|
genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
|
|
},
|
|
),
|
|
)
|
|
}
|
|
|
|
// NewLaconicApp returns a reference to an initialized LaconicApp.
|
|
func NewLaconicApp(
|
|
logger log.Logger,
|
|
db dbm.DB,
|
|
traceStore io.Writer,
|
|
loadLatest bool,
|
|
appOpts servertypes.AppOptions,
|
|
baseAppOptions ...func(*baseapp.BaseApp),
|
|
) (*LaconicApp, error) {
|
|
var (
|
|
app = &LaconicApp{}
|
|
appBuilder *runtime.AppBuilder
|
|
)
|
|
|
|
if err := depinject.Inject(
|
|
depinject.Configs(
|
|
AppConfig(),
|
|
depinject.Supply(
|
|
logger,
|
|
appOpts,
|
|
),
|
|
),
|
|
&appBuilder,
|
|
&app.appCodec,
|
|
&app.legacyAmino,
|
|
&app.txConfig,
|
|
&app.interfaceRegistry,
|
|
&app.AccountKeeper,
|
|
&app.BankKeeper,
|
|
&app.StakingKeeper,
|
|
&app.SlashingKeeper,
|
|
&app.DistrKeeper,
|
|
&app.CrisisKeeper,
|
|
&app.ConsensusParamsKeeper,
|
|
&app.AuctionKeeper,
|
|
&app.BondKeeper,
|
|
&app.RegistryKeeper,
|
|
&app.OnboardingKeeper,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
app.App = appBuilder.Build(db, traceStore, baseAppOptions...)
|
|
|
|
// register streaming services
|
|
if err := app.RegisterStreamingServices(appOpts, app.kvStoreKeys()); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
/**** Module Options ****/
|
|
|
|
app.ModuleManager.RegisterInvariants(app.CrisisKeeper)
|
|
|
|
// create the simulation manager and define the order of the modules for deterministic simulations
|
|
// NOTE: this is not required apps that don't use the simulator for fuzz testing transactions
|
|
app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, make(map[string]module.AppModuleSimulation, 0))
|
|
app.sm.RegisterStoreDecoders()
|
|
|
|
if err := app.Load(loadLatest); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return app, nil
|
|
}
|
|
|
|
// LegacyAmino returns LaconicApp's amino codec.
|
|
func (app *LaconicApp) LegacyAmino() *codec.LegacyAmino {
|
|
return app.legacyAmino
|
|
}
|
|
|
|
// GetKey returns the KVStoreKey for the provided store key.
|
|
func (app *LaconicApp) GetKey(storeKey string) *storetypes.KVStoreKey {
|
|
sk := app.UnsafeFindStoreKey(storeKey)
|
|
kvStoreKey, ok := sk.(*storetypes.KVStoreKey)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
return kvStoreKey
|
|
}
|
|
|
|
func (app *LaconicApp) kvStoreKeys() map[string]*storetypes.KVStoreKey {
|
|
keys := make(map[string]*storetypes.KVStoreKey)
|
|
for _, k := range app.GetStoreKeys() {
|
|
if kv, ok := k.(*storetypes.KVStoreKey); ok {
|
|
keys[kv.Name()] = kv
|
|
}
|
|
}
|
|
|
|
return keys
|
|
}
|
|
|
|
// SimulationManager implements the SimulationApp interface
|
|
func (app *LaconicApp) SimulationManager() *module.SimulationManager {
|
|
return app.sm
|
|
}
|
|
|
|
// RegisterAPIRoutes registers all application module routes with the provided
|
|
// API server.
|
|
func (app *LaconicApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
|
|
app.App.RegisterAPIRoutes(apiSvr, apiConfig)
|
|
// register swagger API in app.go so that other applications can override easily
|
|
if err := server.RegisterSwaggerAPI(apiSvr.ClientCtx, apiSvr.Router, apiConfig.Swagger); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|