Skip to content

Commit

Permalink
Merge branch 'cudos-dev' into cudos-master (merging identical changes…
Browse files Browse the repository at this point in the history
… in two branches with different commit hashes)
  • Loading branch information
kstoykov committed Feb 23, 2023
2 parents ed5a355 + 77e4847 commit ee93e66
Show file tree
Hide file tree
Showing 230 changed files with 30,342 additions and 496 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches: [ $default-branch ]
pull_request:

jobs:

Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Build
run: make build

Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Test
run: make test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cudos-data
node_modules
.idea
.vscode
init-root.sh
build
build
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ BUILD_FLAGS := -ldflags '$(ldflags)'

all: install

install: export CGO_LDFLAGS="-Wl,-rpath=$$ORIGIN/../"
install: export CGO_LDFLAGS=-Wl,-rpath,$$ORIGIN/../
install: go.sum
@echo "--> Installing cudos-noded"
@go install -mod=readonly $(BUILD_FLAGS) -tags "ledger" ./cmd/cudos-noded


build: export CGO_LDFLAGS="-Wl,-rpath=$$ORIGIN/../"
build: export CGO_LDFLAGS=-Wl,-rpath,$$ORIGIN/../
build: go.sum
@echo "--> Building cudos-noded"
@go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ -tags "ledger" ./cmd/cudos-noded
Expand All @@ -30,4 +30,4 @@ go.sum: go.mod
GO111MODULE=on go mod verify

