Skip to content

Commit

Permalink
feat: upgraded the app with scheduler module to SDK v0.50
Browse files Browse the repository at this point in the history
  • Loading branch information
deepan95dev committed Dec 14, 2023
1 parent 8a60bd6 commit 307adc5
Show file tree
Hide file tree
Showing 25 changed files with 880 additions and 655 deletions.
57 changes: 29 additions & 28 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"path/filepath"
"strings"

xchain "github.com/palomachain/paloma/internal/x-chain"

"cosmossdk.io/log"
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
Expand Down Expand Up @@ -140,9 +142,10 @@ import (
// palomamodule "github.com/palomachain/paloma/x/paloma"
// palomamodulekeeper "github.com/palomachain/paloma/x/paloma/keeper"
// palomamoduletypes "github.com/palomachain/paloma/x/paloma/types"
// schedulermodule "github.com/palomachain/paloma/x/scheduler"
// schedulermodulekeeper "github.com/palomachain/paloma/x/scheduler/keeper"
// schedulermoduletypes "github.com/palomachain/paloma/x/scheduler/types"
schedulermodule "github.com/palomachain/paloma/x/scheduler"
schedulermodulekeeper "github.com/palomachain/paloma/x/scheduler/keeper"
schedulermoduletypes "github.com/palomachain/paloma/x/scheduler/types"

// treasurymodule "github.com/palomachain/paloma/x/treasury"
// treasuryclient "github.com/palomachain/paloma/x/treasury/client"
// treasurymodulekeeper "github.com/palomachain/paloma/x/treasury/keeper"
Expand Down Expand Up @@ -243,7 +246,7 @@ type App struct {
ICAHostKeeper icahostkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper

// SchedulerKeeper schedulermodulekeeper.Keeper
SchedulerKeeper schedulermodulekeeper.Keeper
// ConsensusKeeper consensusmodulekeeper.Keeper
// ValsetKeeper valsetmodulekeeper.Keeper
// PalomaKeeper palomamodulekeeper.Keeper
Expand Down Expand Up @@ -321,7 +324,7 @@ func New(
icahosttypes.StoreKey,
icacontrollertypes.StoreKey,
capabilitytypes.StoreKey,
// schedulermoduletypes.StoreKey,
schedulermoduletypes.StoreKey,
// consensusmoduletypes.StoreKey,
// valsetmoduletypes.StoreKey,
// treasurymoduletypes.StoreKey,
Expand Down Expand Up @@ -598,17 +601,15 @@ func New(
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper

// app.SchedulerKeeper = *schedulermodulekeeper.NewKeeper(
// appCodec,
// keys[schedulermoduletypes.StoreKey],
// memKeys[schedulermoduletypes.MemStoreKey],
// app.GetSubspace(schedulermoduletypes.ModuleName),
// app.AccountKeeper,
// app.EvmKeeper,
// []xchain.Bridge{
// app.EvmKeeper,
// },
// )
app.SchedulerKeeper = *schedulermodulekeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[evidencetypes.StoreKey]),
app.AccountKeeper,
app.EvmKeeper,
[]xchain.Bridge{
app.EvmKeeper,
},
)

// app.TreasuryKeeper = *treasurymodulekeeper.NewKeeper(
// appCodec,
Expand Down Expand Up @@ -674,12 +675,12 @@ func New(
wasmConfig,
wasmAvailableCapabilities,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
//wasmkeeper.WithMessageHandlerDecorator(func(old wasmkeeper.Messenger) wasmkeeper.Messenger {
// return wasmkeeper.NewMessageHandlerChain(
// old,
// app.SchedulerKeeper.ExecuteWasmJobEventListener(),
// )
//}),
wasmkeeper.WithMessageHandlerDecorator(func(old wasmkeeper.Messenger) wasmkeeper.Messenger {
return wasmkeeper.NewMessageHandlerChain(
old,
app.SchedulerKeeper.ExecuteWasmJobEventListener(),
)
}),
)

// register wasm gov proposal types
Expand Down Expand Up @@ -737,7 +738,7 @@ func New(
evmModule := evm.NewAppModule(appCodec, app.EvmKeeper, app.AccountKeeper, app.BankKeeper)
// consensusModule := consensusmodule.NewAppModule(appCodec, app.ConsensusKeeper, app.AccountKeeper, app.BankKeeper)
// valsetModule := valsetmodule.NewAppModule(appCodec, app.ValsetKeeper, app.AccountKeeper, app.BankKeeper)
// schedulerModule := schedulermodule.NewAppModule(appCodec, app.SchedulerKeeper, app.AccountKeeper, app.BankKeeper)
schedulerModule := schedulermodule.NewAppModule(appCodec, app.SchedulerKeeper, app.AccountKeeper, app.BankKeeper)
// palomaModule := palomamodule.NewAppModule(appCodec, app.PalomaKeeper, app.AccountKeeper, app.BankKeeper)
// gravityModule := gravitymodule.NewAppModule(appCodec, app.GravityKeeper, app.BankKeeper)
// treasuryModule := treasurymodule.NewAppModule(appCodec, app.TreasuryKeeper, app.AccountKeeper, app.BankKeeper)
Expand All @@ -762,7 +763,7 @@ func New(
upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()),
evidence.NewAppModule(app.EvidenceKeeper),
params.NewAppModule(app.ParamsKeeper),
// schedulerModule,
schedulerModule,
// consensusModule,
// valsetModule,
evmModule,
Expand Down Expand Up @@ -802,7 +803,7 @@ func New(
evidencetypes.ModuleName,
stakingtypes.ModuleName,
feegrant.ModuleName,
// schedulermoduletypes.ModuleName,
schedulermoduletypes.ModuleName,
// consensusmoduletypes.ModuleName,
govtypes.ModuleName,
crisistypes.ModuleName,
Expand Down Expand Up @@ -830,7 +831,7 @@ func New(
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
// schedulermoduletypes.ModuleName,
schedulermoduletypes.ModuleName,
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
minttypes.ModuleName,
Expand Down Expand Up @@ -882,7 +883,7 @@ func New(
genutiltypes.ModuleName,
evidencetypes.ModuleName,
ibctransfertypes.ModuleName,
// schedulermoduletypes.ModuleName,
schedulermoduletypes.ModuleName,
// consensusmoduletypes.ModuleName,
// valsetmoduletypes.ModuleName,
// palomamoduletypes.ModuleName,
Expand Down Expand Up @@ -1138,7 +1139,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
// paramsKeeper.Subspace(schedulermoduletypes.ModuleName)
paramsKeeper.Subspace(schedulermoduletypes.ModuleName)
// paramsKeeper.Subspace(consensusmoduletypes.ModuleName)
// paramsKeeper.Subspace(valsetmoduletypes.ModuleName)
paramsKeeper.Subspace(wasmtypes.ModuleName)
Expand Down
5 changes: 3 additions & 2 deletions internal/x-chain/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xchain

import (
"context"
"github.com/VolumeFi/whoops"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -47,8 +48,8 @@ type JobConfiguration struct {
}

type Jobber interface {
VerifyJob(ctx sdk.Context, definition []byte, payload []byte, refID ReferenceID) (err error)
ExecuteJob(ctx sdk.Context, jcfg *JobConfiguration) (msgID uint64, err error)
VerifyJob(ctx context.Context, definition []byte, payload []byte, refID ReferenceID) (err error)
ExecuteJob(ctx context.Context, jcfg *JobConfiguration) (msgID uint64, err error)
}

//go:generate mockery --name=FundCollecter
Expand Down
6 changes: 4 additions & 2 deletions util/keeper/emit_events.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand All @@ -26,8 +27,9 @@ func ModuleNameFunc(moduleName string) HasModuleName {
})
}

func EmitEvent(k HasModuleName, ctx sdk.Context, name string, attrs ...sdk.Attribute) {
ctx.EventManager().EmitEvent(
func EmitEvent(k HasModuleName, ctx context.Context, name string, attrs ...sdk.Attribute) {
sdkctx := sdk.UnwrapSDKContext(ctx)
sdkctx.EventManager().EmitEvent(
sdk.NewEvent(sdk.EventTypeMessage,
append([]sdk.Attribute{
sdk.NewAttribute(sdk.AttributeKeyModule, k.ModuleName()),
Expand Down
3 changes: 2 additions & 1 deletion util/keeper/id_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
// A helper methods to help with incrementing and getting the last IDs for a given name.

import (
"context"
"encoding/binary"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -30,7 +31,7 @@ func NewIDGenerator(sg StoreGetter, idkey []byte) IDGenerator {

// getLastID returns the last id that was inserted for the given name.
// If one does not exist, then it returns 0,
func (i IDGenerator) GetLastID(ctx sdk.Context, name string) uint64 {
func (i IDGenerator) GetLastID(ctx context.Context, name string) uint64 {
store := i.sg.Store(ctx)
prefixKey := i.nextKeyPrefix([]byte(name))
if !store.Has(prefixKey) {
Expand Down
7 changes: 3 additions & 4 deletions util/keeper/save_load.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package keeper

import (
"github.com/cosmos/gogoproto/proto"
"reflect"

"github.com/cosmos/cosmos-sdk/codec"
storetypes "cosmossdk.io/store/types"

)

func Save(store storetypes.KVStore, pm ProtoMarshaler, key []byte, val codec.ProtoMarshaler) error {
func Save(store storetypes.KVStore, pm ProtoMarshaler, key []byte, val proto.Message) error {
bytez, err := pm.Marshal(val)
if err != nil {
return err
Expand All @@ -17,7 +16,7 @@ func Save(store storetypes.KVStore, pm ProtoMarshaler, key []byte, val codec.Pro
return nil
}

func Load[T codec.ProtoMarshaler](store storetypes.KVStore, pu ProtoUnmarshaler, key []byte) (T, error) {
func Load[T proto.Message](store storetypes.KVStore, pu ProtoUnmarshaler, key []byte) (T, error) {
var val T
if key == nil {
return val, ErrNotFound.Format(val, key)
Expand Down
3 changes: 0 additions & 3 deletions util/liblog/liblog.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ type Logr interface {
func FromSDKLogger(l log.Logger) Logr {
return &lgwr{l}
}
func (l *lgwr) Impl() interface{} {
return l
}

type lgwr struct {
l log.Logger
Expand Down
8 changes: 4 additions & 4 deletions util/wasm/messenger.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package wasm

import (
// wasmvmtypes "github.com/CosmWasm/wasmvm/types"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type MessengerFnc func(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string) (events []sdk.Event, data [][]byte, err error)
type MessengerFnc func(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error)

func (m MessengerFnc) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string) (events []sdk.Event, data [][]byte, err error) {
return m(ctx, contractAddr, contractIBCPortID)
func (m MessengerFnc) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error) {
return m(ctx, contractAddr, contractIBCPortID, msg)
}
63 changes: 31 additions & 32 deletions x/evm/types/tx.pb.go

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

3 changes: 1 addition & 2 deletions x/gravity/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/palomachain/paloma/x/gravity/keeper"
Expand Down Expand Up @@ -58,7 +57,7 @@ func TestNonValidatorBatchConfirm(t *testing.T) {
require.NoError(t, err)

// Run the staking endblocker to ensure valset is correct in state
staking.EndBlocker(input.Context, &input.StakingKeeper)
stakingkeeper.EndBlocker(input.Context, &input.StakingKeeper)

ethAddr, err := types.NewEthAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")
if err != nil {
Expand Down
Loading

0 comments on commit 307adc5

Please sign in to comment.