Skip to content

Commit

Permalink
Update Events to include message nonce (#19475)
Browse files Browse the repository at this point in the history
## Description 

Updated the governance action events to include the message nonce for
indexing purposes.

## Test plan 

Unit tests

---------

Co-authored-by: longbowlu <[email protected]>
  • Loading branch information
Bridgerz and longbowlu authored Sep 21, 2024
1 parent 5efd2c4 commit b4176b6
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 10 deletions.
4 changes: 2 additions & 2 deletions bridge/evm/contracts/BridgeCommittee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ contract BridgeCommittee is IBridgeCommittee, CommitteeUpgradeable {

// update the blocklist
_updateBlocklist(_blocklist, isBlocklisted);

emit BlocklistUpdatedV2(message.nonce, _blocklist, isBlocklisted);
}

/* ========== INTERNAL FUNCTIONS ========== */
Expand All @@ -134,8 +136,6 @@ contract BridgeCommittee is IBridgeCommittee, CommitteeUpgradeable {
for (uint16 i; i < _blocklist.length; i++) {
blocklist[_blocklist[i]] = isBlocklisted;
}

emit BlocklistUpdated(_blocklist, isBlocklisted);
}

/// @notice Splits the provided signature into its r, s, and v components.
Expand Down
8 changes: 4 additions & 4 deletions bridge/evm/contracts/BridgeConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ contract BridgeConfig is IBridgeConfig, CommitteeUpgradeable {
(uint8 tokenID, uint64 price) = BridgeUtils.decodeUpdateTokenPricePayload(message.payload);

_updateTokenPrice(tokenID, price);

emit TokenPriceUpdatedV2(message.nonce, tokenID, price);
}

function addTokensWithSignatures(bytes[] memory signatures, BridgeUtils.Message memory message)
Expand All @@ -137,6 +139,8 @@ contract BridgeConfig is IBridgeConfig, CommitteeUpgradeable {
for (uint8 i; i < tokenIDs.length; i++) {
_addToken(tokenIDs[i], tokenAddresses[i], suiDecimals[i], _tokenPrices[i], native);
}

emit TokensAddedV2(message.nonce, tokenIDs, tokenAddresses, suiDecimals, _tokenPrices);
}

/* ========== PRIVATE FUNCTIONS ========== */
Expand All @@ -149,8 +153,6 @@ contract BridgeConfig is IBridgeConfig, CommitteeUpgradeable {
require(tokenPrice > 0, "BridgeConfig: Invalid token price");

tokenPrices[tokenID] = tokenPrice;

emit TokenPriceUpdated(tokenID, tokenPrice);
}

/// @notice Updates the token with the provided ID.
Expand All @@ -175,8 +177,6 @@ contract BridgeConfig is IBridgeConfig, CommitteeUpgradeable {

supportedTokens[tokenID] = Token(tokenAddress, suiDecimal, native);
tokenPrices[tokenID] = tokenPrice;

emit TokenAdded(tokenID, tokenAddress, suiDecimal, tokenPrice);
}

/* ========== MODIFIERS ========== */
Expand Down
2 changes: 1 addition & 1 deletion bridge/evm/contracts/BridgeLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,6 @@ contract BridgeLimiter is IBridgeLimiter, CommitteeUpgradeable, OwnableUpgradeab
// update the chain limit
chainLimits[sourceChainID] = newLimit;

emit LimitUpdated(sourceChainID, newLimit);
emit LimitUpdatedV2(message.nonce, sourceChainID, newLimit);
}
}
4 changes: 2 additions & 2 deletions bridge/evm/contracts/SuiBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import "./interfaces/ISuiBridge.sol";
import "./interfaces/IBridgeVault.sol";
import "./interfaces/IBridgeLimiter.sol";
import "./interfaces/IBridgeConfig.sol";
import "./interfaces/IWETH9.sol";

/// @title SuiBridge
/// @notice This contract implements a token bridge that enables users to deposit and withdraw
Expand Down Expand Up @@ -121,7 +120,8 @@ contract SuiBridge is ISuiBridge, CommitteeUpgradeable, PausableUpgradeable {

if (isFreezing) _pause();
else _unpause();
// pausing event emitted in 'PausableUpgradeable.sol'

emit EmergencyOperation(message.nonce, isFreezing);
}

