Skip to content
This repository was archived by the owner on Dec 3, 2025. It is now read-only.

Commit f81a637

Browse files
committed
fixup! Replaced explicit warp contract in TeleporterMessenger to use an interface
1 parent 45ec8e1 commit f81a637

File tree

4 files changed

+19
-103
lines changed

4 files changed

+19
-103
lines changed

abi-bindings/go/teleporter/TeleporterMessenger/TeleporterMessenger.go

Lines changed: 2 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

avalanche/contracts/teleporter/ITeleporterMessenger.sol

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@ interface ITeleporterMessenger {
181181
*/
182182
function receiveCrossChainMessage(uint32 messageIndex, address relayerRewardAddress) external;
183183

184-
/**
185-
* @notice Receives an inter-chain message, and marks the `relayerRewardAddress` for fee reward for a successful delivery.
186-
*
187-
*/
188-
function receiveInterChainMessage(ICMMessage calldata icmMessage, address relayerRewardAddress) external;
189-
190184
/**
191185
* @notice Retries the execution of a previously delivered message by verifying the payload matches
192186
* the hash of the payload originally delivered, and calling the destination address again.

avalanche/contracts/teleporter/IWarpExt.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ interface IWarpExt is IWarpMessenger {
2222
* @return message A verified Warp message.
2323
*/
2424
function getVerifiedICMMessage(
25-
ICMMessage calldata icmMessag3
25+
ICMMessage calldata icmMessage
2626
) external view returns (WarpMessage memory message);
2727
}

avalanche/contracts/teleporter/TeleporterMessenger.sol

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -272,26 +272,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards, Initiali
272272
);
273273
_processWarpMessage(warpMessage, relayerRewardAddress);
274274
}
275-
276-
/**
277-
* @dev Emits a {ReceiveCrossChainMessage} event.
278-
* Receives a Warp message as a byte payload and processes it.
279-
* Re-entrancy is explicitly disallowed between receiving functions. One message is not able to receive another message.
280-
* Requirements:
281-
*
282-
* - Valid warp message is decoded from the payload
283-
*
284-
* @inheritdoc ITeleporterMessenger
285-
*/
286-
function receiveInterChainMessage(
287-
ICMMessage calldata icmMessage,
288-
address relayerRewardAddress
289-
) external receiverNonReentrant {
290-
WarpMessage memory warpMessage =
291-
_warpMessenger.getVerifiedICMMessage(icmMessage);
292-
_processWarpMessage(warpMessage, relayerRewardAddress);
293-
}
294-
275+
295276
/**
296277
* @dev A Teleporter message has an associated `requiredGasLimit` that is used to execute the message.
297278
* If the `requiredGasLimit` is too low, then the message execution will fail. This method allows
@@ -672,45 +653,16 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards, Initiali
672653
TeleporterMessageInput memory messageInput,
673654
TeleporterMessageReceipt[] memory receipts
674655
) private returns (bytes32) {
675-
676-
(bytes32 messageID, TeleporterMessage memory teleporterMessage, TeleporterFeeInfo memory adjustedFeeInfo)
677-
= _prepareTeleporterMessage(messageInput, receipts);
678-
679-
bytes memory teleporterMessageBytes = abi.encode(teleporterMessage);
680-
sentMessageInfo[messageID] = SentMessageInfo({
681-
messageHash: keccak256(teleporterMessageBytes),
682-
feeInfo: adjustedFeeInfo
683-
});
684-
685-
emit SendCrossChainMessage(
686-
messageID, messageInput.destinationBlockchainID, teleporterMessage, adjustedFeeInfo
687-
);
688-
689-
// Submit the message to the AWM precompile.
690-
_warpMessenger.sendWarpMessage(teleporterMessageBytes);
691-
692-
return messageID;
693-
}
694-
695-
696-
/**
697-
* @dev Helper function that assempbles the actual telepoter message and associated
698-
* metadata (message id, fee info)
699-
*/
700-
function _prepareTeleporterMessage(
701-
TeleporterMessageInput memory messageInput,
702-
TeleporterMessageReceipt[] memory receipts
703-
) private returns (bytes32 messageID, TeleporterMessage memory teleporterMessage, TeleporterFeeInfo memory ) {
704656
// If the blockchain ID has yet to be initialized, do so now.
705657
bytes32 blockchainID_ = initializeBlockchainID();
706658

707659
// Get the message ID to use for this message by incrementing it.
708660
uint256 messageNonce_ = ++messageNonce;
709-
messageID =
661+
bytes32 messageID =
710662
calculateMessageID(blockchainID_, messageInput.destinationBlockchainID, messageNonce_);
711663

712664
// Construct and serialize the message.
713-
teleporterMessage = TeleporterMessage({
665+
TeleporterMessage memory teleporterMessage = TeleporterMessage({
714666
messageNonce: messageNonce_,
715667
originSenderAddress: msg.sender,
716668
destinationBlockchainID: messageInput.destinationBlockchainID,
@@ -720,7 +672,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards, Initiali
720672
receipts: receipts,
721673
message: messageInput.message
722674
});
723-
675+
bytes memory teleporterMessageBytes = abi.encode(teleporterMessage);
724676

725677
// If the fee amount is non-zero, transfer the asset into control of this TeleporterMessenger contract instance.
726678
// The fee is allowed to be 0 because it's possible for someone to run their own relayer and deliver their own messages,
@@ -745,8 +697,19 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards, Initiali
745697
feeTokenAddress: messageInput.feeInfo.feeTokenAddress,
746698
amount: adjustedFeeAmount
747699
});
700+
sentMessageInfo[messageID] = SentMessageInfo({
701+
messageHash: keccak256(teleporterMessageBytes),
702+
feeInfo: adjustedFeeInfo
703+
});
748704

749-
return (messageID, teleporterMessage, adjustedFeeInfo);
705+
emit SendCrossChainMessage(
706+
messageID, messageInput.destinationBlockchainID, teleporterMessage, adjustedFeeInfo
707+
);
708+
709+
// Submit the message to the AWM precompile.
710+
_warpMessenger.sendWarpMessage(teleporterMessageBytes);
711+
712+
return messageID;
750713
}
751714

752715
/**

0 commit comments

Comments
 (0)