Skip to content

Commit

Permalink
Add additional scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryfan01234 committed Jul 19, 2024
1 parent 3e469e6 commit 579c006
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions protocol/app/basic_manager/basic_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -99,5 +100,6 @@ var (
revsharemodule.AppModuleBasic{},
listingmodule.AppModuleBasic{},
marketmapmodule.AppModuleBasic{},
accountplusmodule.AppModuleBasic{},
)
)
2 changes: 2 additions & 0 deletions protocol/app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func (app *App) setupUpgradeHandlers() {
v6_0_0.CreateUpgradeHandler(
app.ModuleManager,
app.configurator,
app.AccountKeeper,
app.AccountPlusKeeper,
app.ClobKeeper,
app.PricesKeeper,
app.MarketMapKeeper,
Expand Down
2 changes: 2 additions & 0 deletions protocol/app/upgrades/v6.0.0/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -22,6 +23,7 @@ var (
listingtypes.StoreKey,
revsharetypes.StoreKey,
marketmapmoduletypes.StoreKey,
accountplustypes.StoreKey,
},
},
}
Expand Down
21 changes: 21 additions & 0 deletions protocol/app/upgrades/v6.0.0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
"fmt"

upgradetypes "cosmossdk.io/x/upgrade/types"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events"
"github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager"
indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared"
"github.com/dydxprotocol/v4-chain/protocol/lib"
accountpluskeeper "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/keeper"
clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types"
pricestypes "github.com/dydxprotocol/v4-chain/protocol/x/prices/types"
revsharetypes "github.com/dydxprotocol/v4-chain/protocol/x/revshare/types"
Expand Down Expand Up @@ -131,9 +133,26 @@ func initRevShareModuleState(
}
}

func initAccountplusModuleState(
ctx sdk.Context,
accountKeeper authkeeper.AccountKeeper,
accountplusKeeper accountpluskeeper.Keeper,
) {
accounts := accountKeeper.GetAllAccounts(ctx)
for _, account := range accounts {
_, err := accountplusKeeper.InitializeAccount(ctx, account.GetAddress())
panic(fmt.Sprintf(
"failed to initialize accountplus state for address %s caused by\n %d",
account.GetAddress().String(),
err))
}
}

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
accountKeeper authkeeper.AccountKeeper,
accountplusKeeper accountpluskeeper.Keeper,
clobKeeper clobtypes.ClobKeeper,
pricesKeeper pricestypes.PricesKeeper,
mmKeeper marketmapkeeper.Keeper,
Expand All @@ -154,6 +173,8 @@ func CreateUpgradeHandler(
// Initialize the rev share module state.
initRevShareModuleState(sdkCtx, revShareKeeper, pricesKeeper)

initAccountplusModuleState(sdkCtx, accountKeeper, accountplusKeeper)

sdkCtx.Logger().Info("Successfully removed stateful orders from state")

return mm.RunMigrations(ctx, configurator, vm)
Expand Down
5 changes: 4 additions & 1 deletion protocol/scripts/genesis/sample_pregenesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@
"validator_historical_rewards": [],
"validator_slash_events": []
},
"dydxaccountplus": {
"accounts": []
},
"epochs": {
"epoch_info_list": [
{
Expand Down Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions protocol/testing/containertest/preupgrade_genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,9 @@
"delegator_starting_infos": [],
"validator_slash_events": []
},
"dydxaccountplus": {
"accounts": []
},
"epochs": {
"epoch_info_list": [
{
Expand Down

0 comments on commit 579c006

Please sign in to comment.