Skip to content

fix: ensure contracts are only initialized once (C4 M-149) #741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions contracts/gateway/BridgeEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

pragma solidity ^0.7.6;

import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";

import "../upgrades/GraphUpgradeable.sol";
import "../governance/Managed.sol";
import "../token/IGraphToken.sol";
Expand All @@ -12,12 +14,12 @@ import "../token/IGraphToken.sol";
* a set of spenders that can transfer the tokens; the L1 side of each L2 bridge has to be
* approved as a spender.
*/
contract BridgeEscrow is GraphUpgradeable, Managed {
contract BridgeEscrow is Initializable, GraphUpgradeable, Managed {
/**
* @dev Initialize this contract.
* @param _controller Address of the Controller that manages this contract
*/
function initialize(address _controller) external onlyImpl {
function initialize(address _controller) external onlyImpl initializer {
Managed._initialize(_controller);
}

Expand Down
5 changes: 3 additions & 2 deletions contracts/gateway/L1GraphTokenGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pragma solidity ^0.7.6;
pragma abicoder v2;

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

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

// Address of the Graph Token contract on L2
Expand Down Expand Up @@ -97,7 +98,7 @@ contract L1GraphTokenGateway is GraphTokenGateway, L1ArbitrumMessenger {
* - pauseGuardian using setPauseGuardian
* @param _controller Address of the Controller that manages this contract
*/
function initialize(address _controller) external onlyImpl {
function initialize(address _controller) external onlyImpl initializer {
Managed._initialize(_controller);
_paused = true;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/l2/gateway/L2GraphTokenGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger, Reentran
* - pauseGuardian using setPauseGuardian
* @param _controller Address of the Controller that manages this contract
*/
function initialize(address _controller) external onlyImpl {
function initialize(address _controller) external onlyImpl initializer {
Managed._initialize(_controller);
_paused = true;
__ReentrancyGuard_init();
Expand Down
2 changes: 1 addition & 1 deletion contracts/l2/token/L2GraphToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
* - l1Address using setL1Address
* @param _owner Governance address that owns this contract
*/
function initialize(address _owner) external onlyImpl {
function initialize(address _owner) external onlyImpl initializer {
require(_owner != address(0), "Owner must be set");
// Initial supply hard coded to 0 as tokens are only supposed
// to be minted through the bridge.
Expand Down