Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/v3.0.x' into ibc-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed May 27, 2023
2 parents f01d30c + 2cb2c26 commit 90f9228
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# @Sen-Com is the repository administrator who ensures compliance with the White Whale Repository Guideline.
# The remaining code owners help maintain the repository.
* @PolkachuIntern @faddat @Sen-Com @kerber0x @0xFable
* @PolkachuIntern @faddat @Sen-Com @kerber0x @0xFable @vuong177 @pysel @hieuvubk
61 changes: 0 additions & 61 deletions .github/workflows/codacy.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/push-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/White-Whale-Defi-Platform/migaloo-chain:${{ env.MAJOR_VERSION }}
ghcr.io/White-Whale-Defi-Platform/migaloo-chain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}
ghcr.io/White-Whale-Defi-Platform/migaloo-chain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}
ghcr.io/white-whale-defi-platform/migaloo-chain:${{ env.MAJOR_VERSION }}
ghcr.io/white-whale-defi-platform/migaloo-chain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}
ghcr.io/white-whale-defi-platform/migaloo-chain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ linters:
- staticcheck
- stylecheck
- typecheck
- thelper
- unconvert
- unparam
- unused
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Because of this, branching is like:

1. [Website](https://migaloo.zone)
2. [LitePaper]() - Coming Soon
3. [Docs]() - Coming Soon
3. [Docs]( https://docs.migaloo.zone/) - Coming Soon
4. [Roadmap](./docs/ROADMAP.md)
5. [Discord](https://discord.com/channels/908044702794801233/1069611972053712947)
6. [Twitter](https://twitter.com/WhiteWhaleDefi)
Expand Down
82 changes: 77 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import (
ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
ibcporttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
Expand Down Expand Up @@ -144,6 +145,10 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
wasmappparams "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/params"

icq "github.com/strangelove-ventures/async-icq/v7"
icqkeeper "github.com/strangelove-ventures/async-icq/v7/keeper"
icqtypes "github.com/strangelove-ventures/async-icq/v7/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"

Expand Down Expand Up @@ -228,6 +233,7 @@ var (
authzmodule.AppModuleBasic{},
ibc.AppModuleBasic{},
ibctm.AppModuleBasic{},
icq.AppModuleBasic{},
solomachine.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
Expand All @@ -252,6 +258,7 @@ var (
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil,
icatypes.ModuleName: nil,
icqtypes.ModuleName: nil,
wasm.ModuleName: {authtypes.Burner},
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
Expand Down Expand Up @@ -295,6 +302,7 @@ type MigalooApp struct {
EvidenceKeeper evidencekeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
ICQKeeper icqkeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
InterTxKeeper intertxkeeper.Keeper
Expand All @@ -309,6 +317,7 @@ type MigalooApp struct {
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
ScopedICQKeeper capabilitykeeper.ScopedKeeper
ScopedInterTxKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -351,7 +360,7 @@ func NewMigalooApp(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, routertypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
evidencetypes.StoreKey, icqtypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
feegrant.StoreKey, authzkeeper.StoreKey, wasm.StoreKey, icahosttypes.StoreKey,
icacontrollertypes.StoreKey, intertxtypes.StoreKey, ibcfeetypes.StoreKey, tokenfactorytypes.StoreKey,
alliancemoduletypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey,
Expand Down Expand Up @@ -389,6 +398,7 @@ func NewMigalooApp(
memKeys[capabilitytypes.MemStoreKey],
)
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
scopedICQKeeper := app.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedInterTxKeeper := app.CapabilityKeeper.ScopeToModule(intertxtypes.ModuleName)
Expand Down Expand Up @@ -594,17 +604,49 @@ func NewMigalooApp(
panic(fmt.Sprintf("error while reading wasm config: %s", err))
}

// Stargate Queries
// recommended by @larry0x. using the same values as Juno
// ref: https://github.com/CosmosContracts/juno/blob/9885a8cd4ffc8d19546bd42b2da139ec5d224c25/app/keepers/keepers.go#L375-L399
// these are the exact settings from Juno except that we're using govv1 instead of govv1beta1 (which Juno would reference as govtypes)
accepted := wasmkeeper.AcceptedStargateQueries{
// ibc
"/ibc.core.client.v1.Query/ClientState": &ibcclienttypes.QueryClientStateResponse{},
"/ibc.core.client.v1.Query/ConsensusState": &ibcclienttypes.QueryConsensusStateResponse{},
"/ibc.core.connection.v1.Query/Connection": &ibcconnectiontypes.QueryConnectionResponse{},

// governance
"/cosmos.gov.v1beta1.Query/Vote": &govv1.QueryVoteResponse{},

// staking
"/cosmos.staking.v1beta1.Query/Delegation": &stakingtypes.QueryDelegationResponse{},
"/cosmos.staking.v1beta1.Query/Redelegations": &stakingtypes.QueryRedelegationsResponse{},
"/cosmos.staking.v1beta1.Query/UnbondingDelegation": &stakingtypes.QueryUnbondingDelegationResponse{},
"/cosmos.staking.v1beta1.Query/Validator": &stakingtypes.QueryValidatorResponse{},

// token factory
"/osmosis.tokenfactory.v1beta1.Query/Params": &tokenfactorytypes.QueryParamsResponse{},
"/osmosis.tokenfactory.v1beta1.Query/DenomAuthorityMetadata": &tokenfactorytypes.QueryDenomAuthorityMetadataResponse{},
"/osmosis.tokenfactory.v1beta1.Query/DenomsFromCreator": &tokenfactorytypes.QueryDenomsFromCreatorResponse{},
}

querierOpts := wasmkeeper.WithQueryPlugins(
&wasmkeeper.QueryPlugins{
Stargate: wasmkeeper.AcceptListStargateQuerier(accepted, bApp.GRPCQueryRouter(), appCodec),
})

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,token_factory"
wasmOpts = append(bindings.RegisterCustomPlugins(&app.BankKeeper.BaseKeeper, &app.TokenFactoryKeeper), wasmOpts...)
wasmOpts = append(bindings.RegisterCustomPlugins(&app.BankKeeper.BaseKeeper, &app.TokenFactoryKeeper), wasmOpts...) // add token factory options to x/wasm
wasmOpts = append(wasmOpts, querierOpts) // add the querier options to x/wasm // not in the first append for clarity
app.WasmKeeper = wasm.NewKeeper(
appCodec,
keys[wasm.StoreKey],
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
distrkeeper.NewQuerier(app.DistrKeeper),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedWasmKeeper,
Expand All @@ -618,11 +660,23 @@ func NewMigalooApp(
wasmOpts...,
)

// The gov proposal types can be individually enabled
// WASM gov proposal types can be individually enabled
if len(enabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals))
}

// ICQ Keeper
app.ICQKeeper = icqkeeper.NewKeeper(
appCodec,
keys[icqtypes.StoreKey],
app.GetSubspace(icqtypes.ModuleName),
app.IBCKeeper.ChannelKeeper, // may be replaced with middleware
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedICQKeeper,
app.BaseApp, // may be replaced
)

// Create Transfer Stack
var transferStack ibcporttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
Expand All @@ -646,6 +700,14 @@ func NewMigalooApp(
icaHostStack = icahost.NewIBCModule(app.ICAHostKeeper)
icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper)

// Create Interchain Query Stack
// SendQuery, since it is originating from the application to core IBC:
// icqKeeper.SendQuery -> icqKeeper.SendPacket -> channel.SendPacket

// initialize ICQ module with mock module
// var icqStack porttypes.IBCModule
icqStack := icq.NewIBCModule(app.ICQKeeper)

// Create fee enabled wasm ibc Stack
var wasmStack ibcporttypes.IBCModule
wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
Expand All @@ -657,7 +719,9 @@ func NewMigalooApp(
AddRoute(wasm.ModuleName, wasmStack).
AddRoute(intertxtypes.ModuleName, icaControllerStack).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostStack)
AddRoute(icahosttypes.SubModuleName, icaHostStack).
AddRoute(icqtypes.ModuleName, icqStack)

app.IBCKeeper.SetRouter(ibcRouter)

govConfig := govtypes.DefaultConfig()
Expand All @@ -683,6 +747,8 @@ func NewMigalooApp(
),
)

// TODO: add groups module, seems stable and provides another management option

// upgrade handlers
cfg := module.NewConfigurator(appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())

Expand Down Expand Up @@ -719,6 +785,7 @@ func NewMigalooApp(
params.NewAppModule(app.ParamsKeeper),
transfer.NewAppModule(app.TransferKeeper),
icaModule,
icq.NewAppModule(app.ICQKeeper),
alliancemodule.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
ibcfee.NewAppModule(app.IBCFeeKeeper),
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
Expand Down Expand Up @@ -749,6 +816,7 @@ func NewMigalooApp(
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
icqtypes.ModuleName,
// additional non simd modules
routertypes.ModuleName,
ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -779,6 +847,7 @@ func NewMigalooApp(
upgradetypes.ModuleName,
vestingtypes.ModuleName,
// additional non simd modules
icqtypes.ModuleName,
routertypes.ModuleName,
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
Expand Down Expand Up @@ -810,6 +879,7 @@ func NewMigalooApp(
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
icqtypes.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
Expand Down Expand Up @@ -896,6 +966,7 @@ func NewMigalooApp(
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper
app.ScopedInterTxKeeper = scopedInterTxKeeper
app.ScopedICQKeeper = scopedICQKeeper

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand Down Expand Up @@ -1108,13 +1179,14 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(govtypes.ModuleName)
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(tokenfactorytypes.ModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(icqtypes.ModuleName)
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(routertypes.ModuleName)
paramsKeeper.Subspace(alliancemoduletypes.ModuleName)
Expand Down
1 change: 1 addition & 0 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func TestGetEnabledProposals(t *testing.T) {
}

func SetupGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, _ []wasm.Option, app *MigalooApp, balances ...banktypes.Balance) GenesisState {
t.Helper()
genesisState := NewDefaultGenesisState()
// set genesis accounts
authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs)
Expand Down
6 changes: 4 additions & 2 deletions app/test_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ type TestSupport struct {
app *MigalooApp
}

func NewTestSupport(t testing.TB, app *MigalooApp) *TestSupport {
return &TestSupport{t: t, app: app}
// NewTestSupport creates a new TestSupport instance, which provides access to the app for testing.
func NewTestSupport(tb testing.TB, app *MigalooApp) *TestSupport {
tb.Helper()
return &TestSupport{t: tb, app: app}
}

func (s TestSupport) IBCKeeper() *ibckeeper.Keeper {
Expand Down
Loading

0 comments on commit 90f9228

Please sign in to comment.