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(contracts): OZ-L2-L07 Block Container Does Not Enforce Whitelist #651

Merged
merged 2 commits into from
Jul 24, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions contracts/integration-test/L1BlockContainer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,25 @@ describe("L1BlockContainer", async () => {
const [deployer] = await ethers.getSigners();
const L1BlockContainer = await ethers.getContractFactory("L1BlockContainer", deployer);
container = await L1BlockContainer.deploy(deployer.address);

const Whitelist = await ethers.getContractFactory("Whitelist", deployer);
const whitelist = await Whitelist.deploy(deployer.address);
await whitelist.updateWhitelistStatus([deployer.address], true);

await container.updateWhitelist(whitelist.address);
});

it("should revert, when sender not allowed", async () => {
const [deployer] = await ethers.getSigners();
const [, signer] = await ethers.getSigners();
await container.initialize(
test.parentHash,
test.blockHeight - 1,
test.blockTimestamp - 1,
test.baseFee,
test.stateRoot
);
const Whitelist = await ethers.getContractFactory("Whitelist", deployer);
const whitelist = await Whitelist.deploy(deployer.address);
await container.updateWhitelist(whitelist.address);

await expect(container.importBlockHeader(constants.HashZero, [], false)).to.revertedWith(
await expect(container.connect(signer).importBlockHeader(constants.HashZero, [], false)).to.revertedWith(
"Not whitelisted sender"
);
});
Expand Down
8 changes: 1 addition & 7 deletions contracts/src/L2/predeploys/L1BlockContainer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,7 @@ contract L1BlockContainer is OwnableBase, IL1BlockContainer {
bytes calldata _blockHeaderRLP,
bool _updateGasPriceOracle
) external {
{
IWhitelist _whitelist = whitelist;
require(
address(_whitelist) == address(0) || _whitelist.isSenderAllowed(msg.sender),
"Not whitelisted sender"
);
}
require(whitelist.isSenderAllowed(msg.sender), "Not whitelisted sender");

// The encoding order in block header is
// 1. ParentHash: 32 bytes
Expand Down