Skip to content

Commit

Permalink
evm: Propogate sourceChainId to TransferRedeemed event
Browse files Browse the repository at this point in the history
  • Loading branch information
nvsriram committed Dec 3, 2024
1 parent 9973028 commit 6f1b531
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
24 changes: 19 additions & 5 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 @@ -626,7 +640,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
if (cancelled) {
emit OutboundTransferCancelled(uint256(digest), recipient, untrimmedAmount);
} else {
emit TransferRedeemed(digest);
emit TransferRedeemed(sourceChain, digest);
}

if (mode == Mode.LOCKING) {
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 @@ -57,13 +57,15 @@ interface IRateLimiter {

/// @notice Parameters for an outbound queued transfer.
/// @dev
/// - sourceChain: the chain of the sender.
/// - recipient: the recipient of the transfer.
/// - amount: the amount of the transfer, trimmed.
/// - txTimestamp: the timestamp of the transfer.
/// - recipientChain: the chain of the recipient.
/// - sender: the sender of the transfer.
/// - transceiverInstructions: additional instructions to be forwarded to the recipient chain.
struct OutboundQueuedTransfer {
uint16 sourceChain;
bytes32 recipient;
bytes32 refundAddress;
TrimmedAmount amount;
Expand All @@ -75,10 +77,12 @@ interface IRateLimiter {

/// @notice Parameters for an inbound queued transfer.
/// @dev
/// - sourceChain: the chain of the sender.
/// - amount: the amount of the transfer, trimmed.
/// - txTimestamp: the timestamp of the transfer.
/// - recipient: the recipient of the transfer.
struct InboundQueuedTransfer {
uint16 sourceChain;
TrimmedAmount amount;
uint64 txTimestamp;
address recipient;
Expand Down
4 changes: 4 additions & 0 deletions evm/src/libraries/RateLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents {
}

function _enqueueOutboundTransfer(
uint16 sourceChain,
uint64 sequence,
TrimmedAmount amount,
uint16 recipientChain,
Expand All @@ -295,6 +296,7 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents {
bytes memory transceiverInstructions
) internal {
_getOutboundQueueStorage()[sequence] = OutboundQueuedTransfer({
sourceChain: sourceChain,
amount: amount,
recipientChain: recipientChain,
recipient: recipient,
Expand All @@ -308,11 +310,13 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents {
}

function _enqueueInboundTransfer(
uint16 sourceChain,
bytes32 digest,
TrimmedAmount amount,
address recipient
) internal {
_getInboundQueueStorage()[digest] = InboundQueuedTransfer({
sourceChain: sourceChain,
amount: amount,
recipient: recipient,
txTimestamp: uint64(block.timestamp)
Expand Down

0 comments on commit 6f1b531

Please sign in to comment.