Skip to content

Commit 669e409

Browse files
authored
fix(chain-1987): revert in registerMessages if bridge paused (#110)
1 parent 4de91af commit 669e409

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

base/src/BridgeValidator.sol

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {IPartner} from "./interfaces/IPartner.sol";
99
import {MessageLib} from "./libraries/MessageLib.sol";
1010
import {VerificationLib} from "./libraries/VerificationLib.sol";
1111

12+
import {Bridge} from "./Bridge.sol";
13+
1214
/// @title BridgeValidator
1315
///
1416
/// @notice A validator contract to be used during the Stage 0 phase of Base Bridge. This will likely later be replaced
@@ -90,6 +92,9 @@ contract BridgeValidator is Initializable {
9092
/// @notice Thrown when attempting to register an empty batch of messages
9193
error NoMessages();
9294

95+
/// @notice Thrown when the Bridge is paused
96+
error Paused();
97+
9398
//////////////////////////////////////////////////////////////
9499
/// Modifiers ///
95100
//////////////////////////////////////////////////////////////
@@ -100,6 +105,12 @@ contract BridgeValidator is Initializable {
100105
_;
101106
}
102107

108+
/// @dev Restricts function to when the Bridge is not paused
109+
modifier whenNotPaused() {
110+
require(!Bridge(BRIDGE).paused(), Paused());
111+
_;
112+
}
113+
103114
//////////////////////////////////////////////////////////////
104115
/// Public Functions ///
105116
//////////////////////////////////////////////////////////////
@@ -142,7 +153,10 @@ contract BridgeValidator is Initializable {
142153
/// `abi.encode(messageHashes)`, provided in strictly ascending order by signer address.
143154
/// Must include at least `getBaseThreshold()` Base validator signatures. The external
144155
/// signature threshold is controlled by `PARTNER_VALIDATOR_THRESHOLD`.
145-
function registerMessages(bytes32[] calldata innerMessageHashes, bytes calldata validatorSigs) external {
156+
function registerMessages(bytes32[] calldata innerMessageHashes, bytes calldata validatorSigs)
157+
external
158+
whenNotPaused
159+
{
146160
uint256 len = innerMessageHashes.length;
147161
if (len == 0) revert NoMessages();
148162

base/test/BridgeValidator.t.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ contract BridgeValidatorTest is CommonTest {
6565
/// registerMessages Tests ///
6666
//////////////////////////////////////////////////////////////
6767

68+
function test_registerMessages_revertsWhenBridgePaused() public {
69+
// Pause the bridge via guardian
70+
vm.prank(cfg.guardians[0]);
71+
bridge.setPaused(true);
72+
73+
bytes32[] memory innerMessageHashes = new bytes32[](1);
74+
innerMessageHashes[0] = TEST_MESSAGE_HASH_1;
75+
76+
bytes memory sigs = _getValidatorSigs(innerMessageHashes);
77+
78+
vm.expectRevert(BridgeValidator.Paused.selector);
79+
bridgeValidator.registerMessages(innerMessageHashes, sigs);
80+
}
81+
6882
function test_registerMessages_emptyArray_revertsNoMessages() public {
6983
bytes32[] memory emptyArray = new bytes32[](0);
7084
vm.expectRevert(BridgeValidator.NoMessages.selector);

0 commit comments

Comments
 (0)