Skip to content

Commit 85312a0

Browse files
committed
fix: ensure contracts are only initialized once (C4 M-149)
1 parent bcb4802 commit 85312a0

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

contracts/gateway/BridgeEscrow.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
pragma solidity ^0.7.6;
44

5+
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
6+
57
import "../upgrades/GraphUpgradeable.sol";
68
import "../governance/Managed.sol";
79
import "../token/IGraphToken.sol";
@@ -12,12 +14,12 @@ import "../token/IGraphToken.sol";
1214
* a set of spenders that can transfer the tokens; the L1 side of each L2 bridge has to be
1315
* approved as a spender.
1416
*/
15-
contract BridgeEscrow is GraphUpgradeable, Managed {
17+
contract BridgeEscrow is Initializable, GraphUpgradeable, Managed {
1618
/**
1719
* @dev Initialize this contract.
1820
* @param _controller Address of the Controller that manages this contract
1921
*/
20-
function initialize(address _controller) external onlyImpl {
22+
function initialize(address _controller) external onlyImpl initializer {
2123
Managed._initialize(_controller);
2224
}
2325

contracts/gateway/L1GraphTokenGateway.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
pragma solidity ^0.7.6;
44
pragma abicoder v2;
55

6+
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
67
import "@openzeppelin/contracts/utils/Address.sol";
78
import "@openzeppelin/contracts/math/SafeMath.sol";
89

@@ -18,7 +19,7 @@ import "./GraphTokenGateway.sol";
1819
* (See: https://github.com/OffchainLabs/arbitrum/tree/master/packages/arb-bridge-peripherals/contracts/tokenbridge
1920
* and https://github.com/livepeer/arbitrum-lpt-bridge)
2021
*/
21-
contract L1GraphTokenGateway is GraphTokenGateway, L1ArbitrumMessenger {
22+
contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMessenger {
2223
using SafeMath for uint256;
2324

2425
// Address of the Graph Token contract on L2
@@ -97,7 +98,7 @@ contract L1GraphTokenGateway is GraphTokenGateway, L1ArbitrumMessenger {
9798
* - pauseGuardian using setPauseGuardian
9899
* @param _controller Address of the Controller that manages this contract
99100
*/
100-
function initialize(address _controller) external onlyImpl {
101+
function initialize(address _controller) external onlyImpl initializer {
101102
Managed._initialize(_controller);
102103
_paused = true;
103104
}

contracts/l2/gateway/L2GraphTokenGateway.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger, Reentran
8484
* - pauseGuardian using setPauseGuardian
8585
* @param _controller Address of the Controller that manages this contract
8686
*/
87-
function initialize(address _controller) external onlyImpl {
87+
function initialize(address _controller) external onlyImpl initializer {
8888
Managed._initialize(_controller);
8989
_paused = true;
9090
__ReentrancyGuard_init();

contracts/l2/token/L2GraphToken.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
4545
* - l1Address using setL1Address
4646
* @param _owner Governance address that owns this contract
4747
*/
48-
function initialize(address _owner) external onlyImpl {
48+
function initialize(address _owner) external onlyImpl initializer {
4949
require(_owner != address(0), "Owner must be set");
5050
// Initial supply hard coded to 0 as tokens are only supposed
5151
// to be minted through the bridge.

0 commit comments

Comments
 (0)