Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow contracts to query estimate fees endpoint, add IBC Hooks module #588

Merged
merged 9 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Contains all the PRs that improved the code without changing the behaviors.

### Added
- [#577](https://github.com/archway-network/archway/pull/577) - Adding a cute ascii art of Archway for the cli
- [#588](https://github.com/archway-network/archway/pull/588) - Add IBC hooks, bump IBC, allows contracts to query callback fee estimations.

### Changed
- [#573](https://github.com/archway-network/archway/pull/573) - Bump cosmos-sdk to v0.50.6 and ibc to v8.2.1
Expand Down
18 changes: 16 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/gogoproto/proto"
ibchooks "github.com/cosmos/ibc-apps/modules/ibc-hooks/v8"
ibchookskeeper "github.com/cosmos/ibc-apps/modules/ibc-hooks/v8/keeper"
ibchookstypes "github.com/cosmos/ibc-apps/modules/ibc-hooks/v8/types"
"github.com/cosmos/ibc-go/modules/capability"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
Expand Down Expand Up @@ -211,6 +214,7 @@ var (
ibc.AppModuleBasic{},
ibccm.AppModuleBasic{},
ibcfee.AppModuleBasic{},
ibchooks.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
Expand Down Expand Up @@ -327,6 +331,7 @@ func NewArchwayApp(
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
feegrant.StoreKey, authzkeeper.StoreKey, wasmdTypes.StoreKey, consensusparamtypes.StoreKey,
ibchookstypes.StoreKey,
icacontrollertypes.StoreKey, icahosttypes.StoreKey, ibcfeetypes.StoreKey, crisistypes.StoreKey, group.StoreKey, nftkeeper.StoreKey, cwicatypes.StoreKey,

trackingTypes.StoreKey, rewardsTypes.StoreKey, callbackTypes.StoreKey, cwfees.ModuleName, cwerrorsTypes.StoreKey,
Expand Down Expand Up @@ -667,16 +672,21 @@ func NewArchwayApp(
logger,
)

app.Keepers.IBCHooksKeeper = ibchookskeeper.NewKeeper(keys[ibchookstypes.StoreKey])
ics20WasmHooks := ibchooks.NewWasmHooks(&app.Keepers.IBCHooksKeeper, nil, Bech32Prefix)
hooksIcs4Wrapper := ibchooks.NewICS4Middleware(app.Keepers.IBCKeeper.ChannelKeeper, ics20WasmHooks)

var transferStack porttypes.IBCModule
transferStack = transfer.NewIBCModule(app.Keepers.TransferKeeper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.Keepers.IBCFeeKeeper)
transferStack = ibchooks.NewIBCMiddleware(transferStack, &hooksIcs4Wrapper)

// Create Interchain Accounts Stack

var icaControllerStack porttypes.IBCModule
icaControllerStack = cwica.NewIBCModule(app.Keepers.CWICAKeeper)
icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, app.Keepers.ICAControllerKeeper)
//icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.Keepers.IBCFeeKeeper)
// icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.Keepers.IBCFeeKeeper)

// RecvPacket, message that originates from core IBC and goes down to app, the flow is:
// channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket
Expand Down Expand Up @@ -797,6 +807,7 @@ func NewArchwayApp(
ibcfeetypes.ModuleName,
icatypes.ModuleName,
// wasm
ibchookstypes.ModuleName,
wasmdTypes.ModuleName,
)

Expand Down Expand Up @@ -826,6 +837,7 @@ func NewArchwayApp(
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
// wasm
ibchookstypes.ModuleName,
wasmdTypes.ModuleName,
// wasm gas tracking
trackingTypes.ModuleName,
Expand Down Expand Up @@ -870,6 +882,7 @@ func NewArchwayApp(
ibcfeetypes.ModuleName,
icatypes.ModuleName,
// wasm after ibc transfer
ibchookstypes.ModuleName,
wasmdTypes.ModuleName,
// wasm gas tracking
cwfees.ModuleName, // depends on wasmd.
Expand Down Expand Up @@ -1203,6 +1216,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

func getAcceptedStargateQueries() wasmdKeeper.AcceptedStargateQueries {
return wasmdKeeper.AcceptedStargateQueries{
"/archway.cwerrors.v1.Query/Errors": &cwerrorsTypes.QueryErrorsRequest{},
"/archway.cwerrors.v1.Query/Errors": &cwerrorsTypes.QueryErrorsRequest{},
"/archway.callback.v1.Query/EstimateCallbackFees": &callbackTypes.QueryEstimateCallbackFeesRequest{},
}
}
5 changes: 3 additions & 2 deletions app/app_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
upgrade4_0_2 "github.com/archway-network/archway/app/upgrades/4_0_2"
upgrade6_0_0 "github.com/archway-network/archway/app/upgrades/6_0_0"
upgrade7_0_0 "github.com/archway-network/archway/app/upgrades/7_0_0"
upgrade8_0_0 "github.com/archway-network/archway/app/upgrades/8_0_0"
upgrade9_0_0 "github.com/archway-network/archway/app/upgrades/9_0_0"
)

// UPGRADES
Expand All @@ -28,7 +28,8 @@ var Upgrades = []upgrades.Upgrade{
upgrade4_0_2.Upgrade, // v4.0.2
upgrade6_0_0.Upgrade, // v6.0.0
upgrade7_0_0.Upgrade, // v7.0.0
upgrade8_0_0.Upgrade, // v8.0.0
// upgrade8_0_0.Upgrade, // v8.0.0: was reserved for a consensus breaking wasmd upgrade
upgrade9_0_0.Upgrade, // v9.0.0
}

func (app *ArchwayApp) RegisterUpgradeHandlers() {
Expand Down
2 changes: 2 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/archway-network/archway/x/cwfees"

ibchookskeeper "github.com/cosmos/ibc-apps/modules/ibc-hooks/v8/keeper"
icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper"
icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper"
ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
Expand Down Expand Up @@ -52,6 +53,7 @@ type ArchwayKeepers struct {
ConsensusParamsKeeper consensusparamkeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
IBCHooksKeeper ibchookskeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import (
upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
ibchookstypes "github.com/cosmos/ibc-apps/modules/ibc-hooks/v8/types"

"github.com/archway-network/archway/app/keepers"
"github.com/archway-network/archway/app/upgrades"
)

const Name = "v8.0.0"
const NameAsciiArt = `
### ### ###
# # # # # # # #
# # ### # # # #
# # # # # # #
### # ### # ###
const Name = "v9.0.0"
const NameAsciiArt = `
### ### ###
# # # # # # # #
# # ## # # # #
# # # # # #
### # ### # ###

`

Expand All @@ -35,5 +36,7 @@ var Upgrade = upgrades.Upgrade{
return migrations, nil
}
},
StoreUpgrades: storetypes.StoreUpgrades{},
StoreUpgrades: storetypes.StoreUpgrades{
Added: []string{ibchookstypes.StoreKey},
},
}
18 changes: 9 additions & 9 deletions cmd/archwayd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
)

const ArchwayASCII = `
##### ##### ##### ## ## ## ## ##### ## ##
####### ####### ####### ## ## ## ## ####### ## ##
## ## ## ## ## ## ## ## # ## ## ## ## ##
## ## ###### ## #### ## ####### ## ## ####
####### ## ## ## ## ## ## ####### ####### ##
## ## ## ## ####### ## ## ### ### ## ## ##
## ## ## ## ##### ## ## ## ## ## ## ##
##### ##### ##### ## ## ## ## ##### ## ##
####### ####### ####### ## ## ## ## ####### ## ##
## ## ## ## ## ## ## ## # ## ## ## ## ##
## ## ###### ## #### ## ####### ## ## ####
####### ## ## ## ## ## ## ####### ####### ##
## ## ## ## ####### ## ## ### ### ## ## ##
## ## ## ## ##### ## ## ## ## ## ## ##

`

func main() {
Expand All @@ -30,7 +30,7 @@ func main() {
rootCmd.AddCommand(ensureLibWasmVM())

if err := svrcmd.Execute(rootCmd, "ARCHWAY", app.DefaultNodeHome); err != nil {
fmt.Fprintln(rootCmd.OutOrStderr(), err)
_, _ = fmt.Fprintln(rootCmd.OutOrStderr(), err)
os.Exit(1)
}
}
Expand Down
Loading
Loading