Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ScrollChainMockFinalize
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity =0.8.24; import {ScrollChain} from "../L1/rollup/ScrollChain.sol"; import {BatchHeaderV0Codec} from "../libraries/codec/BatchHeaderV0Codec.sol"; import {BatchHeaderV1Codec} from "../libraries/codec/BatchHeaderV1Codec.sol"; contract ScrollChainMockFinalize is ScrollChain { /*************** * Constructor * ***************/ /// @notice Constructor for `ScrollChain` implementation contract. /// /// @param _chainId The chain id of L2. /// @param _messageQueue The address of `L1MessageQueue` contract. /// @param _verifier The address of zkevm verifier contract. constructor( uint64 _chainId, address _messageQueue, address _verifier ) ScrollChain(_chainId, _messageQueue, _verifier) {} /***************************** * Public Mutating Functions * *****************************/ /// @notice Finalize 4844 batch without proof, See the comments of {ScrollChain-finalizeBatchWithProof4844}. function finalizeBatch4844( bytes calldata _batchHeader, bytes32, /*_prevStateRoot*/ bytes32 _postStateRoot, bytes32 _withdrawRoot, bytes calldata _blobDataProof ) external OnlyProver whenNotPaused { (uint256 batchPtr, bytes32 _batchHash, uint256 _batchIndex) = _beforeFinalizeBatch( _batchHeader, _postStateRoot ); // verify blob versioned hash bytes32 _blobVersionedHash = BatchHeaderV1Codec.getBlobVersionedHash(batchPtr); _checkBlobVersionedHash(_blobVersionedHash, _blobDataProof); // Pop finalized and non-skipped message from L1MessageQueue. uint256 _totalL1MessagesPoppedOverall = BatchHeaderV0Codec.getTotalL1MessagePopped(batchPtr); _popL1MessagesMemory( BatchHeaderV1Codec.getSkippedBitmapPtr(batchPtr), _totalL1MessagesPoppedOverall, BatchHeaderV0Codec.getL1MessagePopped(batchPtr) ); _afterFinalizeBatch(_totalL1MessagesPoppedOverall, _batchIndex, _batchHash, _postStateRoot, _withdrawRoot); } /// @notice Finalize bundle without proof, See the comments of {ScrollChain-finalizeBundleWithProof}. function finalizeBundle( bytes calldata _batchHeader, bytes32 _postStateRoot, bytes32 _withdrawRoot ) external OnlyProver whenNotPaused { if (_postStateRoot == bytes32(0)) revert ErrorStateRootIsZero(); // compute pending batch hash and verify (, bytes32 _batchHash, uint256 _batchIndex, uint256 _totalL1MessagesPoppedOverall) = _loadBatchHeader( _batchHeader ); if (_batchIndex <= lastFinalizedBatchIndex) revert ErrorBatchIsAlreadyVerified(); // store in state // @note we do not store intermediate finalized roots lastFinalizedBatchIndex = _batchIndex; finalizedStateRoots[_batchIndex] = _postStateRoot; withdrawRoots[_batchIndex] = _withdrawRoot; // Pop finalized and non-skipped message from L1MessageQueue. _finalizePoppedL1Messages(_totalL1MessagesPoppedOverall); emit FinalizeBatch(_batchIndex, _batchHash, _postStateRoot, _withdrawRoot); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; interface IL1MessageQueue { /********** * Events * **********/ /// @notice Emitted when a new L1 => L2 transaction is appended to the queue. /// @param sender The address of account who initiates the transaction. /// @param target The address of account who will receive the transaction. /// @param value The value passed with the transaction. /// @param queueIndex The index of this transaction in the queue. /// @param gasLimit Gas limit required to complete the message relay on L2. /// @param data The calldata of the transaction. event QueueTransaction( address indexed sender, address indexed target, uint256 value, uint64 queueIndex, uint256 gasLimit, bytes data ); /// @notice Emitted when some L1 => L2 transactions are included in L1. /// @param startIndex The start index of messages popped. /// @param count The number of messages popped. /// @param skippedBitmap A bitmap indicates whether a message is skipped. event DequeueTransaction(uint256 startIndex, uint256 count, uint256 skippedBitmap); /// @notice Emitted when dequeued transactions are reset. /// @param startIndex The start index of messages. event ResetDequeuedTransaction(uint256 startIndex); /// @notice Emitted when some L1 => L2 transactions are finalized in L1. /// @param finalizedIndex The last index of messages finalized. event FinalizedDequeuedTransaction(uint256 finalizedIndex); /// @notice Emitted when a message is dropped from L1. /// @param index The index of message dropped. event DropTransaction(uint256 index); /// @notice Emitted when owner updates gas oracle contract. /// @param _oldGasOracle The address of old gas oracle contract. /// @param _newGasOracle The address of new gas oracle contract. event UpdateGasOracle(address indexed _oldGasOracle, address indexed _newGasOracle); /// @notice Emitted when owner updates max gas limit. /// @param _oldMaxGasLimit The old max gas limit. /// @param _newMaxGasLimit The new max gas limit. event UpdateMaxGasLimit(uint256 _oldMaxGasLimit, uint256 _newMaxGasLimit); /********** * Errors * **********/ /// @dev Thrown when the given address is `address(0)`. error ErrorZeroAddress(); /************************* * Public View Functions * *************************/ /// @notice The start index of all pending inclusion messages. function pendingQueueIndex() external view returns (uint256); /// @notice The start index of all unfinalized messages. /// @dev All messages from `nextUnfinalizedQueueIndex` to `pendingQueueIndex-1` are committed but not finalized. function nextUnfinalizedQueueIndex() external view returns (uint256); /// @notice Return the index of next appended message. /// @dev Also the total number of appended messages. function nextCrossDomainMessageIndex() external view returns (uint256); /// @notice Return the message of in `queueIndex`. /// @param queueIndex The index to query. function getCrossDomainMessage(uint256 queueIndex) external view returns (bytes32); /// @notice Return the amount of ETH should pay for cross domain message. /// @param gasLimit Gas limit required to complete the message relay on L2. function estimateCrossDomainMessageFee(uint256 gasLimit) external view returns (uint256); /// @notice Return the amount of intrinsic gas fee should pay for cross domain message. /// @param _calldata The calldata of L1-initiated transaction. function calculateIntrinsicGasFee(bytes calldata _calldata) external view returns (uint256); /// @notice Return the hash of a L1 message. /// @param sender The address of sender. /// @param queueIndex The queue index of this message. /// @param value The amount of Ether transfer to target. /// @param target The address of target. /// @param gasLimit The gas limit provided. /// @param data The calldata passed to target address. function computeTransactionHash( address sender, uint256 queueIndex, uint256 value, address target, uint256 gasLimit, bytes calldata data ) external view returns (bytes32); /// @notice Return whether the message is skipped. /// @param queueIndex The queue index of the message to check. function isMessageSkipped(uint256 queueIndex) external view returns (bool); /// @notice Return whether the message is dropped. /// @param queueIndex The queue index of the message to check. function isMessageDropped(uint256 queueIndex) external view returns (bool); /***************************** * Public Mutating Functions * *****************************/ /// @notice Append a L1 to L2 message into this contract. /// @param target The address of target contract to call in L2. /// @param gasLimit The maximum gas should be used for relay this message in L2. /// @param data The calldata passed to target contract. function appendCrossDomainMessage( address target, uint256 gasLimit, bytes calldata data ) external; /// @notice Append an enforced transaction to this contract. /// @dev The address of sender should be an EOA. /// @param sender The address of sender who will initiate this transaction in L2. /// @param target The address of target contract to call in L2. /// @param value The value passed /// @param gasLimit The maximum gas should be used for this transaction in L2. /// @param data The calldata passed to target contract. function appendEnforcedTransaction( address sender, address target, uint256 value, uint256 gasLimit, bytes calldata data ) external; /// @notice Pop messages from queue. /// /// @dev We can pop at most 256 messages each time. And if the message is not skipped, /// the corresponding entry will be cleared. /// /// @param startIndex The start index to pop. /// @param count The number of messages to pop. /// @param skippedBitmap A bitmap indicates whether a message is skipped. function popCrossDomainMessage( uint256 startIndex, uint256 count, uint256 skippedBitmap ) external; /// @notice Reset status of popped messages. /// /// @dev We can only reset unfinalized popped messages. /// /// @param startIndex The start index to reset. function resetPoppedCrossDomainMessage(uint256 startIndex) external; /// @notice Finalize status of popped messages. /// @param newFinalizedQueueIndexPlusOne The index of message to finalize plus one. function finalizePoppedCrossDomainMessage(uint256 newFinalizedQueueIndexPlusOne) external; /// @notice Drop a skipped message from the queue. function dropCrossDomainMessage(uint256 index) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; /// @title IScrollChain /// @notice The interface for ScrollChain. interface IScrollChain { /********** * Events * **********/ /// @notice Emitted when a new batch is committed. /// @param batchIndex The index of the batch. /// @param batchHash The hash of the batch. event CommitBatch(uint256 indexed batchIndex, bytes32 indexed batchHash); /// @notice revert a pending batch. /// @param batchIndex The index of the batch. /// @param batchHash The hash of the batch event RevertBatch(uint256 indexed batchIndex, bytes32 indexed batchHash); /// @notice Emitted when a batch is finalized. /// @param batchIndex The index of the batch. /// @param batchHash The hash of the batch /// @param stateRoot The state root on layer 2 after this batch. /// @param withdrawRoot The merkle root on layer2 after this batch. event FinalizeBatch(uint256 indexed batchIndex, bytes32 indexed batchHash, bytes32 stateRoot, bytes32 withdrawRoot); /// @notice Emitted when owner updates the status of sequencer. /// @param account The address of account updated. /// @param status The status of the account updated. event UpdateSequencer(address indexed account, bool status); /// @notice Emitted when owner updates the status of prover. /// @param account The address of account updated. /// @param status The status of the account updated. event UpdateProver(address indexed account, bool status); /// @notice Emitted when the value of `maxNumTxInChunk` is updated. /// @param oldMaxNumTxInChunk The old value of `maxNumTxInChunk`. /// @param newMaxNumTxInChunk The new value of `maxNumTxInChunk`. event UpdateMaxNumTxInChunk(uint256 oldMaxNumTxInChunk, uint256 newMaxNumTxInChunk); /************************* * Public View Functions * *************************/ /// @return The latest finalized batch index. function lastFinalizedBatchIndex() external view returns (uint256); /// @param batchIndex The index of the batch. /// @return The batch hash of a committed batch. function committedBatches(uint256 batchIndex) external view returns (bytes32); /// @param batchIndex The index of the batch. /// @return The state root of a committed batch. function finalizedStateRoots(uint256 batchIndex) external view returns (bytes32); /// @param batchIndex The index of the batch. /// @return The message root of a committed batch. function withdrawRoots(uint256 batchIndex) external view returns (bytes32); /// @param batchIndex The index of the batch. /// @return Whether the batch is finalized by batch index. function isBatchFinalized(uint256 batchIndex) external view returns (bool); /***************************** * Public Mutating Functions * *****************************/ /// @notice Commit a batch of transactions on layer 1. /// /// @param version The version of current batch. /// @param parentBatchHeader The header of parent batch, see the comments of `BatchHeaderV0Codec`. /// @param chunks The list of encoded chunks, see the comments of `ChunkCodec`. /// @param skippedL1MessageBitmap The bitmap indicates whether each L1 message is skipped or not. function commitBatch( uint8 version, bytes calldata parentBatchHeader, bytes[] memory chunks, bytes calldata skippedL1MessageBitmap ) external; /// @notice Commit a batch of transactions on layer 1 with blob data proof. /// /// @dev Memory layout of `blobDataProof`: /// | z | y | kzg_commitment | kzg_proof | /// |---------|---------|----------------|-----------| /// | bytes32 | bytes32 | bytes48 | bytes48 | /// /// @param version The version of current batch. /// @param parentBatchHeader The header of parent batch, see the comments of `BatchHeaderV0Codec`. /// @param chunks The list of encoded chunks, see the comments of `ChunkCodec`. /// @param skippedL1MessageBitmap The bitmap indicates whether each L1 message is skipped or not. /// @param blobDataProof The proof for blob data. function commitBatchWithBlobProof( uint8 version, bytes calldata parentBatchHeader, bytes[] memory chunks, bytes calldata skippedL1MessageBitmap, bytes calldata blobDataProof ) external; /// @notice Revert pending batches. /// @dev one can only revert unfinalized batches. /// @param firstBatchHeader The header of first batch to revert, see the encoding in comments of `commitBatch`. /// @param lastBatchHeader The header of last batch to revert, see the encoding in comments of `commitBatch`. function revertBatch(bytes calldata firstBatchHeader, bytes calldata lastBatchHeader) external; /// @notice Finalize a committed batch (with blob) on layer 1. /// /// @dev Memory layout of `blobDataProof`: /// | z | y | kzg_commitment | kzg_proof | /// |---------|---------|----------------|-----------| /// | bytes32 | bytes32 | bytes48 | bytes48 | /// /// @param batchHeader The header of current batch, see the encoding in comments of `commitBatch. /// @param prevStateRoot The state root of parent batch. /// @param postStateRoot The state root of current batch. /// @param withdrawRoot The withdraw trie root of current batch. /// @param blobDataProof The proof for blob data. /// @param aggrProof The aggregation proof for current batch. function finalizeBatchWithProof4844( bytes calldata batchHeader, bytes32 prevStateRoot, bytes32 postStateRoot, bytes32 withdrawRoot, bytes calldata blobDataProof, bytes calldata aggrProof ) external; /// @notice Finalize a list of committed batches (i.e. bundle) on layer 1. /// @param batchHeader The header of last batch in current bundle, see the encoding in comments of `commitBatch. /// @param postStateRoot The state root after current bundle. /// @param withdrawRoot The withdraw trie root after current batch. /// @param aggrProof The aggregation proof for current bundle. function finalizeBundleWithProof( bytes calldata batchHeader, bytes32 postStateRoot, bytes32 withdrawRoot, bytes calldata aggrProof ) external; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.24; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import {IL1MessageQueue} from "./IL1MessageQueue.sol"; import {IScrollChain} from "./IScrollChain.sol"; import {BatchHeaderV0Codec} from "../../libraries/codec/BatchHeaderV0Codec.sol"; import {BatchHeaderV1Codec} from "../../libraries/codec/BatchHeaderV1Codec.sol"; import {BatchHeaderV3Codec} from "../../libraries/codec/BatchHeaderV3Codec.sol"; import {ChunkCodecV0} from "../../libraries/codec/ChunkCodecV0.sol"; import {ChunkCodecV1} from "../../libraries/codec/ChunkCodecV1.sol"; import {IRollupVerifier} from "../../libraries/verifier/IRollupVerifier.sol"; // solhint-disable no-inline-assembly // solhint-disable reason-string /// @title ScrollChain /// @notice This contract maintains data for the Scroll rollup. contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain { /********** * Errors * **********/ /// @dev Thrown when the given account is not EOA account. error ErrorAccountIsNotEOA(); /// @dev Thrown when committing a committed batch. error ErrorBatchIsAlreadyCommitted(); /// @dev Thrown when finalizing a verified batch. error ErrorBatchIsAlreadyVerified(); /// @dev Thrown when committing empty batch (batch without chunks) error ErrorBatchIsEmpty(); /// @dev Thrown when call precompile failed. error ErrorCallPointEvaluationPrecompileFailed(); /// @dev Thrown when the caller is not prover. error ErrorCallerIsNotProver(); /// @dev Thrown when the caller is not sequencer. error ErrorCallerIsNotSequencer(); /// @dev Thrown when the transaction has multiple blobs. error ErrorFoundMultipleBlobs(); /// @dev Thrown when some fields are not zero in genesis batch. error ErrorGenesisBatchHasNonZeroField(); /// @dev Thrown when importing genesis batch twice. error ErrorGenesisBatchImported(); /// @dev Thrown when data hash in genesis batch is zero. error ErrorGenesisDataHashIsZero(); /// @dev Thrown when the parent batch hash in genesis batch is zero. error ErrorGenesisParentBatchHashIsNonZero(); /// @dev Thrown when the l2 transaction is incomplete. error ErrorIncompleteL2TransactionData(); /// @dev Thrown when the batch hash is incorrect. error ErrorIncorrectBatchHash(); /// @dev Thrown when the batch index is incorrect. error ErrorIncorrectBatchIndex(); /// @dev Thrown when the batch version is incorrect. error ErrorIncorrectBatchVersion(); /// @dev Thrown when the bitmap length is incorrect. error ErrorIncorrectBitmapLength(); /// @dev Thrown when the last message is skipped. error ErrorLastL1MessageSkipped(); /// @dev Thrown when no blob found in the transaction. error ErrorNoBlobFound(); /// @dev Thrown when the number of transactions is less than number of L1 message in one block. error ErrorNumTxsLessThanNumL1Msgs(); /// @dev Thrown when the number of batches to revert is zero. error ErrorRevertZeroBatches(); /// @dev Thrown when the reverted batches are not in the ending of committed batch chain. error ErrorRevertNotStartFromEnd(); /// @dev Thrown when reverting a finalized batch. error ErrorRevertFinalizedBatch(); /// @dev Thrown when the given state root is zero. error ErrorStateRootIsZero(); /// @dev Thrown when a chunk contains too many transactions. error ErrorTooManyTxsInOneChunk(); /// @dev Thrown when the precompile output is incorrect. error ErrorUnexpectedPointEvaluationPrecompileOutput(); /// @dev Thrown when the given address is `address(0)`. error ErrorZeroAddress(); /************* * Constants * *************/ /// @dev Address of the point evaluation precompile used for EIP-4844 blob verification. address internal constant POINT_EVALUATION_PRECOMPILE_ADDR = address(0x0A); /// @dev BLS Modulus value defined in EIP-4844 and the magic value returned from a successful call to the /// point evaluation precompile uint256 internal constant BLS_MODULUS = 52435875175126190479447740508185965837690552500527637822603658699938581184513; /// @notice The chain id of the corresponding layer 2 chain. uint64 public immutable layer2ChainId; /// @notice The address of L1MessageQueue contract. address public immutable messageQueue; /// @notice The address of RollupVerifier. address public immutable verifier; /************* * Variables * *************/ /// @notice The maximum number of transactions allowed in each chunk. uint256 public maxNumTxInChunk; /// @dev The storage slot used as L1MessageQueue contract, which is deprecated now. address private __messageQueue; /// @dev The storage slot used as RollupVerifier contract, which is deprecated now. address private __verifier; /// @notice Whether an account is a sequencer. mapping(address => bool) public isSequencer; /// @notice Whether an account is a prover. mapping(address => bool) public isProver; /// @inheritdoc IScrollChain uint256 public override lastFinalizedBatchIndex; /// @inheritdoc IScrollChain mapping(uint256 => bytes32) public override committedBatches; /// @inheritdoc IScrollChain mapping(uint256 => bytes32) public override finalizedStateRoots; /// @inheritdoc IScrollChain mapping(uint256 => bytes32) public override withdrawRoots; /********************** * Function Modifiers * **********************/ modifier OnlySequencer() { // @note In the decentralized mode, it should be only called by a list of validator. if (!isSequencer[_msgSender()]) revert ErrorCallerIsNotSequencer(); _; } modifier OnlyProver() { if (!isProver[_msgSender()]) revert ErrorCallerIsNotProver(); _; } /*************** * Constructor * ***************/ /// @notice Constructor for `ScrollChain` implementation contract. /// /// @param _chainId The chain id of L2. /// @param _messageQueue The address of `L1MessageQueue` contract. /// @param _verifier The address of zkevm verifier contract. constructor( uint64 _chainId, address _messageQueue, address _verifier ) { if (_messageQueue == address(0) || _verifier == address(0)) { revert ErrorZeroAddress(); } _disableInitializers(); layer2ChainId = _chainId; messageQueue = _messageQueue; verifier = _verifier; } /// @notice Initialize the storage of ScrollChain. /// /// @dev The parameters `_messageQueue` are no longer used. /// /// @param _messageQueue The address of `L1MessageQueue` contract. /// @param _verifier The address of zkevm verifier contract. /// @param _maxNumTxInChunk The maximum number of transactions allowed in each chunk. function initialize( address _messageQueue, address _verifier, uint256 _maxNumTxInChunk ) public initializer { OwnableUpgradeable.__Ownable_init(); maxNumTxInChunk = _maxNumTxInChunk; __verifier = _verifier; __messageQueue = _messageQueue; emit UpdateMaxNumTxInChunk(0, _maxNumTxInChunk); } /************************* * Public View Functions * *************************/ /// @inheritdoc IScrollChain function isBatchFinalized(uint256 _batchIndex) external view override returns (bool) { return _batchIndex <= lastFinalizedBatchIndex; } /***************************** * Public Mutating Functions * *****************************/ /// @notice Import layer 2 genesis block /// @param _batchHeader The header of the genesis batch. /// @param _stateRoot The state root of the genesis block. function importGenesisBatch(bytes calldata _batchHeader, bytes32 _stateRoot) external { // check genesis batch header length if (_stateRoot == bytes32(0)) revert ErrorStateRootIsZero(); // check whether the genesis batch is imported if (finalizedStateRoots[0] != bytes32(0)) revert ErrorGenesisBatchImported(); (uint256 memPtr, bytes32 _batchHash, , ) = _loadBatchHeader(_batchHeader); // check all fields except `dataHash` and `lastBlockHash` are zero unchecked { uint256 sum = BatchHeaderV0Codec.getVersion(memPtr) + BatchHeaderV0Codec.getBatchIndex(memPtr) + BatchHeaderV0Codec.getL1MessagePopped(memPtr) + BatchHeaderV0Codec.getTotalL1MessagePopped(memPtr); if (sum != 0) revert ErrorGenesisBatchHasNonZeroField(); } if (BatchHeaderV0Codec.getDataHash(memPtr) == bytes32(0)) revert ErrorGenesisDataHashIsZero(); if (BatchHeaderV0Codec.getParentBatchHash(memPtr) != bytes32(0)) revert ErrorGenesisParentBatchHashIsNonZero(); committedBatches[0] = _batchHash; finalizedStateRoots[0] = _stateRoot; emit CommitBatch(0, _batchHash); emit FinalizeBatch(0, _batchHash, _stateRoot, bytes32(0)); } /// @inheritdoc IScrollChain function commitBatch( uint8 _version, bytes calldata _parentBatchHeader, bytes[] memory _chunks, bytes calldata _skippedL1MessageBitmap ) external override OnlySequencer whenNotPaused { (bytes32 _parentBatchHash, uint256 _batchIndex, uint256 _totalL1MessagesPoppedOverall) = _beforeCommitBatch( _parentBatchHeader, _chunks ); bytes32 _batchHash; uint256 batchPtr; bytes32 _dataHash; uint256 _totalL1MessagesPoppedInBatch; if (1 <= _version && _version <= 2) { // versions 1 and 2 both use ChunkCodecV1 and BatchHeaderV1Codec, // but they use different blob encoding and different verifiers. (_dataHash, _totalL1MessagesPoppedInBatch) = _commitChunksV1( _totalL1MessagesPoppedOverall, _chunks, _skippedL1MessageBitmap ); assembly { batchPtr := mload(0x40) _totalL1MessagesPoppedOverall := add(_totalL1MessagesPoppedOverall, _totalL1MessagesPoppedInBatch) } // store entries, the order matters // Some are using `BatchHeaderV0Codec`, see comments of `BatchHeaderV1Codec`. BatchHeaderV0Codec.storeVersion(batchPtr, _version); BatchHeaderV0Codec.storeBatchIndex(batchPtr, _batchIndex); BatchHeaderV0Codec.storeL1MessagePopped(batchPtr, _totalL1MessagesPoppedInBatch); BatchHeaderV0Codec.storeTotalL1MessagePopped(batchPtr, _totalL1MessagesPoppedOverall); BatchHeaderV0Codec.storeDataHash(batchPtr, _dataHash); BatchHeaderV1Codec.storeBlobVersionedHash(batchPtr, _getBlobVersionedHash()); BatchHeaderV1Codec.storeParentBatchHash(batchPtr, _parentBatchHash); BatchHeaderV1Codec.storeSkippedBitmap(batchPtr, _skippedL1MessageBitmap); // compute batch hash, V1 and V2 has same code as V0 _batchHash = BatchHeaderV0Codec.computeBatchHash( batchPtr, BatchHeaderV1Codec.BATCH_HEADER_FIXED_LENGTH + _skippedL1MessageBitmap.length ); } else { // we don't allow v0 and other versions revert ErrorIncorrectBatchVersion(); } // verify skippedL1MessageBitmap _checkSkippedL1MessageBitmap( _totalL1MessagesPoppedOverall, _totalL1MessagesPoppedInBatch, _skippedL1MessageBitmap, false ); _afterCommitBatch(_batchIndex, _batchHash); } /// @inheritdoc IScrollChain /// /// @dev This function will revert unless all V0/V1/V2 batches are finalized. This is because we start to /// pop L1 messages in `commitBatchWithBlobProof` but not in `commitBatch`. We also introduce `finalizedQueueIndex` /// in `L1MessageQueue`. If one of V0/V1/V2 batches not finalized, `L1MessageQueue.pendingQueueIndex` will not /// match `parentBatchHeader.totalL1MessagePopped` and thus revert. function commitBatchWithBlobProof( uint8 _version, bytes calldata _parentBatchHeader, bytes[] memory _chunks, bytes calldata _skippedL1MessageBitmap, bytes calldata _blobDataProof ) external override OnlySequencer whenNotPaused { if (_version <= 2) { revert ErrorIncorrectBatchVersion(); } // allocate memory of batch header and store entries if necessary, the order matters // @note why store entries if necessary, to avoid stack overflow problem. // The codes for `version`, `batchIndex`, `l1MessagePopped`, `totalL1MessagePopped` and `dataHash` // are the same as `BatchHeaderV0Codec`. // The codes for `blobVersionedHash`, and `parentBatchHash` are the same as `BatchHeaderV1Codec`. uint256 batchPtr; assembly { batchPtr := mload(0x40) // This is `BatchHeaderV3Codec.BATCH_HEADER_FIXED_LENGTH`, use `193` here to reduce code // complexity. Be careful that the length may changed in future versions. mstore(0x40, add(batchPtr, 193)) } BatchHeaderV0Codec.storeVersion(batchPtr, _version); (bytes32 _parentBatchHash, uint256 _batchIndex, uint256 _totalL1MessagesPoppedOverall) = _beforeCommitBatch( _parentBatchHeader, _chunks ); BatchHeaderV0Codec.storeBatchIndex(batchPtr, _batchIndex); // versions 2 and 3 both use ChunkCodecV1 (bytes32 _dataHash, uint256 _totalL1MessagesPoppedInBatch) = _commitChunksV1( _totalL1MessagesPoppedOverall, _chunks, _skippedL1MessageBitmap ); unchecked { _totalL1MessagesPoppedOverall += _totalL1MessagesPoppedInBatch; } // verify skippedL1MessageBitmap _checkSkippedL1MessageBitmap( _totalL1MessagesPoppedOverall, _totalL1MessagesPoppedInBatch, _skippedL1MessageBitmap, true ); BatchHeaderV0Codec.storeL1MessagePopped(batchPtr, _totalL1MessagesPoppedInBatch); BatchHeaderV0Codec.storeTotalL1MessagePopped(batchPtr, _totalL1MessagesPoppedOverall); BatchHeaderV0Codec.storeDataHash(batchPtr, _dataHash); // verify blob versioned hash bytes32 _blobVersionedHash = _getBlobVersionedHash(); _checkBlobVersionedHash(_blobVersionedHash, _blobDataProof); BatchHeaderV1Codec.storeBlobVersionedHash(batchPtr, _blobVersionedHash); BatchHeaderV1Codec.storeParentBatchHash(batchPtr, _parentBatchHash); uint256 lastBlockTimestamp; { bytes memory lastChunk = _chunks[_chunks.length - 1]; lastBlockTimestamp = ChunkCodecV1.getLastBlockTimestamp(lastChunk); } BatchHeaderV3Codec.storeLastBlockTimestamp(batchPtr, lastBlockTimestamp); BatchHeaderV3Codec.storeBlobDataProof(batchPtr, _blobDataProof); // compute batch hash, V3 has same code as V0 bytes32 _batchHash = BatchHeaderV0Codec.computeBatchHash( batchPtr, BatchHeaderV3Codec.BATCH_HEADER_FIXED_LENGTH ); _afterCommitBatch(_batchIndex, _batchHash); } /// @inheritdoc IScrollChain /// @dev If the owner want to revert a sequence of batches by sending multiple transactions, /// make sure to revert recent batches first. function revertBatch(bytes calldata _firstBatchHeader, bytes calldata _lastBatchHeader) external onlyOwner { ( uint256 firstBatchPtr, , uint256 _firstBatchIndex, uint256 _totalL1MessagesPoppedOverallFirstBatch ) = _loadBatchHeader(_firstBatchHeader); (, , uint256 _lastBatchIndex, ) = _loadBatchHeader(_lastBatchHeader); if (_firstBatchIndex > _lastBatchIndex) revert ErrorRevertZeroBatches(); // make sure no gap is left when reverting from the ending to the beginning. if (committedBatches[_lastBatchIndex + 1] != bytes32(0)) revert ErrorRevertNotStartFromEnd(); // check finalization if (_firstBatchIndex <= lastFinalizedBatchIndex) revert ErrorRevertFinalizedBatch(); // actual revert for (uint256 _batchIndex = _lastBatchIndex; _batchIndex >= _firstBatchIndex; --_batchIndex) { bytes32 _batchHash = committedBatches[_batchIndex]; committedBatches[_batchIndex] = bytes32(0); emit RevertBatch(_batchIndex, _batchHash); } // `getL1MessagePopped` codes are the same in V0, V1, V2, V3 uint256 l1MessagePoppedFirstBatch = BatchHeaderV0Codec.getL1MessagePopped(firstBatchPtr); unchecked { IL1MessageQueue(messageQueue).resetPoppedCrossDomainMessage( _totalL1MessagesPoppedOverallFirstBatch - l1MessagePoppedFirstBatch ); } } /* This function will never be used since we already upgrade to 4844. We comment out the codes for reference. /// @inheritdoc IScrollChain function finalizeBatchWithProof( bytes calldata _batchHeader, bytes32 _prevStateRoot, bytes32 _postStateRoot, bytes32 _withdrawRoot, bytes calldata _aggrProof ) external override OnlyProver whenNotPaused { (uint256 batchPtr, bytes32 _batchHash, uint256 _batchIndex) = _beforeFinalizeBatch( _batchHeader, _postStateRoot ); // compute public input hash bytes32 _publicInputHash; { bytes32 _dataHash = BatchHeaderV0Codec.getDataHash(batchPtr); bytes32 _prevStateRoot = finalizedStateRoots[_batchIndex - 1]; _publicInputHash = keccak256( abi.encodePacked(layer2ChainId, _prevStateRoot, _postStateRoot, _withdrawRoot, _dataHash) ); } // verify batch IRollupVerifier(verifier).verifyAggregateProof(0, _batchIndex, _aggrProof, _publicInputHash); // Pop finalized and non-skipped message from L1MessageQueue. uint256 _totalL1MessagesPoppedOverall = BatchHeaderV0Codec.getTotalL1MessagePopped(batchPtr); _popL1MessagesMemory( BatchHeaderV0Codec.getSkippedBitmapPtr(batchPtr), _totalL1MessagesPoppedOverall, BatchHeaderV0Codec.getL1MessagePopped(batchPtr) ); _afterFinalizeBatch(_totalL1MessagesPoppedOverall, _batchIndex, _batchHash, _postStateRoot, _withdrawRoot); } */ /// @inheritdoc IScrollChain /// @dev Memory layout of `_blobDataProof`: /// ```text /// | z | y | kzg_commitment | kzg_proof | /// |---------|---------|----------------|-----------| /// | bytes32 | bytes32 | bytes48 | bytes48 | /// ``` function finalizeBatchWithProof4844( bytes calldata _batchHeader, bytes32, /*_prevStateRoot*/ bytes32 _postStateRoot, bytes32 _withdrawRoot, bytes calldata _blobDataProof, bytes calldata _aggrProof ) external override OnlyProver whenNotPaused { (uint256 batchPtr, bytes32 _batchHash, uint256 _batchIndex) = _beforeFinalizeBatch( _batchHeader, _postStateRoot ); // compute public input hash bytes32 _publicInputHash; { bytes32 _dataHash = BatchHeaderV0Codec.getDataHash(batchPtr); bytes32 _blobVersionedHash = BatchHeaderV1Codec.getBlobVersionedHash(batchPtr); bytes32 _prevStateRoot = finalizedStateRoots[_batchIndex - 1]; // verify blob versioned hash _checkBlobVersionedHash(_blobVersionedHash, _blobDataProof); _publicInputHash = keccak256( abi.encodePacked( layer2ChainId, _prevStateRoot, _postStateRoot, _withdrawRoot, _dataHash, _blobDataProof[0:64], _blobVersionedHash ) ); } // load version from batch header, it is always the first byte. uint256 batchVersion = BatchHeaderV0Codec.getVersion(batchPtr); // verify batch IRollupVerifier(verifier).verifyAggregateProof(batchVersion, _batchIndex, _aggrProof, _publicInputHash); // Pop finalized and non-skipped message from L1MessageQueue. uint256 _totalL1MessagesPoppedOverall = BatchHeaderV0Codec.getTotalL1MessagePopped(batchPtr); _popL1MessagesMemory( BatchHeaderV1Codec.getSkippedBitmapPtr(batchPtr), _totalL1MessagesPoppedOverall, BatchHeaderV0Codec.getL1MessagePopped(batchPtr) ); _afterFinalizeBatch(_totalL1MessagesPoppedOverall, _batchIndex, _batchHash, _postStateRoot, _withdrawRoot); } /// @inheritdoc IScrollChain function finalizeBundleWithProof( bytes calldata _batchHeader, bytes32 _postStateRoot, bytes32 _withdrawRoot, bytes calldata _aggrProof ) external override OnlyProver whenNotPaused { if (_postStateRoot == bytes32(0)) revert ErrorStateRootIsZero(); // compute pending batch hash and verify ( uint256 batchPtr, bytes32 _batchHash, uint256 _batchIndex, uint256 _totalL1MessagesPoppedOverall ) = _loadBatchHeader(_batchHeader); // retrieve finalized state root and batch hash from storage to construct the public input uint256 _finalizedBatchIndex = lastFinalizedBatchIndex; if (_batchIndex <= _finalizedBatchIndex) revert ErrorBatchIsAlreadyVerified(); bytes memory _publicInput = abi.encodePacked( layer2ChainId, uint32(_batchIndex - _finalizedBatchIndex), // numBatches finalizedStateRoots[_finalizedBatchIndex], // _prevStateRoot committedBatches[_finalizedBatchIndex], // _prevBatchHash _postStateRoot, _batchHash, _withdrawRoot ); // load version from batch header, it is always the first byte. uint256 batchVersion = BatchHeaderV0Codec.getVersion(batchPtr); // verify bundle, choose the correct verifier based on the last batch // our off-chain service will make sure all unfinalized batches have the same batch version. IRollupVerifier(verifier).verifyBundleProof(batchVersion, _batchIndex, _aggrProof, _publicInput); // store in state // @note we do not store intermediate finalized roots lastFinalizedBatchIndex = _batchIndex; finalizedStateRoots[_batchIndex] = _postStateRoot; withdrawRoots[_batchIndex] = _withdrawRoot; // Pop finalized and non-skipped message from L1MessageQueue. _finalizePoppedL1Messages(_totalL1MessagesPoppedOverall); emit FinalizeBatch(_batchIndex, _batchHash, _postStateRoot, _withdrawRoot); } /************************ * Restricted Functions * ************************/ /// @notice Add an account to the sequencer list. /// @param _account The address of account to add. function addSequencer(address _account) external onlyOwner { // @note Currently many external services rely on EOA sequencer to decode metadata directly from tx.calldata. // So we explicitly make sure the account is EOA. if (_account.code.length > 0) revert ErrorAccountIsNotEOA(); isSequencer[_account] = true; emit UpdateSequencer(_account, true); } /// @notice Remove an account from the sequencer list. /// @param _account The address of account to remove. function removeSequencer(address _account) external onlyOwner { isSequencer[_account] = false; emit UpdateSequencer(_account, false); } /// @notice Add an account to the prover list. /// @param _account The address of account to add. function addProver(address _account) external onlyOwner { // @note Currently many external services rely on EOA prover to decode metadata directly from tx.calldata. // So we explicitly make sure the account is EOA. if (_account.code.length > 0) revert ErrorAccountIsNotEOA(); isProver[_account] = true; emit UpdateProver(_account, true); } /// @notice Add an account from the prover list. /// @param _account The address of account to remove. function removeProver(address _account) external onlyOwner { isProver[_account] = false; emit UpdateProver(_account, false); } /// @notice Update the value of `maxNumTxInChunk`. /// @param _maxNumTxInChunk The new value of `maxNumTxInChunk`. function updateMaxNumTxInChunk(uint256 _maxNumTxInChunk) external onlyOwner { uint256 _oldMaxNumTxInChunk = maxNumTxInChunk; maxNumTxInChunk = _maxNumTxInChunk; emit UpdateMaxNumTxInChunk(_oldMaxNumTxInChunk, _maxNumTxInChunk); } /// @notice Pause the contract /// @param _status The pause status to update. function setPause(bool _status) external onlyOwner { if (_status) { _pause(); } else { _unpause(); } } /********************** * Internal Functions * **********************/ /// @dev Internal function to do common checks before actual batch committing. /// @param _parentBatchHeader The parent batch header in calldata. /// @param _chunks The list of chunks in memory. /// @return _parentBatchHash The batch hash of parent batch header. /// @return _batchIndex The index of current batch. /// @return _totalL1MessagesPoppedOverall The total number of L1 messages popped before current batch. function _beforeCommitBatch(bytes calldata _parentBatchHeader, bytes[] memory _chunks) private view returns ( bytes32 _parentBatchHash, uint256 _batchIndex, uint256 _totalL1MessagesPoppedOverall ) { // check whether the batch is empty if (_chunks.length == 0) revert ErrorBatchIsEmpty(); (, _parentBatchHash, _batchIndex, _totalL1MessagesPoppedOverall) = _loadBatchHeader(_parentBatchHeader); unchecked { _batchIndex += 1; } if (committedBatches[_batchIndex] != 0) revert ErrorBatchIsAlreadyCommitted(); } /// @dev Internal function to do common checks after actual batch committing. /// @param _batchIndex The index of current batch. /// @param _batchHash The hash of current batch. function _afterCommitBatch(uint256 _batchIndex, bytes32 _batchHash) private { committedBatches[_batchIndex] = _batchHash; emit CommitBatch(_batchIndex, _batchHash); } /// @dev Internal function to do common checks before actual batch finalization. /// @param _batchHeader The current batch header in calldata. /// @param _postStateRoot The state root after current batch. /// @return batchPtr The start memory offset of current batch in memory. /// @return _batchHash The hash of current batch. /// @return _batchIndex The index of current batch. function _beforeFinalizeBatch(bytes calldata _batchHeader, bytes32 _postStateRoot) internal view returns ( uint256 batchPtr, bytes32 _batchHash, uint256 _batchIndex ) { if (_postStateRoot == bytes32(0)) revert ErrorStateRootIsZero(); // compute batch hash and verify (batchPtr, _batchHash, _batchIndex, ) = _loadBatchHeader(_batchHeader); // avoid duplicated verification if (finalizedStateRoots[_batchIndex] != bytes32(0)) revert ErrorBatchIsAlreadyVerified(); } /// @dev Internal function to do common checks after actual batch finalization. /// @param _totalL1MessagesPoppedOverall The total number of L1 messages popped after current batch. /// @param _batchIndex The index of current batch. /// @param _batchHash The hash of current batch. /// @param _postStateRoot The state root after current batch. /// @param _withdrawRoot The withdraw trie root after current batch. function _afterFinalizeBatch( uint256 _totalL1MessagesPoppedOverall, uint256 _batchIndex, bytes32 _batchHash, bytes32 _postStateRoot, bytes32 _withdrawRoot ) internal { // check and update lastFinalizedBatchIndex unchecked { if (lastFinalizedBatchIndex + 1 != _batchIndex) revert ErrorIncorrectBatchIndex(); lastFinalizedBatchIndex = _batchIndex; } // record state root and withdraw root finalizedStateRoots[_batchIndex] = _postStateRoot; withdrawRoots[_batchIndex] = _withdrawRoot; // Pop finalized and non-skipped message from L1MessageQueue. _finalizePoppedL1Messages(_totalL1MessagesPoppedOverall); emit FinalizeBatch(_batchIndex, _batchHash, _postStateRoot, _withdrawRoot); } /// @dev Internal function to check blob versioned hash. /// @param _blobVersionedHash The blob versioned hash to check. /// @param _blobDataProof The blob data proof used to verify the blob versioned hash. function _checkBlobVersionedHash(bytes32 _blobVersionedHash, bytes calldata _blobDataProof) internal view { // Calls the point evaluation precompile and verifies the output (bool success, bytes memory data) = POINT_EVALUATION_PRECOMPILE_ADDR.staticcall( abi.encodePacked(_blobVersionedHash, _blobDataProof) ); // We verify that the point evaluation precompile call was successful by testing the latter 32 bytes of the // response is equal to BLS_MODULUS as defined in https://eips.ethereum.org/EIPS/eip-4844#point-evaluation-precompile if (!success) revert ErrorCallPointEvaluationPrecompileFailed(); (, uint256 result) = abi.decode(data, (uint256, uint256)); if (result != BLS_MODULUS) revert ErrorUnexpectedPointEvaluationPrecompileOutput(); } /// @dev Internal function to check the `SkippedL1MessageBitmap`. /// @param _totalL1MessagesPoppedOverall The total number of L1 messages popped after current batch. /// @param _totalL1MessagesPoppedInBatch The total number of L1 messages popped in current batch. /// @param _skippedL1MessageBitmap The skipped L1 message bitmap in calldata. /// @param _doPopMessage Whether we actually pop the messages from message queue. function _checkSkippedL1MessageBitmap( uint256 _totalL1MessagesPoppedOverall, uint256 _totalL1MessagesPoppedInBatch, bytes calldata _skippedL1MessageBitmap, bool _doPopMessage ) private { // check the length of bitmap unchecked { if (((_totalL1MessagesPoppedInBatch + 255) / 256) * 32 != _skippedL1MessageBitmap.length) { revert ErrorIncorrectBitmapLength(); } } if (_doPopMessage) { _popL1MessagesCalldata( _skippedL1MessageBitmap, _totalL1MessagesPoppedOverall, _totalL1MessagesPoppedInBatch ); } } /// @dev Internal function to get the blob versioned hash. /// @return _blobVersionedHash The retrieved blob versioned hash. function _getBlobVersionedHash() internal virtual returns (bytes32 _blobVersionedHash) { bytes32 _secondBlob; // Get blob's versioned hash assembly { _blobVersionedHash := blobhash(0) _secondBlob := blobhash(1) } if (_blobVersionedHash == bytes32(0)) revert ErrorNoBlobFound(); if (_secondBlob != bytes32(0)) revert ErrorFoundMultipleBlobs(); } /// @dev Internal function to commit chunks with version 0 /// @param _totalL1MessagesPoppedOverall The number of L1 messages popped before the list of chunks. /// @param _chunks The list of chunks to commit. /// @param _skippedL1MessageBitmap The bitmap indicates whether each L1 message is skipped or not. /// @return _batchDataHash The computed data hash for the list of chunks. /// @return _totalL1MessagesPoppedInBatch The total number of L1 messages popped in this batch, including skipped one. function _commitChunksV0( uint256 _totalL1MessagesPoppedOverall, bytes[] memory _chunks, bytes calldata _skippedL1MessageBitmap ) internal view returns (bytes32 _batchDataHash, uint256 _totalL1MessagesPoppedInBatch) { uint256 _chunksLength = _chunks.length; // load `batchDataHashPtr` and reserve the memory region for chunk data hashes uint256 batchDataHashPtr; assembly { batchDataHashPtr := mload(0x40) mstore(0x40, add(batchDataHashPtr, mul(_chunksLength, 32))) } // compute the data hash for each chunk for (uint256 i = 0; i < _chunksLength; i++) { uint256 _totalNumL1MessagesInChunk; bytes32 _chunkDataHash; (_chunkDataHash, _totalNumL1MessagesInChunk) = _commitChunkV0( _chunks[i], _totalL1MessagesPoppedInBatch, _totalL1MessagesPoppedOverall, _skippedL1MessageBitmap ); unchecked { _totalL1MessagesPoppedInBatch += _totalNumL1MessagesInChunk; _totalL1MessagesPoppedOverall += _totalNumL1MessagesInChunk; } assembly { mstore(batchDataHashPtr, _chunkDataHash) batchDataHashPtr := add(batchDataHashPtr, 0x20) } } assembly { let dataLen := mul(_chunksLength, 0x20) _batchDataHash := keccak256(sub(batchDataHashPtr, dataLen), dataLen) } } /// @dev Internal function to commit chunks with version 1 /// @param _totalL1MessagesPoppedOverall The number of L1 messages popped before the list of chunks. /// @param _chunks The list of chunks to commit. /// @param _skippedL1MessageBitmap The bitmap indicates whether each L1 message is skipped or not. /// @return _batchDataHash The computed data hash for the list of chunks. /// @return _totalL1MessagesPoppedInBatch The total number of L1 messages popped in this batch, including skipped one. function _commitChunksV1( uint256 _totalL1MessagesPoppedOverall, bytes[] memory _chunks, bytes calldata _skippedL1MessageBitmap ) internal view returns (bytes32 _batchDataHash, uint256 _totalL1MessagesPoppedInBatch) { uint256 _chunksLength = _chunks.length; // load `batchDataHashPtr` and reserve the memory region for chunk data hashes uint256 batchDataHashPtr; assembly { batchDataHashPtr := mload(0x40) mstore(0x40, add(batchDataHashPtr, mul(_chunksLength, 32))) } // compute the data hash for each chunk for (uint256 i = 0; i < _chunksLength; i++) { uint256 _totalNumL1MessagesInChunk; bytes32 _chunkDataHash; (_chunkDataHash, _totalNumL1MessagesInChunk) = _commitChunkV1( _chunks[i], _totalL1MessagesPoppedInBatch, _totalL1MessagesPoppedOverall, _skippedL1MessageBitmap ); unchecked { _totalL1MessagesPoppedInBatch += _totalNumL1MessagesInChunk; _totalL1MessagesPoppedOverall += _totalNumL1MessagesInChunk; } assembly { mstore(batchDataHashPtr, _chunkDataHash) batchDataHashPtr := add(batchDataHashPtr, 0x20) } } // compute the data hash for current batch assembly { let dataLen := mul(_chunksLength, 0x20) _batchDataHash := keccak256(sub(batchDataHashPtr, dataLen), dataLen) } } /// @dev Internal function to load batch header from calldata to memory. /// @param _batchHeader The batch header in calldata. /// @return batchPtr The start memory offset of loaded batch header. /// @return _batchHash The hash of the loaded batch header. /// @return _batchIndex The index of this batch. /// @param _totalL1MessagesPoppedOverall The number of L1 messages popped after this batch. function _loadBatchHeader(bytes calldata _batchHeader) internal view virtual returns ( uint256 batchPtr, bytes32 _batchHash, uint256 _batchIndex, uint256 _totalL1MessagesPoppedOverall ) { // load version from batch header, it is always the first byte. uint256 version; assembly { version := shr(248, calldataload(_batchHeader.offset)) } uint256 _length; if (version == 0) { (batchPtr, _length) = BatchHeaderV0Codec.loadAndValidate(_batchHeader); } else if (version <= 2) { (batchPtr, _length) = BatchHeaderV1Codec.loadAndValidate(_batchHeader); } else if (version >= 3) { (batchPtr, _length) = BatchHeaderV3Codec.loadAndValidate(_batchHeader); } // the code for compute batch hash is the same for V0, V1, V2, V3 // also the `_batchIndex` and `_totalL1MessagesPoppedOverall`. _batchHash = BatchHeaderV0Codec.computeBatchHash(batchPtr, _length); _batchIndex = BatchHeaderV0Codec.getBatchIndex(batchPtr); _totalL1MessagesPoppedOverall = BatchHeaderV0Codec.getTotalL1MessagePopped(batchPtr); // only check when genesis is imported if (committedBatches[_batchIndex] != _batchHash && finalizedStateRoots[0] != bytes32(0)) { revert ErrorIncorrectBatchHash(); } } /// @dev Internal function to commit a chunk with version 0. /// @param _chunk The encoded chunk to commit. /// @param _totalL1MessagesPoppedInBatch The total number of L1 messages popped in the current batch before this chunk. /// @param _totalL1MessagesPoppedOverall The total number of L1 messages popped in all batches including the current batch, before this chunk. /// @param _skippedL1MessageBitmap The bitmap indicates whether each L1 message is skipped or not. /// @return _dataHash The computed data hash for this chunk. /// @return _totalNumL1MessagesInChunk The total number of L1 message popped in current chunk function _commitChunkV0( bytes memory _chunk, uint256 _totalL1MessagesPoppedInBatch, uint256 _totalL1MessagesPoppedOverall, bytes calldata _skippedL1MessageBitmap ) internal view returns (bytes32 _dataHash, uint256 _totalNumL1MessagesInChunk) { uint256 chunkPtr; uint256 startDataPtr; uint256 dataPtr; assembly { dataPtr := mload(0x40) startDataPtr := dataPtr chunkPtr := add(_chunk, 0x20) // skip chunkLength } uint256 _numBlocks = ChunkCodecV0.validateChunkLength(chunkPtr, _chunk.length); // concatenate block contexts, use scope to avoid stack too deep { uint256 _totalTransactionsInChunk; for (uint256 i = 0; i < _numBlocks; i++) { dataPtr = ChunkCodecV0.copyBlockContext(chunkPtr, dataPtr, i); uint256 blockPtr = chunkPtr + 1 + i * ChunkCodecV0.BLOCK_CONTEXT_LENGTH; uint256 _numTransactionsInBlock = ChunkCodecV0.getNumTransactions(blockPtr); unchecked { _totalTransactionsInChunk += _numTransactionsInBlock; } } assembly { mstore(0x40, add(dataPtr, mul(_totalTransactionsInChunk, 0x20))) // reserve memory for tx hashes } } // It is used to compute the actual number of transactions in chunk. uint256 txHashStartDataPtr = dataPtr; // concatenate tx hashes uint256 l2TxPtr = ChunkCodecV0.getL2TxPtr(chunkPtr, _numBlocks); chunkPtr += 1; while (_numBlocks > 0) { // concatenate l1 message hashes uint256 _numL1MessagesInBlock = ChunkCodecV0.getNumL1Messages(chunkPtr); dataPtr = _loadL1MessageHashes( dataPtr, _numL1MessagesInBlock, _totalL1MessagesPoppedInBatch, _totalL1MessagesPoppedOverall, _skippedL1MessageBitmap ); // concatenate l2 transaction hashes uint256 _numTransactionsInBlock = ChunkCodecV0.getNumTransactions(chunkPtr); if (_numTransactionsInBlock < _numL1MessagesInBlock) revert ErrorNumTxsLessThanNumL1Msgs(); for (uint256 j = _numL1MessagesInBlock; j < _numTransactionsInBlock; j++) { bytes32 txHash; (txHash, l2TxPtr) = ChunkCodecV0.loadL2TxHash(l2TxPtr); assembly { mstore(dataPtr, txHash) dataPtr := add(dataPtr, 0x20) } } unchecked { _totalNumL1MessagesInChunk += _numL1MessagesInBlock; _totalL1MessagesPoppedInBatch += _numL1MessagesInBlock; _totalL1MessagesPoppedOverall += _numL1MessagesInBlock; _numBlocks -= 1; chunkPtr += ChunkCodecV0.BLOCK_CONTEXT_LENGTH; } } // check the actual number of transactions in the chunk if ((dataPtr - txHashStartDataPtr) / 32 > maxNumTxInChunk) revert ErrorTooManyTxsInOneChunk(); assembly { chunkPtr := add(_chunk, 0x20) } // check chunk has correct length if (l2TxPtr - chunkPtr != _chunk.length) revert ErrorIncompleteL2TransactionData(); // compute data hash and store to memory assembly { _dataHash := keccak256(startDataPtr, sub(dataPtr, startDataPtr)) } } /// @dev Internal function to commit a chunk with version 1. /// @param _chunk The encoded chunk to commit. /// @param _totalL1MessagesPoppedInBatch The total number of L1 messages popped in current batch. /// @param _totalL1MessagesPoppedOverall The total number of L1 messages popped in all batches including current batch. /// @param _skippedL1MessageBitmap The bitmap indicates whether each L1 message is skipped or not. /// @return _dataHash The computed data hash for this chunk. /// @return _totalNumL1MessagesInChunk The total number of L1 message popped in current chunk function _commitChunkV1( bytes memory _chunk, uint256 _totalL1MessagesPoppedInBatch, uint256 _totalL1MessagesPoppedOverall, bytes calldata _skippedL1MessageBitmap ) internal view returns (bytes32 _dataHash, uint256 _totalNumL1MessagesInChunk) { uint256 chunkPtr; uint256 startDataPtr; uint256 dataPtr; assembly { dataPtr := mload(0x40) startDataPtr := dataPtr chunkPtr := add(_chunk, 0x20) // skip chunkLength } uint256 _numBlocks = ChunkCodecV1.validateChunkLength(chunkPtr, _chunk.length); // concatenate block contexts, use scope to avoid stack too deep for (uint256 i = 0; i < _numBlocks; i++) { dataPtr = ChunkCodecV1.copyBlockContext(chunkPtr, dataPtr, i); uint256 blockPtr = chunkPtr + 1 + i * ChunkCodecV1.BLOCK_CONTEXT_LENGTH; uint256 _numL1MessagesInBlock = ChunkCodecV1.getNumL1Messages(blockPtr); unchecked { _totalNumL1MessagesInChunk += _numL1MessagesInBlock; } } assembly { mstore(0x40, add(dataPtr, mul(_totalNumL1MessagesInChunk, 0x20))) // reserve memory for l1 message hashes chunkPtr := add(chunkPtr, 1) } // the number of actual transactions in one chunk: non-skipped l1 messages + l2 txs uint256 _totalTransactionsInChunk; // concatenate tx hashes while (_numBlocks > 0) { // concatenate l1 message hashes uint256 _numL1MessagesInBlock = ChunkCodecV1.getNumL1Messages(chunkPtr); uint256 startPtr = dataPtr; dataPtr = _loadL1MessageHashes( dataPtr, _numL1MessagesInBlock, _totalL1MessagesPoppedInBatch, _totalL1MessagesPoppedOverall, _skippedL1MessageBitmap ); uint256 _numTransactionsInBlock = ChunkCodecV1.getNumTransactions(chunkPtr); if (_numTransactionsInBlock < _numL1MessagesInBlock) revert ErrorNumTxsLessThanNumL1Msgs(); unchecked { _totalTransactionsInChunk += (dataPtr - startPtr) / 32; // number of non-skipped l1 messages _totalTransactionsInChunk += _numTransactionsInBlock - _numL1MessagesInBlock; // number of l2 txs _totalL1MessagesPoppedInBatch += _numL1MessagesInBlock; _totalL1MessagesPoppedOverall += _numL1MessagesInBlock; _numBlocks -= 1; chunkPtr += ChunkCodecV1.BLOCK_CONTEXT_LENGTH; } } // check the actual number of transactions in the chunk if (_totalTransactionsInChunk > maxNumTxInChunk) { revert ErrorTooManyTxsInOneChunk(); } // compute data hash and store to memory assembly { _dataHash := keccak256(startDataPtr, sub(dataPtr, startDataPtr)) } } /// @dev Internal function to load L1 message hashes from the message queue. /// @param _ptr The memory offset to store the transaction hash. /// @param _numL1Messages The number of L1 messages to load. /// @param _totalL1MessagesPoppedInBatch The total number of L1 messages popped in current batch. /// @param _totalL1MessagesPoppedOverall The total number of L1 messages popped in all batches including current batch. /// @param _skippedL1MessageBitmap The bitmap indicates whether each L1 message is skipped or not. /// @return uint256 The new memory offset after loading. function _loadL1MessageHashes( uint256 _ptr, uint256 _numL1Messages, uint256 _totalL1MessagesPoppedInBatch, uint256 _totalL1MessagesPoppedOverall, bytes calldata _skippedL1MessageBitmap ) internal view returns (uint256) { if (_numL1Messages == 0) return _ptr; IL1MessageQueue _messageQueue = IL1MessageQueue(messageQueue); unchecked { uint256 _bitmap; uint256 rem; for (uint256 i = 0; i < _numL1Messages; i++) { uint256 quo = _totalL1MessagesPoppedInBatch >> 8; rem = _totalL1MessagesPoppedInBatch & 0xff; // load bitmap every 256 bits if (i == 0 || rem == 0) { assembly { _bitmap := calldataload(add(_skippedL1MessageBitmap.offset, mul(0x20, quo))) } } if (((_bitmap >> rem) & 1) == 0) { // message not skipped bytes32 _hash = _messageQueue.getCrossDomainMessage(_totalL1MessagesPoppedOverall); assembly { mstore(_ptr, _hash) _ptr := add(_ptr, 0x20) } } _totalL1MessagesPoppedInBatch += 1; _totalL1MessagesPoppedOverall += 1; } // check last L1 message is not skipped, _totalL1MessagesPoppedInBatch must > 0 rem = (_totalL1MessagesPoppedInBatch - 1) & 0xff; if (((_bitmap >> rem) & 1) > 0) revert ErrorLastL1MessageSkipped(); } return _ptr; } /// @param totalL1MessagesPoppedOverall The total number of L1 messages popped in all batches including current batch. function _finalizePoppedL1Messages(uint256 totalL1MessagesPoppedOverall) internal { if (totalL1MessagesPoppedOverall > 0) { unchecked { IL1MessageQueue(messageQueue).finalizePoppedCrossDomainMessage(totalL1MessagesPoppedOverall); } } } /// @dev Internal function to pop l1 messages from `skippedL1MessageBitmap` in memory. /// @param bitmapPtr The memory offset of `skippedL1MessageBitmap` in memory. /// @param totalL1MessagesPoppedOverall The total number of L1 messages popped in all batches including current batch. /// @param totalL1MessagesPoppedInBatch The number of L1 messages popped in current batch. function _popL1MessagesMemory( uint256 bitmapPtr, uint256 totalL1MessagesPoppedOverall, uint256 totalL1MessagesPoppedInBatch ) internal { if (totalL1MessagesPoppedInBatch == 0) return; _popL1Messages(false, bitmapPtr, totalL1MessagesPoppedOverall, totalL1MessagesPoppedInBatch); } /// @dev Internal function to pop l1 messages from `skippedL1MessageBitmap` in calldata. /// @param skippedL1MessageBitmap The `skippedL1MessageBitmap` in calldata. /// @param totalL1MessagesPoppedOverall The total number of L1 messages popped in all batches including current batch. /// @param totalL1MessagesPoppedInBatch The number of L1 messages popped in current batch. function _popL1MessagesCalldata( bytes calldata skippedL1MessageBitmap, uint256 totalL1MessagesPoppedOverall, uint256 totalL1MessagesPoppedInBatch ) internal { if (totalL1MessagesPoppedInBatch == 0) return; uint256 bitmapPtr; assembly { bitmapPtr := skippedL1MessageBitmap.offset } _popL1Messages(true, bitmapPtr, totalL1MessagesPoppedOverall, totalL1MessagesPoppedInBatch); } /// @dev Internal function to pop l1 messages from `skippedL1MessageBitmap` in calldata or memory. /// @param isCalldata Whether the `skippedL1MessageBitmap` is in calldata or memory. /// @param bitmapPtr The offset of `skippedL1MessageBitmap` in calldata or memory. /// @param totalL1MessagesPoppedOverall The total number of L1 messages popped in all batches including current batch. /// @param totalL1MessagesPoppedInBatch The number of L1 messages popped in current batch. function _popL1Messages( bool isCalldata, uint256 bitmapPtr, uint256 totalL1MessagesPoppedOverall, uint256 totalL1MessagesPoppedInBatch ) internal { if (totalL1MessagesPoppedInBatch == 0) return; unchecked { uint256 startIndex = totalL1MessagesPoppedOverall - totalL1MessagesPoppedInBatch; uint256 bitmap; for (uint256 i = 0; i < totalL1MessagesPoppedInBatch; i += 256) { uint256 _count = 256; if (totalL1MessagesPoppedInBatch - i < _count) { _count = totalL1MessagesPoppedInBatch - i; } assembly { switch isCalldata case 1 { bitmap := calldataload(bitmapPtr) } default { bitmap := mload(bitmapPtr) } bitmapPtr := add(bitmapPtr, 0x20) } IL1MessageQueue(messageQueue).popCrossDomainMessage(startIndex, _count, bitmap); startIndex += 256; } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; // solhint-disable no-inline-assembly /// @dev Below is the encoding for `BatchHeader` V0, total 89 + ceil(l1MessagePopped / 256) * 32 bytes. /// ```text /// * Field Bytes Type Index Comments /// * version 1 uint8 0 The batch version /// * batchIndex 8 uint64 1 The index of the batch /// * l1MessagePopped 8 uint64 9 Number of L1 messages popped in the batch /// * totalL1MessagePopped 8 uint64 17 Number of total L1 messages popped after the batch /// * dataHash 32 bytes32 25 The data hash of the batch /// * parentBatchHash 32 bytes32 57 The parent batch hash /// * skippedL1MessageBitmap dynamic uint256[] 89 A bitmap to indicate which L1 messages are skipped in the batch /// ``` library BatchHeaderV0Codec { /// @dev Thrown when the length of batch header is smaller than 89 error ErrorBatchHeaderV0LengthTooSmall(); /// @dev Thrown when the length of skippedL1MessageBitmap is incorrect. error ErrorIncorrectBitmapLengthV0(); /// @dev The length of fixed parts of the batch header. uint256 internal constant BATCH_HEADER_FIXED_LENGTH = 89; /// @notice Load batch header in calldata to memory. /// @param _batchHeader The encoded batch header bytes in calldata. /// @return batchPtr The start memory offset of the batch header in memory. /// @return length The length in bytes of the batch header. function loadAndValidate(bytes calldata _batchHeader) internal pure returns (uint256 batchPtr, uint256 length) { length = _batchHeader.length; if (length < BATCH_HEADER_FIXED_LENGTH) revert ErrorBatchHeaderV0LengthTooSmall(); // copy batch header to memory. assembly { batchPtr := mload(0x40) calldatacopy(batchPtr, _batchHeader.offset, length) mstore(0x40, add(batchPtr, length)) } // check batch header length uint256 _l1MessagePopped = getL1MessagePopped(batchPtr); unchecked { if (length != BATCH_HEADER_FIXED_LENGTH + ((_l1MessagePopped + 255) / 256) * 32) { revert ErrorIncorrectBitmapLengthV0(); } } } /// @notice Get the version of the batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @return _version The version of the batch header. function getVersion(uint256 batchPtr) internal pure returns (uint256 _version) { assembly { _version := shr(248, mload(batchPtr)) } } /// @notice Get the batch index of the batch. /// @param batchPtr The start memory offset of the batch header in memory. /// @return _batchIndex The batch index of the batch. function getBatchIndex(uint256 batchPtr) internal pure returns (uint256 _batchIndex) { assembly { _batchIndex := shr(192, mload(add(batchPtr, 1))) } } /// @notice Get the number of L1 messages of the batch. /// @param batchPtr The start memory offset of the batch header in memory. /// @return _l1MessagePopped The number of L1 messages of the batch. function getL1MessagePopped(uint256 batchPtr) internal pure returns (uint256 _l1MessagePopped) { assembly { _l1MessagePopped := shr(192, mload(add(batchPtr, 9))) } } /// @notice Get the number of L1 messages popped before this batch. /// @param batchPtr The start memory offset of the batch header in memory. /// @return _totalL1MessagePopped The number of L1 messages popped before this batch. function getTotalL1MessagePopped(uint256 batchPtr) internal pure returns (uint256 _totalL1MessagePopped) { assembly { _totalL1MessagePopped := shr(192, mload(add(batchPtr, 17))) } } /// @notice Get the data hash of the batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @return _dataHash The data hash of the batch header. function getDataHash(uint256 batchPtr) internal pure returns (bytes32 _dataHash) { assembly { _dataHash := mload(add(batchPtr, 25)) } } /// @notice Get the parent batch hash of the batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @return _parentBatchHash The parent batch hash of the batch header. function getParentBatchHash(uint256 batchPtr) internal pure returns (bytes32 _parentBatchHash) { assembly { _parentBatchHash := mload(add(batchPtr, 57)) } } /// @notice Get the start memory offset for skipped L1 messages bitmap. /// @param batchPtr The start memory offset of the batch header in memory. /// @return _bitmapPtr the start memory offset for skipped L1 messages bitmap. function getSkippedBitmapPtr(uint256 batchPtr) internal pure returns (uint256 _bitmapPtr) { assembly { _bitmapPtr := add(batchPtr, BATCH_HEADER_FIXED_LENGTH) } } /// @notice Get the skipped L1 messages bitmap. /// @param batchPtr The start memory offset of the batch header in memory. /// @param index The index of bitmap to load. /// @return _bitmap The bitmap from bits `index * 256` to `index * 256 + 255`. function getSkippedBitmap(uint256 batchPtr, uint256 index) internal pure returns (uint256 _bitmap) { assembly { batchPtr := add(batchPtr, BATCH_HEADER_FIXED_LENGTH) _bitmap := mload(add(batchPtr, mul(index, 32))) } } /// @notice Store the version of batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _version The version of batch header. function storeVersion(uint256 batchPtr, uint256 _version) internal pure { assembly { mstore8(batchPtr, _version) } } /// @notice Store the batch index of batch header. /// @dev Because this function can overwrite the subsequent fields, it must be called before /// `storeL1MessagePopped`, `storeTotalL1MessagePopped`, and `storeDataHash`. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _batchIndex The batch index. function storeBatchIndex(uint256 batchPtr, uint256 _batchIndex) internal pure { assembly { mstore(add(batchPtr, 1), shl(192, _batchIndex)) } } /// @notice Store the number of L1 messages popped in current batch to batch header. /// @dev Because this function can overwrite the subsequent fields, it must be called before /// `storeTotalL1MessagePopped` and `storeDataHash`. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _l1MessagePopped The number of L1 messages popped in current batch. function storeL1MessagePopped(uint256 batchPtr, uint256 _l1MessagePopped) internal pure { assembly { mstore(add(batchPtr, 9), shl(192, _l1MessagePopped)) } } /// @notice Store the total number of L1 messages popped after current batch to batch header. /// @dev Because this function can overwrite the subsequent fields, it must be called before /// `storeDataHash`. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _totalL1MessagePopped The total number of L1 messages popped after current batch. function storeTotalL1MessagePopped(uint256 batchPtr, uint256 _totalL1MessagePopped) internal pure { assembly { mstore(add(batchPtr, 17), shl(192, _totalL1MessagePopped)) } } /// @notice Store the data hash of batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _dataHash The data hash. function storeDataHash(uint256 batchPtr, bytes32 _dataHash) internal pure { assembly { mstore(add(batchPtr, 25), _dataHash) } } /// @notice Store the parent batch hash of batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _parentBatchHash The parent batch hash. function storeParentBatchHash(uint256 batchPtr, bytes32 _parentBatchHash) internal pure { assembly { mstore(add(batchPtr, 57), _parentBatchHash) } } /// @notice Store the skipped L1 message bitmap of batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _skippedL1MessageBitmap The skipped L1 message bitmap. function storeSkippedBitmap(uint256 batchPtr, bytes calldata _skippedL1MessageBitmap) internal pure { assembly { calldatacopy( add(batchPtr, BATCH_HEADER_FIXED_LENGTH), _skippedL1MessageBitmap.offset, _skippedL1MessageBitmap.length ) } } /// @notice Compute the batch hash. /// @dev Caller should make sure that the encoded batch header is correct. /// /// @param batchPtr The start memory offset of the batch header in memory. /// @param length The length of the batch. /// @return _batchHash The hash of the corresponding batch. function computeBatchHash(uint256 batchPtr, uint256 length) internal pure returns (bytes32 _batchHash) { // in the current version, the hash is: keccak(BatchHeader without timestamp) assembly { _batchHash := keccak256(batchPtr, length) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {BatchHeaderV0Codec} from "./BatchHeaderV0Codec.sol"; // solhint-disable no-inline-assembly /// @dev Below is the encoding for `BatchHeader` V1, total 121 + ceil(l1MessagePopped / 256) * 32 bytes. /// ```text /// * Field Bytes Type Index Comments /// * version 1 uint8 0 The batch version /// * batchIndex 8 uint64 1 The index of the batch /// * l1MessagePopped 8 uint64 9 Number of L1 messages popped in the batch /// * totalL1MessagePopped 8 uint64 17 Number of total L1 messages popped after the batch /// * dataHash 32 bytes32 25 The data hash of the batch /// * blobVersionedHash 32 bytes32 57 The versioned hash of the blob with this batch’s data /// * parentBatchHash 32 bytes32 89 The parent batch hash /// * skippedL1MessageBitmap dynamic uint256[] 121 A bitmap to indicate which L1 messages are skipped in the batch /// ``` /// /// The codes for `version`, `batchIndex`, `l1MessagePopped`, `totalL1MessagePopped`, `dataHash` and `computeBatchHash` /// are the same as `BatchHeaderV0Codec`. However, we won't reuse the codes in this library since they are very simple. /// Reusing the codes will introduce extra code jump in solidity, which increase gas costs. library BatchHeaderV1Codec { /// @dev Thrown when the length of batch header is smaller than 121. error ErrorBatchHeaderV1LengthTooSmall(); /// @dev Thrown when the length of skippedL1MessageBitmap is incorrect. error ErrorIncorrectBitmapLengthV1(); /// @dev The length of fixed parts of the batch header. uint256 internal constant BATCH_HEADER_FIXED_LENGTH = 121; /// @notice Load batch header in calldata to memory. /// @param _batchHeader The encoded batch header bytes in calldata. /// @return batchPtr The start memory offset of the batch header in memory. /// @return length The length in bytes of the batch header. function loadAndValidate(bytes calldata _batchHeader) internal pure returns (uint256 batchPtr, uint256 length) { length = _batchHeader.length; if (length < BATCH_HEADER_FIXED_LENGTH) revert ErrorBatchHeaderV1LengthTooSmall(); // copy batch header to memory. assembly { batchPtr := mload(0x40) calldatacopy(batchPtr, _batchHeader.offset, length) mstore(0x40, add(batchPtr, length)) } // check batch header length uint256 _l1MessagePopped = BatchHeaderV0Codec.getL1MessagePopped(batchPtr); unchecked { if (length != BATCH_HEADER_FIXED_LENGTH + ((_l1MessagePopped + 255) / 256) * 32) revert ErrorIncorrectBitmapLengthV1(); } } /// @notice Get the blob versioned hash of the batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @return _blobVersionedHash The blob versioned hash of the batch header. function getBlobVersionedHash(uint256 batchPtr) internal pure returns (bytes32 _blobVersionedHash) { assembly { _blobVersionedHash := mload(add(batchPtr, 57)) } } /// @notice Get the parent batch hash of the batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @return _parentBatchHash The parent batch hash of the batch header. function getParentBatchHash(uint256 batchPtr) internal pure returns (bytes32 _parentBatchHash) { assembly { _parentBatchHash := mload(add(batchPtr, 89)) } } /// @notice Get the start memory offset for skipped L1 messages bitmap. /// @param batchPtr The start memory offset of the batch header in memory. /// @return _bitmapPtr the start memory offset for skipped L1 messages bitmap. function getSkippedBitmapPtr(uint256 batchPtr) internal pure returns (uint256 _bitmapPtr) { assembly { _bitmapPtr := add(batchPtr, BATCH_HEADER_FIXED_LENGTH) } } /// @notice Get the skipped L1 messages bitmap. /// @param batchPtr The start memory offset of the batch header in memory. /// @param index The index of bitmap to load. /// @return _bitmap The bitmap from bits `index * 256` to `index * 256 + 255`. function getSkippedBitmap(uint256 batchPtr, uint256 index) internal pure returns (uint256 _bitmap) { assembly { batchPtr := add(batchPtr, BATCH_HEADER_FIXED_LENGTH) _bitmap := mload(add(batchPtr, mul(index, 32))) } } /// @notice Store the parent batch hash of batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _blobVersionedHash The versioned hash of the blob with this batch’s data. function storeBlobVersionedHash(uint256 batchPtr, bytes32 _blobVersionedHash) internal pure { assembly { mstore(add(batchPtr, 57), _blobVersionedHash) } } /// @notice Store the parent batch hash of batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _parentBatchHash The parent batch hash. function storeParentBatchHash(uint256 batchPtr, bytes32 _parentBatchHash) internal pure { assembly { mstore(add(batchPtr, 89), _parentBatchHash) } } /// @notice Store the skipped L1 message bitmap of batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _skippedL1MessageBitmap The skipped L1 message bitmap. function storeSkippedBitmap(uint256 batchPtr, bytes calldata _skippedL1MessageBitmap) internal pure { assembly { calldatacopy( add(batchPtr, BATCH_HEADER_FIXED_LENGTH), _skippedL1MessageBitmap.offset, _skippedL1MessageBitmap.length ) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; // solhint-disable no-inline-assembly /// @dev Below is the encoding for `BatchHeader` V3, total 193 bytes. /// ```text /// * Field Bytes Type Index Comments /// * version 1 uint8 0 The batch version /// * batchIndex 8 uint64 1 The index of the batch /// * l1MessagePopped 8 uint64 9 Number of L1 messages popped in the batch /// * totalL1MessagePopped 8 uint64 17 Number of total L1 messages popped after the batch /// * dataHash 32 bytes32 25 The data hash of the batch /// * blobVersionedHash 32 bytes32 57 The versioned hash of the blob with this batch’s data /// * parentBatchHash 32 bytes32 89 The parent batch hash /// * lastBlockTimestamp 8 uint64 121 A bitmap to indicate which L1 messages are skipped in the batch /// * blobDataProof 64 bytes64 129 The blob data proof: z (32), y (32) /// ``` /// The codes for `version`, `batchIndex`, `l1MessagePopped`, `totalL1MessagePopped`, `dataHash` and `computeBatchHash` /// are the same as `BatchHeaderV0Codec`. The codes for `blobVersionedHash` and `parentBatchHash` are the same as /// `BatchHeaderV1Codec`. However, we won't reuse the codes since they are very simple. Reusing the codes will introduce /// extra code jump in solidity, which increase gas costs. library BatchHeaderV3Codec { /// @dev Thrown when the length of batch header is not equal to 193. error ErrorBatchHeaderV3LengthMismatch(); /// @dev The length of fixed parts of the batch header. uint256 internal constant BATCH_HEADER_FIXED_LENGTH = 193; /// @notice Load batch header in calldata to memory. /// @param _batchHeader The encoded batch header bytes in calldata. /// @return batchPtr The start memory offset of the batch header in memory. /// @return length The length in bytes of the batch header. function loadAndValidate(bytes calldata _batchHeader) internal pure returns (uint256 batchPtr, uint256 length) { length = _batchHeader.length; if (length != BATCH_HEADER_FIXED_LENGTH) { revert ErrorBatchHeaderV3LengthMismatch(); } // copy batch header to memory. assembly { batchPtr := mload(0x40) calldatacopy(batchPtr, _batchHeader.offset, length) mstore(0x40, add(batchPtr, length)) } } /// @notice Store the last block timestamp of batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @param _lastBlockTimestamp The timestamp of the last block in this batch. function storeLastBlockTimestamp(uint256 batchPtr, uint256 _lastBlockTimestamp) internal pure { assembly { mstore(add(batchPtr, 121), shl(192, _lastBlockTimestamp)) } } /// @notice Store the last block timestamp of batch header. /// @param batchPtr The start memory offset of the batch header in memory. /// @param blobDataProof The blob data proof: z (32), y (32) function storeBlobDataProof(uint256 batchPtr, bytes calldata blobDataProof) internal pure { assembly { // z and y is in the first 64 bytes of `blobDataProof` calldatacopy(add(batchPtr, 129), blobDataProof.offset, 64) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; /// @dev Below is the encoding for `Chunk`, total 60*n+1+m bytes. /// ```text /// * Field Bytes Type Index Comments /// * numBlocks 1 uint8 0 The number of blocks in this chunk /// * block[0] 60 BlockContext 1 The first block in this chunk /// * ...... /// * block[i] 60 BlockContext 60*i+1 The (i+1)'th block in this chunk /// * ...... /// * block[n-1] 60 BlockContext 60*n-59 The last block in this chunk /// * l2Transactions dynamic bytes 60*n+1 /// ``` /// /// @dev Below is the encoding for `BlockContext`, total 60 bytes. /// ```text /// * Field Bytes Type Index Comments /// * blockNumber 8 uint64 0 The height of this block. /// * timestamp 8 uint64 8 The timestamp of this block. /// * baseFee 32 uint256 16 The base fee of this block. /// * gasLimit 8 uint64 48 The gas limit of this block. /// * numTransactions 2 uint16 56 The number of transactions in this block, both L1 & L2 txs. /// * numL1Messages 2 uint16 58 The number of l1 messages in this block. /// ``` library ChunkCodecV0 { /// @dev Thrown when no blocks in chunk. error ErrorNoBlockInChunkV0(); /// @dev Thrown when the length of chunk is incorrect. error ErrorIncorrectChunkLengthV0(); /// @dev The length of one block context. uint256 internal constant BLOCK_CONTEXT_LENGTH = 60; /// @notice Validate the length of chunk. /// @param chunkPtr The start memory offset of the chunk in memory. /// @param _length The length of the chunk. /// @return _numBlocks The number of blocks in current chunk. function validateChunkLength(uint256 chunkPtr, uint256 _length) internal pure returns (uint256 _numBlocks) { _numBlocks = getNumBlocks(chunkPtr); // should contain at least one block if (_numBlocks == 0) revert ErrorNoBlockInChunkV0(); // should contain at least the number of the blocks and block contexts if (_length < 1 + _numBlocks * BLOCK_CONTEXT_LENGTH) revert ErrorIncorrectChunkLengthV0(); } /// @notice Return the start memory offset of `l2Transactions`. /// @dev The caller should make sure `_numBlocks` is correct. /// @param chunkPtr The start memory offset of the chunk in memory. /// @param _numBlocks The number of blocks in current chunk. /// @return _l2TxPtr the start memory offset of `l2Transactions`. function getL2TxPtr(uint256 chunkPtr, uint256 _numBlocks) internal pure returns (uint256 _l2TxPtr) { unchecked { _l2TxPtr = chunkPtr + 1 + _numBlocks * BLOCK_CONTEXT_LENGTH; } } /// @notice Return the number of blocks in current chunk. /// @param chunkPtr The start memory offset of the chunk in memory. /// @return _numBlocks The number of blocks in current chunk. function getNumBlocks(uint256 chunkPtr) internal pure returns (uint256 _numBlocks) { assembly { _numBlocks := shr(248, mload(chunkPtr)) } } /// @notice Copy the block context to another memory. /// @param chunkPtr The start memory offset of the chunk in memory. /// @param dstPtr The destination memory offset to store the block context. /// @param index The index of block context to copy. /// @return uint256 The new destination memory offset after copy. function copyBlockContext( uint256 chunkPtr, uint256 dstPtr, uint256 index ) internal pure returns (uint256) { // only first 58 bytes is needed. assembly { chunkPtr := add(chunkPtr, add(1, mul(BLOCK_CONTEXT_LENGTH, index))) mcopy(dstPtr, chunkPtr, 58) dstPtr := add(dstPtr, 58) } return dstPtr; } /// @notice Return the number of transactions in current block. /// @param blockPtr The start memory offset of the block context in memory. /// @return _numTransactions The number of transactions in current block. function getNumTransactions(uint256 blockPtr) internal pure returns (uint256 _numTransactions) { assembly { _numTransactions := shr(240, mload(add(blockPtr, 56))) } } /// @notice Return the number of L1 messages in current block. /// @param blockPtr The start memory offset of the block context in memory. /// @return _numL1Messages The number of L1 messages in current block. function getNumL1Messages(uint256 blockPtr) internal pure returns (uint256 _numL1Messages) { assembly { _numL1Messages := shr(240, mload(add(blockPtr, 58))) } } /// @notice Compute and load the transaction hash. /// @param _l2TxPtr The start memory offset of the transaction in memory. /// @return bytes32 The transaction hash of the transaction. /// @return uint256 The start memory offset of the next transaction in memory. function loadL2TxHash(uint256 _l2TxPtr) internal pure returns (bytes32, uint256) { bytes32 txHash; assembly { // first 4 bytes indicate the length let txPayloadLength := shr(224, mload(_l2TxPtr)) _l2TxPtr := add(_l2TxPtr, 4) txHash := keccak256(_l2TxPtr, txPayloadLength) _l2TxPtr := add(_l2TxPtr, txPayloadLength) } return (txHash, _l2TxPtr); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {ChunkCodecV0} from "./ChunkCodecV0.sol"; /// @dev Below is the encoding for `Chunk`, total 60*n+1 bytes. /// The only difference between `ChunkCodecV0` is we remove `l2Transactions` from chunk encoding. /// ```text /// * Field Bytes Type Index Comments /// * numBlocks 1 uint8 0 The number of blocks in this chunk /// * block[0] 60 BlockContext 1 The first block in this chunk /// * ...... /// * block[i] 60 BlockContext 60*i+1 The (i+1)'th block in this chunk /// * ...... /// * block[n-1] 60 BlockContext 60*n-59 The last block in this chunk /// ``` /// /// @dev Below is the encoding for `BlockContext`, total 60 bytes. /// ```text /// * Field Bytes Type Index Comments /// * blockNumber 8 uint64 0 The height of this block. /// * timestamp 8 uint64 8 The timestamp of this block. /// * baseFee 32 uint256 16 The base fee of this block. /// * gasLimit 8 uint64 48 The gas limit of this block. /// * numTransactions 2 uint16 56 The number of transactions in this block, both L1 & L2 txs. /// * numL1Messages 2 uint16 58 The number of l1 messages in this block. /// ``` library ChunkCodecV1 { /// @dev Thrown when no blocks in chunk. error ErrorNoBlockInChunkV1(); /// @dev Thrown when the length of chunk is incorrect. error ErrorIncorrectChunkLengthV1(); /// @dev The length of one block context. uint256 internal constant BLOCK_CONTEXT_LENGTH = 60; /// @notice Validate the length of chunk. /// @param chunkPtr The start memory offset of the chunk in memory. /// @param _length The length of the chunk. /// @return _numBlocks The number of blocks in current chunk. function validateChunkLength(uint256 chunkPtr, uint256 _length) internal pure returns (uint256 _numBlocks) { _numBlocks = getNumBlocks(chunkPtr); // should contain at least one block if (_numBlocks == 0) revert ErrorNoBlockInChunkV1(); // should contain the number of the blocks and block contexts if (_length != 1 + _numBlocks * BLOCK_CONTEXT_LENGTH) revert ErrorIncorrectChunkLengthV1(); } /// @notice Return the number of blocks in current chunk. /// @param chunkPtr The start memory offset of the chunk in memory. /// @return _numBlocks The number of blocks in current chunk. function getNumBlocks(uint256 chunkPtr) internal pure returns (uint256 _numBlocks) { return ChunkCodecV0.getNumBlocks(chunkPtr); } /// @notice Copy the block context to another memory. /// @param chunkPtr The start memory offset of the chunk in memory. /// @param dstPtr The destination memory offset to store the block context. /// @param index The index of block context to copy. /// @return uint256 The new destination memory offset after copy. function copyBlockContext( uint256 chunkPtr, uint256 dstPtr, uint256 index ) internal pure returns (uint256) { return ChunkCodecV0.copyBlockContext(chunkPtr, dstPtr, index); } /// @notice Return the number of transactions in current block. /// @param blockPtr The start memory offset of the block context in memory. /// @return _numTransactions The number of transactions in current block. function getNumTransactions(uint256 blockPtr) internal pure returns (uint256 _numTransactions) { return ChunkCodecV0.getNumTransactions(blockPtr); } /// @notice Return the number of L1 messages in current block. /// @param blockPtr The start memory offset of the block context in memory. /// @return _numL1Messages The number of L1 messages in current block. function getNumL1Messages(uint256 blockPtr) internal pure returns (uint256 _numL1Messages) { return ChunkCodecV0.getNumL1Messages(blockPtr); } /// @notice Return the block timestamp of last block in current chunk /// @param chunk Current chunk in memory. /// @return _timestamp The number of L1 messages in current block. function getLastBlockTimestamp(bytes memory chunk) internal pure returns (uint256 _timestamp) { assembly { let chunkPtr := add(chunk, 0x20) let numBlocks := shr(248, mload(chunkPtr)) // blockPtr is chunkPtr + 1 + (numBlocks - 1) * BLOCK_CONTEXT_LENGTH let blockPtr := sub(add(chunkPtr, mul(numBlocks, 60)), 59) _timestamp := shr(192, mload(add(blockPtr, 8))) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; /// @title IRollupVerifier /// @notice The interface for rollup verifier. interface IRollupVerifier { /// @notice Verify aggregate zk proof. /// @param batchIndex The batch index to verify. /// @param aggrProof The aggregated proof. /// @param publicInputHash The public input hash. function verifyAggregateProof( uint256 batchIndex, bytes calldata aggrProof, bytes32 publicInputHash ) external view; /// @notice Verify aggregate zk proof. /// @param version The version of verifier to use. /// @param batchIndex The batch index to verify. /// @param aggrProof The aggregated proof. /// @param publicInputHash The public input hash. function verifyAggregateProof( uint256 version, uint256 batchIndex, bytes calldata aggrProof, bytes32 publicInputHash ) external view; /// @notice Verify bundle zk proof. /// @param version The version of verifier to use. /// @param batchIndex The batch index used to select verifier. /// @param bundleProof The aggregated proof. /// @param publicInput The public input. function verifyBundleProof( uint256 version, uint256 batchIndex, bytes calldata bundleProof, bytes calldata publicInput ) external view; }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "cancun", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"uint64","name":"_chainId","type":"uint64"},{"internalType":"address","name":"_messageQueue","type":"address"},{"internalType":"address","name":"_verifier","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ErrorAccountIsNotEOA","type":"error"},{"inputs":[],"name":"ErrorBatchHeaderV0LengthTooSmall","type":"error"},{"inputs":[],"name":"ErrorBatchHeaderV1LengthTooSmall","type":"error"},{"inputs":[],"name":"ErrorBatchHeaderV3LengthMismatch","type":"error"},{"inputs":[],"name":"ErrorBatchIsAlreadyCommitted","type":"error"},{"inputs":[],"name":"ErrorBatchIsAlreadyVerified","type":"error"},{"inputs":[],"name":"ErrorBatchIsEmpty","type":"error"},{"inputs":[],"name":"ErrorCallPointEvaluationPrecompileFailed","type":"error"},{"inputs":[],"name":"ErrorCallerIsNotProver","type":"error"},{"inputs":[],"name":"ErrorCallerIsNotSequencer","type":"error"},{"inputs":[],"name":"ErrorFoundMultipleBlobs","type":"error"},{"inputs":[],"name":"ErrorGenesisBatchHasNonZeroField","type":"error"},{"inputs":[],"name":"ErrorGenesisBatchImported","type":"error"},{"inputs":[],"name":"ErrorGenesisDataHashIsZero","type":"error"},{"inputs":[],"name":"ErrorGenesisParentBatchHashIsNonZero","type":"error"},{"inputs":[],"name":"ErrorIncompleteL2TransactionData","type":"error"},{"inputs":[],"name":"ErrorIncorrectBatchHash","type":"error"},{"inputs":[],"name":"ErrorIncorrectBatchIndex","type":"error"},{"inputs":[],"name":"ErrorIncorrectBatchVersion","type":"error"},{"inputs":[],"name":"ErrorIncorrectBitmapLength","type":"error"},{"inputs":[],"name":"ErrorIncorrectBitmapLengthV0","type":"error"},{"inputs":[],"name":"ErrorIncorrectBitmapLengthV1","type":"error"},{"inputs":[],"name":"ErrorIncorrectChunkLengthV1","type":"error"},{"inputs":[],"name":"ErrorLastL1MessageSkipped","type":"error"},{"inputs":[],"name":"ErrorNoBlobFound","type":"error"},{"inputs":[],"name":"ErrorNoBlockInChunkV1","type":"error"},{"inputs":[],"name":"ErrorNumTxsLessThanNumL1Msgs","type":"error"},{"inputs":[],"name":"ErrorRevertFinalizedBatch","type":"error"},{"inputs":[],"name":"ErrorRevertNotStartFromEnd","type":"error"},{"inputs":[],"name":"ErrorRevertZeroBatches","type":"error"},{"inputs":[],"name":"ErrorStateRootIsZero","type":"error"},{"inputs":[],"name":"ErrorTooManyTxsInOneChunk","type":"error"},{"inputs":[],"name":"ErrorUnexpectedPointEvaluationPrecompileOutput","type":"error"},{"inputs":[],"name":"ErrorZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"batchIndex","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"batchHash","type":"bytes32"}],"name":"CommitBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"batchIndex","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"batchHash","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"stateRoot","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"withdrawRoot","type":"bytes32"}],"name":"FinalizeBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"batchIndex","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"batchHash","type":"bytes32"}],"name":"RevertBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMaxNumTxInChunk","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxNumTxInChunk","type":"uint256"}],"name":"UpdateMaxNumTxInChunk","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"UpdateProver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"UpdateSequencer","type":"event"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"addProver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"addSequencer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_version","type":"uint8"},{"internalType":"bytes","name":"_parentBatchHeader","type":"bytes"},{"internalType":"bytes[]","name":"_chunks","type":"bytes[]"},{"internalType":"bytes","name":"_skippedL1MessageBitmap","type":"bytes"}],"name":"commitBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_version","type":"uint8"},{"internalType":"bytes","name":"_parentBatchHeader","type":"bytes"},{"internalType":"bytes[]","name":"_chunks","type":"bytes[]"},{"internalType":"bytes","name":"_skippedL1MessageBitmap","type":"bytes"},{"internalType":"bytes","name":"_blobDataProof","type":"bytes"}],"name":"commitBatchWithBlobProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"committedBatches","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_batchHeader","type":"bytes"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes32","name":"_postStateRoot","type":"bytes32"},{"internalType":"bytes32","name":"_withdrawRoot","type":"bytes32"},{"internalType":"bytes","name":"_blobDataProof","type":"bytes"}],"name":"finalizeBatch4844","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_batchHeader","type":"bytes"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes32","name":"_postStateRoot","type":"bytes32"},{"internalType":"bytes32","name":"_withdrawRoot","type":"bytes32"},{"internalType":"bytes","name":"_blobDataProof","type":"bytes"},{"internalType":"bytes","name":"_aggrProof","type":"bytes"}],"name":"finalizeBatchWithProof4844","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_batchHeader","type":"bytes"},{"internalType":"bytes32","name":"_postStateRoot","type":"bytes32"},{"internalType":"bytes32","name":"_withdrawRoot","type":"bytes32"}],"name":"finalizeBundle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_batchHeader","type":"bytes"},{"internalType":"bytes32","name":"_postStateRoot","type":"bytes32"},{"internalType":"bytes32","name":"_withdrawRoot","type":"bytes32"},{"internalType":"bytes","name":"_aggrProof","type":"bytes"}],"name":"finalizeBundleWithProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"finalizedStateRoots","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_batchHeader","type":"bytes"},{"internalType":"bytes32","name":"_stateRoot","type":"bytes32"}],"name":"importGenesisBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_messageQueue","type":"address"},{"internalType":"address","name":"_verifier","type":"address"},{"internalType":"uint256","name":"_maxNumTxInChunk","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_batchIndex","type":"uint256"}],"name":"isBatchFinalized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isProver","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isSequencer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastFinalizedBatchIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"layer2ChainId","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxNumTxInChunk","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"messageQueue","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"removeProver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"removeSequencer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_firstBatchHeader","type":"bytes"},{"internalType":"bytes","name":"_lastBatchHeader","type":"bytes"}],"name":"revertBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_status","type":"bool"}],"name":"setPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxNumTxInChunk","type":"uint256"}],"name":"updateMaxNumTxInChunk","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"verifier","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"withdrawRoots","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60e060405234801562000010575f80fd5b5060405162002c1438038062002c14833981016040819052620000339162000181565b8282826001600160a01b03821615806200005457506001600160a01b038116155b15620000735760405163a7f9319d60e01b815260040160405180910390fd5b6200007d620000a7565b6001600160401b039092166080526001600160a01b0390811660a0521660c05250620001d4915050565b5f54610100900460ff1615620001135760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b5f5460ff9081161462000163575f805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b03811681146200017c575f80fd5b919050565b5f805f6060848603121562000194575f80fd5b83516001600160401b0381168114620001ab575f80fd5b9250620001bb6020850162000165565b9150620001cb6040850162000165565b90509250925092565b60805160a05160c0516129dd620002375f395f818161031b015281816105de0152610d4301525f818161035a01528181611038015281816119fa01528181611baf0152611fad01525f81816101ee0152818161054f0152610c7901526129dd5ff3fe608060405234801561000f575f80fd5b50600436106101d0575f3560e01c80635c975abb116100fe5780638a3362311161009e578063ea5f084f1161006e578063ea5f084f1461046d578063eb43a1331461048c578063ef6602ba1461049f578063f2fde38b146104a8575f80fd5b80638a336231146104235780638da5cb5b14610436578063b571d3dd14610447578063bedb86fb1461045a575f80fd5b80636d46e987116100d95780636d46e987146103d35780636df4e686146103f5578063715018a61461040857806386b053a914610410575f80fd5b80635c975abb146103a257806368485e47146103ad5780636989ca7c146103c0575f80fd5b80631d49e457116101745780632b7ac3f3116101445780632b7ac3f3146103165780633b70c18a146103555780633fdeecb21461037c5780634f099e3d1461038f575f80fd5b80631d49e457146102b25780631e228302146102c55780632362f03e146102d85780632571098d146102f7575f80fd5b80630a245924116101af5780630a24592414610244578063116a1f42146102765780631325aca01461028c5780631794bb3c1461029f575f80fd5b8062b0f4d7146101d457806303c7f4af146101e9578063059def611461022d575b5f80fd5b6101e76101e2366004612145565b6104bb565b005b6102107f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160401b0390911681526020015b60405180910390f35b610236609c5481565b604051908152602001610224565b61026661025236600461220f565b609b6020525f908152604090205460ff1681565b6040519015158152602001610224565b61026661028436600461222f565b609c54101590565b6101e761029a366004612385565b610691565b6101e76102ad366004612422565b6107c6565b6101e76102c036600461220f565b610947565b6101e76102d336600461222f565b6109d5565b6102366102e636600461222f565b609d6020525f908152604090205481565b61023661030536600461222f565b609e6020525f908152604090205481565b61033d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610224565b61033d7f000000000000000000000000000000000000000000000000000000000000000081565b6101e761038a36600461245b565b610a22565b6101e761039d3660046124a2565b610be6565b60655460ff16610266565b6101e76103bb3660046124ff565b610e10565b6101e76103ce36600461220f565b610eb6565b6102666103e136600461220f565b609a6020525f908152604090205460ff1681565b6101e7610403366004612584565b610f0c565b6101e7611093565b6101e761041e3660046125ea565b6110a6565b6101e761043136600461220f565b61121d565b6033546001600160a01b031661033d565b6101e761045536600461220f565b6112a4565b6101e76104683660046126af565b6112fa565b61023661047b36600461222f565b609f6020525f908152604090205481565b6101e761049a3660046126ce565b61131b565b61023660975481565b6101e76104b636600461220f565b611404565b335f908152609b602052604090205460ff166104ea57604051637b263b1760e01b815260040160405180910390fd5b6104f261147a565b5f805f6105008c8c8b6114c0565b9250925092505f80610513856019015190565b90505f610521866039015190565b90505f609e8161053260018861272e565b81526020019081526020015f2054905061054d828c8c611529565b7f0000000000000000000000000000000000000000000000000000000000000000818e8e868f8f5f9060409261058593929190612741565b8860405160200161059d989796959493929190612768565b6040516020818303038152906040528051906020012093505050505f6105c4855160f81c90565b604051630581350960e31b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632c09a8489061061b90849087908c908c9089906004016127d6565b5f6040518083038186803b158015610631575f80fd5b505afa158015610643573d5f803e3d5ffd5b505050505f610656866011015160c01c90565b9050610673607987018261066e896009015160c01c90565b611625565b6106808185878f8f611642565b505050505050505050505050505050565b335f908152609a602052604090205460ff166106c057604051631e6edd6f60e11b815260040160405180910390fd5b6106c861147a565b5f805f6106d68888886116b9565b9250925092505f805f808c60ff166001111580156106f8575060028d60ff1611155b1561078757610709858b8b8b611721565b60405196810196945090925090506107248360ff8f16611799565b60c086811b600185015281811b600985015285901b60118401526019830182905261075a836107516117a0565b60399190910152565b6059830187905261076c838a8a6117e6565b6107808361077b8a6079612807565b902090565b93506107a0565b60405163bacd96e960e01b815260040160405180910390fd5b6107ad85828b8b5f6117f2565b6107b78685611835565b50505050505050505050505050565b5f54610100900460ff16158080156107e457505f54600160ff909116105b806107fd5750303b1580156107fd57505f5460ff166001145b6108655760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b5f805460ff191660011790558015610886575f805461ff0019166101001790555b61088e611873565b6097829055609980546001600160a01b038581166001600160a01b0319928316179092556098805492871692909116919091179055604080515f8152602081018490527f6d0f49971e462a2f78a25906f145cb29cd5e7bd01ebf681ac8f58cb814e5877a910160405180910390a18015610941575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b61094f6118a1565b6001600160a01b0381163b1561097857604051632c0fc2e160e11b815260040160405180910390fd5b6001600160a01b0381165f818152609b6020908152604091829020805460ff1916600190811790915591519182527f967f99d5d403870e4356ff46556df3a6b6ba1f50146639aaedfb9f248eb8661e91015b60405180910390a250565b6109dd6118a1565b609780549082905560408051828152602081018490527f6d0f49971e462a2f78a25906f145cb29cd5e7bd01ebf681ac8f58cb814e5877a910160405180910390a15050565b80610a405760405163f9a9465f60e01b815260040160405180910390fd5b5f8052609e6020527fedae58bba15aea52a58242ef195db2cc4de2b75de265dbb0d58482df22a959785415610a885760405163c22a199f60e01b815260040160405180910390fd5b5f80610a9485856118fb565b5050915091505f610aa9836011015160c01c90565b600984015160c01c600185015160c01c855160f81c01010190508015610ae25760405163f4f38de560e01b815260040160405180910390fd5b505f610aef836019015190565b03610b0d576040516303d840a960e41b815260040160405180910390fd5b5f610b19836039015190565b14610b3757604051632781461960e11b815260040160405180910390fd5b5f8080527fc5dc36ae4e7617e4c4d23ddfcde33c79e9ed64c300aed766a9288a6b9b31f63d829055609e6020527fedae58bba15aea52a58242ef195db2cc4de2b75de265dbb0d58482df22a959788490556040518291907f2c32d4ae151744d0bf0b9464a3e897a1d17ed2f1af71f7c9a75f12ce0d28238f908290a3604080518481525f60208201819052839290915f8051602061298883398151915291015b60405180910390a35050505050565b335f908152609b602052604090205460ff16610c1557604051637b263b1760e01b815260040160405180910390fd5b610c1d61147a565b83610c3b5760405163f9a9465f60e01b815260040160405180910390fd5b5f805f80610c498a8a6118fb565b609c5493975091955093509150808311610c765760405163092d315560e41b815260040160405180910390fd5b5f7f0000000000000000000000000000000000000000000000000000000000000000610ca2838661272e565b5f848152609e6020908152604080832054609d83529281902054905160c09590951b6001600160c01b0319169185019190915260e09290921b6001600160e01b0319166028840152602c830152604c820152606c81018b9052608c810186905260ac81018a905260cc0160405160208183030381529060405290505f610d29875160f81c90565b6040516322a262c960e01b81529091506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906322a262c990610d8090849089908e908e90899060040161283c565b5f6040518083038186803b158015610d96575f80fd5b505afa158015610da8573d5f803e3d5ffd5b505050609c869055505f858152609e602090815260408083208e9055609f90915290208a9055610dd7846119de565b604080518c8152602081018c9052879187915f80516020612988833981519152910160405180910390a350505050505050505050505050565b335f908152609b602052604090205460ff16610e3f57604051637b263b1760e01b815260040160405180910390fd5b610e4761147a565b5f805f610e558a8a896114c0565b9250925092505f610e67846039015190565b9050610e74818787611529565b5f610e83856011015160c01c90565b9050610e9b607986018261066e886009015160c01c90565b610ea88184868c8c611642565b505050505050505050505050565b610ebe6118a1565b6001600160a01b0381165f818152609a60209081526040808320805460ff19169055519182527f631cb110fbe6a87fba5414d6b2cff02264480535cd1f5abdbc4fa638bc0b569291016109ca565b610f146118a1565b5f805f610f2187876118fb565b935093505092505f610f3386866118fb565b509250505080831115610f5957604051635453822b60e11b815260040160405180910390fd5b5f609d81610f68846001612807565b81526020019081526020015f205414610f9457604051633f707d7d60e21b815260040160405180910390fd5b609c548311610fb657604051632ad7756360e11b815260040160405180910390fd5b805b83811061100e575f818152609d602052604080822080549083905590519091829184917ecae2739091badfd91c373f0a16cede691e0cd25bb80cff77dd5caeb471014691a3506110078161288f565b9050610fb8565b505f61101e856009015160c01c90565b604051637a6e933360e01b815281850360048201529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637a6e9333906024015f604051808303815f87803b158015611081575f80fd5b505af11580156107b7573d5f803e3d5ffd5b61109b6118a1565b6110a45f611a55565b565b335f908152609a602052604090205460ff166110d557604051631e6edd6f60e11b815260040160405180910390fd5b6110dd61147a565b60028860ff16116111015760405163bacd96e960e01b815260040160405180910390fd5b6040805160c181019091526111198160ff8b16611799565b5f805f6111278b8b8b6116b9565b60c082901b6001880152919450925090505f80611146838c8c8c611721565b91509150808301925061115d83828c8c60016117f2565b60c081811b600988015283901b6011870152601986018290525f61117f6117a0565b905061118c818a8a611529565b60398701819052605987018690525f808d60018f516111ab919061272e565b815181106111bb576111bb6128a4565b6020908102919091018101519081015160f81c603c028101601219015190915060c01c60c081901b60798b015291506111f19050565b6111fc888b8b611aa6565b60c1882061120a8782611835565b5050505050505050505050505050505050565b6112256118a1565b6001600160a01b0381163b1561124e57604051632c0fc2e160e11b815260040160405180910390fd5b6001600160a01b0381165f818152609a6020908152604091829020805460ff1916600190811790915591519182527f631cb110fbe6a87fba5414d6b2cff02264480535cd1f5abdbc4fa638bc0b569291016109ca565b6112ac6118a1565b6001600160a01b0381165f818152609b60209081526040808320805460ff19169055519182527f967f99d5d403870e4356ff46556df3a6b6ba1f50146639aaedfb9f248eb8661e91016109ca565b6113026118a1565b801561131357611310611ab3565b50565b611310611b0d565b335f908152609b602052604090205460ff1661134a57604051637b263b1760e01b815260040160405180910390fd5b61135261147a565b816113705760405163f9a9465f60e01b815260040160405180910390fd5b5f805f61137d87876118fb565b93509350935050609c5482116113a65760405163092d315560e41b815260040160405180910390fd5b609c8290555f828152609e60209081526040808320889055609f90915290208490556113d1816119de565b6040805186815260208101869052849184915f80516020612988833981519152910160405180910390a350505050505050565b61140c6118a1565b6001600160a01b0381166114715760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161085c565b61131081611a55565b60655460ff16156110a45760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161085c565b5f8080836114e15760405163f9a9465f60e01b815260040160405180910390fd5b6114eb86866118fb565b505f818152609e60205260409020549295509093509150156115205760405163092d315560e41b815260040160405180910390fd5b93509350939050565b5f80600a6001600160a01b031685858560405160200161154b939291906128b8565b60408051601f1981840301815290829052611565916128d1565b5f60405180830381855afa9150503d805f811461159d576040519150601f19603f3d011682016040523d82523d5f602084013e6115a2565b606091505b5091509150816115c5576040516371ebedf560e01b815260040160405180910390fd5b5f818060200190518101906115da91906128ec565b9150507f73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001811461161d57604051638a89514360e01b815260040160405180910390fd5b505050505050565b805f0361163157505050565b61163d5f848484611b46565b505050565b83609c546001011461166757604051631d17cec760e21b815260040160405180910390fd5b609c8490555f848152609e60209081526040808320859055609f9091529020819055611692856119de565b6040805183815260208101839052849186915f805160206129888339815191529101610bd7565b5f805f83515f036116dd57604051632974c17360e21b815260040160405180910390fd5b6116e786866118fb565b60019091015f818152609d6020526040902054929650945092501590506115205760405163012137ab60e41b815260040160405180910390fd5b8251604080516020830281019091525f918291825b82811015611782575f806117668a8481518110611755576117556128a4565b6020026020010151878d8c8c611c2b565b9085529a8b019a95909501945050602090910190600101611736565b506020919091029081900320969095509350505050565b8082535050565b5f49600149816117c357604051630168f63160e21b815260040160405180910390fd5b80156117e257604051634c976a6160e11b815260040160405180910390fd5b5090565b80826079850137505050565b8161010060ff8601046020021461181c57604051630808452960e31b815260040160405180910390fd5b801561182e5761182e83838787611d63565b5050505050565b5f828152609d602052604080822083905551829184917f2c32d4ae151744d0bf0b9464a3e897a1d17ed2f1af71f7c9a75f12ce0d28238f9190a35050565b5f54610100900460ff166118995760405162461bcd60e51b815260040161085c9061290e565b6110a4611d77565b6033546001600160a01b031633146110a45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161085c565b5f808080853560f81c81818103611920576119168888611da6565b909650905061194a565b60028211611932576119168888611e1f565b6003821061194a576119448888611e90565b90965090505b808620945061195d866001015160c01c90565b935061196d866011015160c01c90565b5f858152609d602052604090205490935085148015906119b557505f8052609e6020527fedae58bba15aea52a58242ef195db2cc4de2b75de265dbb0d58482df22a959785415155b156119d35760405163150e0a2160e11b815260040160405180910390fd5b505092959194509250565b801561131057604051630e0143f560e21b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906338050fd4906024015f604051808303815f87803b158015611a43575f80fd5b505af115801561182e573d5f803e3d5ffd5b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6040826081850137505050565b611abb61147a565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611af03390565b6040516001600160a01b03909116815260200160405180910390a1565b611b15611ec9565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611af0565b8015610941578082035f805b83811015611c2257610100818503811115611b6c57508084035b8760018114611b7e5787519350611b83565b873593505b50604051632afb09e760e11b8152600481018590526024810182905260448101849052602097909701967f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906355f613ce906064015f604051808303815f87803b158015611bf8575f80fd5b505af1158015611c0a573d5f803e3d5ffd5b50505050610100840193505061010081019050611b52565b50505050505050565b60405185515f91829160208901919081908490611c49908590611f12565b90505f5b81811015611c9e57611c60858483611f79565b92505f611c6e603c83612959565b611c79876001612807565b611c839190612807565b90505f611c8f82611f8d565b97909701965050600101611c4d565b506020850282016040526001840193505f5b8115611d2b575f611cc086611f8d565b905083611cd181838f8f8f8f611f9c565b94505f611cdd886120cb565b905082811015611d0057604051638c5a4ea360e01b815260040160405180910390fd5b9c82019c9b82019b603c97909701965f19949094019360209186039190910492909201910301611cb0565b609754811115611d4e57604051634d56f17560e01b815260040160405180910390fd5b50508190039020989197509095505050505050565b8015610941578361182e6001828585611b46565b5f54610100900460ff16611d9d5760405162461bcd60e51b815260040161085c9061290e565b6110a433611a55565b5f816059811015611dca5760405163027f9c1f60e11b815260040160405180910390fd5b6040519150808483378082016040525f611de8836009015160c01c90565b905061010060ff8201046020026059018214611e175760405163c2110c9b60e01b815260040160405180910390fd5b509250929050565b5f816079811015611e435760405163a40ab48b60e01b815260040160405180910390fd5b6040519150808483378082016040525f611e61836009015160c01c90565b905061010060ff8201046020026079018214611e1757604051630c1c91df60e21b815260040160405180910390fd5b5f8160c18114611eb3576040516332496bf560e21b815260040160405180910390fd5b6040519150808483378082016040529250929050565b60655460ff166110a45760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161085c565b5f611f1c836120da565b9050805f03611f3e57604051634dbe8cff60e01b815260040160405180910390fd5b611f49603c82612959565b611f54906001612807565b8214611f7357604051634edcb40160e11b815260040160405180910390fd5b92915050565b5f611f858484846120e6565b949350505050565b5f611f7382603a015160f01c90565b5f855f03611fab5750856120c1565b7f00000000000000000000000000000000000000000000000000000000000000005f80805b8981101561208d5760ff89169150600889901c811580611fee575082155b15611ffd578060200288013593505b600184841c165f0361207c5760405163ae453cd560e01b8152600481018a90525f906001600160a01b0387169063ae453cd590602401602060405180830381865afa15801561204e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120729190612970565b8d52506020909b019a5b506001988901989788019701611fd0565b505060ff5f1988011681811c600116156120ba57604051632eba9e1160e21b815260040160405180910390fd5b5050879150505b9695505050505050565b5f611f73826038015160f01c90565b5f611f73825160f81c90565b5f81603c0260010184019350603a84845e5050603a01919050565b5f8083601f840112612111575f80fd5b5081356001600160401b03811115612127575f80fd5b60208301915083602082850101111561213e575f80fd5b9250929050565b5f805f805f805f805f60c08a8c03121561215d575f80fd5b89356001600160401b0380821115612173575f80fd5b61217f8d838e01612101565b909b50995060208c0135985060408c0135975060608c0135965060808c01359150808211156121ac575f80fd5b6121b88d838e01612101565b909650945060a08c01359150808211156121d0575f80fd5b506121dd8c828d01612101565b915080935050809150509295985092959850929598565b80356001600160a01b038116811461220a575f80fd5b919050565b5f6020828403121561221f575f80fd5b612228826121f4565b9392505050565b5f6020828403121561223f575f80fd5b5035919050565b803560ff8116811461220a575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b038111828210171561229257612292612256565b604052919050565b5f601f83601f8401126122ab575f80fd5b823560206001600160401b03808311156122c7576122c7612256565b8260051b6122d683820161226a565b93845286810183019383810190898611156122ef575f80fd5b84890192505b858310156123785782358481111561230b575f80fd5b8901603f81018b1361231b575f80fd5b8581013560408682111561233157612331612256565b612342828b01601f1916890161226a565b8281528d82848601011115612355575f80fd5b828285018a8301375f9281018901929092525083525091840191908401906122f5565b9998505050505050505050565b5f805f805f806080878903121561239a575f80fd5b6123a387612246565b955060208701356001600160401b03808211156123be575f80fd5b6123ca8a838b01612101565b909750955060408901359150808211156123e2575f80fd5b6123ee8a838b0161229a565b94506060890135915080821115612403575f80fd5b5061241089828a01612101565b979a9699509497509295939492505050565b5f805f60608486031215612434575f80fd5b61243d846121f4565b925061244b602085016121f4565b9150604084013590509250925092565b5f805f6040848603121561246d575f80fd5b83356001600160401b03811115612482575f80fd5b61248e86828701612101565b909790965060209590950135949350505050565b5f805f805f80608087890312156124b7575f80fd5b86356001600160401b03808211156124cd575f80fd5b6124d98a838b01612101565b909850965060208901359550604089013594506060890135915080821115612403575f80fd5b5f805f805f805f60a0888a031215612515575f80fd5b87356001600160401b038082111561252b575f80fd5b6125378b838c01612101565b909950975060208a0135965060408a0135955060608a0135945060808a0135915080821115612564575f80fd5b506125718a828b01612101565b989b979a50959850939692959293505050565b5f805f8060408587031215612597575f80fd5b84356001600160401b03808211156125ad575f80fd5b6125b988838901612101565b909650945060208701359150808211156125d1575f80fd5b506125de87828801612101565b95989497509550505050565b5f805f805f805f8060a0898b031215612601575f80fd5b61260a89612246565b975060208901356001600160401b0380821115612625575f80fd5b6126318c838d01612101565b909950975060408b0135915080821115612649575f80fd5b6126558c838d0161229a565b965060608b013591508082111561266a575f80fd5b6126768c838d01612101565b909650945060808b013591508082111561268e575f80fd5b5061269b8b828c01612101565b999c989b5096995094979396929594505050565b5f602082840312156126bf575f80fd5b81358015158114612228575f80fd5b5f805f80606085870312156126e1575f80fd5b84356001600160401b038111156126f6575f80fd5b61270287828801612101565b90989097506020870135966040013595509350505050565b634e487b7160e01b5f52601160045260245ffd5b81810381811115611f7357611f7361271a565b5f808585111561274f575f80fd5b8386111561275b575f80fd5b5050820193919092039150565b6001600160401b0360c01b8960c01b16815287600882015286602882015285604882015284606882015282846088830137608892019182015260a8019695505050505050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b858152846020820152608060408201525f6127f56080830185876127ae565b90508260608301529695505050505050565b80820180821115611f7357611f7361271a565b5f5b8381101561283457818101518382015260200161281c565b50505f910152565b858152846020820152608060408201525f61285b6080830185876127ae565b8281036060840152835180825261287981602084016020880161281a565b601f01601f191601602001979650505050505050565b5f8161289d5761289d61271a565b505f190190565b634e487b7160e01b5f52603260045260245ffd5b838152818360208301375f910160200190815292915050565b5f82516128e281846020870161281a565b9190910192915050565b5f80604083850312156128fd575f80fd5b505080516020909101519092909150565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b8082028115828204841417611f7357611f7361271a565b5f60208284031215612980575f80fd5b505191905056fe26ba82f907317eedc97d0cbef23de76a43dd6edb563bdb6e9407645b950a7a2da2646970667358221220f82c5a60d1fedf694a7853287db53587fde66cac82fd1bd823f6002640224fca64736f6c63430008180033000000000000000000000000000000000000000000000000000000000008274f000000000000000000000000f0b2293f5d834eae920c6974d50957a1732de7630000000000000000000000008a360c7f6fca548507017dded732bfe7e078f963
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106101d0575f3560e01c80635c975abb116100fe5780638a3362311161009e578063ea5f084f1161006e578063ea5f084f1461046d578063eb43a1331461048c578063ef6602ba1461049f578063f2fde38b146104a8575f80fd5b80638a336231146104235780638da5cb5b14610436578063b571d3dd14610447578063bedb86fb1461045a575f80fd5b80636d46e987116100d95780636d46e987146103d35780636df4e686146103f5578063715018a61461040857806386b053a914610410575f80fd5b80635c975abb146103a257806368485e47146103ad5780636989ca7c146103c0575f80fd5b80631d49e457116101745780632b7ac3f3116101445780632b7ac3f3146103165780633b70c18a146103555780633fdeecb21461037c5780634f099e3d1461038f575f80fd5b80631d49e457146102b25780631e228302146102c55780632362f03e146102d85780632571098d146102f7575f80fd5b80630a245924116101af5780630a24592414610244578063116a1f42146102765780631325aca01461028c5780631794bb3c1461029f575f80fd5b8062b0f4d7146101d457806303c7f4af146101e9578063059def611461022d575b5f80fd5b6101e76101e2366004612145565b6104bb565b005b6102107f000000000000000000000000000000000000000000000000000000000008274f81565b6040516001600160401b0390911681526020015b60405180910390f35b610236609c5481565b604051908152602001610224565b61026661025236600461220f565b609b6020525f908152604090205460ff1681565b6040519015158152602001610224565b61026661028436600461222f565b609c54101590565b6101e761029a366004612385565b610691565b6101e76102ad366004612422565b6107c6565b6101e76102c036600461220f565b610947565b6101e76102d336600461222f565b6109d5565b6102366102e636600461222f565b609d6020525f908152604090205481565b61023661030536600461222f565b609e6020525f908152604090205481565b61033d7f0000000000000000000000008a360c7f6fca548507017dded732bfe7e078f96381565b6040516001600160a01b039091168152602001610224565b61033d7f000000000000000000000000f0b2293f5d834eae920c6974d50957a1732de76381565b6101e761038a36600461245b565b610a22565b6101e761039d3660046124a2565b610be6565b60655460ff16610266565b6101e76103bb3660046124ff565b610e10565b6101e76103ce36600461220f565b610eb6565b6102666103e136600461220f565b609a6020525f908152604090205460ff1681565b6101e7610403366004612584565b610f0c565b6101e7611093565b6101e761041e3660046125ea565b6110a6565b6101e761043136600461220f565b61121d565b6033546001600160a01b031661033d565b6101e761045536600461220f565b6112a4565b6101e76104683660046126af565b6112fa565b61023661047b36600461222f565b609f6020525f908152604090205481565b6101e761049a3660046126ce565b61131b565b61023660975481565b6101e76104b636600461220f565b611404565b335f908152609b602052604090205460ff166104ea57604051637b263b1760e01b815260040160405180910390fd5b6104f261147a565b5f805f6105008c8c8b6114c0565b9250925092505f80610513856019015190565b90505f610521866039015190565b90505f609e8161053260018861272e565b81526020019081526020015f2054905061054d828c8c611529565b7f000000000000000000000000000000000000000000000000000000000008274f818e8e868f8f5f9060409261058593929190612741565b8860405160200161059d989796959493929190612768565b6040516020818303038152906040528051906020012093505050505f6105c4855160f81c90565b604051630581350960e31b81529091506001600160a01b037f0000000000000000000000008a360c7f6fca548507017dded732bfe7e078f9631690632c09a8489061061b90849087908c908c9089906004016127d6565b5f6040518083038186803b158015610631575f80fd5b505afa158015610643573d5f803e3d5ffd5b505050505f610656866011015160c01c90565b9050610673607987018261066e896009015160c01c90565b611625565b6106808185878f8f611642565b505050505050505050505050505050565b335f908152609a602052604090205460ff166106c057604051631e6edd6f60e11b815260040160405180910390fd5b6106c861147a565b5f805f6106d68888886116b9565b9250925092505f805f808c60ff166001111580156106f8575060028d60ff1611155b1561078757610709858b8b8b611721565b60405196810196945090925090506107248360ff8f16611799565b60c086811b600185015281811b600985015285901b60118401526019830182905261075a836107516117a0565b60399190910152565b6059830187905261076c838a8a6117e6565b6107808361077b8a6079612807565b902090565b93506107a0565b60405163bacd96e960e01b815260040160405180910390fd5b6107ad85828b8b5f6117f2565b6107b78685611835565b50505050505050505050505050565b5f54610100900460ff16158080156107e457505f54600160ff909116105b806107fd5750303b1580156107fd57505f5460ff166001145b6108655760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b5f805460ff191660011790558015610886575f805461ff0019166101001790555b61088e611873565b6097829055609980546001600160a01b038581166001600160a01b0319928316179092556098805492871692909116919091179055604080515f8152602081018490527f6d0f49971e462a2f78a25906f145cb29cd5e7bd01ebf681ac8f58cb814e5877a910160405180910390a18015610941575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b61094f6118a1565b6001600160a01b0381163b1561097857604051632c0fc2e160e11b815260040160405180910390fd5b6001600160a01b0381165f818152609b6020908152604091829020805460ff1916600190811790915591519182527f967f99d5d403870e4356ff46556df3a6b6ba1f50146639aaedfb9f248eb8661e91015b60405180910390a250565b6109dd6118a1565b609780549082905560408051828152602081018490527f6d0f49971e462a2f78a25906f145cb29cd5e7bd01ebf681ac8f58cb814e5877a910160405180910390a15050565b80610a405760405163f9a9465f60e01b815260040160405180910390fd5b5f8052609e6020527fedae58bba15aea52a58242ef195db2cc4de2b75de265dbb0d58482df22a959785415610a885760405163c22a199f60e01b815260040160405180910390fd5b5f80610a9485856118fb565b5050915091505f610aa9836011015160c01c90565b600984015160c01c600185015160c01c855160f81c01010190508015610ae25760405163f4f38de560e01b815260040160405180910390fd5b505f610aef836019015190565b03610b0d576040516303d840a960e41b815260040160405180910390fd5b5f610b19836039015190565b14610b3757604051632781461960e11b815260040160405180910390fd5b5f8080527fc5dc36ae4e7617e4c4d23ddfcde33c79e9ed64c300aed766a9288a6b9b31f63d829055609e6020527fedae58bba15aea52a58242ef195db2cc4de2b75de265dbb0d58482df22a959788490556040518291907f2c32d4ae151744d0bf0b9464a3e897a1d17ed2f1af71f7c9a75f12ce0d28238f908290a3604080518481525f60208201819052839290915f8051602061298883398151915291015b60405180910390a35050505050565b335f908152609b602052604090205460ff16610c1557604051637b263b1760e01b815260040160405180910390fd5b610c1d61147a565b83610c3b5760405163f9a9465f60e01b815260040160405180910390fd5b5f805f80610c498a8a6118fb565b609c5493975091955093509150808311610c765760405163092d315560e41b815260040160405180910390fd5b5f7f000000000000000000000000000000000000000000000000000000000008274f610ca2838661272e565b5f848152609e6020908152604080832054609d83529281902054905160c09590951b6001600160c01b0319169185019190915260e09290921b6001600160e01b0319166028840152602c830152604c820152606c81018b9052608c810186905260ac81018a905260cc0160405160208183030381529060405290505f610d29875160f81c90565b6040516322a262c960e01b81529091506001600160a01b037f0000000000000000000000008a360c7f6fca548507017dded732bfe7e078f96316906322a262c990610d8090849089908e908e90899060040161283c565b5f6040518083038186803b158015610d96575f80fd5b505afa158015610da8573d5f803e3d5ffd5b505050609c869055505f858152609e602090815260408083208e9055609f90915290208a9055610dd7846119de565b604080518c8152602081018c9052879187915f80516020612988833981519152910160405180910390a350505050505050505050505050565b335f908152609b602052604090205460ff16610e3f57604051637b263b1760e01b815260040160405180910390fd5b610e4761147a565b5f805f610e558a8a896114c0565b9250925092505f610e67846039015190565b9050610e74818787611529565b5f610e83856011015160c01c90565b9050610e9b607986018261066e886009015160c01c90565b610ea88184868c8c611642565b505050505050505050505050565b610ebe6118a1565b6001600160a01b0381165f818152609a60209081526040808320805460ff19169055519182527f631cb110fbe6a87fba5414d6b2cff02264480535cd1f5abdbc4fa638bc0b569291016109ca565b610f146118a1565b5f805f610f2187876118fb565b935093505092505f610f3386866118fb565b509250505080831115610f5957604051635453822b60e11b815260040160405180910390fd5b5f609d81610f68846001612807565b81526020019081526020015f205414610f9457604051633f707d7d60e21b815260040160405180910390fd5b609c548311610fb657604051632ad7756360e11b815260040160405180910390fd5b805b83811061100e575f818152609d602052604080822080549083905590519091829184917ecae2739091badfd91c373f0a16cede691e0cd25bb80cff77dd5caeb471014691a3506110078161288f565b9050610fb8565b505f61101e856009015160c01c90565b604051637a6e933360e01b815281850360048201529091507f000000000000000000000000f0b2293f5d834eae920c6974d50957a1732de7636001600160a01b031690637a6e9333906024015f604051808303815f87803b158015611081575f80fd5b505af11580156107b7573d5f803e3d5ffd5b61109b6118a1565b6110a45f611a55565b565b335f908152609a602052604090205460ff166110d557604051631e6edd6f60e11b815260040160405180910390fd5b6110dd61147a565b60028860ff16116111015760405163bacd96e960e01b815260040160405180910390fd5b6040805160c181019091526111198160ff8b16611799565b5f805f6111278b8b8b6116b9565b60c082901b6001880152919450925090505f80611146838c8c8c611721565b91509150808301925061115d83828c8c60016117f2565b60c081811b600988015283901b6011870152601986018290525f61117f6117a0565b905061118c818a8a611529565b60398701819052605987018690525f808d60018f516111ab919061272e565b815181106111bb576111bb6128a4565b6020908102919091018101519081015160f81c603c028101601219015190915060c01c60c081901b60798b015291506111f19050565b6111fc888b8b611aa6565b60c1882061120a8782611835565b5050505050505050505050505050505050565b6112256118a1565b6001600160a01b0381163b1561124e57604051632c0fc2e160e11b815260040160405180910390fd5b6001600160a01b0381165f818152609a6020908152604091829020805460ff1916600190811790915591519182527f631cb110fbe6a87fba5414d6b2cff02264480535cd1f5abdbc4fa638bc0b569291016109ca565b6112ac6118a1565b6001600160a01b0381165f818152609b60209081526040808320805460ff19169055519182527f967f99d5d403870e4356ff46556df3a6b6ba1f50146639aaedfb9f248eb8661e91016109ca565b6113026118a1565b801561131357611310611ab3565b50565b611310611b0d565b335f908152609b602052604090205460ff1661134a57604051637b263b1760e01b815260040160405180910390fd5b61135261147a565b816113705760405163f9a9465f60e01b815260040160405180910390fd5b5f805f61137d87876118fb565b93509350935050609c5482116113a65760405163092d315560e41b815260040160405180910390fd5b609c8290555f828152609e60209081526040808320889055609f90915290208490556113d1816119de565b6040805186815260208101869052849184915f80516020612988833981519152910160405180910390a350505050505050565b61140c6118a1565b6001600160a01b0381166114715760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161085c565b61131081611a55565b60655460ff16156110a45760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161085c565b5f8080836114e15760405163f9a9465f60e01b815260040160405180910390fd5b6114eb86866118fb565b505f818152609e60205260409020549295509093509150156115205760405163092d315560e41b815260040160405180910390fd5b93509350939050565b5f80600a6001600160a01b031685858560405160200161154b939291906128b8565b60408051601f1981840301815290829052611565916128d1565b5f60405180830381855afa9150503d805f811461159d576040519150601f19603f3d011682016040523d82523d5f602084013e6115a2565b606091505b5091509150816115c5576040516371ebedf560e01b815260040160405180910390fd5b5f818060200190518101906115da91906128ec565b9150507f73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001811461161d57604051638a89514360e01b815260040160405180910390fd5b505050505050565b805f0361163157505050565b61163d5f848484611b46565b505050565b83609c546001011461166757604051631d17cec760e21b815260040160405180910390fd5b609c8490555f848152609e60209081526040808320859055609f9091529020819055611692856119de565b6040805183815260208101839052849186915f805160206129888339815191529101610bd7565b5f805f83515f036116dd57604051632974c17360e21b815260040160405180910390fd5b6116e786866118fb565b60019091015f818152609d6020526040902054929650945092501590506115205760405163012137ab60e41b815260040160405180910390fd5b8251604080516020830281019091525f918291825b82811015611782575f806117668a8481518110611755576117556128a4565b6020026020010151878d8c8c611c2b565b9085529a8b019a95909501945050602090910190600101611736565b506020919091029081900320969095509350505050565b8082535050565b5f49600149816117c357604051630168f63160e21b815260040160405180910390fd5b80156117e257604051634c976a6160e11b815260040160405180910390fd5b5090565b80826079850137505050565b8161010060ff8601046020021461181c57604051630808452960e31b815260040160405180910390fd5b801561182e5761182e83838787611d63565b5050505050565b5f828152609d602052604080822083905551829184917f2c32d4ae151744d0bf0b9464a3e897a1d17ed2f1af71f7c9a75f12ce0d28238f9190a35050565b5f54610100900460ff166118995760405162461bcd60e51b815260040161085c9061290e565b6110a4611d77565b6033546001600160a01b031633146110a45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161085c565b5f808080853560f81c81818103611920576119168888611da6565b909650905061194a565b60028211611932576119168888611e1f565b6003821061194a576119448888611e90565b90965090505b808620945061195d866001015160c01c90565b935061196d866011015160c01c90565b5f858152609d602052604090205490935085148015906119b557505f8052609e6020527fedae58bba15aea52a58242ef195db2cc4de2b75de265dbb0d58482df22a959785415155b156119d35760405163150e0a2160e11b815260040160405180910390fd5b505092959194509250565b801561131057604051630e0143f560e21b8152600481018290527f000000000000000000000000f0b2293f5d834eae920c6974d50957a1732de7636001600160a01b0316906338050fd4906024015f604051808303815f87803b158015611a43575f80fd5b505af115801561182e573d5f803e3d5ffd5b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6040826081850137505050565b611abb61147a565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611af03390565b6040516001600160a01b03909116815260200160405180910390a1565b611b15611ec9565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611af0565b8015610941578082035f805b83811015611c2257610100818503811115611b6c57508084035b8760018114611b7e5787519350611b83565b873593505b50604051632afb09e760e11b8152600481018590526024810182905260448101849052602097909701967f000000000000000000000000f0b2293f5d834eae920c6974d50957a1732de7636001600160a01b0316906355f613ce906064015f604051808303815f87803b158015611bf8575f80fd5b505af1158015611c0a573d5f803e3d5ffd5b50505050610100840193505061010081019050611b52565b50505050505050565b60405185515f91829160208901919081908490611c49908590611f12565b90505f5b81811015611c9e57611c60858483611f79565b92505f611c6e603c83612959565b611c79876001612807565b611c839190612807565b90505f611c8f82611f8d565b97909701965050600101611c4d565b506020850282016040526001840193505f5b8115611d2b575f611cc086611f8d565b905083611cd181838f8f8f8f611f9c565b94505f611cdd886120cb565b905082811015611d0057604051638c5a4ea360e01b815260040160405180910390fd5b9c82019c9b82019b603c97909701965f19949094019360209186039190910492909201910301611cb0565b609754811115611d4e57604051634d56f17560e01b815260040160405180910390fd5b50508190039020989197509095505050505050565b8015610941578361182e6001828585611b46565b5f54610100900460ff16611d9d5760405162461bcd60e51b815260040161085c9061290e565b6110a433611a55565b5f816059811015611dca5760405163027f9c1f60e11b815260040160405180910390fd5b6040519150808483378082016040525f611de8836009015160c01c90565b905061010060ff8201046020026059018214611e175760405163c2110c9b60e01b815260040160405180910390fd5b509250929050565b5f816079811015611e435760405163a40ab48b60e01b815260040160405180910390fd5b6040519150808483378082016040525f611e61836009015160c01c90565b905061010060ff8201046020026079018214611e1757604051630c1c91df60e21b815260040160405180910390fd5b5f8160c18114611eb3576040516332496bf560e21b815260040160405180910390fd5b6040519150808483378082016040529250929050565b60655460ff166110a45760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161085c565b5f611f1c836120da565b9050805f03611f3e57604051634dbe8cff60e01b815260040160405180910390fd5b611f49603c82612959565b611f54906001612807565b8214611f7357604051634edcb40160e11b815260040160405180910390fd5b92915050565b5f611f858484846120e6565b949350505050565b5f611f7382603a015160f01c90565b5f855f03611fab5750856120c1565b7f000000000000000000000000f0b2293f5d834eae920c6974d50957a1732de7635f80805b8981101561208d5760ff89169150600889901c811580611fee575082155b15611ffd578060200288013593505b600184841c165f0361207c5760405163ae453cd560e01b8152600481018a90525f906001600160a01b0387169063ae453cd590602401602060405180830381865afa15801561204e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120729190612970565b8d52506020909b019a5b506001988901989788019701611fd0565b505060ff5f1988011681811c600116156120ba57604051632eba9e1160e21b815260040160405180910390fd5b5050879150505b9695505050505050565b5f611f73826038015160f01c90565b5f611f73825160f81c90565b5f81603c0260010184019350603a84845e5050603a01919050565b5f8083601f840112612111575f80fd5b5081356001600160401b03811115612127575f80fd5b60208301915083602082850101111561213e575f80fd5b9250929050565b5f805f805f805f805f60c08a8c03121561215d575f80fd5b89356001600160401b0380821115612173575f80fd5b61217f8d838e01612101565b909b50995060208c0135985060408c0135975060608c0135965060808c01359150808211156121ac575f80fd5b6121b88d838e01612101565b909650945060a08c01359150808211156121d0575f80fd5b506121dd8c828d01612101565b915080935050809150509295985092959850929598565b80356001600160a01b038116811461220a575f80fd5b919050565b5f6020828403121561221f575f80fd5b612228826121f4565b9392505050565b5f6020828403121561223f575f80fd5b5035919050565b803560ff8116811461220a575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b038111828210171561229257612292612256565b604052919050565b5f601f83601f8401126122ab575f80fd5b823560206001600160401b03808311156122c7576122c7612256565b8260051b6122d683820161226a565b93845286810183019383810190898611156122ef575f80fd5b84890192505b858310156123785782358481111561230b575f80fd5b8901603f81018b1361231b575f80fd5b8581013560408682111561233157612331612256565b612342828b01601f1916890161226a565b8281528d82848601011115612355575f80fd5b828285018a8301375f9281018901929092525083525091840191908401906122f5565b9998505050505050505050565b5f805f805f806080878903121561239a575f80fd5b6123a387612246565b955060208701356001600160401b03808211156123be575f80fd5b6123ca8a838b01612101565b909750955060408901359150808211156123e2575f80fd5b6123ee8a838b0161229a565b94506060890135915080821115612403575f80fd5b5061241089828a01612101565b979a9699509497509295939492505050565b5f805f60608486031215612434575f80fd5b61243d846121f4565b925061244b602085016121f4565b9150604084013590509250925092565b5f805f6040848603121561246d575f80fd5b83356001600160401b03811115612482575f80fd5b61248e86828701612101565b909790965060209590950135949350505050565b5f805f805f80608087890312156124b7575f80fd5b86356001600160401b03808211156124cd575f80fd5b6124d98a838b01612101565b909850965060208901359550604089013594506060890135915080821115612403575f80fd5b5f805f805f805f60a0888a031215612515575f80fd5b87356001600160401b038082111561252b575f80fd5b6125378b838c01612101565b909950975060208a0135965060408a0135955060608a0135945060808a0135915080821115612564575f80fd5b506125718a828b01612101565b989b979a50959850939692959293505050565b5f805f8060408587031215612597575f80fd5b84356001600160401b03808211156125ad575f80fd5b6125b988838901612101565b909650945060208701359150808211156125d1575f80fd5b506125de87828801612101565b95989497509550505050565b5f805f805f805f8060a0898b031215612601575f80fd5b61260a89612246565b975060208901356001600160401b0380821115612625575f80fd5b6126318c838d01612101565b909950975060408b0135915080821115612649575f80fd5b6126558c838d0161229a565b965060608b013591508082111561266a575f80fd5b6126768c838d01612101565b909650945060808b013591508082111561268e575f80fd5b5061269b8b828c01612101565b999c989b5096995094979396929594505050565b5f602082840312156126bf575f80fd5b81358015158114612228575f80fd5b5f805f80606085870312156126e1575f80fd5b84356001600160401b038111156126f6575f80fd5b61270287828801612101565b90989097506020870135966040013595509350505050565b634e487b7160e01b5f52601160045260245ffd5b81810381811115611f7357611f7361271a565b5f808585111561274f575f80fd5b8386111561275b575f80fd5b5050820193919092039150565b6001600160401b0360c01b8960c01b16815287600882015286602882015285604882015284606882015282846088830137608892019182015260a8019695505050505050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b858152846020820152608060408201525f6127f56080830185876127ae565b90508260608301529695505050505050565b80820180821115611f7357611f7361271a565b5f5b8381101561283457818101518382015260200161281c565b50505f910152565b858152846020820152608060408201525f61285b6080830185876127ae565b8281036060840152835180825261287981602084016020880161281a565b601f01601f191601602001979650505050505050565b5f8161289d5761289d61271a565b505f190190565b634e487b7160e01b5f52603260045260245ffd5b838152818360208301375f910160200190815292915050565b5f82516128e281846020870161281a565b9190910192915050565b5f80604083850312156128fd575f80fd5b505080516020909101519092909150565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b8082028115828204841417611f7357611f7361271a565b5f60208284031215612980575f80fd5b505191905056fe26ba82f907317eedc97d0cbef23de76a43dd6edb563bdb6e9407645b950a7a2da2646970667358221220f82c5a60d1fedf694a7853287db53587fde66cac82fd1bd823f6002640224fca64736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000000000000000000000000000008274f000000000000000000000000f0b2293f5d834eae920c6974d50957a1732de7630000000000000000000000008a360c7f6fca548507017dded732bfe7e078f963
-----Decoded View---------------
Arg [0] : _chainId (uint64): 534351
Arg [1] : _messageQueue (address): 0xF0B2293F5D834eAe920c6974D50957A1732de763
Arg [2] : _verifier (address): 0x8A360c7F6fca548507017DdeD732bFe7E078F963
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000000000000000000000000000008274f
Arg [1] : 000000000000000000000000f0b2293f5d834eae920c6974d50957a1732de763
Arg [2] : 0000000000000000000000008a360c7f6fca548507017dded732bfe7e078f963
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.