From f33e35770aba2ef1e300af8e2d34019d65f45416 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Fri, 10 Feb 2023 12:26:07 +0800 Subject: [PATCH] Revert "feat(protocol): revert Bridge receive() checks (#13128)" This reverts commit 675611d2a765c706d6d308635a5820639cbd39c4. --- packages/protocol/contracts/bridge/Bridge.sol | 9 ++++++--- .../contracts/bridge/libs/LibBridgeStatus.sol | 12 ++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/bridge/Bridge.sol index 86b2d7a5849..dbc5b9ce85b 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/bridge/Bridge.sol @@ -37,8 +37,7 @@ contract Bridge is EssentialContract, IBridge { event MessageStatusChanged( bytes32 indexed msgHash, - LibBridgeStatus.MessageStatus status, - address transactor + LibBridgeStatus.MessageStatus status ); event DestChainEnabled(uint256 indexed chainId, bool enabled); @@ -49,7 +48,11 @@ contract Bridge is EssentialContract, IBridge { /// Allow Bridge to receive ETH from the TokenVault or EtherVault. receive() external payable { - // TODO(dave,PR#13110): require the sender is the TokenVault or EtherVault + // Ensure the sender is either the Ether vault or the token vault. + require( + msg.sender == this.resolve("token_vault", false) || + msg.sender == this.resolve("ether_vault", true) + ); } /// @dev Initializer to be called after being deployed behind a proxy. diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeStatus.sol b/packages/protocol/contracts/bridge/libs/LibBridgeStatus.sol index f93e435c5a2..19e5404633e 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeStatus.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeStatus.sol @@ -24,11 +24,7 @@ library LibBridgeStatus { FAILED } - event MessageStatusChanged( - bytes32 indexed msgHash, - MessageStatus status, - address transactor - ); + event MessageStatusChanged(bytes32 indexed msgHash, MessageStatus status); /** * @dev If messageStatus is same as in the messageStatus mapping, @@ -42,11 +38,7 @@ library LibBridgeStatus { ) internal { if (getMessageStatus(msgHash) != status) { _setMessageStatus(msgHash, status); - emit LibBridgeStatus.MessageStatusChanged( - msgHash, - status, - msg.sender - ); + emit LibBridgeStatus.MessageStatusChanged(msgHash, status); } }