Skip to content

Commit

Permalink
feat(rollapp): remove alias from rollapp (#1034)
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 authored Aug 7, 2024
1 parent ce6f078 commit 71eac1b
Show file tree
Hide file tree
Showing 57 changed files with 311 additions and 1,167 deletions.
4 changes: 2 additions & 2 deletions app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func (s *KeeperTestHelper) CreateRollappWithNameWithProposer(name string) (strin
},
}

aliceBal := sdk.NewCoins(s.App.RollappKeeper.GetParams(s.Ctx).RegistrationFee)
FundAccount(s.App, s.Ctx, sdk.MustAccAddressFromBech32(alice), aliceBal)
// aliceBal := sdk.NewCoins(s.App.RollappKeeper.GetParams(s.Ctx).RegistrationFee) TODO: enable after x/dymns hooks are wired
// FundAccount(s.App, s.Ctx, sdk.MustAccAddressFromBech32(alice), aliceBal)

msgServer := rollappkeeper.NewMsgServerImpl(*s.App.RollappKeeper)
_, err := msgServer.CreateRollapp(s.Ctx, &msgCreateRollapp)
Expand Down
1 change: 0 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ func (a *AppKeepers) InitKeepers(
a.GetSubspace(rollappmoduletypes.ModuleName),
a.IBCKeeper.ChannelKeeper,
a.IBCKeeper.ClientKeeper,
a.BankKeeper,
)

