Skip to content
Open
9 changes: 7 additions & 2 deletions evm/src/NttManager/ManagerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ abstract contract ManagerBase is
) {
revert TransceiverAlreadyAttestedToMessage(nttManagerMessageHash);
}
_setTransceiverAttestedToMessage(nttManagerMessageHash, msg.sender);
_setTransceiverAttestedToMessage(sourceChainId, nttManagerMessageHash, msg.sender);

return nttManagerMessageHash;
}
Expand Down Expand Up @@ -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.
Expand Down
23 changes: 19 additions & 4 deletions evm/src/NttManager/NttManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
);
}

Expand Down Expand Up @@ -494,6 +506,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {

// queue up and return
_enqueueOutboundTransfer(
chainId,
sequence,
trimmedAmount,
recipientChain,
Expand Down Expand Up @@ -611,6 +624,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
}

function _mintOrUnlockToRecipient(
uint16 sourceChain,
bytes32 digest,
address recipient,
TrimmedAmount amount,
Expand All @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions evm/src/interfaces/IManagerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions evm/src/interfaces/INttManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions evm/src/interfaces/IRateLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -71,17 +72,20 @@ interface IRateLimiter {
uint16 recipientChain;
address sender;
bytes transceiverInstructions;
uint16 sourceChain;
}

/// @notice Parameters for an inbound queued transfer.
/// @dev
/// - 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
Expand Down
8 changes: 6 additions & 2 deletions evm/src/libraries/RateLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents {
}

function _enqueueOutboundTransfer(
uint16 sourceChain,
uint64 sequence,
TrimmedAmount amount,
uint16 recipientChain,
Expand All @@ -311,21 +312,24 @@ 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
) internal {
_getInboundQueueStorage()[digest] = InboundQueuedTransfer({
amount: amount,
recipient: recipient,
txTimestamp: uint64(block.timestamp)
txTimestamp: uint64(block.timestamp),
sourceChain: sourceChain
});

emit InboundTransferQueued(digest);
Expand Down
Loading