Skip to content
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
12 changes: 6 additions & 6 deletions src/contracts/block-hash-pusher/linea/LineaBuffer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ contract LineaBuffer is BaseBuffer {
error SenderMismatch();

constructor(address l2MessageService_, address pusher_) {
_l2MessageService = l2MessageService_;
_pusher = pusher_;

if (l2MessageService_ == address(0)) {
revert InvalidL2MessageServiceAddress();
}
if (pusher_ == address(0)) {
revert InvalidPusherAddress();
}

_l2MessageService = l2MessageService_;
_pusher = pusher_;
}

/// @inheritdoc IBuffer
Expand All @@ -48,9 +51,6 @@ contract LineaBuffer is BaseBuffer {
if (msg.sender != address(l2MessageServiceCached)) {
revert InvalidSender();
}
if (_pusher == address(0)) {
revert InvalidPusherAddress();
}
if (l2MessageServiceCached.sender() != _pusher) {
revert SenderMismatch();
}
Expand Down
7 changes: 7 additions & 0 deletions src/contracts/block-hash-pusher/linea/LineaPusher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ contract LineaPusher is BlockHashArrayBuilder, IPusher {
uint256 _fee;
}

/// @notice Thrown when attempting to set an invalid Linea Rollup address.
error InvalidLineaRollupAddress();

constructor(address rollup_) {
if (rollup_ == address(0)) {
revert InvalidLineaRollupAddress();
}

_lineaRollup = rollup_;
}

Expand Down
12 changes: 6 additions & 6 deletions src/contracts/block-hash-pusher/scroll/ScrollBuffer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ contract ScrollBuffer is BaseBuffer {
error InvalidSender();

constructor(address l2ScrollMessenger_, address pusher_) {
_l2ScrollMessenger = l2ScrollMessenger_;
_pusher = pusher_;

if (l2ScrollMessenger_ == address(0)) {
revert InvalidL2ScrollMessengerAddress();
}
if (pusher_ == address(0)) {
revert InvalidPusherAddress();
}

_l2ScrollMessenger = l2ScrollMessenger_;
_pusher = pusher_;
}

/// @inheritdoc IBuffer
Expand All @@ -45,9 +48,6 @@ contract ScrollBuffer is BaseBuffer {
if (msg.sender != address(l2ScrollMessengerCached)) {
revert InvalidSender();
}
if (_pusher == address(0)) {
revert InvalidPusherAddress();
}
if (l2ScrollMessengerCached.xDomainMessageSender() != _pusher) {
revert DomainMessageSenderMismatch();
}
Expand Down
7 changes: 7 additions & 0 deletions src/contracts/block-hash-pusher/scroll/ScrollPusher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ contract ScrollPusher is BlockHashArrayBuilder, IPusher {
address refundAddress;
}

/// @notice Thrown when attempting to set an invalid L1ScrollMessenger address.
error InvalidL1ScrollMessengerAddress();

constructor(address l1ScrollMessenger_) {
if (l1ScrollMessenger_ == address(0)) {
revert InvalidL1ScrollMessengerAddress();
}

_l1ScrollMessenger = l1ScrollMessenger_;
}

Expand Down
3 changes: 0 additions & 3 deletions src/contracts/block-hash-pusher/zksync/ZkSyncBuffer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ contract ZkSyncBuffer is BaseBuffer {

/// @notice The aliased address of the pusher contract on L2.
function aliasedPusher() public view returns (address) {
if (_pusher == address(0)) {
revert InvalidPusherAddress();
}
return AddressAliasHelper.applyL1ToL2Alias(_pusher);
}
}
7 changes: 7 additions & 0 deletions src/contracts/block-hash-pusher/zksync/ZkSyncPusher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ contract ZkSyncPusher is BlockHashArrayBuilder, IPusher {
/// @notice Thrown when the L2 transaction request fails.
error FailedToPushHashes();

/// @notice Thrown when attempting to set an invalid ZkSync Diamond address.
error InvalidZkSyncDiamondAddress();

/// @notice Parameters for the L2 transaction that will be executed on ZkSync.
/// @param l2GasLimit The gas limit for the L2 transaction.
/// @param l2GasPerPubdataByteLimit The gas per pubdata byte limit.
Expand All @@ -41,6 +44,10 @@ contract ZkSyncPusher is BlockHashArrayBuilder, IPusher {
}

constructor(address zkSyncDiamond_) {
if (zkSyncDiamond_ == address(0)) {
revert InvalidZkSyncDiamondAddress();
}

_zkSyncDiamond = zkSyncDiamond_;
}

Expand Down
10 changes: 10 additions & 0 deletions test/block-hash-pusher/linea/LineaBuffer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ contract LineaBufferTest is Test {
buffer.receiveHashes(1, new bytes32[](1));
}

function test_constructor_reverts_if_pusher_is_zero_address() public {
vm.expectRevert(abi.encodeWithSelector(LineaBuffer.InvalidPusherAddress.selector));
new LineaBuffer(address(mockLineaMessageService), address(0));
}

function test_constructor_reverts_if_l2_message_service_is_zero_address() public {
vm.expectRevert(abi.encodeWithSelector(LineaBuffer.InvalidL2MessageServiceAddress.selector));
new LineaBuffer(address(0), pusher);
}

function testFuzz_receiveHashes_reverts_if_sender_does_not_match_pusher(address notPusher) public {
vm.assume(notPusher != pusher);
LineaBuffer buffer = new LineaBuffer(address(mockLineaMessageService), pusher);
Expand Down
5 changes: 5 additions & 0 deletions test/block-hash-pusher/linea/LineaPusher.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ contract LineaPusherTest is Test {
lineaPusher.pushHashes(buffer, block.number - batchSize, batchSize, l2TransactionData);
}

function test_constructor_reverts_if_rollup_is_zero_address() public {
vm.expectRevert(abi.encodeWithSelector(LineaPusher.InvalidLineaRollupAddress.selector));
new LineaPusher(address(0));
}

function test_viewFunctions() public {
LineaPusher lineaPusher = new LineaPusher(mockLineaRollup);
assertEq(lineaPusher.lineaRollup(), mockLineaRollup);
Expand Down
10 changes: 10 additions & 0 deletions test/block-hash-pusher/scroll/ScrollBuffer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ contract ScrollBufferTest is Test {
mockL2ScrollMessenger.relayMessage(pusher, address(buffer), 0, 0, l2Calldata);
}

function test_constructor_reverts_if_pusher_is_zero_address() public {
vm.expectRevert(abi.encodeWithSelector(ScrollBuffer.InvalidPusherAddress.selector));
new ScrollBuffer(address(mockL2ScrollMessenger), address(0));
}

function test_constructor_reverts_if_l2_scroll_messenger_is_zero_address() public {
vm.expectRevert(abi.encodeWithSelector(ScrollBuffer.InvalidL2ScrollMessengerAddress.selector));
new ScrollBuffer(address(0), pusher);
}

function testFuzz_receiveHashes_reverts_if_sender_is_not_l2_scroll_messenger(address notL2ScrollMessenger) public {
vm.assume(notL2ScrollMessenger != address(mockL2ScrollMessenger));
ScrollBuffer buffer = new ScrollBuffer(address(mockL2ScrollMessenger), pusher);
Expand Down
5 changes: 5 additions & 0 deletions test/block-hash-pusher/scroll/ScrollPusher.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ contract ScrollPusherTest is Test {
scrollPusher.pushHashes(buffer, block.number - batchSize, batchSize, l2TransactionData);
}

function test_constructor_reverts_if_l1_scroll_messenger_is_zero_address() public {
vm.expectRevert(abi.encodeWithSelector(ScrollPusher.InvalidL1ScrollMessengerAddress.selector));
new ScrollPusher(address(0));
}

function test_viewFunctions() public {
ScrollPusher scrollPusher = new ScrollPusher(mockL1ScrollMessenger);
assertEq(scrollPusher.l1ScrollMessenger(), mockL1ScrollMessenger);
Expand Down
5 changes: 5 additions & 0 deletions test/block-hash-pusher/zksync/ZkSyncBuffer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ contract ZkSyncBufferTest is Test {
buffer.receiveHashes(firstBlockNumber, blockHashes);
}

function test_constructor_reverts_if_pusher_is_zero_address() public {
vm.expectRevert(abi.encodeWithSelector(ZkSyncBuffer.InvalidPusherAddress.selector));
new ZkSyncBuffer(address(0));
}

function testFuzz_receiveHashes_reverts_if_not_pusher(address notPusher) public {
vm.assume(notPusher != pusher);
address aliasedPusher = AddressAliasHelper.applyL1ToL2Alias(pusher);
Expand Down
5 changes: 5 additions & 0 deletions test/block-hash-pusher/zksync/ZkSyncPusher.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ contract ZkSyncPusherTest is Test {
zkSyncPusher.pushHashes(buffer, block.number - batchSize, batchSize, l2TransactionData);
}

function test_constructor_reverts_if_zksync_diamond_is_zero_address() public {
vm.expectRevert(abi.encodeWithSelector(ZkSyncPusher.InvalidZkSyncDiamondAddress.selector));
new ZkSyncPusher(address(0));
}

function test_viewFunctions() public {
ZkSyncPusher zkSyncPusher = new ZkSyncPusher(mockZkSyncMailbox);
assertEq(zkSyncPusher.zkSyncDiamond(), mockZkSyncMailbox);
Expand Down