-
Notifications
You must be signed in to change notification settings - Fork 586
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
ICA controller/host submodules #541
Merged
Merged
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
4c32cec
go mod tidy
damiannolan f369f01
creating new genesis types for controller and host submodules
damiannolan 037e691
removing dead root module code
damiannolan 248ef51
updating genesis helpers and adding newly generated types
damiannolan 63a7495
adding interchain-accounts controller submodule
damiannolan 423a992
adding interchain-accounts host submodule
damiannolan 10bdc33
updating simapp to include controller and host ica submodules
damiannolan b7524eb
adding errors returns for disallowed handshake directions, removing e…
damiannolan 269e95a
updating simapp to remove nil arg to ica host ibc module
damiannolan 3b0bed1
removing ics4Wrapper arg from ica host submodule
damiannolan e68338b
cleaning up module.go for controller and host submodules
damiannolan 8eb0293
removing commented out tests
damiannolan db9233e
commit with broken tests to rebase
damiannolan 8c2c61f
Merge branch 'interchain-accounts' into damian/290-ica-submodules
damiannolan 7a7a72b
disabling app version negotation on controller submodule
damiannolan f9a8837
fixing tests - now passing
damiannolan 12a69ea
various cleanup, godocs and moving code
damiannolan 86082e6
updating error msgs to conform to pkg split
damiannolan fdb2ff3
removing commented out code
damiannolan b3f52bd
adding combined ica genesis, consolidating to single ica AppModule, u…
damiannolan c26107f
adding missing godocs
damiannolan f59f0a1
clean up, godocs, rename validate.go -> version.go, move version rela…
damiannolan 6daeac8
updating godocs and code organization
damiannolan 3fc0f71
removing controller module acc, using icatypes module name for module…
damiannolan f73bd83
correcting panic error msg
damiannolan 1cec8b0
Update modules/apps/27-interchain-accounts/controller/ibc_module.go
damiannolan 70d2d59
Update modules/apps/27-interchain-accounts/types/genesis.go
damiannolan e61c5c9
updating logger kvs, and simplifying OnRecvPacket
damiannolan dd4c82f
address nits on error strings and godocs
damiannolan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,37 @@ | ||
package interchain_accounts | ||
package controller | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" | ||
|
||
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/keeper" | ||
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/keeper" | ||
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" | ||
channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" | ||
porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types" | ||
ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported" | ||
) | ||
|
||
// IBCModule implements the ICS26 interface for interchain accounts given the | ||
// interchain account keeper and underlying application. | ||
// IBCModule implements the ICS26 interface for interchain accounts controller chains | ||
type IBCModule struct { | ||
keeper keeper.Keeper | ||
app porttypes.IBCModule | ||
} | ||
|
||
// NewIBCModule creates a new IBCModule given the keeper and underlying application | ||
// NewIBCModule creates a new IBCModule given the associated keeper and underlying application | ||
func NewIBCModule(k keeper.Keeper, app porttypes.IBCModule) IBCModule { | ||
return IBCModule{ | ||
keeper: k, | ||
app: app, | ||
} | ||
} | ||
|
||
// OnChanOpenInit implements the IBCModule interface. Interchain Accounts is | ||
// implemented to act as middleware for connected authentication modules on | ||
// OnChanOpenInit implements the IBCModule interface | ||
// | ||
// Interchain Accounts is implemented to act as middleware for connected authentication modules on | ||
// the controller side. The connected modules may not change the controller side portID or | ||
// version. They will be allowed to perform custom logic without changing | ||
// the parameters stored within a channel struct. | ||
// | ||
// Controller Chain | ||
func (im IBCModule) OnChanOpenInit( | ||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
|
@@ -53,8 +52,6 @@ func (im IBCModule) OnChanOpenInit( | |
} | ||
|
||
// OnChanOpenTry implements the IBCModule interface | ||
// | ||
// Host Chain | ||
func (im IBCModule) OnChanOpenTry( | ||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
|
@@ -66,16 +63,15 @@ func (im IBCModule) OnChanOpenTry( | |
version, | ||
counterpartyVersion string, | ||
) error { | ||
return im.keeper.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, version, counterpartyVersion) | ||
return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") | ||
} | ||
|
||
// OnChanOpenAck implements the IBCModule interface. Interchain Accounts is | ||
// implemented to act as middleware for connected authentication modules on | ||
// OnChanOpenAck implements the IBCModule interface | ||
// | ||
// Interchain Accounts is implemented to act as middleware for connected authentication modules on | ||
// the controller side. The connected modules may not change the portID or | ||
// version. They will be allowed to perform custom logic without changing | ||
// the parameters stored within a channel struct. | ||
// | ||
// Controller Chain | ||
func (im IBCModule) OnChanOpenAck( | ||
ctx sdk.Context, | ||
portID, | ||
|
@@ -91,14 +87,12 @@ func (im IBCModule) OnChanOpenAck( | |
} | ||
|
||
// OnChanOpenAck implements the IBCModule interface | ||
// | ||
// Host Chain | ||
func (im IBCModule) OnChanOpenConfirm( | ||
ctx sdk.Context, | ||
portID, | ||
channelID string, | ||
) error { | ||
return im.keeper.OnChanOpenConfirm(ctx, portID, channelID) | ||
return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") | ||
} | ||
|
||
// OnChanCloseInit implements the IBCModule interface | ||
|
@@ -121,31 +115,15 @@ func (im IBCModule) OnChanCloseConfirm( | |
} | ||
|
||
// OnRecvPacket implements the IBCModule interface | ||
// | ||
// Host Chain | ||
func (im IBCModule) OnRecvPacket( | ||
ctx sdk.Context, | ||
packet channeltypes.Packet, | ||
_ sdk.AccAddress, | ||
) ibcexported.Acknowledgement { | ||
ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) | ||
|
||
// only attempt the application logic if the packet data | ||
// was successfully decoded | ||
if ack.Success() { | ||
err := im.keeper.OnRecvPacket(ctx, packet) | ||
if err != nil { | ||
ack = channeltypes.NewErrorAcknowledgement(err.Error()) | ||
} | ||
} | ||
|
||
// NOTE: acknowledgement will be written synchronously during IBC handler execution. | ||
return ack | ||
return channeltypes.NewErrorAcknowledgement("cannot receive packet on host controller chain") | ||
damiannolan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// OnAcknowledgementPacket implements the IBCModule interface | ||
// | ||
// Controller Chain | ||
func (im IBCModule) OnAcknowledgementPacket( | ||
ctx sdk.Context, | ||
packet channeltypes.Packet, | ||
|
@@ -157,8 +135,6 @@ func (im IBCModule) OnAcknowledgementPacket( | |
} | ||
|
||
// OnTimeoutPacket implements the IBCModule interface | ||
// | ||
// Controller Chain | ||
func (im IBCModule) OnTimeoutPacket( | ||
ctx sdk.Context, | ||
packet channeltypes.Packet, | ||
|
@@ -180,5 +156,5 @@ func (im IBCModule) NegotiateAppVersion( | |
counterparty channeltypes.Counterparty, | ||
proposedVersion string, | ||
) (string, error) { | ||
return im.keeper.NegotiateAppVersion(ctx, order, connectionID, portID, counterparty, proposedVersion) | ||
return "", sdkerrors.Wrap(types.ErrInvalidChannelFlow, "ICS-27 app version negotiation is unsupported on controller chains") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Controller submodule returns an error for invoking |
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Controller submodule returns errors for both
OnChanOpenTry
andOnChanOpenConfirm
handshake callbacks