Skip to content

Commit

Permalink
evm: Emit events when updating inbound and outbound limits (#546)
Browse files Browse the repository at this point in the history
* Add `OutboundTransferLimitUpdated` and `InboundTransferLimitUpdated` events
* Emit these events when `_setOutboundLimit` and `_setInboundLimit` are called respectively
  • Loading branch information
nvsriram authored Nov 7, 2024
1 parent 8d9e6ab commit 6b4ea16
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
15 changes: 15 additions & 0 deletions evm/src/interfaces/IRateLimiterEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,19 @@ interface IRateLimiterEvents {
event OutboundTransferRateLimited(
address indexed sender, uint64 sequence, uint256 amount, uint256 currentCapacity
);

/// @notice Emitted when the outbound transfer limit is updated.
/// @dev Topic0
/// 0x7e3b0fc388be9d36273f66210aed83be975df3a9adfffa4c734033f498f362cd.
/// @param oldLimit The old outbound limit.
/// @param newLimit The new outbound limit.
event OutboundTransferLimitUpdated(uint256 oldLimit, uint256 newLimit);

/// @notice Emitted when the inbound transfer limit is updated.
/// @dev Topic0
/// 0x739ed886fd81a3ddc9f4b327ab69152e513cd45b26fda0c73660eaca8e119301.
/// @param chainId The chain ID the limit is set for.
/// @param oldLimit The old inbound limit.
/// @param newLimit The new inbound limit.
event InboundTransferLimitUpdated(uint16 indexed chainId, uint256 oldLimit, uint256 newLimit);
}
14 changes: 12 additions & 2 deletions evm/src/libraries/RateLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents {
function _setOutboundLimit(
TrimmedAmount limit
) internal virtual {
_setLimit(limit, _getOutboundLimitParamsStorage());
RateLimitParams storage rateLimitParams = _getOutboundLimitParamsStorage();
TrimmedAmount oldLimit = rateLimitParams.limit;
uint8 decimals = tokenDecimals();
_setLimit(limit, rateLimitParams);
emit OutboundTransferLimitUpdated(oldLimit.untrim(decimals), limit.untrim(decimals));
}

function getOutboundLimitParams() public pure virtual returns (RateLimitParams memory) {
Expand All @@ -116,7 +120,13 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents {
}

function _setInboundLimit(TrimmedAmount limit, uint16 chainId_) internal virtual {
_setLimit(limit, _getInboundLimitParamsStorage()[chainId_]);
RateLimitParams storage rateLimitParams = _getInboundLimitParamsStorage()[chainId_];
TrimmedAmount oldLimit = rateLimitParams.limit;
uint8 decimals = tokenDecimals();
_setLimit(limit, rateLimitParams);
emit InboundTransferLimitUpdated(
chainId_, oldLimit.untrim(decimals), limit.untrim(decimals)
);
}

function getInboundLimitParams(
Expand Down

0 comments on commit 6b4ea16

Please sign in to comment.