test:
@go test -mod=readonly $(PACKAGES)
@go test -v -mod=readonly $(PACKAGES)
29 changes: 25 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import (
dbm "github.com/tendermint/tm-db"

appparams "github.com/CudoVentures/cudos-node/app/params"
addressbooktypes "github.com/CudoVentures/cudos-node/x/addressbook/types"
"github.com/CudoVentures/cudos-node/x/admin"
admintypes "github.com/CudoVentures/cudos-node/x/admin/types"
marketplacetypes "github.com/CudoVentures/cudos-node/x/marketplace/types"
"github.com/cosmos/cosmos-sdk/baseapp"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -42,12 +44,11 @@ import (
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
feegrantmod "github.com/cosmos/cosmos-sdk/x/feegrant/module"

"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/group"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
"github.com/cosmos/cosmos-sdk/x/params"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/slashing"
Expand All @@ -63,13 +64,18 @@ import (
ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host"

// this line is used by starport scaffolding # stargate/app/moduleImport
"github.com/althea-net/cosmos-gravity-bridge/module/x/gravity"
gravitytypes "github.com/althea-net/cosmos-gravity-bridge/module/x/gravity/types"

"github.com/CudoVentures/cudos-node/x/cudoMint"
cudominttypes "github.com/CudoVentures/cudos-node/x/cudoMint/types"
nftmodule "github.com/CudoVentures/cudos-node/x/nft"
nftmoduletypes "github.com/CudoVentures/cudos-node/x/nft/types"

"github.com/althea-net/cosmos-gravity-bridge/module/x/gravity"
gravitytypes "github.com/althea-net/cosmos-gravity-bridge/module/x/gravity/types"
addressbook "github.com/CudoVentures/cudos-node/x/addressbook"
marketplace "github.com/CudoVentures/cudos-node/x/marketplace"
"github.com/cosmos/cosmos-sdk/x/group"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
)

const Name = "cudos-node"
Expand Down Expand Up @@ -135,6 +141,8 @@ func New(
gravitytypes.StoreKey,
feegrant.StoreKey,
group.StoreKey,
addressbooktypes.StoreKey,
marketplacetypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -163,11 +171,16 @@ func New(
// set upgrades
app.SetUpgradeHandlers()

marketplaceModule := marketplace.NewAppModule(appCodec, app.MarketplaceKeeper, app.AccountKeeper, app.BankKeeper)

addressbookModule := addressbook.NewAppModule(appCodec, app.AddressbookKeeper, app.AccountKeeper, app.BankKeeper)

transferModule := transfer.NewAppModule(app.TransferKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
ibcRouter.AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.wasmKeeper, app.IBCKeeper.ChannelKeeper))
app.IBCKeeper.SetRouter(ibcRouter)

app.mm = module.NewManager(
Expand All @@ -193,7 +206,9 @@ func New(
feegrantmod.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.feegrantKeeper, app.interfaceRegistry),
// this line is used by starport scaffolding # stargate/app/appModule
nftmodule.NewAppModule(appCodec, app.NftKeeper, app.AccountKeeper, app.BankKeeper),
marketplaceModule,
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
addressbookModule,
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -223,6 +238,8 @@ func New(
ibctransfertypes.ModuleName,
wasmtypes.ModuleName,
group.ModuleName,
addressbooktypes.ModuleName,
marketplacetypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand All @@ -248,6 +265,8 @@ func New(
ibctransfertypes.ModuleName,
wasmtypes.ModuleName,
group.ModuleName,
addressbooktypes.ModuleName,
marketplacetypes.ModuleName,
)
// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
Expand Down Expand Up @@ -282,6 +301,8 @@ func New(
upgradetypes.ModuleName,
paramstypes.ModuleName,
group.ModuleName,
addressbooktypes.ModuleName,
marketplacetypes.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand Down
31 changes: 26 additions & 5 deletions app/app_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ import (

groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"

marketplace "github.com/CudoVentures/cudos-node/x/marketplace"
marketplacekeeper "github.com/CudoVentures/cudos-node/x/marketplace/keeper"
marketplacetypes "github.com/CudoVentures/cudos-node/x/marketplace/types"

addressbook "github.com/CudoVentures/cudos-node/x/addressbook"
addressbookkeeper "github.com/CudoVentures/cudos-node/x/addressbook/keeper"
addressbooktypes "github.com/CudoVentures/cudos-node/x/addressbook/types"
)

// We pull these out so we can set them with LDFLAGS in the Makefile
Expand Down Expand Up @@ -130,6 +138,7 @@ var (
bank.AppModuleBasic{},
capability.AppModuleBasic{},
staking.AppModuleBasic{},
// mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
paramsclient.ProposalHandler,
Expand All @@ -154,6 +163,8 @@ var (
// this line is used by starport scaffolding # stargate/app/moduleBasic
nftmodule.AppModuleBasic{},
groupmodule.AppModuleBasic{},
addressbook.AppModuleBasic{},
marketplace.AppModuleBasic{},
)

maccPerms = map[string][]string{
Expand All @@ -166,6 +177,7 @@ var (
cudoMinttypes.ModuleName: {authtypes.Minter},
gravitytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
wasmtypes.ModuleName: {authtypes.Burner},
marketplacetypes.ModuleName: nil,
}

allowedReceivingModAcc = map[string]bool{
Expand Down Expand Up @@ -210,15 +222,18 @@ type App struct {
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
GravityKeeper gravitykeeper.Keeper
NftKeeper nftmodulekeeper.Keeper
GroupKeeper groupkeeper.Keeper

wasmKeeper wasm.Keeper
adminKeeper adminkeeper.Keeper
cudoMintKeeper cudoMintkeeper.Keeper
feegrantKeeper feegrantkeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

NftKeeper nftmodulekeeper.Keeper
GroupKeeper groupkeeper.Keeper
AddressbookKeeper addressbookkeeper.Keeper
MarketplaceKeeper marketplacekeeper.Keeper
// the module manager
mm *module.Manager
configurator module.Configurator
}
Expand All @@ -240,6 +255,8 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
}

app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}

Expand All @@ -256,6 +273,8 @@ func (app *App) ModuleAccountAddrs() map[string]bool {
return modAccAddrs
}

// BlockedAddrs returns all the app's module account addresses that are not
// allowed to receive external tokens.
func (app *App) BlockedAddrs() map[string]bool {
blockedAddrs := make(map[string]bool)
for acc := range maccPerms {
Expand Down Expand Up @@ -356,9 +375,6 @@ func InitParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

paramsKeeper.Subspace(authtypes.ModuleName)
paramsKeeper.Subspace(banktypes.ModuleName)
paramsKeeper.Subspace(authz.ModuleName)
paramsKeeper.Subspace(feegrant.ModuleName)
paramsKeeper.Subspace(group.ModuleName)
paramsKeeper.Subspace(stakingtypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
Expand All @@ -371,6 +387,11 @@ func InitParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(nftmoduletypes.ModuleName)
paramsKeeper.Subspace(cudoMinttypes.ModuleName)
paramsKeeper.Subspace(gravitytypes.ModuleName)
paramsKeeper.Subspace(addressbooktypes.ModuleName)
paramsKeeper.Subspace(marketplacetypes.ModuleName)
paramsKeeper.Subspace(authz.ModuleName)
paramsKeeper.Subspace(feegrant.ModuleName)
paramsKeeper.Subspace(group.ModuleName)

return paramsKeeper
}
22 changes: 22 additions & 0 deletions app/app_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ import (

"github.com/cosmos/cosmos-sdk/x/group"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"

marketplacekeeper "github.com/CudoVentures/cudos-node/x/marketplace/keeper"
marketplacetypes "github.com/CudoVentures/cudos-node/x/marketplace/types"

addressbookkeeper "github.com/CudoVentures/cudos-node/x/addressbook/keeper"
addressbooktypes "github.com/CudoVentures/cudos-node/x/addressbook/types"
)

func (app *App) AddKeepers(skipUpgradeHeights map[int64]bool, homePath string, appOpts servertypes.AppOptions) {
Expand Down Expand Up @@ -137,6 +143,22 @@ func (app *App) AddKeepers(skipUpgradeHeights map[int64]bool, homePath string, a
app.keys[nftmoduletypes.MemStoreKey],
)

app.AddressbookKeeper = *addressbookkeeper.NewKeeper(
app.appCodec,
app.keys[addressbooktypes.StoreKey],
app.keys[addressbooktypes.MemStoreKey],
app.GetSubspace(addressbooktypes.ModuleName),
)

app.MarketplaceKeeper = *marketplacekeeper.NewKeeper(
app.appCodec,
app.keys[marketplacetypes.StoreKey],
app.keys[marketplacetypes.MemStoreKey],
app.GetSubspace(marketplacetypes.ModuleName),
app.BankKeeper,
app.NftKeeper,
)

supportedFeatures := "iterator,staking,stargate"
customEncoderOptions := GetCustomMsgEncodersOptions()
customQueryOptions := GetCustomMsgQueryOptions(app.NftKeeper)
Expand Down
44 changes: 40 additions & 4 deletions app/app_upgrades.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,62 @@
package app

import (
"strings"

addressbookTypes "github.com/CudoVentures/cudos-node/x/addressbook/types"
cudoMinttypes "github.com/CudoVentures/cudos-node/x/cudoMint/types"
marketplaceTypes "github.com/CudoVentures/cudos-node/x/marketplace/types"
nfttypes "github.com/CudoVentures/cudos-node/x/nft/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/authz"
"github.com/cosmos/cosmos-sdk/x/group"

upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func (app *App) SetUpgradeHandlers() {
setV110Handler(app)
setHandlerForVersion_1_0(app)
setHandlerForVersion_1_1(app)
}

func setHandlerForVersion_1_0(app *App) {
app.UpgradeKeeper.SetUpgradeHandler("v1.0", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ss, ok := app.ParamsKeeper.GetSubspace(cudoMinttypes.ModuleName)
if ok {
bpd := ss.GetRaw(ctx, []byte("BlocksPerDay"))

bpdString := strings.ReplaceAll(string(bpd), "\"", "")

bpdInt, parseOk := sdk.NewIntFromString(bpdString)
if parseOk {
ss.Set(ctx, []byte("IncrementModifier"), bpdInt)
}
}

return fromVM, nil
})
}

func setV110Handler(app *App) {
const upgradeVersion string = "v1.1.0"
func setHandlerForVersion_1_1(app *App) {
const upgradeVersion string = "v1.1"

app.UpgradeKeeper.SetUpgradeHandler(upgradeVersion, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if len(fromVM) == 0 {
fromVM = app.mm.GetVersionMap()
delete(fromVM, authz.ModuleName)
delete(fromVM, group.ModuleName)
delete(fromVM, addressbookTypes.ModuleName)
delete(fromVM, marketplaceTypes.ModuleName)

if _, ok := fromVM[nfttypes.ModuleName]; ok {
if fromVM[nfttypes.ModuleName] == 2 {
fromVM[nfttypes.ModuleName] = 1
}
} else {
fromVM[nfttypes.ModuleName] = 1
}
}

return app.mm.RunMigrations(ctx, app.configurator, fromVM)
Expand All @@ -33,7 +69,7 @@ func setV110Handler(app *App) {

if upgradeInfo.Name == upgradeVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{authz.ModuleName, group.ModuleName},
Added: []string{authz.ModuleName, group.ModuleName, addressbookTypes.ModuleName, marketplaceTypes.ModuleName},
}

app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
Expand Down
Loading

0 comments on commit ee93e66

Please sign in to comment.