Skip to content

Commit

Permalink
fix: set channelIds as destination
Browse files Browse the repository at this point in the history
  • Loading branch information
reednaa committed Apr 22, 2024
1 parent 6de3b28 commit 73593f9
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/apps/polymer/vIBCEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ contract IncentivizedPolymerEscrow is APolymerEscrow, IbcReceiverBase, IbcReceiv

//--- IBC Packet Callbacks ---//

// packet.srcPortAddr is the IncentivizedPolymerEscrow address on the source chain.
// packet.destPortAddr is the address of this contract.
// channelId: the channel id from the running chain's perspective, which can be used to identify the counterparty chain.
function onRecvPacket(IbcPacket calldata packet)
external override
onlyIbcDispatcher
Expand All @@ -129,12 +126,12 @@ contract IncentivizedPolymerEscrow is APolymerEscrow, IbcReceiverBase, IbcReceiv
uint256 gasLimit = gasleft();
bytes32 feeRecipitent = bytes32(uint256(uint160(tx.origin)));

// Collect the implementation identifier we added. Remember, this is trusted IFF packet.src.channelId is trusted.
// Collect the implementation identifier we added. Remember, this is trusted IFF packet.dest.channelId is trusted.
// sourceImplementationIdentifier has already been defined by the channel on channel creation.
bytes memory sourceImplementationIdentifier = packet.data[POLYMER_SENDER_IDENTIFIER_START:POLYMER_SENDER_IDENTIFIER_END];

bytes memory receiveAck = _handleMessage(
packet.src.channelId,
packet.dest.channelId,
sourceImplementationIdentifier,
packet.data[POLYMER_PACKAGE_PAYLOAD_START: ],
feeRecipitent,
Expand All @@ -155,18 +152,18 @@ contract IncentivizedPolymerEscrow is APolymerEscrow, IbcReceiverBase, IbcReceiv
uint256 gasLimit = gasleft();
bytes32 feeRecipitent = bytes32(uint256(uint160(tx.origin)));

// Collect the implementation identifier we added. Remember, this is trusted IFF packet.src.channelId is trusted.
// Collect the implementation identifier we added. Remember, this is trusted IFF packet.dest.channelId is trusted.
bytes memory destinationImplementationIdentifier = ack.data[POLYMER_SENDER_IDENTIFIER_START:POLYMER_SENDER_IDENTIFIER_END];

// Get the payload by removing the implementation identifier.
bytes calldata rawMessage = ack.data[POLYMER_PACKAGE_PAYLOAD_START:];

// Set a verificaiton context so we can recover the ack.
isVerifiedMessageHash[keccak256(rawMessage)] = VerifiedMessageHashContext({
chainIdentifier: packet.src.channelId,
chainIdentifier: packet.dest.channelId,
implementationIdentifier: destinationImplementationIdentifier
});
_handleAck(packet.src.channelId, destinationImplementationIdentifier, rawMessage, feeRecipitent, gasLimit);
_handleAck(packet.dest.channelId, destinationImplementationIdentifier, rawMessage, feeRecipitent, gasLimit);
}

function onTimeoutPacket(IbcPacket calldata packet) external override onlyIbcDispatcher{
Expand All @@ -178,7 +175,7 @@ contract IncentivizedPolymerEscrow is APolymerEscrow, IbcReceiverBase, IbcReceiv
bytes32 messageIdentifier = bytes32(rawMessage[MESSAGE_IDENTIFIER_START:MESSAGE_IDENTIFIER_END]);
address fromApplication = address(uint160(bytes20(rawMessage[FROM_APPLICATION_START_EVM:FROM_APPLICATION_END])));
_handleTimeout(
packet.src.channelId, messageIdentifier, fromApplication, rawMessage[CTX0_MESSAGE_START:], feeRecipitent, gasLimit
packet.dest.channelId, messageIdentifier, fromApplication, rawMessage[CTX0_MESSAGE_START:], feeRecipitent, gasLimit
);
}

Expand Down

0 comments on commit 73593f9

Please sign in to comment.