Skip to content

Commit

Permalink
Merge pull request #757 from cybercongress/v4-clock-module
Browse files Browse the repository at this point in the history
Addec clock (cron) module
  • Loading branch information
cyborgshead authored Jul 25, 2024
2 parents 563c22c + 474a601 commit 043b31b
Show file tree
Hide file tree
Showing 55 changed files with 9,614 additions and 1,034 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ contracts
# Scripts
*.mjs

std_test.wasm
*.wasm
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protoVer=0.13.1
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

proto-all: proto-format proto-lint proto-gen format
proto-all: proto-format proto-lint proto-gen

proto-gen:
@echo "Generating Protobuf files"
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/global_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

const codespace = "juno-global"
const codespace = "cyber-global"

var (
ErrInvalidAddress = sdkerrors.ErrInvalidAddress
Expand Down
14 changes: 14 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/cosmos/cosmos-sdk/x/nft"
nftkeeper "github.com/cosmos/cosmos-sdk/x/nft/keeper"
clocktypes "github.com/cybercongress/go-cyber/v4/x/clock/types"
tokenfactorykeeper "github.com/cybercongress/go-cyber/v4/x/tokenfactory/keeper"
tokenfactorytypes "github.com/cybercongress/go-cyber/v4/x/tokenfactory/types"
"path/filepath"
Expand Down Expand Up @@ -87,6 +88,8 @@ import (
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"

govv1beta "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

clockkeeper "github.com/cybercongress/go-cyber/v4/x/clock/keeper"
)

var (
Expand Down Expand Up @@ -156,6 +159,8 @@ type AppKeepers struct {
GridKeeper gridkeeper.Keeper
DmnKeeper *dmnkeeper.Keeper
ResourcesKeeper resourceskeeper.Keeper
ContractKeeper wasmtypes.ContractOpsKeeper
ClockKeeper clockkeeper.Keeper

ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -523,6 +528,15 @@ func NewAppKeepers(
wasmOpts...,
)

appKeepers.ContractKeeper = wasmkeeper.NewDefaultPermissionKeeper(&appKeepers.WasmKeeper)
appKeepers.ClockKeeper = clockkeeper.NewKeeper(
appKeepers.keys[clocktypes.StoreKey],
appCodec,
appKeepers.WasmKeeper,
appKeepers.ContractKeeper,
govModAddress,
)

appKeepers.DmnKeeper.SetWasmKeeper(appKeepers.WasmKeeper)

// register wasm gov proposal types
Expand Down
2 changes: 2 additions & 0 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
clocktypes "github.com/cybercongress/go-cyber/v4/x/clock/types"
tokenfactorytypes "github.com/cybercongress/go-cyber/v4/x/tokenfactory/types"

liquiditytypes "github.com/cybercongress/go-cyber/v4/x/liquidity/types"
Expand All @@ -49,6 +50,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {
ibctransfertypes.StoreKey,
ibcfeetypes.StoreKey,
wasmtypes.StoreKey,
clocktypes.StoreKey,
// our additions
liquiditytypes.StoreKey,
bandwidthtypes.StoreKey,
Expand Down
13 changes: 10 additions & 3 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/cybercongress/go-cyber/v4/x/clock"
"github.com/cybercongress/go-cyber/v4/x/tokenfactory"
tokenfactorytypes "github.com/cybercongress/go-cyber/v4/x/tokenfactory/types"

Expand All @@ -72,6 +73,7 @@ import (
stakingwrap "github.com/cybercongress/go-cyber/v4/x/staking"

authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
clocktypes "github.com/cybercongress/go-cyber/v4/x/clock/types"
)

// ModuleBasics TODO add notes which modules have functional blockers
Expand Down Expand Up @@ -110,6 +112,7 @@ var ModuleBasics = module.NewBasicManager(
dmn.AppModuleBasic{},
resources.AppModuleBasic{},
tokenfactory.AppModuleBasic{},
clock.AppModuleBasic{},
// https://github.com/cosmos/ibc-go/blob/main/docs/docs/05-migrations/08-v6-to-v7.md
ibctm.AppModuleBasic{},
solomachine.AppModuleBasic{},
Expand Down Expand Up @@ -164,6 +167,7 @@ func appModules(
// NOTE add Bank Proxy here to resolve issue when new neuron is created during token-factory token transfer
// TODO add storage listener to update neurons memory index out of cyberbank proxy
tokenfactory.NewAppModule(app.AppKeepers.TokenFactoryKeeper, app.AppKeepers.AccountKeeper, app.CyberbankKeeper.Proxy, app.GetSubspace(tokenfactorytypes.ModuleName)),
clock.NewAppModule(appCodec, app.AppKeepers.ClockKeeper),
}
}

Expand Down Expand Up @@ -220,14 +224,15 @@ func orderBeginBlockers() []string {
nft.ModuleName,
consensusparamtypes.ModuleName,
// additional modules
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
liquiditytypes.ModuleName,
dmntypes.ModuleName,
clocktypes.ModuleName,
bandwidthtypes.ModuleName,
cyberbanktypes.ModuleName,
graphtypes.ModuleName,
gridtypes.ModuleName,
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
ranktypes.ModuleName,
resourcestypes.ModuleName,
ibcfeetypes.ModuleName,
Expand Down Expand Up @@ -260,15 +265,16 @@ func orderEndBlockers() []string {
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
ibcfeetypes.ModuleName,
clocktypes.ModuleName,
tokenfactorytypes.ModuleName,
graphtypes.ModuleName,
dmntypes.ModuleName,
gridtypes.ModuleName,
resourcestypes.ModuleName,
liquiditytypes.ModuleName,
wasm.ModuleName,
cyberbanktypes.ModuleName,
bandwidthtypes.ModuleName,
graphtypes.ModuleName,
ranktypes.ModuleName,
}
}
Expand Down Expand Up @@ -298,6 +304,7 @@ func orderInitBlockers() []string {
ibcexported.ModuleName,
liquiditytypes.ModuleName,
ibcfeetypes.ModuleName,
clocktypes.ModuleName,
tokenfactorytypes.ModuleName,
wasm.ModuleName,
bandwidthtypes.ModuleName,
Expand Down
2 changes: 2 additions & 0 deletions app/upgrades/v4/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/cosmos/cosmos-sdk/x/nft"
clocktypes "github.com/cybercongress/go-cyber/v4/x/clock/types"
tokenfactorytypes "github.com/cybercongress/go-cyber/v4/x/tokenfactory/types"

resourcestypes "github.com/cybercongress/go-cyber/v4/x/resources/types"
Expand All @@ -24,6 +25,7 @@ var Upgrade = upgrades.Upgrade{
resourcestypes.ModuleName,
tokenfactorytypes.ModuleName,
nft.ModuleName,
clocktypes.ModuleName,
},
},
}
9 changes: 9 additions & 0 deletions app/upgrades/v4/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
generaltypes "github.com/cybercongress/go-cyber/v4/types"
clocktypes "github.com/cybercongress/go-cyber/v4/x/clock/types"
tokenfactorytypes "github.com/cybercongress/go-cyber/v4/x/tokenfactory/types"
"time"

Expand Down Expand Up @@ -129,6 +130,14 @@ func CreateV4UpgradeHandler(
}
logger.Info("set tokenfactory params")

// x/clock
if err := keepers.ClockKeeper.SetParams(ctx, clocktypes.Params{
ContractGasLimit: 250_000, // TODO update
}); err != nil {
return nil, err
}
logger.Info("set clock params")

after := time.Now()

ctx.Logger().Info("migration time", "duration_ms", after.Sub(before).Milliseconds())
Expand Down
Loading

0 comments on commit 043b31b

Please sign in to comment.