Skip to content

Commit

Permalink
Merge branch 'main' into fixate_rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarom Swisa authored and Yarom Swisa committed Aug 29, 2022
2 parents 0313c13 + e771a19 commit 8a580a0
Show file tree
Hide file tree
Showing 91 changed files with 16,817 additions and 1,583 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ jobs:
######################################################
- name: Run Lava E2E Tests IGNITE VERSION:0.22.1 -timeout 960s
run: go test ./testutil/e2e/ -v -timeout 960s # 11mins

# Show ETH Logs
- name: cat clientEth.log
run: cat ./testutil/e2e/logs/clientEth.log
- name: cat providers_eth.log
run: cat ./testutil/e2e/logs/providers_eth.log

# Show OSMOSIS Logs
- name: cat clientOsmoRest.log
Expand All @@ -72,6 +66,24 @@ jobs:
run: cat ./testutil/e2e/logs/clientOsmoRPC.log
- name: cat providers_osmosis.log
run: cat ./testutil/e2e/logs/providers_eth.log

# Show ETH Logs
- name: cat clientETH.log
run: cat ./testutil/e2e/logs/clientETH.log
- name: cat providers_eth.log
run: cat ./testutil/e2e/logs/providers_eth.log

# Show GTH Logs
- name: cat clientGTH.log
run: cat ./testutil/e2e/logs/clientGTH.log
- name: cat providers_gth.log
run: cat ./testutil/e2e/logs/providers_gth.log

# Show FTM Logs
- name: cat clientFTM.log
run: cat ./testutil/e2e/logs/clientFTM.log
- name: cat providers_ftm.log
run: cat ./testutil/e2e/logs/providers_ftm.log
# - name: docker build
# run: docker build -t lava-docker scripts/docker

