Skip to content

Commit 253f9fd

Browse files
committed
require
1 parent ac1ca31 commit 253f9fd

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

packages/protocol/contracts/bridge/Bridge.sol

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,23 @@ contract Bridge is EssentialContract, IBridge {
8787

8888
/// @notice Initializes the contract.
8989
/// @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+
}
9496

9597
/// @notice Suspend or unsuspend invocation for a list of messages.
9698
function suspendMessages(
9799
bytes32[] calldata msgHashes,
98100
bool toSuspend
99101
)
100-
external
102+
external
101103
onlyFromOwnerOrNamed("bridge_watchdog")
102104
{
105+
// Improved visibility check and removal of magic numbers.
106+
require(block.chainid == CHAIN_ID, "Invalid chain");
103107
uint64 _timestamp = toSuspend ? type(uint64).max : uint64(block.timestamp);
104108
for (uint256 i; i < msgHashes.length; ++i) {
105109
bytes32 msgHash = msgHashes[i];
@@ -114,7 +118,7 @@ contract Bridge is EssentialContract, IBridge {
114118
address addr,
115119
bool toBan
116120
)
117-
external
121+
external
118122
onlyFromOwnerOrNamed("bridge_watchdog")
119123
nonReentrant
120124
{
@@ -358,6 +362,10 @@ contract Bridge is EssentialContract, IBridge {
358362
whenNotPaused
359363
sameChain(message.destChainId)
360364
{
365+
require(
366+
message.gasLimit > 0 || isLastAttempt,
367+
"Invalid gas limit or unauthorized retry"
368+
);
361369
// If the gasLimit is set to 0 or isLastAttempt is true, the caller must
362370
// be the message.owner.
363371
if (message.gasLimit == 0 || isLastAttempt) {
@@ -495,7 +503,12 @@ contract Bridge is EssentialContract, IBridge {
495503
virtual
496504
override
497505
onlyFromOwnerOrNamed("bridge_watchdog")
498-
{ }
506+
{
507+
require(
508+
addr == owner() || namedAddresses["bridge_watchdog"] == addr,
509+
"Unauthorized to pause/unpause the bridge"
510+
);
511+
}
499512

500513
/// @notice Invokes a call message on the Bridge.
501514
/// @param message The call message to be invoked.
@@ -513,7 +526,7 @@ contract Bridge is EssentialContract, IBridge {
513526
private
514527
returns (bool success)
515528
{
516-
if (gasLimit == 0) revert B_INVALID_GAS_LIMIT();
529+
require(gasLimit > 0, "Invalid gas limit");
517530
assert(message.from != address(this));
518531

519532
_ctx = Context({ msgHash: msgHash, from: message.from, srcChainId: message.srcChainId });

0 commit comments

Comments
 (0)