Skip to content
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

[Fix] G-01 Removing old initialize function #212

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions contracts/contracts/messageService/l2/L2MessageManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { Utils } from "../../lib/Utils.sol";
abstract contract L2MessageManager is AccessControlUpgradeable, IL2MessageManager, L2MessageManagerV1 {
using Utils for *;

bytes32 public constant L1_L2_MESSAGE_SETTER_ROLE = keccak256("L1_L2_MESSAGE_SETTER_ROLE");

uint256 public lastAnchoredL1MessageNumber;
mapping(uint256 messageNumber => bytes32 rollingHash) public l1RollingHashes;

Expand Down
10 changes: 0 additions & 10 deletions contracts/contracts/messageService/l2/v1/L2MessageManagerV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ abstract contract L2MessageManagerV1 is Initializable, L2MessageServicePauseMana
uint8 public constant INBOX_STATUS_RECEIVED = 1;
uint8 public constant INBOX_STATUS_CLAIMED = 2;

bytes32 public constant L1_L2_MESSAGE_SETTER_ROLE = keccak256("L1_L2_MESSAGE_SETTER_ROLE");

/**
* @dev Mapping to store L1->L2 message hashes status.
* @dev messageHash => messageStatus (0: unknown, 1: received, 2: claimed).
Expand All @@ -32,14 +30,6 @@ abstract contract L2MessageManagerV1 is Initializable, L2MessageServicePauseMana

/// @dev Total contract storage is 1 slot.

/**
* @notice Initialises L2 message manager contract.
* @param _l1l2MessageSetter The address owning the L1_L2_MESSAGE_SETTER_ROLE role.
*/
function __L2MessageManager_init(address _l1l2MessageSetter) internal onlyInitializing {
_grantRole(L1_L2_MESSAGE_SETTER_ROLE, _l1l2MessageSetter);
}

/**
* @notice Update the status of L1->L2 message when a user claims a message on L2.
* @param _messageHash Hash of the message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ contract TestL2MessageManager is Initializable, L2MessageManager, IGenericErrors
__ERC165_init();
__Context_init();
__AccessControl_init();
__L2MessageManager_init(_l1l2MessageSetter);
__PauseManager_init(_pauseTypeRoles, _unpauseTypeRoles);

_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(PAUSE_ALL_ROLE, _pauserManager);
_grantRole(UNPAUSE_ALL_ROLE, _pauserManager);
}

function tryInitialize(address _l1l2MessageSetter) external {
__L2MessageManager_init(_l1l2MessageSetter);
_grantRole(L1_L2_MESSAGE_SETTER_ROLE, _l1l2MessageSetter);
}

function updateL1L2MessageStatusToClaimed(bytes32 _messageHash) external {
Expand Down
8 changes: 3 additions & 5 deletions contracts/test/L2MessageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
DEFAULT_ADMIN_ROLE,
GENERAL_PAUSE_TYPE,
HASH_ZERO,
INITIALIZED_ERROR_MESSAGE,
L1_L2_MESSAGE_SETTER_ROLE,
pauseTypeRoles,
unpauseTypeRoles,
Expand Down Expand Up @@ -46,12 +45,11 @@ describe("L2MessageManager", () => {
});

describe("Initialization checks", () => {
it("Deployer has default admin role", async () => {
it("Deployer has DEFAULT_ADMIN_ROLE", async () => {
expect(await l2MessageManager.hasRole(DEFAULT_ADMIN_ROLE, admin.address)).to.be.true;
});

it("It should fail when not initializing", async () => {
await expectRevertWithReason(l2MessageManager.tryInitialize(admin.address), INITIALIZED_ERROR_MESSAGE);
it("l1l2MessageSetter has L1_L2_MESSAGE_SETTER_ROLE", async () => {
expect(await l2MessageManager.hasRole(L1_L2_MESSAGE_SETTER_ROLE, l1l2MessageSetter.address)).to.be.true;
});
});

Expand Down
Loading