Skip to content

Commit

Permalink
trimming events to reduce contract size
Browse files Browse the repository at this point in the history
  • Loading branch information
carmenjiawenc committed Jan 18, 2024
1 parent 5945c9c commit 67aa9ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions protocol/contracts/MessageLibManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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]
Expand Down Expand Up @@ -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);
}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions protocol/contracts/interfaces/IMessageLibManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 67aa9ef

Please sign in to comment.