// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 // solhint-disable-next-line compiler-version pragma solidity >=0.6.9 <0.9.0; pragma experimental ABIEncoderV2; import "../libraries/IGasRefunder.sol"; import "./IDelayedMessageProvider.sol"; import "./IBridge.sol"; import "./Messages.sol"; import "./DelayBufferTypes.sol"; interface ISequencerInbox is IDelayedMessageProvider { /// @notice The maximum amount of time variatin between a message being posted on the L1 and being executed on the L2 /// @param delayBlocks The max amount of blocks in the past that a message can be received on L2 /// @param futureBlocks The max amount of blocks in the future that a message can be received on L2 /// @param delaySeconds The max amount of seconds in the past that a message can be received on L2 /// @param futureSeconds The max amount of seconds in the future that a message can be received on L2 struct MaxTimeVariation { uint256 delayBlocks; uint256 futureBlocks; uint256 delaySeconds; uint256 futureSeconds; } event SequencerBatchDelivered( uint256 indexed batchSequenceNumber, bytes32 indexed beforeAcc, bytes32 indexed afterAcc, bytes32 delayedAcc, uint256 afterDelayedMessagesRead, IBridge.TimeBounds timeBounds, IBridge.BatchDataLocation dataLocation ); event OwnerFunctionCalled(uint256 indexed id); /// @dev a separate event that emits batch data when this isn't easily accessible in the tx.input event SequencerBatchData(uint256 indexed batchSequenceNumber, bytes data); /// @dev a valid keyset was added event SetValidKeyset(bytes32 indexed keysetHash, bytes keysetBytes); /// @dev a keyset was invalidated event InvalidateKeyset(bytes32 indexed keysetHash); /// @dev Owner set max time variation. /// This event may have been introduced in an upgrade and therefore might not give the full history. /// To get the full history, search for `OwnerFunctionCalled(0)` events. event MaxTimeVariationSet(MaxTimeVariation maxTimeVariation); /// @dev Owner set a batch poster. /// This event may have been introduced in an upgrade and therefore might not give the full history. /// To get the full history, search for `OwnerFunctionCalled(1)` events. event BatchPosterSet(address batchPoster, bool isBatchPoster); /// @dev Owner or batch poster manager set a sequencer. /// This event may have been introduced in an upgrade and therefore might not give the full history. /// To get the full history, search for `OwnerFunctionCalled(4)` events. event SequencerSet(address addr, bool isSequencer); /// @dev Owner set the batch poster manager. /// This event may have been introduced in an upgrade and therefore might not give the full history. /// To get the full history, search for `OwnerFunctionCalled(5)` events. event BatchPosterManagerSet(address newBatchPosterManager); /// @dev Owner set the buffer config. event BufferConfigSet(BufferConfig bufferConfig); /// @dev Owner set the fee token pricer. event FeeTokenPricerSet(address feeTokenPricer); function totalDelayedMessagesRead() external view returns (uint256); function bridge() external view returns (IBridge); /// @dev The size of the batch header // solhint-disable-next-line func-name-mixedcase function HEADER_LENGTH() external view returns (uint256); /// @dev If the first batch data byte after the header has this bit set, /// the sequencer inbox has authenticated the data. Currently only used for 4844 blob support. /// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go // solhint-disable-next-line func-name-mixedcase function DATA_AUTHENTICATED_FLAG() external view returns (bytes1); /// @dev If the first data byte after the header has this bit set, /// then the batch data is to be found in 4844 data blobs /// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go // solhint-disable-next-line func-name-mixedcase function DATA_BLOB_HEADER_FLAG() external view returns (bytes1); /// @dev If the first data byte after the header has this bit set, /// then the batch data is a das message /// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go // solhint-disable-next-line func-name-mixedcase function DAS_MESSAGE_HEADER_FLAG() external view returns (bytes1); /// @dev If the first data byte after the header has this bit set, /// then the batch data is a das message that employs a merklesization strategy /// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go // solhint-disable-next-line func-name-mixedcase function TREE_DAS_MESSAGE_HEADER_FLAG() external view returns (bytes1); /// @dev If the first data byte after the header has this bit set, /// then the batch data has been brotli compressed /// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go // solhint-disable-next-line func-name-mixedcase function BROTLI_MESSAGE_HEADER_FLAG() external view returns (bytes1); /// @dev If the first data byte after the header has this bit set, /// then the batch data uses a zero heavy encoding /// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go // solhint-disable-next-line func-name-mixedcase function ZERO_HEAVY_MESSAGE_HEADER_FLAG() external view returns (bytes1); function rollup() external view returns (IOwnable); function isBatchPoster( address ) external view returns (bool); function isSequencer( address ) external view returns (bool); /// @notice True is the sequencer inbox is delay bufferable function isDelayBufferable() external view returns (bool); function maxDataSize() external view returns (uint256); /// @notice The batch poster manager has the ability to change the batch poster addresses /// This enables the batch poster to do key rotation function batchPosterManager() external view returns (address); /// @notice The fee token pricer is used to get the exchange rate between the child chain's fee token /// and parent chain's fee token. This is needed when the child chain uses a custom fee /// token which is different from the parent chain's fee token. The exchange rate is /// used to correctly report converted gas price in the batch spending reports, so /// the batch poster can get properly reimbursed on the child chain. If the chain uses /// a custom fee token, but the pricer is not set, then the batch poster reports won't be reported /// and the batch poster won't get reimbursed. function feeTokenPricer() external view returns (IFeeTokenPricer); struct DasKeySetInfo { bool isValidKeyset; uint64 creationBlock; } /// @dev returns 4 uint256 to be compatible with older version function maxTimeVariation() external view returns ( uint256 delayBlocks, uint256 futureBlocks, uint256 delaySeconds, uint256 futureSeconds ); function dasKeySetInfo( bytes32 ) external view returns (bool, uint64); /// @notice Remove force inclusion delay after a L1 chainId fork function removeDelayAfterFork() external; /// @notice Force messages from the delayed inbox to be included in the chain /// Callable by any address, but message can only be force-included after maxTimeVariation.delayBlocks /// has elapsed. As part of normal behaviour the sequencer will include these /// messages so it's only necessary to call this if the sequencer is down, or not including any delayed messages. /// @param _totalDelayedMessagesRead The total number of messages to read up to /// @param kind The kind of the last message to be included /// @param l1BlockAndTime The l1 block and the l1 timestamp of the last message to be included /// @param baseFeeL1 The l1 gas price of the last message to be included /// @param sender The sender of the last message to be included /// @param messageDataHash The messageDataHash of the last message to be included function forceInclusion( uint256 _totalDelayedMessagesRead, uint8 kind, uint64[2] calldata l1BlockAndTime, uint256 baseFeeL1, address sender, bytes32 messageDataHash ) external; function inboxAccs( uint256 index ) external view returns (bytes32); function batchCount() external view returns (uint256); function isValidKeysetHash( bytes32 ksHash ) external view returns (bool); /// @notice the creation block is intended to still be available after a keyset is deleted function getKeysetCreationBlock( bytes32 ksHash ) external view returns (uint256); /// @dev The delay buffer can change due to pending depletion/replenishment. /// This function applies pending buffer changes to proactively calculate the force inclusion deadline. /// This is only relevant when the buffer is less than the delayBlocks (unhappy case), otherwise force inclusion deadline is fixed at delayBlocks. /// @notice Calculates the upper bounds of the delay buffer /// @param blockNumber The block number when a delayed message was created /// @return blockNumberDeadline The block number at when the message can be force included function forceInclusionDeadline( uint64 blockNumber ) external view returns (uint64 blockNumberDeadline); // ---------- BatchPoster functions ---------- /// @dev Deprecated, kept for abi generation and will be removed in the future function addSequencerL2BatchFromOrigin( uint256 sequenceNumber, bytes calldata data, uint256 afterDelayedMessagesRead, IGasRefunder gasRefunder ) external; /// @dev Will be deprecated due to EIP-3074, use `addSequencerL2Batch` instead function addSequencerL2BatchFromOrigin( uint256 sequenceNumber, bytes calldata data, uint256 afterDelayedMessagesRead, IGasRefunder gasRefunder, uint256 prevMessageCount, uint256 newMessageCount ) external; function addSequencerL2Batch( uint256 sequenceNumber, bytes calldata data, uint256 afterDelayedMessagesRead, IGasRefunder gasRefunder, uint256 prevMessageCount, uint256 newMessageCount ) external; function addSequencerL2BatchFromBlobs( uint256 sequenceNumber, uint256 afterDelayedMessagesRead, IGasRefunder gasRefunder, uint256 prevMessageCount, uint256 newMessageCount ) external; /// @dev Proves message delays, updates delay buffers, and posts an L2 batch with blob data. /// DelayProof proves the delay of the message and syncs the delay buffer. function addSequencerL2BatchFromBlobsDelayProof( uint256 sequenceNumber, uint256 afterDelayedMessagesRead, IGasRefunder gasRefunder, uint256 prevMessageCount, uint256 newMessageCount, DelayProof calldata delayProof ) external; /// @dev Proves message delays, updates delay buffers, and posts an L2 batch with calldata posted from an EOA. /// DelayProof proves the delay of the message and syncs the delay buffer. /// Will be deprecated due to EIP-3074, use `addSequencerL2BatchDelayProof` instead function addSequencerL2BatchFromOriginDelayProof( uint256 sequenceNumber, bytes calldata data, uint256 afterDelayedMessagesRead, IGasRefunder gasRefunder, uint256 prevMessageCount, uint256 newMessageCount, DelayProof calldata delayProof ) external; /// @dev Proves message delays, updates delay buffers, and posts an L2 batch with calldata. /// delayProof is used to prove the delay of the message and syncs the delay buffer. function addSequencerL2BatchDelayProof( uint256 sequenceNumber, bytes calldata data, uint256 afterDelayedMessagesRead, IGasRefunder gasRefunder, uint256 prevMessageCount, uint256 newMessageCount, DelayProof calldata delayProof ) external; // ---------- onlyRollupOrOwner functions ---------- /** * @notice Set max delay for sequencer inbox * @param maxTimeVariation_ the maximum time variation parameters */ function setMaxTimeVariation( MaxTimeVariation memory maxTimeVariation_ ) external; /** * @notice Updates whether an address is authorized to be a batch poster at the sequencer inbox * @param addr the address * @param isBatchPoster_ if the specified address should be authorized as a batch poster */ function setIsBatchPoster(address addr, bool isBatchPoster_) external; /** * @notice Makes Data Availability Service keyset valid * @param keysetBytes bytes of the serialized keyset */ function setValidKeyset( bytes calldata keysetBytes ) external; /** * @notice Invalidates a Data Availability Service keyset * @param ksHash hash of the keyset */ function invalidateKeysetHash( bytes32 ksHash ) external; /** * @notice Updates whether an address is authorized to be a sequencer. * @dev The IsSequencer information is used only off-chain by the nitro node to validate sequencer feed signer. * @param addr the address * @param isSequencer_ if the specified address should be authorized as a sequencer */ function setIsSequencer(address addr, bool isSequencer_) external; /** * @notice Updates the batch poster manager, the address which has the ability to rotate batch poster keys * @param newBatchPosterManager The new batch poster manager to be set */ function setBatchPosterManager( address newBatchPosterManager ) external; /** * @notice Updates the fee token pricer, the contract which is used to get the exchange rate between child * chain's fee token and parent chain's fee token in rollups that use a custom fee token. * @param newFeeTokenPricer The new fee token pricer to be set */ function setFeeTokenPricer( IFeeTokenPricer newFeeTokenPricer ) external; /// @notice Allows the rollup owner to sync the rollup address function updateRollupAddress() external; // ---------- initializer ---------- function initialize( IBridge bridge_, MaxTimeVariation calldata maxTimeVariation_, BufferConfig calldata bufferConfig_, IFeeTokenPricer feeTokenPricer_ ) external; } interface IFeeTokenPricer { /** * @notice Get the number of child chain fee tokens per 1 parent chain fee token. Exchange rate must be * denominated in 18 decimals. Function is mutable so it allows the pricer to keep internal state. * @dev For example, parent chain's native token is ETH, fee token is DAI. If price of 1ETH = 2000DAI, then function should return 2000*1e18. * If fee token is USDC instead and price of 1ETH = 2000USDC, function should still return 2000*1e18, despite USDC using 6 decimals. */ function getExchangeRate() external returns (uint256); }