Skip to content

Commit

Permalink
fix(evm): ensure we provide counterparty channel at OpenAck
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-aitlahcen committed Oct 16, 2023
1 parent 29baa53 commit 62a6501
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions evm/contracts/apps/Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ abstract contract IBCAppBase is Context, IIBCModule {
function onChanOpenAck(
string calldata portId,
string calldata channelId,
string calldata counterpartyChannelId,
string calldata counterpartyVersion
) external virtual override onlyIBC {}

Expand Down
11 changes: 6 additions & 5 deletions evm/contracts/apps/ucs/00-pingpong/PingPong.sol
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ contract PingPong is IBCAppBase {
function onChanOpenAck(
string calldata _portId,
string calldata _channelId,
string calldata
string calldata _counterpartyChannelId,
string calldata _counterpartyVersion
) external virtual override onlyIBC {
portId = _portId;
channelId = _channelId;
Expand All @@ -168,15 +169,15 @@ contract PingPong is IBCAppBase {
}

function onChanCloseInit(
string calldata,
string calldata
string calldata _portId,
string calldata _channelId
) external virtual override onlyIBC {
revert("This game is infinite");
}

function onChanCloseConfirm(
string calldata,
string calldata
string calldata _portId,
string calldata _channelId
) external virtual override onlyIBC {
revert("This game is infinite");
}
Expand Down
11 changes: 8 additions & 3 deletions evm/contracts/apps/ucs/01-relay/Relay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,15 @@ contract UCS01Relay is IBCAppBase {
}

function onChanOpenAck(
string calldata _portId,
string calldata _channelId,
string calldata portId,
string calldata channelId,
string calldata counterpartyChannelId,
string calldata _counterpartyVersion
) external virtual override onlyIBC {}
) external virtual override onlyIBC {
// Counterparty channel was empty.
counterpartyEndpoints[portId][channelId]
.channel_id = counterpartyChannelId;
}

function onChanOpenConfirm(
string calldata _portId,
Expand Down
1 change: 1 addition & 0 deletions evm/contracts/core/05-port/IIBCModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface IIBCModule {
function onChanOpenAck(
string calldata portId,
string calldata channelId,
string calldata counterpartyChannelId,
string calldata counterpartyVersion
) external;

Expand Down
1 change: 1 addition & 0 deletions evm/contracts/core/25-handler/IBCChannelHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ abstract contract IBCChannelHandler is ModuleManager {
lookupModuleByPort(msg_.portId).onChanOpenAck(
msg_.portId,
msg_.channelId,
msg_.counterpartyChannelId,
msg_.counterpartyVersion
);

Expand Down
7 changes: 6 additions & 1 deletion evm/contracts/core/DevnetIBCHandlerInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ contract DevnetIBCHandlerInit is IBCHost {
channel.counterparty,
channel.version
);
module.onChanOpenAck(portId, channelId, channel.version);
module.onChanOpenAck(
portId,
channelId,
channel.counterparty.channel_id,
channel.version
);
claimCapability(
channelCapabilityPath(portId, channelId),
address(module)
Expand Down
1 change: 1 addition & 0 deletions evm/tests/src/MockApp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ contract MockApp is IIBCModule {
function onChanOpenAck(
string calldata portId,
string calldata channelId,
string calldata counterpartyChannelId,
string calldata counterpartyVersion
) external virtual override {}

Expand Down
1 change: 1 addition & 0 deletions evm/tests/src/utils/MockApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ contract MockApp is IIBCModule {
function onChanOpenAck(
string calldata portId,
string calldata channelId,
string calldata counterpartyChannelId,
string calldata counterpartyVersion
) external virtual override {
emit MockChannelOpenAck();
Expand Down

0 comments on commit 62a6501

Please sign in to comment.