Skip to content

Commit

Permalink
Nicolas/async icq whitelist (#4358)
Browse files Browse the repository at this point in the history
* added initial icq params

* added ntoe
  • Loading branch information
nicolaslara authored and pysel committed Feb 21, 2023
1 parent 13358b1 commit 9852b0d
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/upgrades/v15/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v15

import (
sdk "github.com/cosmos/cosmos-sdk/types"
icqkeeper "github.com/strangelove-ventures/async-icq/v4/keeper"

bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

Expand All @@ -16,3 +17,7 @@ func MigrateNextPoolId(ctx sdk.Context, gammKeeper *gammkeeper.Keeper, poolmanag
func RegisterOsmoIonMetadata(ctx sdk.Context, bankKeeper bankkeeper.Keeper) {
registerOsmoIonMetadata(ctx, bankKeeper)
}

func SetICQParams(ctx sdk.Context, icqKeeper *icqkeeper.Keeper) {
setICQParams(ctx, icqKeeper)
}
10 changes: 10 additions & 0 deletions app/upgrades/v15/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,13 @@ func (suite *UpgradeTestSuite) TestRegisterOsmoIonMetadata() {
suite.Require().Equal(expectedUosmodenom, uosmoMetadata.Base)
suite.Require().Equal(expectedUiondenom, uionMetadata.Base)
}

func (suite *UpgradeTestSuite) TestSetICQParams() {
suite.SetupTest() // reset

// system under test.
v15.SetICQParams(suite.Ctx, suite.App.ICQKeeper)

suite.Require().True(suite.App.ICQKeeper.IsHostEnabled(suite.Ctx))
suite.Require().Len(suite.App.ICQKeeper.GetAllowQueries(suite.Ctx), 62)
}
116 changes: 116 additions & 0 deletions app/upgrades/v15/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icqkeeper "github.com/strangelove-ventures/async-icq/v4/keeper"
icqtypes "github.com/strangelove-ventures/async-icq/v4/types"
packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"

banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand All @@ -18,6 +20,113 @@ import (
poolmanagertypes "github.com/osmosis-labs/osmosis/v14/x/poolmanager/types"
)

// an array of 10 strings containing the numbers from 1 to 10:

// Using the same queries as stargate_whitelist.go
var whitelistedQueries = []string{
// cosmos-sdk queries

// auth
"/cosmos.auth.v1beta1.Query/Account",
"/cosmos.auth.v1beta1.Query/Params",

// bank
"/cosmos.bank.v1beta1.Query/Balance",
"/cosmos.bank.v1beta1.Query/DenomMetadata",
"/cosmos.bank.v1beta1.Query/Params",
"/cosmos.bank.v1beta1.Query/SupplyOf",

// distribution
"/cosmos.distribution.v1beta1.Query/Params",
"/cosmos.distribution.v1beta1.Query/DelegatorWithdrawAddress",
"/cosmos.distribution.v1beta1.Query/ValidatorCommission",

// gov
"/cosmos.gov.v1beta1.Query/Deposit",
"/cosmos.gov.v1beta1.Query/Params",
"/cosmos.gov.v1beta1.Query/Vote",

//slashing
"/cosmos.slashing.v1beta1.Query/Params",
"/cosmos.slashing.v1beta1.Query/SigningInfo",

//staking
"/cosmos.staking.v1beta1.Query/Delegation",
"/cosmos.staking.v1beta1.Query/Params",
"/cosmos.staking.v1beta1.Query/Validator",

//osmosis queries

//epochs
"/osmosis.epochs.v1beta1.Query/EpochInfos",
"/osmosis.epochs.v1beta1.Query/CurrentEpoch",

//gamm
"/osmosis.gamm.v1beta1.Query/NumPools",
"/osmosis.gamm.v1beta1.Query/TotalLiquidity",
"/osmosis.gamm.v1beta1.Query/Pool",
"/osmosis.gamm.v1beta1.Query/PoolParams",
"/osmosis.gamm.v1beta1.Query/TotalPoolLiquidity",
"/osmosis.gamm.v1beta1.Query/TotalShares",
"/osmosis.gamm.v1beta1.Query/CalcJoinPoolShares",
"/osmosis.gamm.v1beta1.Query/CalcExitPoolCoinsFromShares",
"/osmosis.gamm.v1beta1.Query/CalcJoinPoolNoSwapShares",
"/osmosis.gamm.v1beta1.Query/PoolType",
"/osmosis.gamm.v2.Query/SpotPrice",
"/osmosis.gamm.v1beta1.Query/EstimateSwapExactAmountIn",
"/osmosis.gamm.v1beta1.Query/EstimateSwapExactAmountOut",

//incentives
"/osmosis.incentives.Query/ModuleToDistributeCoins",
"/osmosis.incentives.Query/LockableDurations",

//lockup
"/osmosis.lockup.Query/ModuleBalance",
"/osmosis.lockup.Query/ModuleLockedAmount",
"/osmosis.lockup.Query/AccountUnlockableCoins",
"/osmosis.lockup.Query/AccountUnlockingCoins",
"/osmosis.lockup.Query/LockedDenom",
"/osmosis.lockup.Query/LockedByID",

//mint
"/osmosis.mint.v1beta1.Query/EpochProvisions",
"/osmosis.mint.v1beta1.Query/Params",

//pool-incentives
"/osmosis.poolincentives.v1beta1.Query/GaugeIds",

//superfluid
"/osmosis.superfluid.Query/Params",
"/osmosis.superfluid.Query/AssetType",
"/osmosis.superfluid.Query/AllAssets",
"/osmosis.superfluid.Query/AssetMultiplier",

//poolmanager
"/osmosis.poolmanager.v1beta1.Query/NumPools",
"/osmosis.poolmanager.v1beta1.Query/EstimateSwapExactAmountIn",
"/osmosis.poolmanager.v1beta1.Query/EstimateSwapExactAmountOut",

//txfees
"/osmosis.txfees.v1beta1.Query/FeeTokens",
"/osmosis.txfees.v1beta1.Query/DenomSpotPrice",
"/osmosis.txfees.v1beta1.Query/DenomPoolId",
"/osmosis.txfees.v1beta1.Query/BaseDenom",

//tokenfactory
"/osmosis.tokenfactory.v1beta1.Query/params",
"/osmosis.tokenfactory.v1beta1.Query/DenomAuthorityMetadata",

//twap
"/osmosis.twap.v1beta1.Query/ArithmeticTwap",
"/osmosis.twap.v1beta1.Query/ArithmeticTwapToNow",
"/osmosis.twap.v1beta1.Query/GeometricTwap",
"/osmosis.twap.v1beta1.Query/GeometricTwapToNow",
"/osmosis.twap.v1beta1.Query/Params",

//downtime-detector
"/osmosis.downtimedetector.v1beta1.Query/RecoveredSinceDowntimeOfLength",
}

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
Expand All @@ -29,6 +138,7 @@ func CreateUpgradeHandler(

keepers.PoolManagerKeeper.SetParams(ctx, poolmanagerParams)
keepers.PacketForwardKeeper.SetParams(ctx, packetforwardtypes.DefaultParams())
setICQParams(ctx, keepers.ICQKeeper)

// N.B: pool id in gamm is to be deprecated in the future
// Instead,it is moved to poolmanager.
Expand All @@ -47,6 +157,12 @@ func CreateUpgradeHandler(
}
}

func setICQParams(ctx sdk.Context, icqKeeper *icqkeeper.Keeper) {
icqparams := icqtypes.DefaultParams()
icqparams.AllowQueries = whitelistedQueries
icqKeeper.SetParams(ctx, icqparams)
}

func migrateNextPoolId(ctx sdk.Context, gammKeeper *gammkeeper.Keeper, poolmanagerKeeper *poolmanager.Keeper) {
// N.B: pool id in gamm is to be deprecated in the future
// Instead,it is moved to poolmanager.
Expand Down
3 changes: 3 additions & 0 deletions wasmbinding/stargate_whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import (
// thread safe sync.Map.
var stargateWhitelist sync.Map

// Note: When adding a migration here, we should also add it to the Async ICQ params in the upgrade.
// In the future we may want to find a better way to keep these in sync

//nolint:staticcheck
func init() {
// cosmos-sdk queries
Expand Down

0 comments on commit 9852b0d

Please sign in to comment.