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 5 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{},
}
}
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
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
13 changes: 8 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/archway-network/archway

go 1.21
go 1.22

toolchain go1.23.0

require (
cosmossdk.io/api v0.7.5
Expand All @@ -18,15 +20,16 @@ require (
cosmossdk.io/x/tx v0.13.3
cosmossdk.io/x/upgrade v0.1.2
github.com/CosmWasm/cosmwasm-go v0.5.1-0.20220822092235-974247a04ac7
github.com/CosmWasm/wasmd v0.50.0
github.com/CosmWasm/wasmd v0.51.0
github.com/CosmWasm/wasmvm v1.5.4
github.com/cometbft/cometbft v0.38.10
github.com/cosmos/cosmos-db v1.0.2
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.7
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20240820215527-05462618a4e8
github.com/cosmos/ibc-go/modules/capability v1.0.0
github.com/cosmos/ibc-go/v8 v8.3.2
github.com/cosmos/ibc-go/v8 v8.4.0
github.com/dvsekhvalnov/jose2go v1.6.0
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.4
Expand All @@ -53,7 +56,7 @@ require (
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/99designs/keyring v1.2.2 // indirect
github.com/CosmWasm/tinyjson v0.9.0 // indirect
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
github.com/DataDog/zstd v1.5.5 // indirect
Expand All @@ -74,7 +77,7 @@ require (
github.com/cockroachdb/pebble v1.1.0 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft-db v0.9.1 // indirect
github.com/cometbft/cometbft-db v0.11.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zum
git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4=
github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o=
github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA=
github.com/99designs/keyring v1.2.2 h1:pZd3neh/EmUzWONb35LxQfvuY7kiSXAq3HQd97+XBn0=
github.com/99designs/keyring v1.2.2/go.mod h1:wes/FrByc8j7lFOAGLGSNEg8f/PaI3cgTBqhFkHUrPk=
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
Expand Down Expand Up @@ -951,8 +951,8 @@ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/cometbft/cometbft v0.38.10 h1:2ePuglchT+j0Iao+cfmt/nw5U7K2lnGDzXSUPGVdXaU=
github.com/cometbft/cometbft v0.38.10/go.mod h1:jHPx9vQpWzPHEAiYI/7EDKaB1NXhK6o3SArrrY8ExKc=
github.com/cometbft/cometbft-db v0.9.1 h1:MIhVX5ja5bXNHF8EYrThkG9F7r9kSfv8BX4LWaxWJ4M=
github.com/cometbft/cometbft-db v0.9.1/go.mod h1:iliyWaoV0mRwBJoizElCwwRA9Tf7jZJOURcRZF9m60U=
github.com/cometbft/cometbft-db v0.11.0 h1:M3Lscmpogx5NTbb1EGyGDaFRdsoLWrUWimFEyf7jej8=
github.com/cometbft/cometbft-db v0.11.0/go.mod h1:GDPJAC/iFHNjmZZPN8V8C1yr/eyityhi2W1hz2MGKSc=
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
Expand All @@ -978,10 +978,12 @@ github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8Jp
github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY=
github.com/cosmos/iavl v1.1.2 h1:zL9FK7C4L/P4IF1Dm5fIwz0WXCnn7Bp1M2FxH0ayM7Y=
github.com/cosmos/iavl v1.1.2/go.mod h1:jLeUvm6bGT1YutCaL2fIar/8vGUE8cPZvh/gXEWDaDM=
github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20240820215527-05462618a4e8 h1:n9Gn7E7g9ZxrAdXRAfHe3xOF5HmLnvdDUVgq3ea2IZw=
github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20240820215527-05462618a4e8/go.mod h1:9+Z14xz3Y+5uEn5i1CvLcDN1aTthEhYUdI7pphySkY8=
github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE=
github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco=
github.com/cosmos/ibc-go/v8 v8.3.2 h1:8X1oHHKt2Bh9hcExWS89rntLaCKZp2EjFTUSxKlPhGI=
github.com/cosmos/ibc-go/v8 v8.3.2/go.mod h1:WVVIsG39jGrF9Cjggjci6LzySyWGloz194sjTxiGNIE=
github.com/cosmos/ibc-go/v8 v8.4.0 h1:K2PfX0AZ+1XKZytHGEMuSjQXG/MZshPb83RSTQt2+cE=
github.com/cosmos/ibc-go/v8 v8.4.0/go.mod h1:zh6x1osR0hNvEcFrC/lhGD08sMfQmr9wHVvZ/mRWMCs=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0=
github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM=
Expand Down
Loading