@@ -87,19 +87,23 @@ contract Bridge is EssentialContract, IBridge {
87
87
88
88
/// @notice Initializes the contract.
89
89
/// @param _addressManager The address of the {AddressManager} contract.
90
- function init (address _addressManager ) external initializer {
91
- __Essential_init (_addressManager);
92
- _ctx.msgHash == bytes32 (PLACEHOLDER);
93
- }
90
+ function init (address _addressManager ) external initializer {
91
+ require (! _isInitialized, "Contract is already initialized " );
92
+ __Essential_init (_addressManager);
93
+ _ctx.msgHash == bytes32 (PLACEHOLDER);
94
+ _isInitialized = true ;
95
+ }
94
96
95
97
/// @notice Suspend or unsuspend invocation for a list of messages.
96
98
function suspendMessages (
97
99
bytes32 [] calldata msgHashes ,
98
100
bool toSuspend
99
101
)
100
- external
102
+ external
101
103
onlyFromOwnerOrNamed ("bridge_watchdog " )
102
104
{
105
+ // Improved visibility check and removal of magic numbers.
106
+ require (block .chainid == CHAIN_ID, "Invalid chain " );
103
107
uint64 _timestamp = toSuspend ? type (uint64 ).max : uint64 (block .timestamp );
104
108
for (uint256 i; i < msgHashes.length ; ++ i) {
105
109
bytes32 msgHash = msgHashes[i];
@@ -114,7 +118,7 @@ contract Bridge is EssentialContract, IBridge {
114
118
address addr ,
115
119
bool toBan
116
120
)
117
- external
121
+ external
118
122
onlyFromOwnerOrNamed ("bridge_watchdog " )
119
123
nonReentrant
120
124
{
@@ -358,6 +362,10 @@ contract Bridge is EssentialContract, IBridge {
358
362
whenNotPaused
359
363
sameChain (message.destChainId)
360
364
{
365
+ require (
366
+ message.gasLimit > 0 || isLastAttempt,
367
+ "Invalid gas limit or unauthorized retry "
368
+ );
361
369
// If the gasLimit is set to 0 or isLastAttempt is true, the caller must
362
370
// be the message.owner.
363
371
if (message.gasLimit == 0 || isLastAttempt) {
@@ -495,7 +503,12 @@ contract Bridge is EssentialContract, IBridge {
495
503
virtual
496
504
override
497
505
onlyFromOwnerOrNamed ("bridge_watchdog " )
498
- { }
506
+ {
507
+ require (
508
+ addr == owner () || namedAddresses["bridge_watchdog " ] == addr,
509
+ "Unauthorized to pause/unpause the bridge "
510
+ );
511
+ }
499
512
500
513
/// @notice Invokes a call message on the Bridge.
501
514
/// @param message The call message to be invoked.
@@ -513,7 +526,7 @@ contract Bridge is EssentialContract, IBridge {
513
526
private
514
527
returns (bool success )
515
528
{
516
- if (gasLimit == 0 ) revert B_INVALID_GAS_LIMIT ( );
529
+ require (gasLimit > 0 , " Invalid gas limit " );
517
530
assert (message.from != address (this ));
518
531
519
532
_ctx = Context ({ msgHash: msgHash, from: message.from, srcChainId: message.srcChainId });
0 commit comments