Skip to content

Commit

Permalink
linter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Mar 5, 2024
1 parent ac319cb commit 9dc69d0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
42 changes: 42 additions & 0 deletions l1-contracts/src/core/interfaces/messagebridge/INewInbox.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Aztec Labs.
pragma solidity >=0.8.18;

import {DataStructures} from "../../libraries/DataStructures.sol";

/**
* @title Inbox
* @author Aztec Labs
* @notice Lives on L1 and is used to pass messages into the rollup, e.g., L1 -> L2 messages.
*/
// TODO: rename to IInbox once all the pieces of the new message model are in place.
interface INewInbox {
event LeafInserted(uint256 indexed blockNumber, uint256 index, bytes32 value);

// docs:start:send_l1_to_l2_message
/**
* @notice Inserts a new message into the Inbox
* @dev Emits `LeafInserted` with data for easy access by the sequencer
* @param _recipient - The recipient of the message
* @param _content - The content of the message (application specific)
* @param _secretHash - The secret hash of the message (make it possible to hide when a specific message is consumed on L2)
* @return The key of the message in the set
*/
function sendL2Message(
DataStructures.L2Actor memory _recipient,
bytes32 _content,
bytes32 _secretHash
) external returns (bytes32);
// docs:end:send_l1_to_l2_message

// docs:start:inbox_batch_consume
/**
* @notice Consumes the current tree, and starts a new one if needed
* @dev Only callable by the rollup contract
* @dev In the first iteration we return empty tree root because first block's messages tree is always
* empty because there has to be a 1 block lag to prevent sequencer DOS attacks
* @return The root of the consumed tree
*/
function consume() external returns (bytes32);
// docs:end:inbox_batch_consume
}
9 changes: 4 additions & 5 deletions l1-contracts/src/core/messagebridge/NewInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pragma solidity >=0.8.18;
// Interfaces
import {IFrontier} from "../interfaces/messagebridge/IFrontier.sol";
import {IRegistry} from "../interfaces/messagebridge/IRegistry.sol";
import {INewInbox} from "../interfaces/messagebridge/INewInbox.sol";

// Libraries
import {Constants} from "../libraries/ConstantsGen.sol";
Expand All @@ -21,7 +22,7 @@ import {FrontierMerkle} from "./frontier_tree/Frontier.sol";
* @notice Lives on L1 and is used to pass messages into the rollup, e.g., L1 -> L2 messages.
*/
// TODO: rename to Inbox once all the pieces of the new message model are in place.
contract NewInbox {
contract NewInbox is INewInbox {
using Hash for DataStructures.L1ToL2Msg;

address public immutable ROLLUP;
Expand All @@ -35,8 +36,6 @@ contract NewInbox {

mapping(uint256 blockNumber => IFrontier tree) internal trees;

event LeafInserted(uint256 indexed blockNumber, uint256 index, bytes32 value);

constructor(address _rollup, uint256 _height) {
ROLLUP = _rollup;

Expand All @@ -62,7 +61,7 @@ contract NewInbox {
DataStructures.L2Actor memory _recipient,
bytes32 _content,
bytes32 _secretHash
) external returns (bytes32) {
) external override(INewInbox) returns (bytes32) {
if (uint256(_recipient.actor) > Constants.MAX_FIELD_VALUE) {
revert Errors.Inbox__ActorTooLarge(_recipient.actor);
}
Expand Down Expand Up @@ -104,7 +103,7 @@ contract NewInbox {
* empty because there has to be a 1 block lag to prevent sequencer DOS attacks
* @return The root of the consumed tree
*/
function consume() external returns (bytes32) {
function consume() external override(INewInbox) returns (bytes32) {
if (msg.sender != ROLLUP) {
revert Errors.Inbox__Unauthorized();
}
Expand Down

0 comments on commit 9dc69d0

Please sign in to comment.