Skip to content

Commit

Permalink
Merge branch 'main' into PRT-820-extensions-pairing-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarom Swisa authored and Yarom Swisa committed Aug 1, 2023
2 parents fe91846 + ddb18aa commit fab1036
Show file tree
Hide file tree
Showing 170 changed files with 40,065 additions and 24,700 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
fetch-depth: '0'
- uses: actions/setup-go@v3
with:
go-version: 1.18.2
go-version: 1.19.11

# Install Ignite
- name: ignite install
run: git clone --depth 1 --branch v0.22.2 https://github.com/ignite/cli && cd cli && make install
run: git clone --depth 1 --branch v0.26.1 https://github.com/ignite/cli && cd cli && make install
# run: curl https://get.ignite.com/cli! | bash
- name: ignite version
run: ignite version
Expand Down
5 changes: 2 additions & 3 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (
func NewAnteHandler(accountKeeper ante.AccountKeeper, bankKeeper authtypes.BankKeeper, signModeHandler signing.SignModeHandler, feegrantKeeper ante.FeegrantKeeper, sigGasConsumer ante.SignatureVerificationGasConsumer) sdk.AnteHandler {
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewRejectExtensionOptionsDecorator(),
ante.NewMempoolFeeDecorator(),
ante.NewExtensionOptionsDecorator(nil),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(accountKeeper),
ante.NewConsumeGasForTxSizeDecorator(accountKeeper),
ante.NewDeductFeeDecorator(accountKeeper, bankKeeper, feegrantKeeper),
ante.NewDeductFeeDecorator(accountKeeper, bankKeeper, feegrantKeeper, nil),
ante.NewSetPubKeyDecorator(accountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(accountKeeper),
ante.NewSigGasConsumeDecorator(accountKeeper, sigGasConsumer),
Expand Down
85 changes: 49 additions & 36 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import (
"os"
"path/filepath"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/server/api"
Expand All @@ -21,7 +24,6 @@ import (
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
Expand Down Expand Up @@ -71,16 +73,16 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/ibc-go/v3/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v3/modules/core"
ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
ibcporttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
"github.com/cosmos/ibc-go/v6/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v6/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v6/modules/core"
ibcclient "github.com/cosmos/ibc-go/v6/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v6/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
ibcporttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
"github.com/lavanet/lava/app/keepers"
appparams "github.com/lavanet/lava/app/params"
"github.com/lavanet/lava/app/upgrades"
Expand Down Expand Up @@ -132,6 +134,7 @@ const (
var Upgrades = []upgrades.Upgrade{
upgrades.Upgrade_0_20_1,
upgrades.Upgrade_0_20_2,
upgrades.Upgrade_0_20_3,
}

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
Expand All @@ -143,8 +146,8 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
govProposalHandlers = append(govProposalHandlers,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.ProposalHandler,
upgradeclient.CancelProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
specmoduleclient.SpecAddProposalHandler,
Expand All @@ -171,7 +174,7 @@ var (
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()...),
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
Expand Down Expand Up @@ -239,9 +242,9 @@ type LavaApp struct {
invCheckPeriod uint

// keys to access the substores
keys map[string]*sdk.KVStoreKey
tkeys map[string]*sdk.TransientStoreKey
memKeys map[string]*sdk.MemoryStoreKey
keys map[string]*storetypes.KVStoreKey
tkeys map[string]*storetypes.TransientStoreKey
memKeys map[string]*storetypes.MemoryStoreKey

// this line is used by starport scaffolding # stargate/app/keeperDeclaration

Expand Down Expand Up @@ -310,7 +313,7 @@ func New(
app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])

// set the BaseApp's parameter store
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()))
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()))

// add capability keeper and ScopeToModule for ibc module
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
Expand All @@ -323,6 +326,7 @@ func New(
// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms,
sdk.GetConfig().GetBech32AccountAddrPrefix(),
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(),
Expand All @@ -336,7 +340,7 @@ func New(
)
app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
&stakingKeeper, authtypes.FeeCollectorName,
)
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
Expand All @@ -346,7 +350,14 @@ func New(
)

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)
app.UpgradeKeeper = upgradekeeper.NewKeeper(
skipUpgradeHeights,
keys[upgradetypes.StoreKey],
appCodec,
homePath,
app.BaseApp,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// Upgrade the KVStoreKey after upgrade keeper initialization
app.setupUpgradeStoreLoaders()
Expand Down Expand Up @@ -397,8 +408,8 @@ func New(
plansModule := plansmodule.NewAppModule(appCodec, app.PlansKeeper)

// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
govRouter := v1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, v1beta1.ProposalHandler).
//
// user defined
AddRoute(specmoduletypes.ProposalsRouterKey, specmodule.NewSpecProposalsHandler(app.SpecKeeper)).
Expand Down Expand Up @@ -429,9 +440,10 @@ func New(
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper

govConfig := govtypes.DefaultConfig()
app.GovKeeper = govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter,
&stakingKeeper, govRouter, app.MsgServiceRouter(), govConfig,
)

app.ProjectsKeeper = *projectsmodulekeeper.NewKeeper(
Expand Down Expand Up @@ -529,7 +541,7 @@ func New(
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
Expand Down Expand Up @@ -660,7 +672,7 @@ func New(
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
Expand Down Expand Up @@ -807,21 +819,21 @@ func (app *LavaApp) InterfaceRegistry() types.InterfaceRegistry {
// GetKey returns the KVStoreKey for the provided store key.
//
// NOTE: This is solely to be used for testing purposes.
func (app *LavaApp) GetKey(storeKey string) *sdk.KVStoreKey {
func (app *LavaApp) GetKey(storeKey string) *storetypes.KVStoreKey {
return app.keys[storeKey]
}

// GetTKey returns the TransientStoreKey for the provided store key.
//
// NOTE: This is solely to be used for testing purposes.
func (app *LavaApp) GetTKey(storeKey string) *sdk.TransientStoreKey {
func (app *LavaApp) GetTKey(storeKey string) *storetypes.TransientStoreKey {
return app.tkeys[storeKey]
}

// GetMemKey returns the MemStoreKey for the provided mem key.
//
// NOTE: This is solely used for testing purposes.
func (app *LavaApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey {
func (app *LavaApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey {
return app.memKeys[storeKey]
}

Expand All @@ -837,16 +849,12 @@ func (app *LavaApp) GetSubspace(moduleName string) paramstypes.Subspace {
// API server.
func (app *LavaApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx
rpc.RegisterRoutes(clientCtx, apiSvr.Router)
// Register legacy tx routes.
authrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router)
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// register app's OpenAPI routes.
Expand All @@ -860,7 +868,12 @@ func (app *LavaApp) RegisterTxService(clientCtx client.Context) {

// RegisterTendermintService implements the Application.RegisterTendermintService method.
func (app *LavaApp) RegisterTendermintService(clientCtx client.Context) {
tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry)
tmservice.RegisterTendermintService(
clientCtx,
app.BaseApp.GRPCQueryRouter(),
app.interfaceRegistry,
app.Query,
)
}

// GetMaccPerms returns a copy of the module account permissions
Expand All @@ -873,7 +886,7 @@ func GetMaccPerms() map[string][]string {
}

// initParamsKeeper init params keeper and its subspaces
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper {
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

paramsKeeper.Subspace(authtypes.ModuleName)
Expand All @@ -882,7 +895,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(v1.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
Expand Down
4 changes: 2 additions & 2 deletions app/keepers/lavaKeepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
ibctransferkeeper "github.com/cosmos/ibc-go/v6/modules/apps/transfer/keeper"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
conflictmodulekeeper "github.com/lavanet/lava/x/conflict/keeper"
downtimekeeper "github.com/lavanet/lava/x/downtime/keeper"
epochstoragemodulekeeper "github.com/lavanet/lava/x/epochstorage/keeper"
Expand Down
6 changes: 6 additions & 0 deletions app/upgrades/empty_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ var Upgrade_0_20_2 = Upgrade{
CreateUpgradeHandler: defaultUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}

var Upgrade_0_20_3 = Upgrade{
UpgradeName: "v0.20.3",
CreateUpgradeHandler: defaultUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
7 changes: 5 additions & 2 deletions cmd/lavad/cmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
}

// attempt to lookup address from Keybase if no address was provided
kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, clientCtx.HomeDir, inBuf)
kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, clientCtx.HomeDir, inBuf, clientCtx.Codec)
if err != nil {
return err
}
Expand All @@ -69,7 +69,10 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
return fmt.Errorf("failed to get address from Keybase: %w", err)
}

addr = info.GetAddress()
addr, err = info.GetAddress()
if err != nil {
return fmt.Errorf("failed to get address from Info: %w", err)
}
}

vestingStart, err := cmd.Flags().GetInt64(flagVestingStart)
Expand Down
17 changes: 11 additions & 6 deletions cmd/lavad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"path/filepath"
"strings"

snapshotoptions "github.com/cosmos/cosmos-sdk/snapshots/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
Expand Down Expand Up @@ -74,7 +76,7 @@ func NewRootCmd() (*cobra.Command, appparams.EncodingConfig) {

customAppTemplate, customAppConfig := initAppConfig()
return server.InterceptConfigsPreRunHandler(
cmd, customAppTemplate, customAppConfig,
cmd, customAppTemplate, customAppConfig, tmcfg.DefaultConfig(),
)
},
}
Expand Down Expand Up @@ -123,7 +125,7 @@ func NewLavaProtocolRootCmd() *cobra.Command {

customAppTemplate, customAppConfig := initAppConfig()
return server.InterceptConfigsPreRunHandler(
cmd, customAppTemplate, customAppConfig,
cmd, customAppTemplate, customAppConfig, tmcfg.DefaultConfig(),
)
},
}
Expand Down Expand Up @@ -307,7 +309,7 @@ func (a appCreator) newApp(

snapshotDir := filepath.Join(
cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots")
snapshotDB, err := sdk.NewLevelDB("metadata", snapshotDir)
snapshotDB, err := dbm.NewDB("metadata", dbm.GoLevelDBBackend, snapshotDir)
if err != nil {
panic(err)
}
Expand All @@ -316,6 +318,11 @@ func (a appCreator) newApp(
panic(err)
}

snapshotOptions := snapshotoptions.NewSnapshotOptions(
cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval)),
cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)),
)

return app.New(
logger,
db,
Expand All @@ -334,9 +341,7 @@ func (a appCreator) newApp(
baseapp.SetInterBlockCache(cache),
baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
baseapp.SetSnapshotStore(snapshotStore),
baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))),
baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))),
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/lavad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func main() {
testCmd.AddCommand(rpcprovider.CreateTestRPCProviderCobraCommand())
testCmd.AddCommand(rpcprovider.CreateTestRPCProviderCACertificateCobraCommand())
testCmd.AddCommand(statetracker.CreateEventsCobraCommand())
if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
switch e := err.(type) {
case server.ErrorCode:
os.Exit(e.Code)
Expand Down
Loading

0 comments on commit fab1036

Please sign in to comment.