Skip to content

Commit

Permalink
Enable permissioned keys by default (backport #2645) (#2649)
Browse files Browse the repository at this point in the history
Co-authored-by: jayy04 <[email protected]>
  • Loading branch information
mergify[bot] and jayy04 authored Dec 12, 2024
1 parent 653fd2c commit 2bdb3dc
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion protocol/app/testdata/default_genesis_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
"dydxaccountplus": {
"accounts": [],
"params": {
"is_smart_account_active": false
"is_smart_account_active": true
},
"next_authenticator_id": "0",
"authenticator_data": []
Expand Down
12 changes: 11 additions & 1 deletion protocol/app/upgrades/v8.0/migrate_accountplus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
}

Expand Down
2 changes: 2 additions & 0 deletions protocol/app/upgrades/v8.0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
19 changes: 19 additions & 0 deletions protocol/app/upgrades/v8.0/upgrade_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion protocol/scripts/genesis/sample_pregenesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@
"authenticator_data": [],
"next_authenticator_id": "0",
"params": {
"is_smart_account_active": false
"is_smart_account_active": true
}
},
"epochs": {
Expand Down
2 changes: 1 addition & 1 deletion protocol/testing/containertest/preupgrade_genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@
"dydxaccountplus": {
"accounts": [],
"params": {
"is_smart_account_active": false
"is_smart_account_active": true
},
"next_authenticator_id": "0",
"authenticator_data": []
Expand Down
3 changes: 3 additions & 0 deletions protocol/testing/genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion protocol/testutil/constants/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
Expand Down
6 changes: 5 additions & 1 deletion protocol/x/accountplus/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2bdb3dc

Please sign in to comment.