From 4ba5f39ddccd7d26ccd8c74a3fb24ca45f57ec72 Mon Sep 17 00:00:00 2001 From: jayy04 <103467857+jayy04@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:15:53 -0500 Subject: [PATCH] Enable permissioned keys by default (#2645) (cherry picked from commit 3d5913173ea35d2b8111f55de6a04be182bcacb3) --- .../app/testdata/default_genesis_state.json | 2 +- .../upgrades/v8.0/migrate_accountplus_test.go | 12 +++++++++++- protocol/app/upgrades/v8.0/upgrade.go | 2 ++ .../upgrades/v8.0/upgrade_container_test.go | 19 +++++++++++++++++++ .../scripts/genesis/sample_pregenesis.json | 2 +- .../containertest/preupgrade_genesis.json | 2 +- protocol/testing/genesis.sh | 3 +++ protocol/testutil/constants/genesis.go | 2 +- protocol/x/accountplus/types/genesis.go | 6 +++++- 9 files changed, 44 insertions(+), 6 deletions(-) diff --git a/protocol/app/testdata/default_genesis_state.json b/protocol/app/testdata/default_genesis_state.json index 598d1dbc98..71380d8fba 100644 --- a/protocol/app/testdata/default_genesis_state.json +++ b/protocol/app/testdata/default_genesis_state.json @@ -156,7 +156,7 @@ "dydxaccountplus": { "accounts": [], "params": { - "is_smart_account_active": false + "is_smart_account_active": true }, "next_authenticator_id": "0", "authenticator_data": [] diff --git a/protocol/app/upgrades/v8.0/migrate_accountplus_test.go b/protocol/app/upgrades/v8.0/migrate_accountplus_test.go index ce46cbf01e..c8c70ab005 100644 --- a/protocol/app/upgrades/v8.0/migrate_accountplus_test.go +++ b/protocol/app/upgrades/v8.0/migrate_accountplus_test.go @@ -3,6 +3,7 @@ package v_8_0_test import ( "testing" + "github.com/cometbft/cometbft/types" v_8_0 "github.com/dydxprotocol/v4-chain/protocol/app/upgrades/v8.0" "cosmossdk.io/store/prefix" @@ -24,7 +25,16 @@ func TestMigrateAccountplusAccountState(t *testing.T) { } func (s *UpgradeTestSuite) SetupTest() { - s.tApp = testapp.NewTestAppBuilder(s.T()).Build() + s.tApp = testapp.NewTestAppBuilder(s.T()).WithGenesisDocFn(func() (genesis types.GenesisDoc) { + genesis = testapp.DefaultGenesis() + testapp.UpdateGenesisDocWithAppStateForModule( + &genesis, + func(genesisState *accountplustypes.GenesisState) { + genesisState.Params.IsSmartAccountActive = false + }, + ) + return genesis + }).Build() s.Ctx = s.tApp.InitChain() } diff --git a/protocol/app/upgrades/v8.0/upgrade.go b/protocol/app/upgrades/v8.0/upgrade.go index 4864a65bce..bb75cf5fa3 100644 --- a/protocol/app/upgrades/v8.0/upgrade.go +++ b/protocol/app/upgrades/v8.0/upgrade.go @@ -102,6 +102,8 @@ func CreateUpgradeHandler( MigrateAccountplusAccountState(sdkCtx, accountplusKeeper) + accountplusKeeper.SetActiveState(sdkCtx, true) + // Set market, perpetual, and clob ids to a set number setMarketListingBaseIds(sdkCtx, pricesKeeper, perpetualsKeeper, clobKeeper) diff --git a/protocol/app/upgrades/v8.0/upgrade_container_test.go b/protocol/app/upgrades/v8.0/upgrade_container_test.go index 90846694fc..b50a0f2a7e 100644 --- a/protocol/app/upgrades/v8.0/upgrade_container_test.go +++ b/protocol/app/upgrades/v8.0/upgrade_container_test.go @@ -11,6 +11,7 @@ import ( clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" + aptypes "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types" perptypes "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types" pricetypes "github.com/dydxprotocol/v4-chain/protocol/x/prices/types" @@ -45,9 +46,27 @@ func preUpgradeChecks(node *containertest.Node, t *testing.T) { func postUpgradeChecks(node *containertest.Node, t *testing.T) { // Check that the listing module state has been initialized with the hard cap and default deposit params. + postUpgradeSmartAccountActiveCheck(node, t) postUpgradeMarketIdsCheck(node, t) } +func postUpgradeSmartAccountActiveCheck(node *containertest.Node, t *testing.T) { + // query the smart account active + resp, err := containertest.Query( + node, + aptypes.NewQueryClient, + aptypes.QueryClient.Params, + &aptypes.QueryParamsRequest{}, + ) + require.NoError(t, err) + require.NotNil(t, resp) + + queryResponse := aptypes.QueryParamsResponse{} + err = proto.UnmarshalText(resp.String(), &queryResponse) + require.NoError(t, err) + require.Equal(t, true, queryResponse.Params.IsSmartAccountActive) +} + func postUpgradeMarketIdsCheck(node *containertest.Node, t *testing.T) { // query the next market id resp, err := containertest.Query( diff --git a/protocol/scripts/genesis/sample_pregenesis.json b/protocol/scripts/genesis/sample_pregenesis.json index 33cb521f3c..4648ab4b52 100644 --- a/protocol/scripts/genesis/sample_pregenesis.json +++ b/protocol/scripts/genesis/sample_pregenesis.json @@ -667,7 +667,7 @@ "authenticator_data": [], "next_authenticator_id": "0", "params": { - "is_smart_account_active": false + "is_smart_account_active": true } }, "epochs": { diff --git a/protocol/testing/containertest/preupgrade_genesis.json b/protocol/testing/containertest/preupgrade_genesis.json index 5638c4f3d4..6093d3b07a 100644 --- a/protocol/testing/containertest/preupgrade_genesis.json +++ b/protocol/testing/containertest/preupgrade_genesis.json @@ -823,7 +823,7 @@ "dydxaccountplus": { "accounts": [], "params": { - "is_smart_account_active": false + "is_smart_account_active": true }, "next_authenticator_id": "0", "authenticator_data": [] diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index 0ff02a04d9..b5e1560689 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -2152,6 +2152,9 @@ function edit_genesis() { dasel put -t string -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].vault_params.status" -v 'VAULT_STATUS_QUOTING' vault_idx=$(($vault_idx + 1)) done + + # Update accountplus module. + dasel put -t bool -f "$GENESIS" '.app_state.dydxaccountplus.params.is_smart_account_active' -v 'true' } function add_subaccount() { diff --git a/protocol/testutil/constants/genesis.go b/protocol/testutil/constants/genesis.go index b2cdbb41ae..10cf082283 100644 --- a/protocol/testutil/constants/genesis.go +++ b/protocol/testutil/constants/genesis.go @@ -445,7 +445,7 @@ const GenesisState = `{ "dydxaccountplus": { "accounts": [], "params": { - "is_smart_account_active": false + "is_smart_account_active": true }, "next_authenticator_id": "0", "authenticator_data": [] diff --git a/protocol/x/accountplus/types/genesis.go b/protocol/x/accountplus/types/genesis.go index 315d5df0ae..877a02b489 100644 --- a/protocol/x/accountplus/types/genesis.go +++ b/protocol/x/accountplus/types/genesis.go @@ -2,7 +2,11 @@ package types // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { - return &GenesisState{} + return &GenesisState{ + Params: Params{ + IsSmartAccountActive: true, + }, + } } // Validate performs basic genesis state validation returning an error upon any