From 67aa9efe0f63bdaa6737a0e5c0b5a1a0c869e0dc Mon Sep 17 00:00:00 2001 From: Carmen Cheng Date: Thu, 18 Jan 2024 19:07:34 +0800 Subject: [PATCH] trimming events to reduce contract size --- protocol/contracts/MessageLibManager.sol | 10 ++++------ protocol/contracts/interfaces/IMessageLibManager.sol | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/protocol/contracts/MessageLibManager.sol b/protocol/contracts/MessageLibManager.sol index 89a6292..607f8ef 100644 --- a/protocol/contracts/MessageLibManager.sol +++ b/protocol/contracts/MessageLibManager.sol @@ -158,9 +158,8 @@ abstract contract MessageLibManager is Ownable, IMessageLibManager { uint32 _eid, address _newLib ) external onlyOwner onlyRegistered(_newLib) isSendLib(_newLib) onlySupportedEid(_newLib, _eid) { - address oldLib = defaultSendLibrary[_eid]; // must provide a different value - if (oldLib == _newLib) revert Errors.SameValue(); + if (defaultSendLibrary[_eid] == _newLib) revert Errors.SameValue(); defaultSendLibrary[_eid] = _newLib; emit DefaultSendLibrarySet(_eid, _newLib); } @@ -179,7 +178,7 @@ abstract contract MessageLibManager is Ownable, IMessageLibManager { if (oldLib == _newLib) revert Errors.SameValue(); defaultReceiveLibrary[_eid] = _newLib; - emit DefaultReceiveLibrarySet(_eid, oldLib, _newLib); + emit DefaultReceiveLibrarySet(_eid, _newLib); if (_gracePeriod > 0) { // override the current default timeout to the [old_lib + new expiry] @@ -232,9 +231,8 @@ abstract contract MessageLibManager is Ownable, IMessageLibManager { ) external onlyRegisteredOrDefault(_newLib) isSendLib(_newLib) onlySupportedEid(_newLib, _eid) { _assertAuthorized(_oapp); - address oldLib = sendLibrary[_oapp][_eid]; // must provide a different value - if (oldLib == _newLib) revert Errors.SameValue(); + if (sendLibrary[_oapp][_eid] == _newLib) revert Errors.SameValue(); sendLibrary[_oapp][_eid] = _newLib; emit SendLibrarySet(_oapp, _eid, _newLib); } @@ -256,7 +254,7 @@ abstract contract MessageLibManager is Ownable, IMessageLibManager { // must provide new values if (oldLib == _newLib) revert Errors.SameValue(); receiveLibrary[_oapp][_eid] = _newLib; - emit ReceiveLibrarySet(_oapp, _eid, oldLib, _newLib); + emit ReceiveLibrarySet(_oapp, _eid, _newLib); if (_gracePeriod > 0) { // to simplify the logic, we only allow to set timeout if neither the new lib nor old lib is DEFAULT_LIB, which would should read the default timeout configurations diff --git a/protocol/contracts/interfaces/IMessageLibManager.sol b/protocol/contracts/interfaces/IMessageLibManager.sol index bf72c5f..5b101f4 100644 --- a/protocol/contracts/interfaces/IMessageLibManager.sol +++ b/protocol/contracts/interfaces/IMessageLibManager.sol @@ -16,10 +16,10 @@ interface IMessageLibManager { event LibraryRegistered(address newLib); event DefaultSendLibrarySet(uint32 eid, address newLib); - event DefaultReceiveLibrarySet(uint32 eid, address oldLib, address newLib); + event DefaultReceiveLibrarySet(uint32 eid, address newLib); event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry); event SendLibrarySet(address sender, uint32 eid, address newLib); - event ReceiveLibrarySet(address receiver, uint32 eid, address oldLib, address newLib); + event ReceiveLibrarySet(address receiver, uint32 eid, address newLib); event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout); function registerLibrary(address _lib) external;