Skip to content

Commit

Permalink
feat(dymns): add Dymension Name Service (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorTrustyDev authored Aug 20, 2024
1 parent 1ec00c0 commit f7b7296
Show file tree
Hide file tree
Showing 212 changed files with 92,010 additions and 8,783 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ DEPS_IBC_GO_VERSION := $(shell cat go.sum | grep 'github.com/cosmos/ibc-go' | gr
DEPS_COSMOS_PROTO_VERSION := $(shell cat go.sum | grep 'github.com/cosmos/cosmos-proto' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')
DEPS_COSMOS_GOGOPROTO_VERSION := $(shell cat go.sum | grep 'github.com/cosmos/gogoproto' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')
DEPS_CONFIO_ICS23_VERSION := go/$(shell cat go.sum | grep 'github.com/confio/ics23/go' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')
DEPS_COSMOS_ICS23 := go/$(shell cat go.sum | grep 'github.com/cosmos/ics23/go' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')

export GO111MODULE = on

Expand Down Expand Up @@ -174,6 +175,8 @@ proto-gen:
@go mod tidy

proto-swagger-gen:
@echo "Downloading Protobuf dependencies"
@make proto-download-deps
@echo "Generating Protobuf Swagger"
$(protoCosmosImage) sh ./scripts/protoc-swagger-gen.sh

Expand Down Expand Up @@ -257,4 +260,7 @@ proto-download-deps:
mkdir -p "$(THIRD_PARTY_DIR)/confio/ics23" && \
curl -sSL https://raw.githubusercontent.com/confio/ics23/$(DEPS_CONFIO_ICS23_VERSION)/proofs.proto > "$(THIRD_PARTY_DIR)/proofs.proto"

.PHONY: proto-gen proto-swagger-gen proto-format proto-lint proto-download-deps
mkdir -p "$(THIRD_PARTY_DIR)/cosmos/ics23/v1" && \
curl -sSL "https://raw.githubusercontent.com/cosmos/ics23/$(DEPS_COSMOS_ICS23)/proto/cosmos/ics23/v1/proofs.proto" > "$(THIRD_PARTY_DIR)/cosmos/ics23/v1/proofs.proto"

.PHONY: proto-gen proto-swagger-gen proto-format proto-lint proto-download-deps
31 changes: 29 additions & 2 deletions app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package apptesting
import (
"strings"

bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/dymensionxyz/dymension/v3/app/params"
dymnstypes "github.com/dymensionxyz/dymension/v3/x/dymns/types"

"github.com/cometbft/cometbft/libs/rand"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
Expand Down Expand Up @@ -44,14 +48,13 @@ func (s *KeeperTestHelper) CreateDefaultRollapp() string {
}

func (s *KeeperTestHelper) CreateRollappByName(name string) {
alias := strings.NewReplacer("_", "", "-", "").Replace(name) // base it on rollappID to avoid alias conflicts
msgCreateRollapp := rollapptypes.MsgCreateRollapp{
Creator: alice,
RollappId: name,
InitialSequencer: "*",
Bech32Prefix: strings.ToLower(rand.Str(3)),
GenesisChecksum: "1234567890abcdefg",
Alias: alias,
Alias: strings.ToLower(rand.Str(7)),
VmType: rollapptypes.Rollapp_EVM,
Metadata: &rollapptypes.RollappMetadata{
Website: "https://dymension.xyz",
Expand All @@ -63,6 +66,8 @@ func (s *KeeperTestHelper) CreateRollappByName(name string) {
},
}

s.FundForAliasRegistration(msgCreateRollapp)

msgServer := rollappkeeper.NewMsgServerImpl(*s.App.RollappKeeper)
_, err := msgServer.CreateRollapp(s.Ctx, &msgCreateRollapp)
s.Require().NoError(err)
Expand Down Expand Up @@ -139,3 +144,25 @@ func (s *KeeperTestHelper) StateNotAltered() {
newState := s.App.ExportState(s.Ctx)
s.Require().Equal(oldState, newState)
}

func (s *KeeperTestHelper) FundForAliasRegistration(msgCreateRollApp rollapptypes.MsgCreateRollapp) {
err := FundForAliasRegistration(s.Ctx, s.App.BankKeeper, msgCreateRollApp)
s.Require().NoError(err)
}

func FundForAliasRegistration(
ctx sdk.Context,
bankKeeper bankkeeper.Keeper,
msgCreateRollApp rollapptypes.MsgCreateRollapp,
) error {
if msgCreateRollApp.Alias == "" {
return nil
}
dymNsParams := dymnstypes.DefaultPriceParams()
aliasRegistrationCost := sdk.NewCoins(sdk.NewCoin(
params.BaseDenom, dymNsParams.GetAliasPrice(msgCreateRollApp.Alias),
))
return bankutil.FundAccount(
bankKeeper, ctx, sdk.MustAccAddressFromBech32(msgCreateRollApp.Creator), aliasRegistrationCost,
)
}
18 changes: 18 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ import (
denommetadatamodule "github.com/dymensionxyz/dymension/v3/x/denommetadata"
denommetadatamodulekeeper "github.com/dymensionxyz/dymension/v3/x/denommetadata/keeper"
denommetadatamoduletypes "github.com/dymensionxyz/dymension/v3/x/denommetadata/types"
dymnsmodule "github.com/dymensionxyz/dymension/v3/x/dymns"
dymnskeeper "github.com/dymensionxyz/dymension/v3/x/dymns/keeper"
dymnstypes "github.com/dymensionxyz/dymension/v3/x/dymns/types"
eibckeeper "github.com/dymensionxyz/dymension/v3/x/eibc/keeper"
eibcmoduletypes "github.com/dymensionxyz/dymension/v3/x/eibc/types"
incentiveskeeper "github.com/dymensionxyz/dymension/v3/x/incentives/keeper"
Expand Down Expand Up @@ -144,6 +147,8 @@ type AppKeepers struct {
DelayedAckKeeper delayedackkeeper.Keeper
DenomMetadataKeeper *denommetadatamodulekeeper.Keeper

DymNSKeeper dymnskeeper.Keeper

// keys to access the substores
keys map[string]*storetypes.KVStoreKey
tkeys map[string]*storetypes.TransientStoreKey
Expand Down Expand Up @@ -397,6 +402,15 @@ func (a *AppKeepers) InitKeepers(
nil,
)

a.DymNSKeeper = dymnskeeper.NewKeeper(
appCodec,
a.keys[dymnstypes.StoreKey],
a.GetSubspace(dymnstypes.ModuleName),
a.BankKeeper,
a.RollappKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// Create Transfer Keepers
a.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -434,6 +448,7 @@ func (a *AppKeepers) InitKeepers(
AddRoute(streamermoduletypes.RouterKey, streamermodule.NewStreamerProposalHandler(a.StreamerKeeper)).
AddRoute(rollappmoduletypes.RouterKey, rollappmodule.NewRollappProposalHandler(a.RollappKeeper)).
AddRoute(denommetadatamoduletypes.RouterKey, denommetadatamodule.NewDenomMetadataProposalHandler(a.DenomMetadataKeeper)).
AddRoute(dymnstypes.RouterKey, dymnsmodule.NewDymNsProposalHandler(a.DymNSKeeper)).
AddRoute(evmtypes.RouterKey, evm.NewEvmProposalHandler(a.EvmKeeper))

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
Expand Down Expand Up @@ -542,6 +557,7 @@ func (a *AppKeepers) SetupHooks() {
a.StreamerKeeper.Hooks(),
a.TxFeesKeeper.Hooks(),
a.DelayedAckKeeper.GetEpochHooks(),
a.DymNSKeeper.GetEpochHooks(),
),
)

Expand All @@ -558,6 +574,7 @@ func (a *AppKeepers) SetupHooks() {
a.SequencerKeeper.RollappHooks(),
a.delayedAckMiddleware,
a.StreamerKeeper.Hooks(),
a.DymNSKeeper.GetRollAppHooks(),
))
}

Expand Down Expand Up @@ -598,6 +615,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(denommetadatamoduletypes.ModuleName)
paramsKeeper.Subspace(delayedacktypes.ModuleName)
paramsKeeper.Subspace(eibcmoduletypes.ModuleName)
paramsKeeper.Subspace(dymnstypes.ModuleName)

// ethermint subspaces
paramsKeeper.Subspace(evmtypes.ModuleName)
Expand Down
2 changes: 2 additions & 0 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
dymnstypes "github.com/dymensionxyz/dymension/v3/x/dymns/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
epochstypes "github.com/osmosis-labs/osmosis/v15/x/epochs/types"
Expand Down Expand Up @@ -118,6 +119,7 @@ var KVStoreKeys = sdk.NewKVStoreKeys(
packetforwardtypes.StoreKey,
delayedacktypes.StoreKey,
eibcmoduletypes.StoreKey,
dymnstypes.StoreKey,
// ethermint keys
evmtypes.StoreKey,
feemarkettypes.StoreKey,
Expand Down
11 changes: 11 additions & 0 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ import (
ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
dymnsmodule "github.com/dymensionxyz/dymension/v3/x/dymns"
dymnsmoduleclient "github.com/dymensionxyz/dymension/v3/x/dymns/client"
dymnstypes "github.com/dymensionxyz/dymension/v3/x/dymns/types"
"github.com/evmos/ethermint/x/evm"
evmclient "github.com/evmos/ethermint/x/evm/client"
evmtypes "github.com/evmos/ethermint/x/evm/types"
Expand Down Expand Up @@ -124,6 +127,8 @@ var ModuleBasics = module.NewBasicManager(
rollappmoduleclient.SubmitFraudHandler,
denommetadatamoduleclient.CreateDenomMetadataHandler,
denommetadatamoduleclient.UpdateDenomMetadataHandler,
dymnsmoduleclient.MigrateChainIdsProposalHandler,
dymnsmoduleclient.UpdateAliasesProposalHandler,
evmclient.UpdateVirtualFrontierBankContractProposalHandler,
}),
params.AppModuleBasic{},
Expand All @@ -144,6 +149,7 @@ var ModuleBasics = module.NewBasicManager(
packetforward.AppModuleBasic{},
delayedack.AppModuleBasic{},
eibc.AppModuleBasic{},
dymnsmodule.AppModuleBasic{},

// Ethermint modules
evm.AppModuleBasic{},
Expand Down Expand Up @@ -195,6 +201,7 @@ func (a *AppKeepers) SetupModules(
delayedackmodule.NewAppModule(appCodec, a.DelayedAckKeeper),
denommetadatamodule.NewAppModule(a.DenomMetadataKeeper, *a.EvmKeeper, a.BankKeeper),
eibcmodule.NewAppModule(appCodec, a.EIBCKeeper, a.AccountKeeper, a.BankKeeper),
dymnsmodule.NewAppModule(appCodec, a.DymNSKeeper),

// Ethermint app modules
evm.NewAppModule(a.EvmKeeper, a.AccountKeeper, a.BankKeeper, a.GetSubspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable())),
Expand Down Expand Up @@ -242,6 +249,7 @@ var maccPerms = map[string][]string{
lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner},
incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner},
txfeestypes.ModuleName: {authtypes.Burner},
dymnstypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}

var BeginBlockers = []string{
Expand Down Expand Up @@ -274,6 +282,7 @@ var BeginBlockers = []string{
denommetadatamoduletypes.ModuleName,
delayedacktypes.ModuleName,
eibcmoduletypes.ModuleName,
dymnstypes.ModuleName,
lockuptypes.ModuleName,
gammtypes.ModuleName,
poolmanagertypes.ModuleName,
Expand Down Expand Up @@ -311,6 +320,7 @@ var EndBlockers = []string{
denommetadatamoduletypes.ModuleName,
delayedacktypes.ModuleName,
eibcmoduletypes.ModuleName,
dymnstypes.ModuleName,
epochstypes.ModuleName,
lockuptypes.ModuleName,
gammtypes.ModuleName,
Expand Down Expand Up @@ -349,6 +359,7 @@ var InitGenesis = []string{
denommetadatamoduletypes.ModuleName, // must after `x/bank` to trigger hooks
delayedacktypes.ModuleName,
eibcmoduletypes.ModuleName,
dymnstypes.ModuleName,
epochstypes.ModuleName,
lockuptypes.ModuleName,
gammtypes.ModuleName,
Expand Down
30 changes: 19 additions & 11 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,47 @@
},
"apis": [
{
"url": "./tmp-swagger-gen/dymension/delayedack/query.swagger.json",
"url": "./tmp-swagger-gen/dymensionxyz/dymension/delayedack/query.swagger.json",
"operationIds": {
"rename": {
"Params": "DelayedAckParams"
}
}
},
{
"url": "./tmp-swagger-gen/dymension/eibc/query.swagger.json",
"url": "./tmp-swagger-gen/dymensionxyz/dymension/eibc/query.swagger.json",
"operationIds": {
"rename": {
"Params": "EIbcParams"
}
}
},
{
"url": "./tmp-swagger-gen/dymension/rollapp/query.swagger.json",
"url": "./tmp-swagger-gen/dymensionxyz/dymension/dymns/query.swagger.json",
"operationIds": {
"rename": {
"Params": "DymNSParams"
}
}
},
{
"url": "./tmp-swagger-gen/dymensionxyz/dymension/rollapp/query.swagger.json",
"operationIds": {
"rename": {
"Params": "RollAppParams"
}
}
},
{
"url": "./tmp-swagger-gen/dymension/sequencer/query.swagger.json",
"url": "./tmp-swagger-gen/dymensionxyz/dymension/sequencer/query.swagger.json",
"operationIds": {
"rename": {
"Params": "SequencerParams"
}
}
},
{
"url": "./tmp-swagger-gen/dymension/streamer/query.swagger.json",
"url": "./tmp-swagger-gen/dymensionxyz/dymension/streamer/query.swagger.json",
"operationIds": {
"rename": {
"Params": "StreamerParams",
Expand All @@ -65,15 +73,15 @@
}
},
{
"url": "./tmp-swagger-gen/osmosis/gamm/v2/query.swagger.json",
"url": "./tmp-swagger-gen/dymensionxyz/dymension/gamm/v2/query.swagger.json",
"operationIds": {
"rename": {
"SpotPrice": "SpotPriceV2"
}
}
},
{
"url": "./tmp-swagger-gen/osmosis/gamm/v1beta1/query.swagger.json",
"url": "./tmp-swagger-gen/dymensionxyz/dymension/gamm/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "GammParams",
Expand All @@ -83,10 +91,10 @@
}
},
{
"url": "./tmp-swagger-gen/osmosis/epochs/query.swagger.json"
"url": "./tmp-swagger-gen/dymensionxyz/dymension/epochs/v1beta1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/osmosis/incentives/query.swagger.json",
"url": "./tmp-swagger-gen/dymensionxyz/dymension/incentives/query.swagger.json",
"operationIds": {
"rename": {
"Params": "IncentivesParams",
Expand All @@ -95,15 +103,15 @@
}
},
{
"url": "./tmp-swagger-gen/osmosis/lockup/query.swagger.json",
"url": "./tmp-swagger-gen/dymensionxyz/dymension/lockup/query.swagger.json",
"operationIds": {
"rename": {
"Params": "LockupParams"
}
}
},
{
"url": "./tmp-swagger-gen/osmosis/txfees/v1beta1/query.swagger.json",
"url": "./tmp-swagger-gen/dymensionxyz/dymension/txfees/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "TxFeesParams"
Expand Down
Loading

0 comments on commit f7b7296

Please sign in to comment.