diff --git a/evm/src/NttManager/ManagerBase.sol b/evm/src/NttManager/ManagerBase.sol index 8a336fccc..506cab3f1 100644 --- a/evm/src/NttManager/ManagerBase.sol +++ b/evm/src/NttManager/ManagerBase.sol @@ -150,7 +150,7 @@ abstract contract ManagerBase is ) { revert TransceiverAlreadyAttestedToMessage(nttManagerMessageHash); } - _setTransceiverAttestedToMessage(nttManagerMessageHash, msg.sender); + _setTransceiverAttestedToMessage(sourceChainId, nttManagerMessageHash, msg.sender); return nttManagerMessageHash; } @@ -419,12 +419,17 @@ abstract contract ManagerBase is _getMessageAttestationsStorage()[digest].attestedTransceivers |= uint64(1 << index); } - function _setTransceiverAttestedToMessage(bytes32 digest, address transceiver) internal { + function _setTransceiverAttestedToMessage( + uint16 sourceChainId, + bytes32 digest, + address transceiver + ) internal { _setTransceiverAttestedToMessage(digest, _getTransceiverInfosStorage()[transceiver].index); emit MessageAttestedTo( digest, transceiver, _getTransceiverInfosStorage()[transceiver].index ); + emit MessageAttestedTo(sourceChainId); } /// @dev Returns the bitmap of attestations from enabled transceivers for a given message. diff --git a/evm/src/NttManager/NttManager.sol b/evm/src/NttManager/NttManager.sol index 7ac021b91..25e5c716c 100644 --- a/evm/src/NttManager/NttManager.sol +++ b/evm/src/NttManager/NttManager.sol @@ -256,7 +256,9 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { sourceChainId, sourceNttManagerAddress, message.id, message.sender, nativeTokenTransfer ); - _mintOrUnlockToRecipient(digest, transferRecipient, nativeTransferAmount, false); + _mintOrUnlockToRecipient( + sourceChainId, digest, transferRecipient, nativeTransferAmount, false + ); } /// @dev Override this function to process an additional payload on the NativeTokenTransfer @@ -284,7 +286,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { bool isRateLimited = _isInboundAmountRateLimited(nativeTransferAmount, sourceChainId); if (isRateLimited) { // queue up the transfer - _enqueueInboundTransfer(digest, nativeTransferAmount, transferRecipient); + _enqueueInboundTransfer(sourceChainId, digest, nativeTransferAmount, transferRecipient); // end execution early return true; @@ -317,7 +319,13 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { delete _getInboundQueueStorage()[digest]; // run it through the mint/unlock logic - _mintOrUnlockToRecipient(digest, queuedTransfer.recipient, queuedTransfer.amount, false); + _mintOrUnlockToRecipient( + queuedTransfer.sourceChain, + digest, + queuedTransfer.recipient, + queuedTransfer.amount, + false + ); } /// @inheritdoc INttManager @@ -370,7 +378,11 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { // return the queued funds to the sender _mintOrUnlockToRecipient( - bytes32(uint256(messageSequence)), msg.sender, queuedTransfer.amount, true + queuedTransfer.sourceChain, + bytes32(uint256(messageSequence)), + msg.sender, + queuedTransfer.amount, + true ); } @@ -494,6 +506,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { // queue up and return _enqueueOutboundTransfer( + chainId, sequence, trimmedAmount, recipientChain, @@ -611,6 +624,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { } function _mintOrUnlockToRecipient( + uint16 sourceChain, bytes32 digest, address recipient, TrimmedAmount amount, @@ -627,6 +641,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { emit OutboundTransferCancelled(uint256(digest), recipient, untrimmedAmount); } else { emit TransferRedeemed(digest); + emit TransferRedeemed(sourceChain); } if (mode == Mode.LOCKING) { diff --git a/evm/src/interfaces/IManagerBase.sol b/evm/src/interfaces/IManagerBase.sol index c4d1d565f..749e2f86c 100644 --- a/evm/src/interfaces/IManagerBase.sol +++ b/evm/src/interfaces/IManagerBase.sol @@ -39,6 +39,12 @@ interface IManagerBase { /// @param index The index of the transceiver in the bitmap. event MessageAttestedTo(bytes32 digest, address transceiver, uint8 index); + /// @notice Emitted when a message has been attested to. + /// @dev Topic0 + /// 0x9fbae37d6867991331ee754b07fe4cc479ea8f0cd952e61f450740d6c350e580. + /// @param sourceChain The source chain. + event MessageAttestedTo(uint16 indexed sourceChain); + /// @notice Emmitted when the threshold required transceivers is changed. /// @dev Topic0 /// 0x2a855b929b9a53c6fb5b5ed248b27e502b709c088e036a5aa17620c8fc5085a9. diff --git a/evm/src/interfaces/INttManager.sol b/evm/src/interfaces/INttManager.sol index 3ace687fe..f1f558dbc 100644 --- a/evm/src/interfaces/INttManager.sol +++ b/evm/src/interfaces/INttManager.sol @@ -61,6 +61,13 @@ interface INttManager is IManagerBase { /// @param digest The digest of the message. event TransferRedeemed(bytes32 indexed digest); + /// @notice Emitted when a transfer has been redeemed + /// (either minted or unlocked on the recipient chain). + /// @dev Topic0 + /// 0x56b025e18da6f1f65995c2b538c47cabdb4103d11c9bb3ebbacb098d14fa12c6. + /// @param sourceChain The source chain. + event TransferRedeemed(uint16 indexed sourceChain); + /// @notice Emitted when an outbound transfer has been cancelled /// @dev Topic0 /// 0xf80e572ae1b63e2449629b6c7d783add85c36473926f216077f17ee002bcfd07. diff --git a/evm/src/interfaces/IRateLimiter.sol b/evm/src/interfaces/IRateLimiter.sol index 05aec9751..3849e652d 100644 --- a/evm/src/interfaces/IRateLimiter.sol +++ b/evm/src/interfaces/IRateLimiter.sol @@ -63,6 +63,7 @@ interface IRateLimiter { /// - recipientChain: the chain of the recipient. /// - sender: the sender of the transfer. /// - transceiverInstructions: additional instructions to be forwarded to the recipient chain. + /// - sourceChain: the chain of the sender. struct OutboundQueuedTransfer { bytes32 recipient; bytes32 refundAddress; @@ -71,6 +72,7 @@ interface IRateLimiter { uint16 recipientChain; address sender; bytes transceiverInstructions; + uint16 sourceChain; } /// @notice Parameters for an inbound queued transfer. @@ -78,10 +80,12 @@ interface IRateLimiter { /// - amount: the amount of the transfer, trimmed. /// - txTimestamp: the timestamp of the transfer. /// - recipient: the recipient of the transfer. + /// - sourceChain: the chain of the sender. struct InboundQueuedTransfer { TrimmedAmount amount; uint64 txTimestamp; address recipient; + uint16 sourceChain; } /// @notice Returns the currently remaining outbound capacity allowed diff --git a/evm/src/libraries/RateLimiter.sol b/evm/src/libraries/RateLimiter.sol index 877c86ee1..fc5531709 100644 --- a/evm/src/libraries/RateLimiter.sol +++ b/evm/src/libraries/RateLimiter.sol @@ -296,6 +296,7 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents { } function _enqueueOutboundTransfer( + uint16 sourceChain, uint64 sequence, TrimmedAmount amount, uint16 recipientChain, @@ -311,13 +312,15 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents { refundAddress: refundAddress, txTimestamp: uint64(block.timestamp), sender: senderAddress, - transceiverInstructions: transceiverInstructions + transceiverInstructions: transceiverInstructions, + sourceChain: sourceChain }); emit OutboundTransferQueued(sequence); } function _enqueueInboundTransfer( + uint16 sourceChain, bytes32 digest, TrimmedAmount amount, address recipient @@ -325,7 +328,8 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents { _getInboundQueueStorage()[digest] = InboundQueuedTransfer({ amount: amount, recipient: recipient, - txTimestamp: uint64(block.timestamp) + txTimestamp: uint64(block.timestamp), + sourceChain: sourceChain }); emit InboundTransferQueued(digest);