/// @notice Enables the caller to deposit supported tokens to be bridged to a given
Expand Down
4 changes: 4 additions & 0 deletions bridge/evm/contracts/interfaces/IBridgeCommittee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ interface IBridgeCommittee {
/* ========== EVENTS ========== */

/// @notice Emitted when the blocklist is updated.
/// @param nonce The governance action nonce.
/// @param updatedMembers The addresses of the updated committee members.
/// @param isBlocklisted A boolean indicating whether the committee members are blocklisted or not.
event BlocklistUpdatedV2(uint64 nonce, address[] updatedMembers, bool isBlocklisted);

/// @dev (deprecated in favor of BlocklistUpdatedV2)
event BlocklistUpdated(address[] updatedMembers, bool isBlocklisted);
}
23 changes: 23 additions & 0 deletions bridge/evm/contracts/interfaces/IBridgeConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ interface IBridgeConfig {
/// @notice Returns the chain ID of the bridge.
function chainID() external view returns (uint8);

/// @notice Event for the addition of a new token.
/// @param nonce The governance action nonce.
/// @param tokenIDs The IDs of the tokens added.
/// @param tokenAddresses The addresses of the tokens added.
/// @param suiDecimals The added token's decimal places on Sui.
/// @param tokenPrices The prices of the tokens added in USD.
event TokensAddedV2(
uint64 nonce,
uint8[] tokenIDs,
address[] tokenAddresses,
uint8[] suiDecimals,
uint64[] tokenPrices
);

/// @dev (deprecated in favor of TokensAddedV2)
event TokenAdded(uint8 tokenID, address tokenAddress, uint8 suiDecimal, uint64 tokenPrice);

/// @notice Event for the price update of a token.
/// @param nonce The governance action nonce.
/// @param tokenID The ID of the token updated.
/// @param tokenPrice The new price of the token in USD.
event TokenPriceUpdatedV2(uint64 nonce, uint8 tokenID, uint64 tokenPrice);

/// @dev (deprecated in favor of TokenPriceUpdatedV2)
event TokenPriceUpdated(uint8 tokenID, uint64 tokenPrice);
}
4 changes: 4 additions & 0 deletions bridge/evm/contracts/interfaces/IBridgeLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ interface IBridgeLimiter {
event HourlyTransferAmountUpdated(uint32 hourUpdated, uint256 amount);

/// @dev Emitted when the total limit is updated.
/// @param nonce The governance action nonce.
/// @param sourceChainID The ID of the source chain.
/// @param newLimit The new limit in USD with 4 decimal places (e.g. 10000 -> $1)
event LimitUpdatedV2(uint64 nonce, uint8 sourceChainID, uint64 newLimit);

/// @dev (deprecated in favor of LimitUpdatedV2)
event LimitUpdated(uint8 sourceChainID, uint64 newLimit);
}
5 changes: 5 additions & 0 deletions bridge/evm/contracts/interfaces/ISuiBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ interface ISuiBridge {
bytes senderAddress,
address recipientAddress
);

/// @notice Emitted when the bridge is paused or unpaused.
/// @param nonce The governance action nonce.
/// @param paused A boolean indicating whether the bridge is paused or not.
event EmergencyOperation(uint64 nonce, bool paused);
}
10 changes: 9 additions & 1 deletion bridge/evm/contracts/utils/CommitteeUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ abstract contract CommitteeUpgradeable is
// authorize upgrade
_upgradeAuthorized = true;
// upgrade contract
upgradeToAndCall(implementation, callData); // Upgraded event emitted with new implementation address
upgradeToAndCall(implementation, callData);

emit ContractUpgraded(message.nonce, proxy, implementation);
}

/* ========== INTERNAL FUNCTIONS ========== */
Expand All @@ -69,4 +71,10 @@ abstract contract CommitteeUpgradeable is
require(_upgradeAuthorized, "CommitteeUpgradeable: Unauthorized upgrade");
_upgradeAuthorized = false;
}

/// @notice Event emitted when the contract is upgraded
/// @param nonce The nonce of the upgrade message.
/// @param proxy The address of the proxy contract.
/// @param implementation The address of the new implementation.
event ContractUpgraded(uint256 nonce, address proxy, address implementation);
}

0 comments on commit b4176b6

Please sign in to comment.