a.SequencerKeeper = *sequencermodulekeeper.NewKeeper(
Expand Down
5 changes: 1 addition & 4 deletions app/params/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@ type EncodingConfig struct {
Amino *codec.LegacyAmino
}

const (
StakePerAccount = "stake_per_account"
InitiallyBondedValidators = "initially_bonded_validators"
)
const StakePerAccount = "stake_per_account"
6 changes: 1 addition & 5 deletions app/upgrades/v4/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package v4

import (
"strings"

"github.com/cometbft/cometbft/crypto"
"github.com/cosmos/cosmos-sdk/baseapp"

Expand Down Expand Up @@ -136,7 +134,6 @@ func migrateSequencers(ctx sdk.Context, sequencerkeeper sequencerkeeper.Keeper)

func ConvertOldRollappToNew(oldRollapp rollapptypes.Rollapp) rollapptypes.Rollapp {
bech32Prefix := oldRollapp.RollappId[:5]
alias := strings.Split(oldRollapp.RollappId, "_")[0]
return rollapptypes.Rollapp{
RollappId: oldRollapp.RollappId,
Owner: oldRollapp.Owner,
Expand All @@ -147,8 +144,7 @@ func ConvertOldRollappToNew(oldRollapp rollapptypes.Rollapp) rollapptypes.Rollap
// TODO: regarding missing data - https://github.com/dymensionxyz/dymension/issues/986
Bech32Prefix: bech32Prefix, // placeholder data
GenesisChecksum: string(crypto.Sha256([]byte(oldRollapp.RollappId))), // placeholder data
Alias: alias,
VmType: rollapptypes.Rollapp_EVM, // placeholder data
VmType: rollapptypes.Rollapp_EVM, // placeholder data
Metadata: &rollapptypes.RollappMetadata{
Website: "",
Description: "",
Expand Down
4 changes: 1 addition & 3 deletions app/upgrades/v4/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const (
expectDelayedackEpochIdentifier = "hour"

expectDisputePeriodInBlocks = 3
expectRegistrationFee = "10000000000000000000adym"
)

var expectDelayedackBridgingFee = sdk.NewDecWithPrec(1, 3)
Expand Down Expand Up @@ -154,8 +153,7 @@ func (s *UpgradeTestSuite) validateDelayedAckParamsMigration() error {

func (s *UpgradeTestSuite) validateRollappParamsMigration() error {
rollappParams := s.App.RollappKeeper.GetParams(s.Ctx)
cond := rollappParams.DisputePeriodInBlocks == expectDisputePeriodInBlocks &&
rollappParams.RegistrationFee.String() == expectRegistrationFee
cond := rollappParams.DisputePeriodInBlocks == expectDisputePeriodInBlocks

if !cond {
return fmt.Errorf("rollapp parameters not set correctly")
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d
github.com/cockroachdb/errors v1.11.1
github.com/cometbft/cometbft v0.37.5
github.com/cometbft/cometbft-db v0.11.0
github.com/cosmos/cosmos-proto v1.0.0-beta.5
Expand All @@ -20,7 +21,6 @@ require (
github.com/dymensionxyz/sdk-utils v0.2.7-0.20240807091416-0717365f0f61
github.com/ethereum/go-ethereum v1.10.26
github.com/evmos/ethermint v0.22.0
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.4
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand Down Expand Up @@ -70,7 +70,6 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.0 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
Expand Down Expand Up @@ -112,6 +111,7 @@ require (
github.com/go-stack/stack v1.8.1 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions ibctesting/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ func (s *utilSuite) rollappMsgServer() rollapptypes.MsgServer {
func (s *utilSuite) SetupTest() {
s.coordinator = ibctesting.NewCoordinator(s.T(), 2) // initializes test chains
s.coordinator.Chains[rollappChainID()] = s.newTestChainWithSingleValidator(s.T(), s.coordinator, rollappChainID())
s.fundSenderAccount()
// s.fundSenderAccount() // TODO: enable after x/dymns hooks are wired
}

func (s *utilSuite) fundSenderAccount() {
apptesting.FundAccount(s.hubApp(), s.hubCtx(), s.hubChain().SenderAccount.GetAddress(), sdk.NewCoins(rollapptypes.DefaultRegistrationFee))
// apptesting.FundAccount(s.hubApp(), s.hubCtx(), s.hubChain().SenderAccount.GetAddress(), sdk.NewCoins(rollapptypes.DefaultRegistrationFee))
}

// CreateRollappWithFinishedGenesis creates a rollapp whose 'genesis' protocol is complete:
Expand Down
3 changes: 0 additions & 3 deletions proto/dymensionxyz/dymension/rollapp/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@ message Params {
[ (gogoproto.moretags) = "yaml:\"dispute_period_in_blocks\"" ];

reserved 2,3;
// registration_fee is the fee that is required to register a rollapp
cosmos.base.v1beta1.Coin registration_fee = 4
[ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"registration_fee\"" ];
}
8 changes: 0 additions & 8 deletions proto/dymensionxyz/dymension/rollapp/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ service Query {
"/dymensionxyz/dymension/rollapp/eip155/{eip155}";
}

rpc RollappByAlias(QueryGetRollappByAliasRequest)
returns (QueryGetRollappResponse) {
option (google.api.http).get =
"/dymensionxyz/dymension/rollapp/alias/{alias}";
}

// Queries a list of Rollapp items.
rpc RollappAll(QueryAllRollappRequest) returns (QueryAllRollappResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/rollapp/rollapp";
Expand Down Expand Up @@ -74,8 +68,6 @@ message QueryGetRollappRequest { string rollappId = 1; }

message QueryGetRollappByEIP155Request { uint64 eip155 = 1; }

message QueryGetRollappByAliasRequest { string alias = 1; }

message QueryGetLatestHeightRequest {
string rollappId = 1;
bool finalized = 2;
Expand Down
4 changes: 1 addition & 3 deletions proto/dymensionxyz/dymension/rollapp/rollapp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ message Rollapp {
repeated string registeredDenoms = 10;
// unique bech32 prefix
string bech32_prefix = 11;
// alias is the chain alias used for display and namespace system
string alias = 12;
// checksum used to verify integrity of the genesis file
string genesis_checksum = 13;
string genesis_checksum = 12;
// metadata is the rollapp metadata
RollappMetadata metadata = 14;
// initial_sequencer is an option to preset one or more coma-separated bech32-encoded addresses of the
Expand Down
6 changes: 2 additions & 4 deletions proto/dymensionxyz/dymension/rollapp/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ message MsgUpdateRollappInformation {
// sequencer that are allowed to initially serve this rollappId.
// wildcard '*' means any sequencer is allowed to be the first proposer.
string initial_sequencer = 3;
// alias is the chain alias used for display and namespace system
string alias = 4;
// checksum used to verify integrity
string genesis_checksum = 5;
string genesis_checksum = 4;
// metadata is the rollapp metadata
RollappMetadata metadata = 6 [(gogoproto.nullable) = true ];
RollappMetadata metadata = 5 [(gogoproto.nullable) = true ];
}

message MsgUpdateRollappInformationResponse {
Expand Down
2 changes: 1 addition & 1 deletion testutil/keeper/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func RollappKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
memStoreKey,
"RollappParams",
)
k := keeper.NewKeeper(cdc, storeKey, paramsSubspace, nil, nil, nil)

k := keeper.NewKeeper(cdc, storeKey, paramsSubspace, nil, nil)
ctx := sdk.NewContext(stateStore, cometbftproto.Header{}, false, log.NewNopLogger())

// Initialize params
Expand Down
9 changes: 9 additions & 0 deletions x/common/types/stub_hooks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package types

import sdk "github.com/cosmos/cosmos-sdk/types"

type StubGammHooks struct{}

func (StubGammHooks) AfterJoinPool(sdk.Context, sdk.AccAddress, uint64, sdk.Coins, sdk.Int) {}
func (StubGammHooks) AfterExitPool(sdk.Context, sdk.AccAddress, uint64, sdk.Int, sdk.Coins) {}
func (StubGammHooks) AfterSwap(sdk.Context, sdk.AccAddress, uint64, sdk.Coins, sdk.Coins) {}
4 changes: 3 additions & 1 deletion x/delayedack/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ import (
"github.com/dymensionxyz/dymension/v3/x/delayedack/keeper"
"github.com/dymensionxyz/dymension/v3/x/delayedack/types"
rollappkeeper "github.com/dymensionxyz/dymension/v3/x/rollapp/keeper"
rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
)

var _ porttypes.Middleware = &IBCMiddleware{}

type IBCMiddleware struct {
porttypes.IBCModule
keeper.Keeper // keeper is an ics4 wrapper
raKeeper rollappkeeper.Keeper
rollapptypes.StubRollappCreatedHooks
raKeeper rollappkeeper.Keeper
}

type option func(*IBCMiddleware)
Expand Down
9 changes: 0 additions & 9 deletions x/delayedack/rollapp_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import (

var _ rollapptypes.RollappHooks = &IBCMiddleware{}

func (w IBCMiddleware) BeforeUpdateState(ctx sdk.Context, seqAddr string, rollappId string) error {
return nil
}

// AfterStateFinalized implements the RollappHooks interface
func (w IBCMiddleware) AfterStateFinalized(ctx sdk.Context, rollappID string, stateInfo *rollapptypes.StateInfo) error {
// Finalize the packets for the rollapp at the given height
Expand All @@ -22,8 +18,3 @@ func (w IBCMiddleware) AfterStateFinalized(ctx sdk.Context, rollappID string, st
func (w IBCMiddleware) FraudSubmitted(ctx sdk.Context, rollappID string, height uint64, seqAddr string) error {
return w.HandleFraud(ctx, rollappID, w.IBCModule)
}

// RollappCreated implements types.RollappHooks.
func (im IBCMiddleware) RollappCreated(ctx sdk.Context, rollappID string) error {
return nil
}
4 changes: 4 additions & 0 deletions x/delayedack/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import (
chantypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
"github.com/stretchr/testify/require"

appparams "github.com/dymensionxyz/dymension/v3/app/params"
ctypes "github.com/dymensionxyz/dymension/v3/x/common/types"
"github.com/dymensionxyz/dymension/v3/x/delayedack/types"
)

// this is needed to register the correct BECH32 prefix
const _ = appparams.BaseDenom

func TestGenesisState_Validate(t *testing.T) {
for _, tc := range []struct {
desc string
Expand Down
2 changes: 1 addition & 1 deletion x/incentives/client/cli/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type QueryTestSuite struct {
// SetupLockAndGauge creates both a lock and a gauge.
func (suite *QueryTestSuite) CreateDefaultRollapp() string {
alice := sdk.AccAddress("addr1---------------")
suite.FundAcc(alice, sdk.NewCoins(rollapptypes.DefaultRegistrationFee))
// suite.FundAcc(alice, sdk.NewCoins(rollapptypes.DefaultRegistrationFee)) TODO: enable after x/dymns hooks are wired

msgCreateRollapp := rollapptypes.MsgCreateRollapp{
Creator: alice.String(),
Expand Down
2 changes: 1 addition & 1 deletion x/incentives/keeper/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (suite *KeeperTestSuite) SetupLockAndGauge(isPerpetual bool) (sdk.AccAddres

// SetupLockAndGauge creates both a lock and a gauge.
func (suite *KeeperTestSuite) CreateDefaultRollapp(addr sdk.AccAddress) string {
suite.FundAcc(addr, sdk.NewCoins(rollapptypes.DefaultRegistrationFee))
// suite.FundAcc(addr, sdk.NewCoins(rollapptypes.DefaultRegistrationFee)) TODO: enable after x/dymns hooks are wired

msgCreateRollapp := rollapptypes.MsgCreateRollapp{
Creator: addr.String(),
Expand Down
3 changes: 0 additions & 3 deletions x/rollapp/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (
const (
FlagInitSequencer = "init-sequencer"
FlagGenesisChecksum = "genesis-checksum"
FlagAlias = "alias"
FlagMetadata = "metadata"
FlagByAlias = "by-alias"
)

// FlagSetCreateRollapp returns flags for creating rollapps.
Expand All @@ -25,7 +23,6 @@ func FlagSetUpdateRollapp() *flag.FlagSet {

fs.String(FlagInitSequencer, "", "The address of the sequencer that will be used to initialize the rollapp")
fs.String(FlagGenesisChecksum, "", "The checksum of the genesis file of the rollapp")
fs.String(FlagAlias, "", "The alias of the rollapp")
fs.String(FlagMetadata, "", "The metadata of the rollapp")

return fs
Expand Down
6 changes: 1 addition & 5 deletions x/rollapp/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ package cli

import (
"fmt"
// "strings"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
// "github.com/cosmos/cosmos-sdk/client/flags"
// sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"

"github.com/dymensionxyz/dymension/v3/x/rollapp/types"
)
Expand Down
47 changes: 8 additions & 39 deletions x/rollapp/client/cli/query_rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/gogo/protobuf/proto"
"github.com/spf13/cobra"

"github.com/dymensionxyz/dymension/v3/x/rollapp/types"
Expand Down Expand Up @@ -46,24 +45,19 @@ func CmdListRollapp() *cobra.Command {

func CmdShowRollapp() *cobra.Command {
cmd := &cobra.Command{
Use: "show [rollapp-id] [by-alias]",
Short: "Query the rollapp associated with the specified rollapp-id or alias",
Use: "show [rollapp-id]",
Short: "Query the rollapp associated with the specified rollapp-id",
Args: cobra.ExactArgs(1),
Example: "dymd query rollapp show ROLLAPP_CHAIN_ID, dymd query rollapp show ROLLAPP_ALIAS --by-alias",
Example: "dymd query rollapp show ROLLAPP_CHAIN_ID",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
queryClient := types.NewQueryClient(clientCtx)
argRollapp := args[0]

var (
res proto.Message
err error
)
if byAlias, _ := cmd.Flags().GetBool(FlagByAlias); byAlias {
res, err = rollappByAlias(cmd.Context(), queryClient, argRollapp)
} else {
res, err = rollappByID(cmd.Context(), queryClient, argRollapp)

params := &types.QueryGetRollappRequest{
RollappId: args[0],
}

res, err := queryClient.Rollapp(cmd.Context(), params)
if err != nil {
return err
}
Expand All @@ -72,32 +66,7 @@ func CmdShowRollapp() *cobra.Command {
},
}

cmd.Flags().BoolP(FlagByAlias, "a", false, "Query the rollapp by alias")
flags.AddQueryFlagsToCmd(cmd)

return cmd
}

func rollappByID(ctx context.Context, queryClient types.QueryClient, rollappID string) (*types.QueryGetRollappResponse, error) {
params := &types.QueryGetRollappRequest{
RollappId: rollappID,
}

res, err := queryClient.Rollapp(ctx, params)
if err != nil {
return nil, err
}
return res, nil
}

func rollappByAlias(ctx context.Context, queryClient types.QueryClient, alias string) (*types.QueryGetRollappResponse, error) {
params := &types.QueryGetRollappByAliasRequest{
Alias: alias,
}

res, err := queryClient.RollappByAlias(ctx, params)
if err != nil {
return nil, err
}
return res, nil
}
Loading

0 comments on commit 71eac1b

Please sign in to comment.