Expand Down
99 changes: 74 additions & 25 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"fmt"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -83,6 +84,7 @@ import (
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
"github.com/ignite-hq/cli/ignite/pkg/cosmoscmd"
"github.com/ignite-hq/cli/ignite/pkg/openapiconsole"
"github.com/lavanet/lava/app/upgrades"
"github.com/lavanet/lava/docs"
conflictmodule "github.com/lavanet/lava/x/conflict"
conflictmodulekeeper "github.com/lavanet/lava/x/conflict/keeper"
Expand Down Expand Up @@ -112,6 +114,11 @@ const (
Name = "lava"
)

var (
// add here future upgrades (upgrades.Upgrade)
Upgrades = []upgrades.Upgrade{}
)

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals

func getGovProposalHandlers() []govclient.ProposalHandler {
Expand Down Expand Up @@ -182,9 +189,9 @@ var (
)

var (
_ cosmoscmd.App = (*App)(nil)
_ servertypes.Application = (*App)(nil)
_ simapp.App = (*App)(nil)
_ cosmoscmd.App = (*LavaApp)(nil)
_ servertypes.Application = (*LavaApp)(nil)
_ simapp.App = (*LavaApp)(nil)
)

func init() {
Expand All @@ -196,10 +203,10 @@ func init() {
DefaultNodeHome = filepath.Join(userHomeDir, "."+Name)
}

// App extends an ABCI application, but with most of its parameters exported.
// LavaApp 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 App struct {
type LavaApp struct {
*baseapp.BaseApp

cdc *codec.LegacyAmino
Expand Down Expand Up @@ -248,6 +255,9 @@ type App struct {

// sm is the simulation manager
sm *module.SimulationManager

// module configurator.
configurator module.Configurator
}

// New returns a reference to an initialized blockchain app
Expand Down Expand Up @@ -286,7 +296,7 @@ func New(
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)

app := &App{
app := &LavaApp{
BaseApp: bApp,
cdc: cdc,
appCodec: appCodec,
Expand Down Expand Up @@ -338,6 +348,9 @@ func New(
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)

// Upgrade the KVStoreKey after upgrade keeper initialization
app.setupUpgradeStoreLoaders()

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper = *stakingKeeper.SetHooks(
Expand Down Expand Up @@ -564,7 +577,11 @@ func New(

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterServices(module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()))
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

// setupUpgradeHandlers. must be called before LoadLatestVersion as storeloader is sealed after that
app.setupUpgradeHandlers()

// create the simulation manager and define the order of the modules for deterministic simulations
app.sm = module.NewSimulationManager(
Expand Down Expand Up @@ -627,24 +644,56 @@ func New(
return app
}

// setupUpgradeStoreLoaders when intoducing new modules.
func (app *LavaApp) setupUpgradeStoreLoaders() {
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err))
}

if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
return
}

for _, upgrade := range Upgrades {
if upgradeInfo.Name == upgrade.UpgradeName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades))
}
}
}

// setupUpgradeHandlers when modifing already existing modules
func (app *LavaApp) setupUpgradeHandlers() {
for _, upgrade := range Upgrades {
app.UpgradeKeeper.SetUpgradeHandler(
upgrade.UpgradeName,
upgrade.CreateUpgradeHandler(
app.mm,
app.configurator,
app.BaseApp,
),
)
}
}

// Name returns the name of the App
func (app *App) Name() string { return app.BaseApp.Name() }
func (app *LavaApp) Name() string { return app.BaseApp.Name() }

// GetBaseApp returns the base app of the application
func (app App) GetBaseApp() *baseapp.BaseApp { return app.BaseApp }
func (app LavaApp) GetBaseApp() *baseapp.BaseApp { return app.BaseApp }

// BeginBlocker application updates every begin block
func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
func (app *LavaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
return app.mm.BeginBlock(ctx, req)
}

// EndBlocker application updates every end block
func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
func (app *LavaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
return app.mm.EndBlock(ctx, req)
}

// InitChainer application update at chain initialization
func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
func (app *LavaApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
var genesisState GenesisState
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
Expand All @@ -654,12 +703,12 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
}

// LoadHeight loads a particular height
func (app *App) LoadHeight(height int64) error {
func (app *LavaApp) LoadHeight(height int64) error {
return app.LoadVersion(height)
}

// ModuleAccountAddrs returns all the app's module account addresses.
func (app *App) ModuleAccountAddrs() map[string]bool {
func (app *LavaApp) ModuleAccountAddrs() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range maccPerms {
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
Expand All @@ -672,55 +721,55 @@ func (app *App) ModuleAccountAddrs() map[string]bool {
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
// for modules to register their own custom testing types.
func (app *App) LegacyAmino() *codec.LegacyAmino {
func (app *LavaApp) LegacyAmino() *codec.LegacyAmino {
return app.cdc
}

// AppCodec returns an app codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
// for modules to register their own custom testing types.
func (app *App) AppCodec() codec.Codec {
func (app *LavaApp) AppCodec() codec.Codec {
return app.appCodec
}

// InterfaceRegistry returns an InterfaceRegistry
func (app *App) InterfaceRegistry() types.InterfaceRegistry {
func (app *LavaApp) InterfaceRegistry() types.InterfaceRegistry {
return app.interfaceRegistry
}

// GetKey returns the KVStoreKey for the provided store key.
//
// NOTE: This is solely to be used for testing purposes.
func (app *App) GetKey(storeKey string) *sdk.KVStoreKey {
func (app *LavaApp) GetKey(storeKey string) *sdk.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 *App) GetTKey(storeKey string) *sdk.TransientStoreKey {
func (app *LavaApp) GetTKey(storeKey string) *sdk.TransientStoreKey {
return app.tkeys[storeKey]
}

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

// GetSubspace returns a param subspace for a given module name.
//
// NOTE: This is solely to be used for testing purposes.
func (app *App) GetSubspace(moduleName string) paramstypes.Subspace {
func (app *LavaApp) GetSubspace(moduleName string) paramstypes.Subspace {
subspace, _ := app.ParamsKeeper.GetSubspace(moduleName)
return subspace
}

// RegisterAPIRoutes registers all application module routes with the provided
// API server.
func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
func (app *LavaApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx
rpc.RegisterRoutes(clientCtx, apiSvr.Router)
// Register legacy tx routes.
Expand All @@ -740,12 +789,12 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig
}

// RegisterTxService implements the Application.RegisterTxService method.
func (app *App) RegisterTxService(clientCtx client.Context) {
func (app *LavaApp) RegisterTxService(clientCtx client.Context) {
authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry)
}

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

Expand Down Expand Up @@ -782,6 +831,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
}

// SimulationManager implements the SimulationApp interface
func (app *App) SimulationManager() *module.SimulationManager {
func (app *LavaApp) SimulationManager() *module.SimulationManager {
return app.sm
}
4 changes: 2 additions & 2 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

// ExportAppStateAndValidators exports the state of the application for a genesis
// file.
func (app *App) ExportAppStateAndValidators(
func (app *LavaApp) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string,
) (servertypes.ExportedApp, error) {

Expand Down Expand Up @@ -51,7 +51,7 @@ func (app *App) ExportAppStateAndValidators(
// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favour of export at a block height
func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
func (app *LavaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false

// check if there is a allowed address list
Expand Down
21 changes: 21 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package upgrades

import (
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
abci "github.com/tendermint/tendermint/abci/types"
)

type BaseAppParamManager interface {
GetConsensusParams(ctx sdk.Context) *abci.ConsensusParams
StoreConsensusParams(ctx sdk.Context, cp *abci.ConsensusParams)
}

type Upgrade struct {
// Upgrade version name.
UpgradeName string
CreateUpgradeHandler func(*module.Manager, module.Configurator, BaseAppParamManager) upgradetypes.UpgradeHandler
StoreUpgrades store.StoreUpgrades
}
5 changes: 5 additions & 0 deletions cmd/lavad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"strconv"
"strings"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand All @@ -13,6 +14,7 @@ import (
"github.com/ignite-hq/cli/ignite/pkg/cosmoscmd"
"github.com/lavanet/lava/app"
"github.com/lavanet/lava/relayer"
"github.com/lavanet/lava/utils"
"github.com/spf13/cobra"
)

Expand All @@ -33,6 +35,7 @@ func main() {
Long: `server`,
Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) error {
utils.LavaFormatInfo("Provider process started", &map[string]string{"args": strings.Join(args, ",")})
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
Expand Down Expand Up @@ -67,6 +70,7 @@ func main() {
Long: `portal server`,
Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error {
utils.LavaFormatInfo("Gateway Proxy process started", &map[string]string{"args": strings.Join(args, ",")})
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
Expand Down Expand Up @@ -94,6 +98,7 @@ func main() {
Long: `test client`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
utils.LavaFormatInfo("Test consumer process started", &map[string]string{"args": strings.Join(args, ",")})
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ accounts:
coins: ["200000000ulava"]
- name: user3
coins: ["200000000ulava"]
- name: user4
coins: ["200000000ulava"]
- name: servicer1
coins: ["200000000ulava"]
- name: servicer2
Expand Down
Loading

0 comments on commit 8a580a0

Please sign in to comment.