diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/genesis.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/genesis.ts index 7d31cd2ac3..00311a9921 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/genesis.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/genesis.ts @@ -4,13 +4,11 @@ import { DeepPartial } from "../../helpers"; /** Module genesis state */ export interface GenesisState { - /** Module genesis state */ accounts: AccountState[]; } /** Module genesis state */ export interface GenesisStateSDKType { - /** Module genesis state */ accounts: AccountStateSDKType[]; } diff --git a/proto/dydxprotocol/accountplus/accountplus.proto b/proto/dydxprotocol/accountplus/accountplus.proto index 07305b0854..838fa5ab72 100644 --- a/proto/dydxprotocol/accountplus/accountplus.proto +++ b/proto/dydxprotocol/accountplus/accountplus.proto @@ -1,12 +1,15 @@ syntax = "proto3"; package dydxprotocol.accountplus; +import "gogoproto/gogo.proto"; + option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types"; // Account State message AccountState { string address = 1; - TimestampNonceDetails timestamp_nonce_details = 2; + TimestampNonceDetails timestamp_nonce_details = 2 + [ (gogoproto.nullable) = false ]; } // Timestamp nonce details diff --git a/proto/dydxprotocol/accountplus/genesis.proto b/proto/dydxprotocol/accountplus/genesis.proto index 0a0129a7f7..9358dca161 100644 --- a/proto/dydxprotocol/accountplus/genesis.proto +++ b/proto/dydxprotocol/accountplus/genesis.proto @@ -1,9 +1,12 @@ syntax = "proto3"; package dydxprotocol.accountplus; +import "gogoproto/gogo.proto"; import "dydxprotocol/accountplus/accountplus.proto"; option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types"; // Module genesis state -message GenesisState { repeated AccountState accounts = 1; } +message GenesisState { + repeated AccountState accounts = 1 [ (gogoproto.nullable) = false ]; +} diff --git a/protocol/app/app.go b/protocol/app/app.go index 46bde305a8..2a8ae57738 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -130,6 +130,9 @@ import ( daemontypes "github.com/dydxprotocol/v4-chain/protocol/daemons/types" // Modules + accountplusmodule "github.com/dydxprotocol/v4-chain/protocol/x/accountplus" + accountplusmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/keeper" + accountplusmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types" assetsmodule "github.com/dydxprotocol/v4-chain/protocol/x/assets" assetsmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/assets/keeper" assetsmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/assets/types" @@ -294,6 +297,7 @@ type App struct { FeeGrantKeeper feegrantkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper GovPlusKeeper govplusmodulekeeper.Keeper + AccountPlusKeeper accountplusmodulekeeper.Keeper MarketMapKeeper marketmapmodulekeeper.Keeper @@ -450,6 +454,7 @@ func New( govplusmoduletypes.StoreKey, vaultmoduletypes.StoreKey, revsharemoduletypes.StoreKey, + accountplusmoduletypes.StoreKey, marketmapmoduletypes.StoreKey, ) keys[authtypes.StoreKey] = keys[authtypes.StoreKey].WithLocking() @@ -1165,6 +1170,12 @@ func New( ) listingModule := listingmodule.NewAppModule(appCodec, app.ListingKeeper) + app.AccountPlusKeeper = *accountplusmodulekeeper.NewKeeper( + appCodec, + keys[govplusmoduletypes.StoreKey], + ) + accountplusModule := accountplusmodule.NewAppModule(appCodec, app.AccountPlusKeeper) + /**** Module Options ****/ // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment @@ -1235,6 +1246,7 @@ func New( vaultModule, listingModule, revShareModule, + accountplusModule, marketmapModule, ) @@ -1285,6 +1297,7 @@ func New( vaultmoduletypes.ModuleName, listingmoduletypes.ModuleName, revsharemoduletypes.ModuleName, + accountplusmoduletypes.ModuleName, marketmapmoduletypes.ModuleName, ) @@ -1331,6 +1344,7 @@ func New( vaultmoduletypes.ModuleName, listingmoduletypes.ModuleName, revsharemoduletypes.ModuleName, + accountplusmoduletypes.ModuleName, marketmapmoduletypes.ModuleName, authz.ModuleName, // No-op. blocktimemoduletypes.ModuleName, // Must be last @@ -1378,6 +1392,7 @@ func New( vaultmoduletypes.ModuleName, listingmoduletypes.ModuleName, revsharemoduletypes.ModuleName, + accountplusmoduletypes.ModuleName, marketmapmoduletypes.ModuleName, authz.ModuleName, ) @@ -1421,6 +1436,7 @@ func New( vaultmoduletypes.ModuleName, listingmoduletypes.ModuleName, revsharemoduletypes.ModuleName, + accountplusmoduletypes.ModuleName, marketmapmoduletypes.ModuleName, authz.ModuleName, diff --git a/protocol/app/app_test.go b/protocol/app/app_test.go index f8dca3c3e3..a91b93ae50 100644 --- a/protocol/app/app_test.go +++ b/protocol/app/app_test.go @@ -1,13 +1,12 @@ package app_test import ( - marketmapmodule "github.com/skip-mev/slinky/x/marketmap" "reflect" "strings" "testing" "time" - listingmodule "github.com/dydxprotocol/v4-chain/protocol/x/listing" + marketmapmodule "github.com/skip-mev/slinky/x/marketmap" evidencemodule "cosmossdk.io/x/evidence" feegrantmodule "cosmossdk.io/x/feegrant/module" @@ -34,6 +33,7 @@ import ( custommodule "github.com/dydxprotocol/v4-chain/protocol/app/module" "github.com/dydxprotocol/v4-chain/protocol/mocks" testapp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" + accountplusmodule "github.com/dydxprotocol/v4-chain/protocol/x/accountplus" assetsmodule "github.com/dydxprotocol/v4-chain/protocol/x/assets" blocktimemodule "github.com/dydxprotocol/v4-chain/protocol/x/blocktime" bridgemodule "github.com/dydxprotocol/v4-chain/protocol/x/bridge" @@ -42,6 +42,7 @@ import ( epochsmodule "github.com/dydxprotocol/v4-chain/protocol/x/epochs" feetiersmodule "github.com/dydxprotocol/v4-chain/protocol/x/feetiers" govplusmodule "github.com/dydxprotocol/v4-chain/protocol/x/govplus" + listingmodule "github.com/dydxprotocol/v4-chain/protocol/x/listing" perpetualsmodule "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals" pricesmodule "github.com/dydxprotocol/v4-chain/protocol/x/prices" ratelimitmodule "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit" @@ -220,6 +221,7 @@ func TestModuleBasics(t *testing.T) { vaultmodule.AppModuleBasic{}, listingmodule.AppModuleBasic{}, revsharemodule.AppModuleBasic{}, + accountplusmodule.AppModuleBasic{}, // slinky marketmap marketmapmodule.AppModuleBasic{}, diff --git a/protocol/app/basic_manager/basic_manager.go b/protocol/app/basic_manager/basic_manager.go index e6dd2a0f56..ddbc361b7a 100644 --- a/protocol/app/basic_manager/basic_manager.go +++ b/protocol/app/basic_manager/basic_manager.go @@ -23,6 +23,7 @@ import ( listingmodule "github.com/dydxprotocol/v4-chain/protocol/x/listing" custommodule "github.com/dydxprotocol/v4-chain/protocol/app/module" + accountplusmodule "github.com/dydxprotocol/v4-chain/protocol/x/accountplus" assetsmodule "github.com/dydxprotocol/v4-chain/protocol/x/assets" blocktimemodule "github.com/dydxprotocol/v4-chain/protocol/x/blocktime" bridgemodule "github.com/dydxprotocol/v4-chain/protocol/x/bridge" @@ -99,5 +100,6 @@ var ( revsharemodule.AppModuleBasic{}, listingmodule.AppModuleBasic{}, marketmapmodule.AppModuleBasic{}, + accountplusmodule.AppModuleBasic{}, ) ) diff --git a/protocol/app/testdata/default_genesis_state.json b/protocol/app/testdata/default_genesis_state.json index 727d29aed0..cdcd06887a 100644 --- a/protocol/app/testdata/default_genesis_state.json +++ b/protocol/app/testdata/default_genesis_state.json @@ -127,6 +127,9 @@ "delegator_starting_infos": [], "validator_slash_events": [] }, + "dydxaccountplus": { + "accounts": [] + }, "epochs": { "epoch_info_list": [ { diff --git a/protocol/app/upgrades/v6.0.0/constants.go b/protocol/app/upgrades/v6.0.0/constants.go index d9e4785672..59b3253405 100644 --- a/protocol/app/upgrades/v6.0.0/constants.go +++ b/protocol/app/upgrades/v6.0.0/constants.go @@ -6,6 +6,7 @@ import ( marketmapmoduletypes "github.com/skip-mev/slinky/x/marketmap/types" "github.com/dydxprotocol/v4-chain/protocol/app/upgrades" + accountplustypes "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types" listingtypes "github.com/dydxprotocol/v4-chain/protocol/x/listing/types" revsharetypes "github.com/dydxprotocol/v4-chain/protocol/x/revshare/types" ) @@ -22,6 +23,7 @@ var ( listingtypes.StoreKey, revsharetypes.StoreKey, marketmapmoduletypes.StoreKey, + accountplustypes.StoreKey, }, }, } diff --git a/protocol/scripts/genesis/sample_pregenesis.json b/protocol/scripts/genesis/sample_pregenesis.json index 5e886afbd1..807d63a8a9 100644 --- a/protocol/scripts/genesis/sample_pregenesis.json +++ b/protocol/scripts/genesis/sample_pregenesis.json @@ -636,6 +636,9 @@ "validator_historical_rewards": [], "validator_slash_events": [] }, + "dydxaccountplus": { + "accounts": [] + }, "epochs": { "epoch_info_list": [ { @@ -1859,7 +1862,7 @@ ] } }, - "app_version": "5.0.0-dev0-385-gb5b86472", + "app_version": "5.0.0-dev0-378-ge9777b09", "chain_id": "dydx-sample-1", "consensus": { "params": { diff --git a/protocol/testing/containertest/preupgrade_genesis.json b/protocol/testing/containertest/preupgrade_genesis.json index 0dc8155688..b911f4246b 100644 --- a/protocol/testing/containertest/preupgrade_genesis.json +++ b/protocol/testing/containertest/preupgrade_genesis.json @@ -774,6 +774,9 @@ "delegator_starting_infos": [], "validator_slash_events": [] }, + "dydxaccountplus": { + "accounts": [] + }, "epochs": { "epoch_info_list": [ { diff --git a/protocol/x/accountplus/genesis.go b/protocol/x/accountplus/genesis.go index 2d47e2d6a1..d84289a0db 100644 --- a/protocol/x/accountplus/genesis.go +++ b/protocol/x/accountplus/genesis.go @@ -13,8 +13,12 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) { } } -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState { - return types.GenesisState{ - Accounts: k.GetAllAccountStates(ctx), +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + accounts, err := k.GetAllAccountStates(ctx) + if err != nil { + panic(err) + } + return &types.GenesisState{ + Accounts: accounts, } } diff --git a/protocol/x/accountplus/genesis_test.go b/protocol/x/accountplus/genesis_test.go index cfcb93f9d9..dc0a82d055 100644 --- a/protocol/x/accountplus/genesis_test.go +++ b/protocol/x/accountplus/genesis_test.go @@ -4,13 +4,10 @@ import ( "math" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" + testapp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" - keepertest "github.com/dydxprotocol/v4-chain/protocol/testutil/keeper" "github.com/dydxprotocol/v4-chain/protocol/x/accountplus" - "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/keeper" "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types" - "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" ) @@ -18,96 +15,93 @@ func TestImportExportGenesis(t *testing.T) { baseTsNonce := uint64(math.Pow(2, 40)) tests := map[string]struct { genesisState *types.GenesisState + // The order of this list may not match the order in GenesisState. We want our tests to be deterministic so + // order of expectedAccountStates was manually set based on test debug. This ordering should only be changed if + // additional accounts added to genesisState. If a feature breaks the existing ordering, should look into why. + expectedAccountStates []types.AccountState }{ "non-empty genesis": { genesisState: &types.GenesisState{ - Accounts: []*types.AccountState{ + Accounts: []types.AccountState{ { Address: constants.AliceAccAddress.String(), - TimestampNonceDetails: &types.TimestampNonceDetails{ + TimestampNonceDetails: types.TimestampNonceDetails{ TimestampNonces: []uint64{baseTsNonce + 1, baseTsNonce + 2, baseTsNonce + 3}, MaxEjectedNonce: baseTsNonce, }, }, { Address: constants.BobAccAddress.String(), - TimestampNonceDetails: &types.TimestampNonceDetails{ + TimestampNonceDetails: types.TimestampNonceDetails{ TimestampNonces: []uint64{baseTsNonce + 5, baseTsNonce + 6, baseTsNonce + 7}, MaxEjectedNonce: baseTsNonce + 1, }, }, + { + Address: constants.CarlAccAddress.String(), + TimestampNonceDetails: types.TimestampNonceDetails{ + TimestampNonces: []uint64{baseTsNonce + 5, baseTsNonce + 6, baseTsNonce + 7}, + MaxEjectedNonce: baseTsNonce + 1, + }, + }, + }, + }, + expectedAccountStates: []types.AccountState{ + { + Address: constants.AliceAccAddress.String(), + TimestampNonceDetails: types.TimestampNonceDetails{ + TimestampNonces: []uint64{baseTsNonce + 1, baseTsNonce + 2, baseTsNonce + 3}, + MaxEjectedNonce: baseTsNonce, + }, + }, + { + Address: constants.CarlAccAddress.String(), + TimestampNonceDetails: types.TimestampNonceDetails{ + TimestampNonces: []uint64{baseTsNonce + 5, baseTsNonce + 6, baseTsNonce + 7}, + MaxEjectedNonce: baseTsNonce + 1, + }, + }, + { + Address: constants.BobAccAddress.String(), + TimestampNonceDetails: types.TimestampNonceDetails{ + TimestampNonces: []uint64{baseTsNonce + 5, baseTsNonce + 6, baseTsNonce + 7}, + MaxEjectedNonce: baseTsNonce + 1, + }, }, }, }, "empty genesis": { genesisState: &types.GenesisState{ - Accounts: []*types.AccountState{}, + Accounts: []types.AccountState{}, }, + expectedAccountStates: []types.AccountState{}, }, } for name, tc := range tests { t.Run(name, func(t *testing.T) { - // TODO: deprecated, reference protocol/vest/genesis_test.go for up to date initialization - ctx, k, _, _ := keepertest.TimestampNonceKeepers(t) + tApp := testapp.NewTestAppBuilder(t).Build() + ctx := tApp.InitChain() + k := tApp.App.AccountPlusKeeper - // Initialize genesis state - accountplus.InitGenesis(ctx, *k, *tc.genesisState) + accountplus.InitGenesis(ctx, k, *tc.genesisState) - // Check that keeper state is correct - compareKeeperWithGenesisState(t, ctx, k, tc.genesisState) + // Check that keeper accounts states are correct + actualAccountStates, _ := k.GetAllAccountStates(ctx) + require.Equal( + t, + tc.expectedAccountStates, + actualAccountStates, + "Keeper account states do not match Genesis account states", + ) - // Export the genesis state - exportedGenesis := accountplus.ExportGenesis(ctx, *k) + exportedGenesis := accountplus.ExportGenesis(ctx, k) - // Ensure the exported state matches the expected state - requireGenesisStatesEqual(t, tc.genesisState, &exportedGenesis) + // Check that the exported state matches the expected state + expectedGenesis := &types.GenesisState{ + Accounts: tc.expectedAccountStates, + } + require.Equal(t, *exportedGenesis, *expectedGenesis) }) } } - -func compareKeeperWithGenesisState(t *testing.T, ctx sdk.Context, k *keeper.Keeper, genesisState *types.GenesisState) { - accountStates := k.GetAllAccountStates(ctx) - - compareAccountStates(t, accountStates, genesisState.GetAccounts()) -} - -func requireGenesisStatesEqual(t *testing.T, actualGenesisState, expectedGenesisState *types.GenesisState) { - compareAccountStates(t, actualGenesisState.GetAccounts(), expectedGenesisState.GetAccounts()) -} - -func compareAccountStates(t *testing.T, actualAccountStates, expectedAccountStates []*types.AccountState) { - require.Equal(t, len(actualAccountStates), len(expectedAccountStates), "GenesisState.Accounts length mismatch") - // Iterate through the account states and test equality on each field - // We require that the ordering of accountState be deterministic so that should more complicated logic - // be introduced in the future, this test can catch any unintended effects. - for i := range actualAccountStates { - require.Equal( - t, - actualAccountStates[i].Address, - expectedAccountStates[i].Address, - "Account address mismatch at index %d", i, - ) - compareTimestampNonceDetails( - t, - actualAccountStates[i].GetTimestampNonceDetails(), - expectedAccountStates[i].GetTimestampNonceDetails(), - ) - } -} - -func compareTimestampNonceDetails(t *testing.T, actualDetails, expectedDetails *types.TimestampNonceDetails) { - equal := cmp.Equal( - actualDetails.GetTimestampNonces(), - expectedDetails.GetTimestampNonces(), - ) - - require.True(t, equal, "TimestampNonces mismatch for account") - - require.Equal( - t, - actualDetails.GetMaxEjectedNonce(), - expectedDetails.GetMaxEjectedNonce(), - "LastEjectedNonce mismatch", - ) -} diff --git a/protocol/x/accountplus/keeper/keeper.go b/protocol/x/accountplus/keeper/keeper.go index 59f3787889..9f3ef67c43 100644 --- a/protocol/x/accountplus/keeper/keeper.go +++ b/protocol/x/accountplus/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + "errors" "fmt" "cosmossdk.io/log" @@ -10,6 +11,16 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types" ) +func DefaultAccountState(address sdk.AccAddress) types.AccountState { + return types.AccountState{ + Address: address.String(), + TimestampNonceDetails: types.TimestampNonceDetails{ + MaxEjectedNonce: 0, + TimestampNonces: []uint64{}, + }, + } +} + type Keeper struct { cdc codec.BinaryCodec storeKey storetypes.StoreKey @@ -31,43 +42,78 @@ func (k Keeper) InitializeForGenesis(ctx sdk.Context) { } // Get all account details pairs in store -func (k Keeper) GetAllAccountStates(ctx sdk.Context) []*types.AccountState { +func (k Keeper) GetAllAccountStates(ctx sdk.Context) ([]types.AccountState, error) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, nil) defer iterator.Close() - var accounts []*types.AccountState + accounts := []types.AccountState{} for ; iterator.Valid(); iterator.Next() { - var account types.AccountState - k.cdc.MustUnmarshal(iterator.Value(), &account) - accounts = append(accounts, &account) + accountState, found := k.GetAccountState(ctx, iterator.Key()) + if !found { + return accounts, errors.New("Could not get account state for address: " + sdk.AccAddress(iterator.Key()).String()) + } + accounts = append(accounts, accountState) } - return accounts + return accounts, nil } // Set genesis state func (k Keeper) SetGenesisState(ctx sdk.Context, data types.GenesisState) error { - store := ctx.KVStore(k.storeKey) - for _, account := range data.Accounts { address, err := sdk.AccAddressFromBech32(account.Address) if err != nil { return err } - k.setAccountState(store, address, *account) + k.setAccountState(ctx, address, account) + } + + return nil +} + +func (k Keeper) InitializeAccount(ctx sdk.Context, address sdk.AccAddress) error { + if _, found := k.GetAccountState(ctx, address); found { + return errors.New( + "Cannot initialize AccountState for address with existing AccountState, address: " + address.String(), + ) } + k.setAccountState(ctx, address, DefaultAccountState(address)) + return nil } +// Get the AccountState from KVStore for a given account address +func (k Keeper) GetAccountState( + ctx sdk.Context, + address sdk.AccAddress, +) (types.AccountState, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(address.Bytes()) + if bz == nil { + return types.AccountState{}, false + } + + var accountState types.AccountState + k.cdc.MustUnmarshal(bz, &accountState) + + // By default empty slices are Unmarshed into nil + if accountState.TimestampNonceDetails.TimestampNonces == nil { + accountState.TimestampNonceDetails.TimestampNonces = make([]uint64, 0) + } + + return accountState, true +} + // Set the AccountState into KVStore for a given account address func (k Keeper) setAccountState( - store storetypes.KVStore, + ctx sdk.Context, address sdk.AccAddress, accountState types.AccountState, ) { + store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&accountState) store.Set(address.Bytes(), bz) } diff --git a/protocol/x/accountplus/keeper/keeper_test.go b/protocol/x/accountplus/keeper/keeper_test.go new file mode 100644 index 0000000000..0d0b01b6f4 --- /dev/null +++ b/protocol/x/accountplus/keeper/keeper_test.go @@ -0,0 +1,57 @@ +package keeper_test + +import ( + "math" + "testing" + + keepertest "github.com/dydxprotocol/v4-chain/protocol/testutil/keeper" + "github.com/stretchr/testify/require" + + "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" + "github.com/dydxprotocol/v4-chain/protocol/x/accountplus" + "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/keeper" + "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types" +) + +func TestInitializeAccount(t *testing.T) { + baseTsNonce := uint64(math.Pow(2, 40)) + genesisState := &types.GenesisState{ + Accounts: []types.AccountState{ + { + Address: constants.AliceAccAddress.String(), + TimestampNonceDetails: types.TimestampNonceDetails{ + TimestampNonces: []uint64{baseTsNonce + 1, baseTsNonce + 2, baseTsNonce + 3}, + MaxEjectedNonce: baseTsNonce, + }, + }, + { + Address: constants.BobAccAddress.String(), + TimestampNonceDetails: types.TimestampNonceDetails{ + TimestampNonces: []uint64{baseTsNonce + 5, baseTsNonce + 6, baseTsNonce + 7}, + MaxEjectedNonce: baseTsNonce + 1, + }, + }, + }, + } + + t.Run("Cannot initialize existing account", func(t *testing.T) { + ctx, k, _, _ := keepertest.TimestampNonceKeepers(t) + accountplus.InitGenesis(ctx, *k, *genesisState) + err := k.InitializeAccount(ctx, constants.AliceAccAddress) + require.NotNil(t, err, "Account should not be able to be initialized if already exists") + }) + + t.Run("Can initialize new account", func(t *testing.T) { + ctx, k, _, _ := keepertest.TimestampNonceKeepers(t) + accountplus.InitGenesis(ctx, *k, *genesisState) + + expectedAccount := keeper.DefaultAccountState(constants.CarlAccAddress) + + err := k.InitializeAccount(ctx, constants.CarlAccAddress) + require.Nil(t, err, "Should be able to initialize account if it did not exist") + + actualAccount, found := k.GetAccountState(ctx, constants.CarlAccAddress) + require.True(t, found, "Could not find account") + require.Equal(t, actualAccount, expectedAccount) + }) +} diff --git a/protocol/x/accountplus/keeper/timestampnonce.go b/protocol/x/accountplus/keeper/timestampnonce.go new file mode 100644 index 0000000000..957b854096 --- /dev/null +++ b/protocol/x/accountplus/keeper/timestampnonce.go @@ -0,0 +1,3 @@ +package keeper + +func Placeholder() {} diff --git a/protocol/x/accountplus/keeper/timestampnonce_test.go b/protocol/x/accountplus/keeper/timestampnonce_test.go new file mode 100644 index 0000000000..e2d6fabe21 --- /dev/null +++ b/protocol/x/accountplus/keeper/timestampnonce_test.go @@ -0,0 +1,7 @@ +package keeper_test + +import ( + "testing" +) + +func Placeholder(t *testing.T) {} diff --git a/protocol/x/accountplus/module.go b/protocol/x/accountplus/module.go new file mode 100644 index 0000000000..f1e3b6a0ae --- /dev/null +++ b/protocol/x/accountplus/module.go @@ -0,0 +1,150 @@ +package accountplus + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/keeper" + "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types" +) + +var ( + _ module.AppModuleBasic = AppModuleBasic{} + _ module.HasGenesisBasics = AppModuleBasic{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasEndBlocker = AppModule{} + _ module.HasConsensusVersion = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methodsa Cosmos SDK module +// needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs +// to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users +// to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + // accountplus is currently purely for storage and does not support user-submitted transactions + return nil +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by +// end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + // accountplus is currently purely for storage and does not support queries + return nil +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default +// GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// IsOnePerModuleType is a marker function just indicates that this is a one-per-module type. +func (am AppModule) IsOnePerModuleType() {} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + // accountplus does not have message and query +} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each +// consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should +// be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(ctx context.Context) error { + return nil +} diff --git a/protocol/x/accountplus/types/accountplus.pb.go b/protocol/x/accountplus/types/accountplus.pb.go index fcb6dcf482..7ebb29da1d 100644 --- a/protocol/x/accountplus/types/accountplus.pb.go +++ b/protocol/x/accountplus/types/accountplus.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -24,8 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Account State type AccountState struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - TimestampNonceDetails *TimestampNonceDetails `protobuf:"bytes,2,opt,name=timestamp_nonce_details,json=timestampNonceDetails,proto3" json:"timestamp_nonce_details,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + TimestampNonceDetails TimestampNonceDetails `protobuf:"bytes,2,opt,name=timestamp_nonce_details,json=timestampNonceDetails,proto3" json:"timestamp_nonce_details"` } func (m *AccountState) Reset() { *m = AccountState{} } @@ -68,11 +69,11 @@ func (m *AccountState) GetAddress() string { return "" } -func (m *AccountState) GetTimestampNonceDetails() *TimestampNonceDetails { +func (m *AccountState) GetTimestampNonceDetails() TimestampNonceDetails { if m != nil { return m.TimestampNonceDetails } - return nil + return TimestampNonceDetails{} } // Timestamp nonce details @@ -140,24 +141,25 @@ func init() { } var fileDescriptor_391b06af1cfe6fb0 = []byte{ - // 269 bytes of a gzipped FileDescriptorProto + // 288 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4a, 0xa9, 0x4c, 0xa9, 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0xc8, 0x29, 0x2d, 0x46, 0x66, 0xeb, 0x81, 0x15, 0x08, 0x49, 0x20, 0xab, 0xd5, 0x43, 0x92, - 0x57, 0x9a, 0xc8, 0xc8, 0xc5, 0xe3, 0x08, 0xe1, 0x07, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0x49, 0x70, - 0xb1, 0x27, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xc1, - 0xb8, 0x42, 0xe9, 0x5c, 0xe2, 0x25, 0x99, 0xb9, 0xa9, 0xc5, 0x25, 0x89, 0xb9, 0x05, 0xf1, 0x79, - 0xf9, 0x79, 0xc9, 0xa9, 0xf1, 0x29, 0xa9, 0x25, 0x89, 0x99, 0x39, 0xc5, 0x12, 0x4c, 0x0a, 0x8c, - 0x1a, 0xdc, 0x46, 0xfa, 0x7a, 0xb8, 0xac, 0xd1, 0x0b, 0x81, 0x69, 0xf4, 0x03, 0xe9, 0x73, 0x81, - 0x68, 0x0b, 0x12, 0x2d, 0xc1, 0x26, 0xac, 0x94, 0xc7, 0x25, 0x8a, 0x55, 0xbd, 0x90, 0x26, 0x97, - 0x00, 0x9a, 0x0b, 0x40, 0x8e, 0x64, 0xd6, 0x60, 0x09, 0xe2, 0x47, 0x35, 0xa9, 0x58, 0x48, 0x8b, - 0x4b, 0x30, 0x37, 0xb1, 0x22, 0x3e, 0x35, 0x2b, 0x35, 0xb9, 0x24, 0x35, 0x05, 0xa2, 0x18, 0xec, - 0x4c, 0x96, 0x20, 0xfe, 0xdc, 0xc4, 0x0a, 0x57, 0x88, 0x38, 0x58, 0xb1, 0x53, 0xf8, 0x89, 0x47, - 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, - 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xd9, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, - 0x25, 0xe7, 0xe7, 0xea, 0xa3, 0x04, 0x77, 0x99, 0x89, 0x6e, 0x72, 0x46, 0x62, 0x66, 0x9e, 0x3e, - 0x5c, 0xa4, 0x02, 0x25, 0x0a, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xb2, 0xc6, 0x80, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x61, 0x2f, 0x18, 0xab, 0x01, 0x00, 0x00, + 0x97, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xe8, 0x83, 0x58, 0x10, 0xf5, 0x4a, 0xd3, 0x19, + 0xb9, 0x78, 0x1c, 0x21, 0xaa, 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0x24, 0xb8, 0xd8, 0x13, 0x53, + 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0xa1, 0x5c, + 0x2e, 0xf1, 0x92, 0xcc, 0xdc, 0xd4, 0xe2, 0x92, 0xc4, 0xdc, 0x82, 0xf8, 0xbc, 0xfc, 0xbc, 0xe4, + 0xd4, 0xf8, 0x94, 0xd4, 0x92, 0xc4, 0xcc, 0x9c, 0x62, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x6e, 0x23, + 0x7d, 0x3d, 0x5c, 0x96, 0xeb, 0x85, 0xc0, 0x34, 0xfa, 0x81, 0xf4, 0xb9, 0x40, 0xb4, 0x39, 0xb1, + 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x24, 0x5a, 0x82, 0x4d, 0x52, 0x29, 0x8f, 0x4b, 0x14, 0xab, 0x2e, + 0x21, 0x4d, 0x2e, 0x01, 0x34, 0x77, 0x80, 0x9c, 0xca, 0xac, 0xc1, 0x12, 0xc4, 0x8f, 0x6a, 0x52, + 0xb1, 0x90, 0x16, 0x97, 0x60, 0x6e, 0x62, 0x45, 0x7c, 0x6a, 0x56, 0x6a, 0x72, 0x49, 0x6a, 0x0a, + 0x44, 0x31, 0xd8, 0xb1, 0x2c, 0x41, 0xfc, 0xb9, 0x89, 0x15, 0xae, 0x10, 0x71, 0xb0, 0x62, 0xa7, + 0xf0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, + 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xb2, 0x4d, 0xcf, 0x2c, 0xc9, + 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0x89, 0x8a, 0x32, 0x13, 0xdd, 0xe4, 0x8c, 0xc4, + 0xcc, 0x3c, 0x7d, 0xb8, 0x48, 0x05, 0x4a, 0xf4, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, + 0x65, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xed, 0x5d, 0xef, 0x80, 0xc7, 0x01, 0x00, 0x00, } func (m *AccountState) Marshal() (dAtA []byte, err error) { @@ -180,18 +182,16 @@ func (m *AccountState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.TimestampNonceDetails != nil { - { - size, err := m.TimestampNonceDetails.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAccountplus(dAtA, i, uint64(size)) + { + size, err := m.TimestampNonceDetails.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintAccountplus(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) @@ -269,10 +269,8 @@ func (m *AccountState) Size() (n int) { if l > 0 { n += 1 + l + sovAccountplus(uint64(l)) } - if m.TimestampNonceDetails != nil { - l = m.TimestampNonceDetails.Size() - n += 1 + l + sovAccountplus(uint64(l)) - } + l = m.TimestampNonceDetails.Size() + n += 1 + l + sovAccountplus(uint64(l)) return n } @@ -391,9 +389,6 @@ func (m *AccountState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.TimestampNonceDetails == nil { - m.TimestampNonceDetails = &TimestampNonceDetails{} - } if err := m.TimestampNonceDetails.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/protocol/x/accountplus/types/codec.go b/protocol/x/accountplus/types/codec.go new file mode 100644 index 0000000000..994545c1e9 --- /dev/null +++ b/protocol/x/accountplus/types/codec.go @@ -0,0 +1,16 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" +) + +func RegisterCodec(cdc *codec.LegacyAmino) {} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/protocol/x/accountplus/types/genesis.go b/protocol/x/accountplus/types/genesis.go new file mode 100644 index 0000000000..315d5df0ae --- /dev/null +++ b/protocol/x/accountplus/types/genesis.go @@ -0,0 +1,12 @@ +package types + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{} +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + return nil +} diff --git a/protocol/x/accountplus/types/genesis.pb.go b/protocol/x/accountplus/types/genesis.pb.go index 5945a650a9..13a13d224e 100644 --- a/protocol/x/accountplus/types/genesis.pb.go +++ b/protocol/x/accountplus/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -24,7 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Module genesis state type GenesisState struct { - Accounts []*AccountState `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts,omitempty"` + Accounts []AccountState `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -60,7 +61,7 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetAccounts() []*AccountState { +func (m *GenesisState) GetAccounts() []AccountState { if m != nil { return m.Accounts } @@ -76,19 +77,20 @@ func init() { } var fileDescriptor_03516b8fa43b3a59 = []byte{ - // 183 bytes of a gzipped FileDescriptorProto + // 202 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0xa9, 0x4c, 0xa9, 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0xc8, 0x29, 0x2d, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x03, 0x4b, 0x0a, - 0x49, 0x20, 0xab, 0xd3, 0x43, 0x52, 0x27, 0xa5, 0x85, 0xd3, 0x04, 0x24, 0x36, 0xc4, 0x14, 0xa5, - 0x20, 0x2e, 0x1e, 0x77, 0x88, 0xb1, 0xc1, 0x25, 0x89, 0x25, 0xa9, 0x42, 0x4e, 0x5c, 0x1c, 0x50, - 0x45, 0xc5, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x6a, 0x7a, 0xb8, 0x2c, 0xd2, 0x73, 0x84, - 0xb0, 0xc1, 0x3a, 0x83, 0xe0, 0xfa, 0x9c, 0xc2, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, - 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, - 0x8e, 0x21, 0xca, 0x36, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xc5, - 0x91, 0x65, 0x26, 0xba, 0xc9, 0x19, 0x89, 0x99, 0x79, 0xfa, 0x70, 0x91, 0x0a, 0x14, 0x87, 0x97, - 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x65, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x06, - 0xfe, 0xb4, 0xa0, 0x23, 0x01, 0x00, 0x00, + 0x49, 0x20, 0xab, 0xd3, 0x43, 0x52, 0x27, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x96, 0xd1, 0x07, + 0xb1, 0x20, 0xea, 0xa5, 0xb4, 0x70, 0x9a, 0x8b, 0xc4, 0x86, 0xa8, 0x55, 0x8a, 0xe0, 0xe2, 0x71, + 0x87, 0x58, 0x16, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0xe4, 0xc1, 0xc5, 0x01, 0x55, 0x54, 0x2c, 0xc1, + 0xa8, 0xc0, 0xac, 0xc1, 0x6d, 0xa4, 0xa6, 0x87, 0xcb, 0x7a, 0x3d, 0x47, 0x08, 0x1b, 0xac, 0xd3, + 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xb8, 0x6e, 0xa7, 0xf0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, + 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, + 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xb2, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, + 0xd5, 0x47, 0x71, 0x6a, 0x99, 0x89, 0x6e, 0x72, 0x46, 0x62, 0x66, 0x9e, 0x3e, 0x5c, 0xa4, 0x02, + 0xc5, 0xf9, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x59, 0x63, 0x40, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xfa, 0x84, 0x6b, 0x24, 0x3f, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -218,7 +220,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Accounts = append(m.Accounts, &AccountState{}) + m.Accounts = append(m.Accounts, AccountState{}) if err := m.Accounts[len(m.Accounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/protocol/x/accountplus/types/keys.go b/protocol/x/accountplus/types/keys.go index 66ab963f50..3dbc04fc89 100644 --- a/protocol/x/accountplus/types/keys.go +++ b/protocol/x/accountplus/types/keys.go @@ -2,8 +2,9 @@ package types // Module name and store keys. const ( - // ModuleName defines the module name. - ModuleName = "accountplus" + // The Account module uses "acc" as its module name. + // KVStore keys cannot have other keys as prefixes so we prepend "dydx" to "accountplus" + ModuleName = "dydxaccountplus" // StoreKey defines the primary module store key. StoreKey = ModuleName