Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 22,507 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Append Sequencer... | 19437272 | 257 days ago | IN | 0 ETH | 0.00499844 | ||||
Append Sequencer... | 19437224 | 257 days ago | IN | 0 ETH | 0.0047362 | ||||
Append Sequencer... | 19437173 | 257 days ago | IN | 0 ETH | 0.00468285 | ||||
Append Sequencer... | 19437163 | 257 days ago | IN | 0 ETH | 0.00423725 | ||||
Append Sequencer... | 19437159 | 257 days ago | IN | 0 ETH | 0.0049205 | ||||
Append Sequencer... | 19437148 | 257 days ago | IN | 0 ETH | 0.00456889 | ||||
Append Sequencer... | 19437142 | 257 days ago | IN | 0 ETH | 0.00433334 | ||||
Append Sequencer... | 19437135 | 257 days ago | IN | 0 ETH | 0.00433408 | ||||
Append Sequencer... | 19437131 | 257 days ago | IN | 0 ETH | 0.00436767 | ||||
Append Sequencer... | 19437126 | 257 days ago | IN | 0 ETH | 0.00453379 | ||||
Append Sequencer... | 19437118 | 257 days ago | IN | 0 ETH | 0.00401282 | ||||
Append Sequencer... | 19437108 | 257 days ago | IN | 0 ETH | 0.00408732 | ||||
Append Sequencer... | 19437103 | 257 days ago | IN | 0 ETH | 0.00463815 | ||||
Append Sequencer... | 19436782 | 257 days ago | IN | 0 ETH | 0.00469137 | ||||
Append Sequencer... | 19436623 | 257 days ago | IN | 0 ETH | 0.00454918 | ||||
Append Sequencer... | 19436488 | 257 days ago | IN | 0 ETH | 0.0040989 | ||||
Append Sequencer... | 19436324 | 257 days ago | IN | 0 ETH | 0.00653063 | ||||
Append Sequencer... | 19436160 | 257 days ago | IN | 0 ETH | 0.00695189 | ||||
Append Sequencer... | 19436000 | 257 days ago | IN | 0 ETH | 0.00506192 | ||||
Append Sequencer... | 19435841 | 257 days ago | IN | 0 ETH | 0.00534569 | ||||
Append Sequencer... | 19435677 | 257 days ago | IN | 0 ETH | 0.00610267 | ||||
Append Sequencer... | 19435524 | 257 days ago | IN | 0 ETH | 0.00698692 | ||||
Append Sequencer... | 19435368 | 257 days ago | IN | 0 ETH | 0.00890911 | ||||
Append Sequencer... | 19435215 | 257 days ago | IN | 0 ETH | 0.00659377 | ||||
Append Sequencer... | 19435052 | 257 days ago | IN | 0 ETH | 0.00659171 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
CanonicalTransactionChain
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /* Library Imports */ import { AddressAliasHelper } from "../../standards/AddressAliasHelper.sol"; import { Lib_BVMCodec } from "../../libraries/codec/Lib_BVMCodec.sol"; import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; /* Interface Imports */ import { ICanonicalTransactionChain } from "./ICanonicalTransactionChain.sol"; import { IChainStorageContainer } from "./IChainStorageContainer.sol"; /** * @title CanonicalTransactionChain * @dev The Canonical Transaction Chain (CTC) contract is an append-only log of transactions * which must be applied to the rollup state. It defines the ordering of rollup transactions by * writing them to the 'CTC:batches' instance of the Chain Storage Container. * The CTC also allows any account to 'enqueue' an L2 transaction, which will require that the * Sequencer will eventually append it to the rollup state. * */ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressResolver { /************* * Constants * *************/ // L2 tx gas-related uint256 public constant MIN_ROLLUP_TX_GAS = 100000; uint256 public constant MAX_ROLLUP_TX_SIZE = 50000; // The approximate cost of calling the enqueue function uint256 public enqueueGasCost; // The ratio of the cost of L1 gas to the cost of L2 gas uint256 public l2GasDiscountDivisor; // The amount of L2 gas which can be forwarded to L2 without spam prevention via 'gas burn'. // Calculated as the product of l2GasDiscountDivisor * enqueueGasCost. // See comments in enqueue() for further detail. uint256 public enqueueL2GasPrepaid; // Encoding-related (all in bytes) uint256 internal constant BATCH_CONTEXT_SIZE = 16; // slither-disable-next-line unused-state uint256 internal constant BATCH_CONTEXT_LENGTH_POS = 12; uint256 internal constant BATCH_CONTEXT_START_POS = 15; // slither-disable-next-line unused-state uint256 internal constant TX_DATA_HEADER_SIZE = 3; // slither-disable-next-line unused-state uint256 internal constant BYTES_TILL_TX_DATA = 65; /************* * Variables * *************/ uint256 public maxTransactionGasLimit; /*************** * Queue State * ***************/ uint40 private _nextQueueIndex; // index of the first queue element not yet included Lib_BVMCodec.QueueElement[] queueElements; /*************** * Constructor * ***************/ constructor( address _libAddressManager, uint256 _maxTransactionGasLimit, uint256 _l2GasDiscountDivisor, uint256 _enqueueGasCost ) Lib_AddressResolver(_libAddressManager) { maxTransactionGasLimit = _maxTransactionGasLimit; l2GasDiscountDivisor = _l2GasDiscountDivisor; enqueueGasCost = _enqueueGasCost; enqueueL2GasPrepaid = _l2GasDiscountDivisor * _enqueueGasCost; } /********************** * Function Modifiers * **********************/ /** * Modifier to enforce that, if configured, only the Burn Admin may * successfully call a method. */ modifier onlyBurnAdmin() { require(msg.sender == libAddressManager.owner(), "Only callable by the Burn Admin."); _; } /******************************* * Authorized Setter Functions * *******************************/ /** * Allows the Burn Admin to update the parameters which determine the amount of gas to burn. * The value of enqueueL2GasPrepaid is immediately updated as well. */ function setGasParams(uint256 _l2GasDiscountDivisor, uint256 _enqueueGasCost) external onlyBurnAdmin { enqueueGasCost = _enqueueGasCost; l2GasDiscountDivisor = _l2GasDiscountDivisor; // See the comment in enqueue() for the rationale behind this formula. enqueueL2GasPrepaid = _l2GasDiscountDivisor * _enqueueGasCost; emit L2GasParamsUpdated(l2GasDiscountDivisor, enqueueGasCost, enqueueL2GasPrepaid); } /******************** * Public Functions * ********************/ /** * Accesses the batch storage container. * @return Reference to the batch storage container. */ function batches() public view returns (IChainStorageContainer) { return IChainStorageContainer(resolve("ChainStorageContainer-CTC-batches")); } /** * Retrieves the total number of elements submitted. * @return _totalElements Total submitted elements. */ function getTotalElements() public view returns (uint256 _totalElements) { (uint40 totalElements, , , ) = _getBatchExtraData(); return uint256(totalElements); } /** * Retrieves the total number of batches submitted. * @return _totalBatches Total submitted batches. */ // slither-disable-next-line external-function function getTotalBatches() public view returns (uint256 _totalBatches) { return batches().length(); } /** * Returns the index of the next element to be enqueued. * @return Index for the next queue element. */ // slither-disable-next-line external-function function getNextQueueIndex() public view returns (uint40) { return _nextQueueIndex; } /** * Returns the timestamp of the last transaction. * @return Timestamp for the last transaction. */ // slither-disable-next-line external-function function getLastTimestamp() public view returns (uint40) { (, , uint40 lastTimestamp, ) = _getBatchExtraData(); return lastTimestamp; } /** * Returns the blocknumber of the last transaction. * @return Blocknumber for the last transaction. */ // slither-disable-next-line external-function function getLastBlockNumber() public view returns (uint40) { (, , , uint40 lastBlockNumber) = _getBatchExtraData(); return lastBlockNumber; } /** * Gets the queue element at a particular index. * @param _index Index of the queue element to access. * @return _element Queue element at the given index. */ // slither-disable-next-line external-function function getQueueElement(uint256 _index) public view returns (Lib_BVMCodec.QueueElement memory _element) { return queueElements[_index]; } /** * Get the number of queue elements which have not yet been included. * @return Number of pending queue elements. */ // slither-disable-next-line external-function function getNumPendingQueueElements() public view returns (uint40) { return uint40(queueElements.length) - _nextQueueIndex; } /** * Retrieves the length of the queue, including * both pending and canonical transactions. * @return Length of the queue. */ // slither-disable-next-line external-function function getQueueLength() public view returns (uint40) { return uint40(queueElements.length); } /** * Adds a transaction to the queue. * @param _target Target L2 contract to send the transaction to. * @param _gasLimit Gas limit for the enqueued L2 transaction. * @param _data Transaction data. */ function enqueue( address _target, uint256 _gasLimit, bytes memory _data ) external { require( _data.length <= MAX_ROLLUP_TX_SIZE, "Transaction data size exceeds maximum for rollup transaction." ); require( _gasLimit <= maxTransactionGasLimit, "Transaction gas limit exceeds maximum for rollup transaction." ); require(_gasLimit >= MIN_ROLLUP_TX_GAS, "Transaction gas limit too low to enqueue."); // Transactions submitted to the queue lack a method for paying gas fees to the Sequencer. // So we need to prevent spam attacks by ensuring that the cost of enqueueing a transaction // from L1 to L2 is not underpriced. For transaction with a high L2 gas limit, we do this by // burning some extra gas on L1. Of course there is also some intrinsic cost to enqueueing a // transaction, so we want to make sure not to over-charge (by burning too much L1 gas). // Therefore, we define 'enqueueL2GasPrepaid' as the L2 gas limit above which we must burn // additional gas on L1. This threshold is the product of two inputs: // 1. enqueueGasCost: the base cost of calling this function. // 2. l2GasDiscountDivisor: the ratio between the cost of gas on L1 and L2. This is a // positive integer, meaning we assume L2 gas is always less costly. // The calculation below for gasToConsume can be seen as converting the difference (between // the specified L2 gas limit and the prepaid L2 gas limit) to an L1 gas amount. if (_gasLimit > enqueueL2GasPrepaid) { uint256 gasToConsume = (_gasLimit - enqueueL2GasPrepaid) / l2GasDiscountDivisor; uint256 startingGas = gasleft(); // Although this check is not necessary (burn below will run out of gas if not true), it // gives the user an explicit reason as to why the enqueue attempt failed. require(startingGas > gasToConsume, "Insufficient gas for L2 rate limiting burn."); uint256 i; while (startingGas - gasleft() < gasToConsume) { i++; } } // Apply an aliasing unless msg.sender == tx.origin. This prevents an attack in which a // contract on L1 has the same address as a contract on L2 but doesn't have the same code. // We can safely ignore this for EOAs because they're guaranteed to have the same "code" // (i.e. no code at all). This also makes it possible for users to interact with contracts // on L2 even when the Sequencer is down. address sender; if (msg.sender == tx.origin) { sender = msg.sender; } else { sender = AddressAliasHelper.applyL1ToL2Alias(msg.sender); } bytes32 transactionHash = keccak256(abi.encode(sender, _target, _gasLimit, _data)); queueElements.push( Lib_BVMCodec.QueueElement({ transactionHash: transactionHash, timestamp: uint40(block.timestamp), blockNumber: uint40(block.number) }) ); uint256 queueIndex = queueElements.length - 1; emit TransactionEnqueued(sender, _target, _gasLimit, _data, queueIndex, block.timestamp); } /** * Allows the sequencer to append a batch of transactions. * @dev This function uses a custom encoding scheme for efficiency reasons. * .param _shouldStartAtElement Specific batch we expect to start appending to. * .param _totalElementsToAppend Total number of batch elements we expect to append. * .param _contexts Array of batch contexts. * .param _transactionDataFields Array of raw transaction data. */ function appendSequencerBatch() external { uint40 shouldStartAtElement; uint24 totalElementsToAppend; uint24 numContexts; assembly { shouldStartAtElement := shr(216, calldataload(4)) totalElementsToAppend := shr(232, calldataload(9)) numContexts := shr(232, calldataload(12)) } require( shouldStartAtElement == getTotalElements(), "Actual batch start index does not match expected start index." ); require( msg.sender == resolve("BVM_Sequencer"), "Function can only be called by the Sequencer." ); uint40 nextTransactionPtr = uint40( BATCH_CONTEXT_START_POS + BATCH_CONTEXT_SIZE * numContexts ); require(msg.data.length >= nextTransactionPtr, "Not enough BatchContexts provided."); // Counter for number of sequencer transactions appended so far. uint32 numSequencerTransactions = 0; // Cache the _nextQueueIndex storage variable to a temporary stack variable. // This is safe as long as nothing reads or writes to the storage variable // until it is updated by the temp variable. uint40 nextQueueIndex = _nextQueueIndex; BatchContext memory curContext; for (uint32 i = 0; i < numContexts; i++) { BatchContext memory nextContext = _getBatchContext(i); // Now we can update our current context. curContext = nextContext; // Process sequencer transactions first. numSequencerTransactions += uint32(curContext.numSequencedTransactions); // Now process any subsequent queue transactions. nextQueueIndex += uint40(curContext.numSubsequentQueueTransactions); } require( nextQueueIndex <= queueElements.length, "Attempted to append more elements than are available in the queue." ); // Generate the required metadata that we need to append this batch uint40 numQueuedTransactions = totalElementsToAppend - numSequencerTransactions; uint40 blockTimestamp; uint40 blockNumber; if (curContext.numSubsequentQueueTransactions == 0) { // The last element is a sequencer tx, therefore pull timestamp and block number from // the last context. blockTimestamp = uint40(curContext.timestamp); blockNumber = uint40(curContext.blockNumber); } else { // The last element is a queue tx, therefore pull timestamp and block number from the // queue element. // curContext.numSubsequentQueueTransactions > 0 which means that we've processed at // least one queue element. We increment nextQueueIndex after processing each queue // element, so the index of the last element we processed is nextQueueIndex - 1. Lib_BVMCodec.QueueElement memory lastElement = queueElements[nextQueueIndex - 1]; blockTimestamp = lastElement.timestamp; blockNumber = lastElement.blockNumber; } // Cache the previous blockhash to ensure all transaction data can be retrieved efficiently. // slither-disable-next-line reentrancy-no-eth, reentrancy-events _appendBatch( blockhash(block.number - 1), totalElementsToAppend, numQueuedTransactions, blockTimestamp, blockNumber ); // slither-disable-next-line reentrancy-events emit SequencerBatchAppended( nextQueueIndex - numQueuedTransactions, numQueuedTransactions, getTotalElements() ); // Update the _nextQueueIndex storage variable. // slither-disable-next-line reentrancy-no-eth _nextQueueIndex = nextQueueIndex; } /********************** * Internal Functions * **********************/ /** * Returns the BatchContext located at a particular index. * @param _index The index of the BatchContext * @return The BatchContext at the specified index. */ function _getBatchContext(uint256 _index) internal pure returns (BatchContext memory) { uint256 contextPtr = 15 + _index * BATCH_CONTEXT_SIZE; // slither-disable-next-line similar-names uint256 numSequencedTransactions; uint256 numSubsequentQueueTransactions; uint256 ctxTimestamp; uint256 ctxBlockNumber; assembly { numSequencedTransactions := shr(232, calldataload(contextPtr)) numSubsequentQueueTransactions := shr(232, calldataload(add(contextPtr, 3))) ctxTimestamp := shr(216, calldataload(add(contextPtr, 6))) ctxBlockNumber := shr(216, calldataload(add(contextPtr, 11))) } return BatchContext({ numSequencedTransactions: numSequencedTransactions, numSubsequentQueueTransactions: numSubsequentQueueTransactions, timestamp: ctxTimestamp, blockNumber: ctxBlockNumber }); } /** * Parses the batch context from the extra data. * @return Total number of elements submitted. * @return Index of the next queue element. */ function _getBatchExtraData() internal view returns ( uint40, uint40, uint40, uint40 ) { bytes27 extraData = batches().getGlobalMetadata(); uint40 totalElements; uint40 nextQueueIndex; uint40 lastTimestamp; uint40 lastBlockNumber; // solhint-disable max-line-length assembly { extraData := shr(40, extraData) totalElements := and( extraData, 0x000000000000000000000000000000000000000000000000000000FFFFFFFFFF ) nextQueueIndex := shr( 40, and(extraData, 0x00000000000000000000000000000000000000000000FFFFFFFFFF0000000000) ) lastTimestamp := shr( 80, and(extraData, 0x0000000000000000000000000000000000FFFFFFFFFF00000000000000000000) ) lastBlockNumber := shr( 120, and(extraData, 0x000000000000000000000000FFFFFFFFFF000000000000000000000000000000) ) } // solhint-enable max-line-length return (totalElements, nextQueueIndex, lastTimestamp, lastBlockNumber); } /** * Encodes the batch context for the extra data. * @param _totalElements Total number of elements submitted. * @param _nextQueueIdx Index of the next queue element. * @param _timestamp Timestamp for the last batch. * @param _blockNumber Block number of the last batch. * @return Encoded batch context. */ function _makeBatchExtraData( uint40 _totalElements, uint40 _nextQueueIdx, uint40 _timestamp, uint40 _blockNumber ) internal pure returns (bytes27) { bytes27 extraData; assembly { extraData := _totalElements extraData := or(extraData, shl(40, _nextQueueIdx)) extraData := or(extraData, shl(80, _timestamp)) extraData := or(extraData, shl(120, _blockNumber)) extraData := shl(40, extraData) } return extraData; } /** * Inserts a batch into the chain of batches. * @param _transactionRoot Root of the transaction tree for this batch. * @param _batchSize Number of elements in the batch. * @param _numQueuedTransactions Number of queue transactions in the batch. * @param _timestamp The latest batch timestamp. * @param _blockNumber The latest batch blockNumber. */ function _appendBatch( bytes32 _transactionRoot, uint256 _batchSize, uint256 _numQueuedTransactions, uint40 _timestamp, uint40 _blockNumber ) internal { IChainStorageContainer batchesRef = batches(); (uint40 totalElements, uint40 nextQueueIndex, , ) = _getBatchExtraData(); Lib_BVMCodec.ChainBatchHeader memory header = Lib_BVMCodec.ChainBatchHeader({ batchIndex: batchesRef.length(), batchRoot: _transactionRoot, batchSize: _batchSize, prevTotalElements: totalElements, signature: hex"", extraData: hex"" }); emit TransactionBatchAppended( header.batchIndex, header.batchRoot, header.batchSize, header.prevTotalElements, header.signature, header.extraData ); bytes32 batchHeaderHash = Lib_BVMCodec.hashBatchHeader(header); bytes27 latestBatchContext = _makeBatchExtraData( totalElements + uint40(header.batchSize), nextQueueIndex + uint40(_numQueuedTransactions), _timestamp, _blockNumber ); // slither-disable-next-line reentrancy-no-eth, reentrancy-events batchesRef.push(batchHeaderHash, latestBatchContext); } /** * Reset the index when the ctc data is dirtyed */ function resetIndex(uint256 _batchIndex, uint40 _totalElement, uint40 _batchSize, uint40 _nextqIndex,uint40 _numQueuedTransactions , uint40 _timestamp, uint40 _blockNumber) external { require(_batchIndex < batches().length(), "Invalid batch index."); require(msg.sender == libAddressManager.owner(), "Only callable by the address manager owner."); bytes27 latestBatchContext = _makeBatchExtraData( _totalElement + _batchSize, _nextqIndex + _numQueuedTransactions, _timestamp, _blockNumber ); // slither-disable-next-line reentrancy-events batches().deleteElementsAfterInclusive(_batchIndex,latestBatchContext); _nextQueueIndex = _nextqIndex; // slither-disable-next-line reentrancy-events emit CTCBatchReset(_batchIndex,_nextqIndex,_totalElement,_batchSize,_numQueuedTransactions,_timestamp,_blockNumber); } }
// SPDX-License-Identifier: Apache-2.0 /* * Copyright 2019-2021, Offchain Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity ^0.8.7; library AddressAliasHelper { uint160 constant offset = uint160(0x1111000000000000000000000000000000001111); /// @notice Utility function that converts the address in the L1 that submitted a tx to /// the inbox to the msg.sender viewed in the L2 /// @param l1Address the address in the L1 that triggered the tx to L2 /// @return l2Address L2 address as viewed in msg.sender function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) { unchecked { l2Address = address(uint160(l1Address) + offset); } } /// @notice Utility function that converts the msg.sender viewed in the L2 to the /// address in the L1 that submitted a tx to the inbox /// @param l2Address L2 address as viewed in msg.sender /// @return l1Address the address in the L1 that triggered the tx to L2 function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) { unchecked { l1Address = address(uint160(l2Address) - offset); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /* Library Imports */ import { Lib_RLPReader } from "../rlp/Lib_RLPReader.sol"; import { Lib_RLPWriter } from "../rlp/Lib_RLPWriter.sol"; import { Lib_BytesUtils } from "../utils/Lib_BytesUtils.sol"; import { Lib_Bytes32Utils } from "../utils/Lib_Bytes32Utils.sol"; /** * @title Lib_BVMCodec */ library Lib_BVMCodec { /********* * Enums * *********/ enum QueueOrigin { SEQUENCER_QUEUE, L1TOL2_QUEUE } /*********** * Structs * ***********/ struct EVMAccount { uint256 nonce; uint256 balance; bytes32 storageRoot; bytes32 codeHash; } struct ChainBatchHeader { uint256 batchIndex; bytes32 batchRoot; uint256 batchSize; uint256 prevTotalElements; bytes signature; bytes extraData; } struct ChainInclusionProof { uint256 index; bytes32[] siblings; } struct Transaction { uint256 timestamp; uint256 blockNumber; QueueOrigin l1QueueOrigin; address l1TxOrigin; address entrypoint; uint256 gasLimit; bytes data; } struct TransactionChainElement { bool isSequenced; uint256 queueIndex; // QUEUED TX ONLY uint256 timestamp; // SEQUENCER TX ONLY uint256 blockNumber; // SEQUENCER TX ONLY bytes txData; // SEQUENCER TX ONLY } struct QueueElement { bytes32 transactionHash; uint40 timestamp; uint40 blockNumber; } /********************** * Internal Functions * **********************/ /** * Encodes a standard BVM transaction. * @param _transaction BVM transaction to encode. * @return Encoded transaction bytes. */ function encodeTransaction(Transaction memory _transaction) internal pure returns (bytes memory) { return abi.encodePacked( _transaction.timestamp, _transaction.blockNumber, _transaction.l1QueueOrigin, _transaction.l1TxOrigin, _transaction.entrypoint, _transaction.gasLimit, _transaction.data ); } /** * Hashes a standard BVM transaction. * @param _transaction BVM transaction to encode. * @return Hashed transaction */ function hashTransaction(Transaction memory _transaction) internal pure returns (bytes32) { return keccak256(encodeTransaction(_transaction)); } /** * @notice Decodes an RLP-encoded account state into a useful struct. * @param _encoded RLP-encoded account state. * @return Account state struct. */ function decodeEVMAccount(bytes memory _encoded) internal pure returns (EVMAccount memory) { Lib_RLPReader.RLPItem[] memory accountState = Lib_RLPReader.readList(_encoded); return EVMAccount({ nonce: Lib_RLPReader.readUint256(accountState[0]), balance: Lib_RLPReader.readUint256(accountState[1]), storageRoot: Lib_RLPReader.readBytes32(accountState[2]), codeHash: Lib_RLPReader.readBytes32(accountState[3]) }); } /** * Calculates a hash for a given batch header. * @param _batchHeader Header to hash. * @return Hash of the header. */ function hashBatchHeader(Lib_BVMCodec.ChainBatchHeader memory _batchHeader) internal pure returns (bytes32) { return keccak256( abi.encode( _batchHeader.batchRoot, _batchHeader.batchSize, _batchHeader.prevTotalElements, _batchHeader.signature, _batchHeader.extraData ) ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /* Library Imports */ import { Lib_AddressManager } from "./Lib_AddressManager.sol"; /** * @title Lib_AddressResolver */ abstract contract Lib_AddressResolver { /************* * Variables * *************/ Lib_AddressManager public libAddressManager; /*************** * Constructor * ***************/ /** * @param _libAddressManager Address of the Lib_AddressManager. */ constructor(address _libAddressManager) { libAddressManager = Lib_AddressManager(_libAddressManager); } /******************** * Public Functions * ********************/ /** * Resolves the address associated with a given name. * @param _name Name to resolve an address for. * @return Address associated with the given name. */ function resolve(string memory _name) public view returns (address) { return libAddressManager.getAddress(_name); } }
// SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.9.0; /** * @title IChainStorageContainer */ interface IChainStorageContainer { /******************** * Public Functions * ********************/ /** * Sets the container's global metadata field. We're using `bytes27` here because we use five * bytes to maintain the length of the underlying data structure, meaning we have an extra * 27 bytes to store arbitrary data. * @param _globalMetadata New global metadata to set. */ function setGlobalMetadata(bytes27 _globalMetadata) external; /** * Retrieves the container's global metadata field. * @return Container global metadata field. */ function getGlobalMetadata() external view returns (bytes27); /** * Retrieves the number of objects stored in the container. * @return Number of objects in the container. */ function length() external view returns (uint256); /** * Pushes an object into the container. * @param _object A 32 byte value to insert into the container. */ function push(bytes32 _object) external; /** * Pushes an object into the container. Function allows setting the global metadata since * we'll need to touch the "length" storage slot anyway, which also contains the global * metadata (it's an optimization). * @param _object A 32 byte value to insert into the container. * @param _globalMetadata New global metadata for the container. */ function push(bytes32 _object, bytes27 _globalMetadata) external; /** * Retrieves an object from the container. * @param _index Index of the particular object to access. * @return 32 byte object value. */ function get(uint256 _index) external view returns (bytes32); /** * Removes all objects after and including a given index. * @param _index Object index to delete from. */ function deleteElementsAfterInclusive(uint256 _index) external; /** * Removes all objects after and including a given index. Also allows setting the global * metadata field. * @param _index Object index to delete from. * @param _globalMetadata New global metadata for the container. */ function deleteElementsAfterInclusive(uint256 _index, bytes27 _globalMetadata) external; }
// SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.9.0; /* Library Imports */ import { Lib_BVMCodec } from "../../libraries/codec/Lib_BVMCodec.sol"; /* Interface Imports */ import { IChainStorageContainer } from "./IChainStorageContainer.sol"; /** * @title ICanonicalTransactionChain */ interface ICanonicalTransactionChain { /********** * Events * **********/ event L2GasParamsUpdated( uint256 l2GasDiscountDivisor, uint256 enqueueGasCost, uint256 enqueueL2GasPrepaid ); event TransactionEnqueued( address indexed _l1TxOrigin, address indexed _target, uint256 _gasLimit, bytes _data, uint256 indexed _queueIndex, uint256 _timestamp ); event QueueBatchAppended( uint256 _startingQueueIndex, uint256 _numQueueElements, uint256 _totalElements ); event SequencerBatchAppended( uint256 _startingQueueIndex, uint256 _numQueueElements, uint256 _totalElements ); event TransactionBatchAppended( uint256 indexed _batchIndex, bytes32 _batchRoot, uint256 _batchSize, uint256 _prevTotalElements, bytes _signature, bytes _extraData ); event CTCBatchReset( uint256 indexed _batchIndex, uint40 _nextqIndex, uint40 _totalElement, uint40 _batchSize, uint40 _numQueuedTransactions , uint40 _timestamp, uint40 _blockNumber ); /*********** * Structs * ***********/ struct BatchContext { uint256 numSequencedTransactions; uint256 numSubsequentQueueTransactions; uint256 timestamp; uint256 blockNumber; } /******************************* * Authorized Setter Functions * *******************************/ /** * Allows the Burn Admin to update the parameters which determine the amount of gas to burn. * The value of enqueueL2GasPrepaid is immediately updated as well. */ function setGasParams(uint256 _l2GasDiscountDivisor, uint256 _enqueueGasCost) external; /******************** * Public Functions * ********************/ /** * Accesses the batch storage container. * @return Reference to the batch storage container. */ function batches() external view returns (IChainStorageContainer); /** * Retrieves the total number of elements submitted. * @return _totalElements Total submitted elements. */ function getTotalElements() external view returns (uint256 _totalElements); /** * Retrieves the total number of batches submitted. * @return _totalBatches Total submitted batches. */ function getTotalBatches() external view returns (uint256 _totalBatches); /** * Returns the index of the next element to be enqueued. * @return Index for the next queue element. */ function getNextQueueIndex() external view returns (uint40); /** * Gets the queue element at a particular index. * @param _index Index of the queue element to access. * @return _element Queue element at the given index. */ function getQueueElement(uint256 _index) external view returns (Lib_BVMCodec.QueueElement memory _element); /** * Returns the timestamp of the last transaction. * @return Timestamp for the last transaction. */ function getLastTimestamp() external view returns (uint40); /** * Returns the blocknumber of the last transaction. * @return Blocknumber for the last transaction. */ function getLastBlockNumber() external view returns (uint40); /** * Get the number of queue elements which have not yet been included. * @return Number of pending queue elements. */ function getNumPendingQueueElements() external view returns (uint40); /** * Retrieves the length of the queue, including * both pending and canonical transactions. * @return Length of the queue. */ function getQueueLength() external view returns (uint40); /** * Adds a transaction to the queue. * @param _target Target contract to send the transaction to. * @param _gasLimit Gas limit for the given transaction. * @param _data Transaction data. */ function enqueue( address _target, uint256 _gasLimit, bytes memory _data ) external; /** * Allows the sequencer to append a batch of transactions. * @dev This function uses a custom encoding scheme for efficiency reasons. * .param _shouldStartAtElement Specific batch we expect to start appending to. * .param _totalElementsToAppend Total number of batch elements we expect to append. * .param _contexts Array of batch contexts. * .param _transactionDataFields Array of raw transaction data. */ function appendSequencerBatch( // uint40 _shouldStartAtElement, // uint24 _totalElementsToAppend, // BatchContext[] _contexts, // bytes[] _transactionDataFields ) external; function resetIndex(uint256 _batchIndex, uint40 _totalElement, uint40 _batchSize, uint40 _nextqIndex,uint40 _numQueuedTransactions , uint40 _timestamp, uint40 _blockNumber) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title Lib_RLPReader * @dev Adapted from "RLPReader" by Hamdi Allam ([email protected]). */ library Lib_RLPReader { /************* * Constants * *************/ uint256 internal constant MAX_LIST_LENGTH = 32; /********* * Enums * *********/ enum RLPItemType { DATA_ITEM, LIST_ITEM } /*********** * Structs * ***********/ struct RLPItem { uint256 length; uint256 ptr; } /********************** * Internal Functions * **********************/ /** * Converts bytes to a reference to memory position and length. * @param _in Input bytes to convert. * @return Output memory reference. */ function toRLPItem(bytes memory _in) internal pure returns (RLPItem memory) { uint256 ptr; assembly { ptr := add(_in, 32) } return RLPItem({ length: _in.length, ptr: ptr }); } /** * Reads an RLP list value into a list of RLP items. * @param _in RLP list value. * @return Decoded RLP list items. */ function readList(RLPItem memory _in) internal pure returns (RLPItem[] memory) { (uint256 listOffset, , RLPItemType itemType) = _decodeLength(_in); require(itemType == RLPItemType.LIST_ITEM, "Invalid RLP list value."); // Solidity in-memory arrays can't be increased in size, but *can* be decreased in size by // writing to the length. Since we can't know the number of RLP items without looping over // the entire input, we'd have to loop twice to accurately size this array. It's easier to // simply set a reasonable maximum list length and decrease the size before we finish. RLPItem[] memory out = new RLPItem[](MAX_LIST_LENGTH); uint256 itemCount = 0; uint256 offset = listOffset; while (offset < _in.length) { require(itemCount < MAX_LIST_LENGTH, "Provided RLP list exceeds max list length."); (uint256 itemOffset, uint256 itemLength, ) = _decodeLength( RLPItem({ length: _in.length - offset, ptr: _in.ptr + offset }) ); out[itemCount] = RLPItem({ length: itemLength + itemOffset, ptr: _in.ptr + offset }); itemCount += 1; offset += itemOffset + itemLength; } // Decrease the array size to match the actual item count. assembly { mstore(out, itemCount) } return out; } /** * Reads an RLP list value into a list of RLP items. * @param _in RLP list value. * @return Decoded RLP list items. */ function readList(bytes memory _in) internal pure returns (RLPItem[] memory) { return readList(toRLPItem(_in)); } /** * Reads an RLP bytes value into bytes. * @param _in RLP bytes value. * @return Decoded bytes. */ function readBytes(RLPItem memory _in) internal pure returns (bytes memory) { (uint256 itemOffset, uint256 itemLength, RLPItemType itemType) = _decodeLength(_in); require(itemType == RLPItemType.DATA_ITEM, "Invalid RLP bytes value."); return _copy(_in.ptr, itemOffset, itemLength); } /** * Reads an RLP bytes value into bytes. * @param _in RLP bytes value. * @return Decoded bytes. */ function readBytes(bytes memory _in) internal pure returns (bytes memory) { return readBytes(toRLPItem(_in)); } /** * Reads an RLP string value into a string. * @param _in RLP string value. * @return Decoded string. */ function readString(RLPItem memory _in) internal pure returns (string memory) { return string(readBytes(_in)); } /** * Reads an RLP string value into a string. * @param _in RLP string value. * @return Decoded string. */ function readString(bytes memory _in) internal pure returns (string memory) { return readString(toRLPItem(_in)); } /** * Reads an RLP bytes32 value into a bytes32. * @param _in RLP bytes32 value. * @return Decoded bytes32. */ function readBytes32(RLPItem memory _in) internal pure returns (bytes32) { require(_in.length <= 33, "Invalid RLP bytes32 value."); (uint256 itemOffset, uint256 itemLength, RLPItemType itemType) = _decodeLength(_in); require(itemType == RLPItemType.DATA_ITEM, "Invalid RLP bytes32 value."); uint256 ptr = _in.ptr + itemOffset; bytes32 out; assembly { out := mload(ptr) // Shift the bytes over to match the item size. if lt(itemLength, 32) { out := div(out, exp(256, sub(32, itemLength))) } } return out; } /** * Reads an RLP bytes32 value into a bytes32. * @param _in RLP bytes32 value. * @return Decoded bytes32. */ function readBytes32(bytes memory _in) internal pure returns (bytes32) { return readBytes32(toRLPItem(_in)); } /** * Reads an RLP uint256 value into a uint256. * @param _in RLP uint256 value. * @return Decoded uint256. */ function readUint256(RLPItem memory _in) internal pure returns (uint256) { return uint256(readBytes32(_in)); } /** * Reads an RLP uint256 value into a uint256. * @param _in RLP uint256 value. * @return Decoded uint256. */ function readUint256(bytes memory _in) internal pure returns (uint256) { return readUint256(toRLPItem(_in)); } /** * Reads an RLP bool value into a bool. * @param _in RLP bool value. * @return Decoded bool. */ function readBool(RLPItem memory _in) internal pure returns (bool) { require(_in.length == 1, "Invalid RLP boolean value."); uint256 ptr = _in.ptr; uint256 out; assembly { out := byte(0, mload(ptr)) } require(out == 0 || out == 1, "Lib_RLPReader: Invalid RLP boolean value, must be 0 or 1"); return out != 0; } /** * Reads an RLP bool value into a bool. * @param _in RLP bool value. * @return Decoded bool. */ function readBool(bytes memory _in) internal pure returns (bool) { return readBool(toRLPItem(_in)); } /** * Reads an RLP address value into a address. * @param _in RLP address value. * @return Decoded address. */ function readAddress(RLPItem memory _in) internal pure returns (address) { if (_in.length == 1) { return address(0); } require(_in.length == 21, "Invalid RLP address value."); return address(uint160(readUint256(_in))); } /** * Reads an RLP address value into a address. * @param _in RLP address value. * @return Decoded address. */ function readAddress(bytes memory _in) internal pure returns (address) { return readAddress(toRLPItem(_in)); } /** * Reads the raw bytes of an RLP item. * @param _in RLP item to read. * @return Raw RLP bytes. */ function readRawBytes(RLPItem memory _in) internal pure returns (bytes memory) { return _copy(_in); } /********************* * Private Functions * *********************/ /** * Decodes the length of an RLP item. * @param _in RLP item to decode. * @return Offset of the encoded data. * @return Length of the encoded data. * @return RLP item type (LIST_ITEM or DATA_ITEM). */ function _decodeLength(RLPItem memory _in) private pure returns ( uint256, uint256, RLPItemType ) { require(_in.length > 0, "RLP item cannot be null."); uint256 ptr = _in.ptr; uint256 prefix; assembly { prefix := byte(0, mload(ptr)) } if (prefix <= 0x7f) { // Single byte. return (0, 1, RLPItemType.DATA_ITEM); } else if (prefix <= 0xb7) { // Short string. // slither-disable-next-line variable-scope uint256 strLen = prefix - 0x80; require(_in.length > strLen, "Invalid RLP short string."); return (1, strLen, RLPItemType.DATA_ITEM); } else if (prefix <= 0xbf) { // Long string. uint256 lenOfStrLen = prefix - 0xb7; require(_in.length > lenOfStrLen, "Invalid RLP long string length."); uint256 strLen; assembly { // Pick out the string length. strLen := div(mload(add(ptr, 1)), exp(256, sub(32, lenOfStrLen))) } require(_in.length > lenOfStrLen + strLen, "Invalid RLP long string."); return (1 + lenOfStrLen, strLen, RLPItemType.DATA_ITEM); } else if (prefix <= 0xf7) { // Short list. // slither-disable-next-line variable-scope uint256 listLen = prefix - 0xc0; require(_in.length > listLen, "Invalid RLP short list."); return (1, listLen, RLPItemType.LIST_ITEM); } else { // Long list. uint256 lenOfListLen = prefix - 0xf7; require(_in.length > lenOfListLen, "Invalid RLP long list length."); uint256 listLen; assembly { // Pick out the list length. listLen := div(mload(add(ptr, 1)), exp(256, sub(32, lenOfListLen))) } require(_in.length > lenOfListLen + listLen, "Invalid RLP long list."); return (1 + lenOfListLen, listLen, RLPItemType.LIST_ITEM); } } /** * Copies the bytes from a memory location. * @param _src Pointer to the location to read from. * @param _offset Offset to start reading from. * @param _length Number of bytes to read. * @return Copied bytes. */ function _copy( uint256 _src, uint256 _offset, uint256 _length ) private pure returns (bytes memory) { bytes memory out = new bytes(_length); if (out.length == 0) { return out; } uint256 src = _src + _offset; uint256 dest; assembly { dest := add(out, 32) } // Copy over as many complete words as we can. for (uint256 i = 0; i < _length / 32; i++) { assembly { mstore(dest, mload(src)) } src += 32; dest += 32; } // Pick out the remaining bytes. uint256 mask; unchecked { mask = 256**(32 - (_length % 32)) - 1; } assembly { mstore(dest, or(and(mload(src), not(mask)), and(mload(dest), mask))) } return out; } /** * Copies an RLP item into bytes. * @param _in RLP item to copy. * @return Copied bytes. */ function _copy(RLPItem memory _in) private pure returns (bytes memory) { return _copy(_in.ptr, 0, _in.length); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title Lib_BytesUtils */ library Lib_BytesUtils { /********************** * Internal Functions * **********************/ function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_start + _length >= _start, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function slice(bytes memory _bytes, uint256 _start) internal pure returns (bytes memory) { if (_start >= _bytes.length) { return bytes(""); } return slice(_bytes, _start, _bytes.length - _start); } function toBytes32(bytes memory _bytes) internal pure returns (bytes32) { if (_bytes.length < 32) { bytes32 ret; assembly { ret := mload(add(_bytes, 32)) } return ret; } return abi.decode(_bytes, (bytes32)); // will truncate if input length > 32 bytes } function toUint256(bytes memory _bytes) internal pure returns (uint256) { return uint256(toBytes32(_bytes)); } function toNibbles(bytes memory _bytes) internal pure returns (bytes memory) { bytes memory nibbles = new bytes(_bytes.length * 2); for (uint256 i = 0; i < _bytes.length; i++) { nibbles[i * 2] = _bytes[i] >> 4; nibbles[i * 2 + 1] = bytes1(uint8(_bytes[i]) % 16); } return nibbles; } function fromNibbles(bytes memory _bytes) internal pure returns (bytes memory) { bytes memory ret = new bytes(_bytes.length / 2); for (uint256 i = 0; i < ret.length; i++) { ret[i] = (_bytes[i * 2] << 4) | (_bytes[i * 2 + 1]); } return ret; } function equal(bytes memory _bytes, bytes memory _other) internal pure returns (bool) { return keccak256(_bytes) == keccak256(_other); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title Lib_RLPWriter * @author Bakaoh (with modifications) */ library Lib_RLPWriter { /********************** * Internal Functions * **********************/ /** * RLP encodes a byte string. * @param _in The byte string to encode. * @return The RLP encoded string in bytes. */ function writeBytes(bytes memory _in) internal pure returns (bytes memory) { bytes memory encoded; if (_in.length == 1 && uint8(_in[0]) < 128) { encoded = _in; } else { encoded = abi.encodePacked(_writeLength(_in.length, 128), _in); } return encoded; } /** * RLP encodes a list of RLP encoded byte byte strings. * @param _in The list of RLP encoded byte strings. * @return The RLP encoded list of items in bytes. */ function writeList(bytes[] memory _in) internal pure returns (bytes memory) { bytes memory list = _flatten(_in); return abi.encodePacked(_writeLength(list.length, 192), list); } /** * RLP encodes a string. * @param _in The string to encode. * @return The RLP encoded string in bytes. */ function writeString(string memory _in) internal pure returns (bytes memory) { return writeBytes(bytes(_in)); } /** * RLP encodes an address. * @param _in The address to encode. * @return The RLP encoded address in bytes. */ function writeAddress(address _in) internal pure returns (bytes memory) { return writeBytes(abi.encodePacked(_in)); } /** * RLP encodes a uint. * @param _in The uint256 to encode. * @return The RLP encoded uint256 in bytes. */ function writeUint(uint256 _in) internal pure returns (bytes memory) { return writeBytes(_toBinary(_in)); } /** * RLP encodes a bool. * @param _in The bool to encode. * @return The RLP encoded bool in bytes. */ function writeBool(bool _in) internal pure returns (bytes memory) { bytes memory encoded = new bytes(1); encoded[0] = (_in ? bytes1(0x01) : bytes1(0x80)); return encoded; } /********************* * Private Functions * *********************/ /** * Encode the first byte, followed by the `len` in binary form if `length` is more than 55. * @param _len The length of the string or the payload. * @param _offset 128 if item is string, 192 if item is list. * @return RLP encoded bytes. */ function _writeLength(uint256 _len, uint256 _offset) private pure returns (bytes memory) { bytes memory encoded; if (_len < 56) { encoded = new bytes(1); encoded[0] = bytes1(uint8(_len) + uint8(_offset)); } else { uint256 lenLen; uint256 i = 1; while (_len / i != 0) { lenLen++; i *= 256; } encoded = new bytes(lenLen + 1); encoded[0] = bytes1(uint8(lenLen) + uint8(_offset) + 55); for (i = 1; i <= lenLen; i++) { encoded[i] = bytes1(uint8((_len / (256**(lenLen - i))) % 256)); } } return encoded; } /** * Encode integer in big endian binary form with no leading zeroes. * @notice TODO: This should be optimized with assembly to save gas costs. * @param _x The integer to encode. * @return RLP encoded bytes. */ function _toBinary(uint256 _x) private pure returns (bytes memory) { bytes memory b = abi.encodePacked(_x); uint256 i = 0; for (; i < 32; i++) { if (b[i] != 0) { break; } } bytes memory res = new bytes(32 - i); for (uint256 j = 0; j < res.length; j++) { res[j] = b[i++]; } return res; } /** * Copies a piece of memory to another location. * @notice From: https://github.com/Arachnid/solidity-stringutils/blob/master/src/strings.sol. * @param _dest Destination location. * @param _src Source location. * @param _len Length of memory to copy. */ function _memcpy( uint256 _dest, uint256 _src, uint256 _len ) private pure { uint256 dest = _dest; uint256 src = _src; uint256 len = _len; for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint256 mask; unchecked { mask = 256**(32 - len) - 1; } assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /** * Flattens a list of byte strings into one byte string. * @notice From: https://github.com/sammayo/solidity-rlp-encoder/blob/master/RLPEncode.sol. * @param _list List of byte strings to flatten. * @return The flattened byte string. */ function _flatten(bytes[] memory _list) private pure returns (bytes memory) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i = 0; for (; i < _list.length; i++) { len += _list[i].length; } bytes memory flattened = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(flattened, 0x20) } for (i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20) } _memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } return flattened; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title Lib_Byte32Utils */ library Lib_Bytes32Utils { /********************** * Internal Functions * **********************/ /** * Converts a bytes32 value to a boolean. Anything non-zero will be converted to "true." * @param _in Input bytes32 value. * @return Bytes32 as a boolean. */ function toBool(bytes32 _in) internal pure returns (bool) { return _in != 0; } /** * Converts a boolean to a bytes32 value. * @param _in Input boolean value. * @return Boolean as a bytes32. */ function fromBool(bool _in) internal pure returns (bytes32) { return bytes32(uint256(_in ? 1 : 0)); } /** * Converts a bytes32 value to an address. Takes the *last* 20 bytes. * @param _in Input bytes32 value. * @return Bytes32 as an address. */ function toAddress(bytes32 _in) internal pure returns (address) { return address(uint160(uint256(_in))); } /** * Converts an address to a bytes32. * @param _in Input address value. * @return Address as a bytes32. */ function fromAddress(address _in) internal pure returns (bytes32) { return bytes32(uint256(uint160(_in))); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /* External Imports */ import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; /** * @title Lib_AddressManager */ contract Lib_AddressManager is Ownable { /********** * Events * **********/ event AddressSet(string indexed _name, address _newAddress, address _oldAddress); /************* * Variables * *************/ mapping(bytes32 => address) private addresses; /******************** * Public Functions * ********************/ /** * Changes the address associated with a particular name. * @param _name String name to associate an address with. * @param _address Address to associate with the name. */ function setAddress(string memory _name, address _address) external onlyOwner { bytes32 nameHash = _getNameHash(_name); address oldAddress = addresses[nameHash]; addresses[nameHash] = _address; emit AddressSet(_name, _address, oldAddress); } /** * Retrieves the address associated with a given name. * @param _name Name to retrieve an address for. * @return Address associated with the given name. */ function getAddress(string memory _name) external view returns (address) { return addresses[_getNameHash(_name)]; } /********************** * Internal Functions * **********************/ /** * Computes the hash of a name. * @param _name Name to compute a hash for. * @return Hash of the given name. */ function _getNameHash(string memory _name) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_name)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.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 Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(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"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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 Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_libAddressManager","type":"address"},{"internalType":"uint256","name":"_maxTransactionGasLimit","type":"uint256"},{"internalType":"uint256","name":"_l2GasDiscountDivisor","type":"uint256"},{"internalType":"uint256","name":"_enqueueGasCost","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_batchIndex","type":"uint256"},{"indexed":false,"internalType":"uint40","name":"_nextqIndex","type":"uint40"},{"indexed":false,"internalType":"uint40","name":"_totalElement","type":"uint40"},{"indexed":false,"internalType":"uint40","name":"_batchSize","type":"uint40"},{"indexed":false,"internalType":"uint40","name":"_numQueuedTransactions","type":"uint40"},{"indexed":false,"internalType":"uint40","name":"_timestamp","type":"uint40"},{"indexed":false,"internalType":"uint40","name":"_blockNumber","type":"uint40"}],"name":"CTCBatchReset","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"l2GasDiscountDivisor","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"enqueueGasCost","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"enqueueL2GasPrepaid","type":"uint256"}],"name":"L2GasParamsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_startingQueueIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_numQueueElements","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_totalElements","type":"uint256"}],"name":"QueueBatchAppended","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_startingQueueIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_numQueueElements","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_totalElements","type":"uint256"}],"name":"SequencerBatchAppended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_batchIndex","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"_batchRoot","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"_batchSize","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_prevTotalElements","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"_signature","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"TransactionBatchAppended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_l1TxOrigin","type":"address"},{"indexed":true,"internalType":"address","name":"_target","type":"address"},{"indexed":false,"internalType":"uint256","name":"_gasLimit","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"_data","type":"bytes"},{"indexed":true,"internalType":"uint256","name":"_queueIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"TransactionEnqueued","type":"event"},{"inputs":[],"name":"MAX_ROLLUP_TX_SIZE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_ROLLUP_TX_GAS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"appendSequencerBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"batches","outputs":[{"internalType":"contract IChainStorageContainer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"enqueue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enqueueGasCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enqueueL2GasPrepaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastBlockNumber","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastTimestamp","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextQueueIndex","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNumPendingQueueElements","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getQueueElement","outputs":[{"components":[{"internalType":"bytes32","name":"transactionHash","type":"bytes32"},{"internalType":"uint40","name":"timestamp","type":"uint40"},{"internalType":"uint40","name":"blockNumber","type":"uint40"}],"internalType":"struct Lib_BVMCodec.QueueElement","name":"_element","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getQueueLength","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalBatches","outputs":[{"internalType":"uint256","name":"_totalBatches","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalElements","outputs":[{"internalType":"uint256","name":"_totalElements","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"l2GasDiscountDivisor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"libAddressManager","outputs":[{"internalType":"contract Lib_AddressManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTransactionGasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_batchIndex","type":"uint256"},{"internalType":"uint40","name":"_totalElement","type":"uint40"},{"internalType":"uint40","name":"_batchSize","type":"uint40"},{"internalType":"uint40","name":"_nextqIndex","type":"uint40"},{"internalType":"uint40","name":"_numQueuedTransactions","type":"uint40"},{"internalType":"uint40","name":"_timestamp","type":"uint40"},{"internalType":"uint40","name":"_blockNumber","type":"uint40"}],"name":"resetIndex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"name":"resolve","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_l2GasDiscountDivisor","type":"uint256"},{"internalType":"uint256","name":"_enqueueGasCost","type":"uint256"}],"name":"setGasParams","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5060405162001a5838038062001a5883398101604081905261003191610072565b600080546001600160a01b0319166001600160a01b03861617905560048390556002829055600181905561006581836100bd565b600355506100ea92505050565b6000806000806080858703121561008857600080fd5b84516001600160a01b038116811461009f57600080fd5b60208601516040870151606090970151919890975090945092505050565b60008160001904831182151516156100e557634e487b7160e01b600052601160045260246000fd5b500290565b61195e80620000fa6000396000f3fe608060405234801561001057600080fd5b50600436106101375760003560e01c8063876ed5cb116100b8578063cfdf677e1161007c578063cfdf677e1461026c578063d0f8934414610274578063e561dddc1461027c578063e654b1fb14610284578063edcc4a451461028d578063f722b41a146102a057600080fd5b8063876ed5cb146102365780638d38c6c11461023f578063a17e44c614610248578063b8f770051461025b578063ccf987c81461026357600080fd5b80635ae6256d116100ff5780635ae6256d146101f85780636fee07e01461020057806378f4b2f2146102155780637a167a8a1461021f5780637aa63a861461022e57600080fd5b80630b3dfa971461013c578063299ca478146101585780632a7f18be1461018357806337899770146101c7578063461a4478146101e5575b600080fd5b61014560035481565b6040519081526020015b60405180910390f35b60005461016b906001600160a01b031681565b6040516001600160a01b03909116815260200161014f565b6101966101913660046113fd565b6102a8565b604080518251815260208084015164ffffffffff90811691830191909152928201519092169082015260600161014f565b6101cf610326565b60405164ffffffffff909116815260200161014f565b61016b6101f33660046114a2565b61033a565b6101cf6103c1565b61021361020e36600461150b565b6103d5565b005b610145620186a081565b60055464ffffffffff166101cf565b61014561075c565b61014561c35081565b61014560045481565b610213610256366004611592565b610777565b6006546101cf565b61014560025481565b61016b610a55565b610213610a7d565b610145610ea7565b61014560015481565b61021361029b366004611611565b610f21565b6101cf61106a565b6040805160608101825260008082526020820181905291810191909152600682815481106102d8576102d8611633565b6000918252602091829020604080516060810182526002909302909101805483526001015464ffffffffff808216948401949094526501000000000090049092169181019190915292915050565b600080610331611086565b50949350505050565b6000805460405163bf40fac160e01b81526001600160a01b039091169063bf40fac19061036b908590600401611696565b60206040518083038186803b15801561038357600080fd5b505afa158015610397573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103bb91906116b0565b92915050565b6000806103cc611086565b95945050505050565b61c350815111156104535760405162461bcd60e51b815260206004820152603d60248201527f5472616e73616374696f6e20646174612073697a652065786365656473206d6160448201527f78696d756d20666f7220726f6c6c7570207472616e73616374696f6e2e00000060648201526084015b60405180910390fd5b6004548211156104cb5760405162461bcd60e51b815260206004820152603d60248201527f5472616e73616374696f6e20676173206c696d69742065786365656473206d6160448201527f78696d756d20666f7220726f6c6c7570207472616e73616374696f6e2e000000606482015260840161044a565b620186a08210156105305760405162461bcd60e51b815260206004820152602960248201527f5472616e73616374696f6e20676173206c696d697420746f6f206c6f7720746f6044820152681032b738bab2bab29760b91b606482015260840161044a565b6003548211156105ec5760006002546003548461054d91906116e3565b61055791906116fa565b905060005a90508181116105c15760405162461bcd60e51b815260206004820152602b60248201527f496e73756666696369656e742067617320666f72204c322072617465206c696d60448201526a34ba34b73390313ab9371760a91b606482015260840161044a565b60005b825a6105d090846116e3565b10156105e857806105e08161171c565b9150506105c4565b5050505b6000333214156105fd575033610616565b5033731111000000000000000000000000000000001111015b60008185858560405160200161062f9493929190611737565b60408051601f19818403018152828252805160209182012060608401835280845264ffffffffff42811692850192835243811693850193845260068054600181810183556000838152975160029092027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f81019290925594517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40909101805496518416650100000000000269ffffffffffffffffffff1990971691909316179490941790559154919350610702916116e3565b905080866001600160a01b0316846001600160a01b03167f4b388aecf9fa6cc92253704e5975a6129a4f735bdbd99567df4ed0094ee4ceb588884260405161074c93929190611774565b60405180910390a4505050505050565b600080610767611086565b50505064ffffffffff1692915050565b61077f610a55565b6001600160a01b0316631f7b6d326040518163ffffffff1660e01b815260040160206040518083038186803b1580156107b757600080fd5b505afa1580156107cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ef919061179d565b87106108345760405162461bcd60e51b815260206004820152601460248201527324b73b30b634b2103130ba31b41034b73232bc1760611b604482015260640161044a565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561088057600080fd5b505afa158015610894573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b891906116b0565b6001600160a01b0316336001600160a01b03161461092c5760405162461bcd60e51b815260206004820152602b60248201527f4f6e6c792063616c6c61626c65206279207468652061646472657373206d616e60448201526a30b3b2b91037bbb732b91760a91b606482015260840161044a565b600061095f61093b87896117b6565b61094586886117b6565b602890811b91909117605086901b17607885901b17901b90565b9050610969610a55565b60405163167fd68160e01b8152600481018a905264ffffffffff19831660248201526001600160a01b03919091169063167fd68190604401600060405180830381600087803b1580156109bb57600080fd5b505af11580156109cf573d6000803e3d6000fd5b50506005805464ffffffffff191664ffffffffff898116918217909255604080519182528b831660208301528a8316908201528782166060820152868216608082015290851660a08201528a92507f293a9e87838119a52e3dd8eabf034ae7eda0da1bfdb33ee7721a6afca0b166b8915060c00160405180910390a25050505050505050565b6000610a786040518060600160405280602181526020016119086021913961033a565b905090565b60043560d81c60093560e890811c90600c35901c610a9961075c565b8364ffffffffff1614610b145760405162461bcd60e51b815260206004820152603d60248201527f41637475616c20626174636820737461727420696e64657820646f6573206e6f60448201527f74206d6174636820657870656374656420737461727420696e6465782e000000606482015260840161044a565b610b426040518060400160405280600d81526020016c212b26afa9b2b8bab2b731b2b960991b81525061033a565b6001600160a01b0316336001600160a01b031614610bb85760405162461bcd60e51b815260206004820152602d60248201527f46756e6374696f6e2063616e206f6e6c792062652063616c6c6564206279207460448201526c34329029b2b8bab2b731b2b91760991b606482015260840161044a565b6000610bca62ffffff831660106117df565b610bd590600f6117fe565b905064ffffffffff8116361015610c395760405162461bcd60e51b815260206004820152602260248201527f4e6f7420656e6f756768204261746368436f6e74657874732070726f76696465604482015261321760f11b606482015260840161044a565b6005546040805160808101825260008082526020820181905291810182905260608101829052909164ffffffffff169060005b8562ffffff168163ffffffff161015610cca576000610c908263ffffffff16611134565b8051909350839150610ca29086611816565b9450826020015184610cb491906117b6565b9350508080610cc290611835565b915050610c6c565b5060065464ffffffffff83161115610d555760405162461bcd60e51b815260206004820152604260248201527f417474656d7074656420746f20617070656e64206d6f726520656c656d656e7460448201527f73207468616e2061726520617661696c61626c6520696e207468652071756575606482015261329760f11b608482015260a40161044a565b6000610d668462ffffff8916611859565b63ffffffff169050600080836020015160001415610d8f57505060408201516060830151610e00565b60006006610d9e60018861187e565b64ffffffffff1681548110610db557610db5611633565b6000918252602091829020604080516060810182526002909302909101805483526001015464ffffffffff808216948401859052650100000000009091041691018190529093509150505b610e24610e0e6001436116e3565b408a62ffffff168564ffffffffff1685856111bb565b7f602f1aeac0ca2e7a13e281a9ef0ad7838542712ce16780fa2ecffd351f05f899610e4f848761187e565b84610e5861075c565b6040805164ffffffffff94851681529390921660208401529082015260600160405180910390a150506005805464ffffffffff191664ffffffffff949094169390931790925550505050505050565b6000610eb1610a55565b6001600160a01b0316631f7b6d326040518163ffffffff1660e01b815260040160206040518083038186803b158015610ee957600080fd5b505afa158015610efd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a78919061179d565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f6d57600080fd5b505afa158015610f81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa591906116b0565b6001600160a01b0316336001600160a01b0316146110055760405162461bcd60e51b815260206004820181905260248201527f4f6e6c792063616c6c61626c6520627920746865204275726e2041646d696e2e604482015260640161044a565b6001819055600282905561101981836117df565b60038190556002546001546040805192835260208301919091528101919091527fc6ed75e96b8b18b71edc1a6e82a9d677f8268c774a262c624eeb2cf0a8b3e07e9060600160405180910390a15050565b600554600654600091610a789164ffffffffff9091169061187e565b6000806000806000611096610a55565b6001600160a01b031663ccf8f9696040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ce57600080fd5b505afa1580156110e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611106919061189c565b64ffffffffff602882901c811697605083901c82169750607883901c8216965060a09290921c169350915050565b61115f6040518060800160405280600081526020016000815260200160008152602001600081525090565b600061116c6010846117df565b61117790600f6117fe565b60408051608081018252823560e890811c82526003840135901c6020820152600683013560d890811c92820192909252600b90920135901c60608201529392505050565b60006111c5610a55565b90506000806111d2611086565b50509150915060006040518060c00160405280856001600160a01b0316631f7b6d326040518163ffffffff1660e01b815260040160206040518083038186803b15801561121e57600080fd5b505afa158015611232573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611256919061179d565b81526020018a81526020018981526020018464ffffffffff16815260200160405180602001604052806000815250815260200160405180602001604052806000815250815250905080600001517fa47512905cf577d4cfae2efc3df461008ddb7234e91ce7f4eefcdb51e1077ccf82602001518360400151846060015185608001518660a001516040516112ee9594939291906118c4565b60405180910390a26000611301826113b4565b9050600061133c83604001518661131891906117b6565b6113228b876117b6565b602890811b9190911760508b901b1760788a901b17901b90565b60405163080549db60e21b81526004810184905264ffffffffff19821660248201529091506001600160a01b03871690632015276c90604401600060405180830381600087803b15801561138f57600080fd5b505af11580156113a3573d6000803e3d6000fd5b505050505050505050505050505050565b6020808201516040808401516060850151608086015160a087015193516000966113e0969591016118c4565b604051602081830303815290604052805190602001209050919050565b60006020828403121561140f57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561144757611447611416565b604051601f8501601f19908116603f0116810190828211818310171561146f5761146f611416565b8160405280935085815286868601111561148857600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156114b457600080fd5b813567ffffffffffffffff8111156114cb57600080fd5b8201601f810184136114dc57600080fd5b6114eb8482356020840161142c565b949350505050565b6001600160a01b038116811461150857600080fd5b50565b60008060006060848603121561152057600080fd5b833561152b816114f3565b925060208401359150604084013567ffffffffffffffff81111561154e57600080fd5b8401601f8101861361155f57600080fd5b61156e8682356020840161142c565b9150509250925092565b803564ffffffffff8116811461158d57600080fd5b919050565b600080600080600080600060e0888a0312156115ad57600080fd5b873596506115bd60208901611578565b95506115cb60408901611578565b94506115d960608901611578565b93506115e760808901611578565b92506115f560a08901611578565b915061160360c08901611578565b905092959891949750929550565b6000806040838503121561162457600080fd5b50508035926020909101359150565b634e487b7160e01b600052603260045260246000fd5b6000815180845260005b8181101561166f57602081850181015186830182015201611653565b81811115611681576000602083870101525b50601f01601f19169290920160200192915050565b6020815260006116a96020830184611649565b9392505050565b6000602082840312156116c257600080fd5b81516116a9816114f3565b634e487b7160e01b600052601160045260246000fd5b6000828210156116f5576116f56116cd565b500390565b60008261171757634e487b7160e01b600052601260045260246000fd5b500490565b6000600019821415611730576117306116cd565b5060010190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061176a90830184611649565b9695505050505050565b83815260606020820152600061178d6060830185611649565b9050826040830152949350505050565b6000602082840312156117af57600080fd5b5051919050565b600064ffffffffff8083168185168083038211156117d6576117d66116cd565b01949350505050565b60008160001904831182151516156117f9576117f96116cd565b500290565b60008219821115611811576118116116cd565b500190565b600063ffffffff8083168185168083038211156117d6576117d66116cd565b600063ffffffff8083168181141561184f5761184f6116cd565b6001019392505050565b600063ffffffff83811690831681811015611876576118766116cd565b039392505050565b600064ffffffffff83811690831681811015611876576118766116cd565b6000602082840312156118ae57600080fd5b815164ffffffffff19811681146116a957600080fd5b85815284602082015283604082015260a0606082015260006118e960a0830185611649565b82810360808401526118fb8185611649565b9897505050505050505056fe436861696e53746f72616765436f6e7461696e65722d4354432d62617463686573a2646970667358221220bf21e62c8db82d401b403c33025017ab1d3f80d9b950a2220a3c716d2618bca164736f6c634300080900330000000000000000000000006968f3f16c3e64003f02e121cf0d5ccbf5625a420000000000000000000000000000000000000000000000000000000001c9c3800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000ea60
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101375760003560e01c8063876ed5cb116100b8578063cfdf677e1161007c578063cfdf677e1461026c578063d0f8934414610274578063e561dddc1461027c578063e654b1fb14610284578063edcc4a451461028d578063f722b41a146102a057600080fd5b8063876ed5cb146102365780638d38c6c11461023f578063a17e44c614610248578063b8f770051461025b578063ccf987c81461026357600080fd5b80635ae6256d116100ff5780635ae6256d146101f85780636fee07e01461020057806378f4b2f2146102155780637a167a8a1461021f5780637aa63a861461022e57600080fd5b80630b3dfa971461013c578063299ca478146101585780632a7f18be1461018357806337899770146101c7578063461a4478146101e5575b600080fd5b61014560035481565b6040519081526020015b60405180910390f35b60005461016b906001600160a01b031681565b6040516001600160a01b03909116815260200161014f565b6101966101913660046113fd565b6102a8565b604080518251815260208084015164ffffffffff90811691830191909152928201519092169082015260600161014f565b6101cf610326565b60405164ffffffffff909116815260200161014f565b61016b6101f33660046114a2565b61033a565b6101cf6103c1565b61021361020e36600461150b565b6103d5565b005b610145620186a081565b60055464ffffffffff166101cf565b61014561075c565b61014561c35081565b61014560045481565b610213610256366004611592565b610777565b6006546101cf565b61014560025481565b61016b610a55565b610213610a7d565b610145610ea7565b61014560015481565b61021361029b366004611611565b610f21565b6101cf61106a565b6040805160608101825260008082526020820181905291810191909152600682815481106102d8576102d8611633565b6000918252602091829020604080516060810182526002909302909101805483526001015464ffffffffff808216948401949094526501000000000090049092169181019190915292915050565b600080610331611086565b50949350505050565b6000805460405163bf40fac160e01b81526001600160a01b039091169063bf40fac19061036b908590600401611696565b60206040518083038186803b15801561038357600080fd5b505afa158015610397573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103bb91906116b0565b92915050565b6000806103cc611086565b95945050505050565b61c350815111156104535760405162461bcd60e51b815260206004820152603d60248201527f5472616e73616374696f6e20646174612073697a652065786365656473206d6160448201527f78696d756d20666f7220726f6c6c7570207472616e73616374696f6e2e00000060648201526084015b60405180910390fd5b6004548211156104cb5760405162461bcd60e51b815260206004820152603d60248201527f5472616e73616374696f6e20676173206c696d69742065786365656473206d6160448201527f78696d756d20666f7220726f6c6c7570207472616e73616374696f6e2e000000606482015260840161044a565b620186a08210156105305760405162461bcd60e51b815260206004820152602960248201527f5472616e73616374696f6e20676173206c696d697420746f6f206c6f7720746f6044820152681032b738bab2bab29760b91b606482015260840161044a565b6003548211156105ec5760006002546003548461054d91906116e3565b61055791906116fa565b905060005a90508181116105c15760405162461bcd60e51b815260206004820152602b60248201527f496e73756666696369656e742067617320666f72204c322072617465206c696d60448201526a34ba34b73390313ab9371760a91b606482015260840161044a565b60005b825a6105d090846116e3565b10156105e857806105e08161171c565b9150506105c4565b5050505b6000333214156105fd575033610616565b5033731111000000000000000000000000000000001111015b60008185858560405160200161062f9493929190611737565b60408051601f19818403018152828252805160209182012060608401835280845264ffffffffff42811692850192835243811693850193845260068054600181810183556000838152975160029092027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f81019290925594517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40909101805496518416650100000000000269ffffffffffffffffffff1990971691909316179490941790559154919350610702916116e3565b905080866001600160a01b0316846001600160a01b03167f4b388aecf9fa6cc92253704e5975a6129a4f735bdbd99567df4ed0094ee4ceb588884260405161074c93929190611774565b60405180910390a4505050505050565b600080610767611086565b50505064ffffffffff1692915050565b61077f610a55565b6001600160a01b0316631f7b6d326040518163ffffffff1660e01b815260040160206040518083038186803b1580156107b757600080fd5b505afa1580156107cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ef919061179d565b87106108345760405162461bcd60e51b815260206004820152601460248201527324b73b30b634b2103130ba31b41034b73232bc1760611b604482015260640161044a565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561088057600080fd5b505afa158015610894573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b891906116b0565b6001600160a01b0316336001600160a01b03161461092c5760405162461bcd60e51b815260206004820152602b60248201527f4f6e6c792063616c6c61626c65206279207468652061646472657373206d616e60448201526a30b3b2b91037bbb732b91760a91b606482015260840161044a565b600061095f61093b87896117b6565b61094586886117b6565b602890811b91909117605086901b17607885901b17901b90565b9050610969610a55565b60405163167fd68160e01b8152600481018a905264ffffffffff19831660248201526001600160a01b03919091169063167fd68190604401600060405180830381600087803b1580156109bb57600080fd5b505af11580156109cf573d6000803e3d6000fd5b50506005805464ffffffffff191664ffffffffff898116918217909255604080519182528b831660208301528a8316908201528782166060820152868216608082015290851660a08201528a92507f293a9e87838119a52e3dd8eabf034ae7eda0da1bfdb33ee7721a6afca0b166b8915060c00160405180910390a25050505050505050565b6000610a786040518060600160405280602181526020016119086021913961033a565b905090565b60043560d81c60093560e890811c90600c35901c610a9961075c565b8364ffffffffff1614610b145760405162461bcd60e51b815260206004820152603d60248201527f41637475616c20626174636820737461727420696e64657820646f6573206e6f60448201527f74206d6174636820657870656374656420737461727420696e6465782e000000606482015260840161044a565b610b426040518060400160405280600d81526020016c212b26afa9b2b8bab2b731b2b960991b81525061033a565b6001600160a01b0316336001600160a01b031614610bb85760405162461bcd60e51b815260206004820152602d60248201527f46756e6374696f6e2063616e206f6e6c792062652063616c6c6564206279207460448201526c34329029b2b8bab2b731b2b91760991b606482015260840161044a565b6000610bca62ffffff831660106117df565b610bd590600f6117fe565b905064ffffffffff8116361015610c395760405162461bcd60e51b815260206004820152602260248201527f4e6f7420656e6f756768204261746368436f6e74657874732070726f76696465604482015261321760f11b606482015260840161044a565b6005546040805160808101825260008082526020820181905291810182905260608101829052909164ffffffffff169060005b8562ffffff168163ffffffff161015610cca576000610c908263ffffffff16611134565b8051909350839150610ca29086611816565b9450826020015184610cb491906117b6565b9350508080610cc290611835565b915050610c6c565b5060065464ffffffffff83161115610d555760405162461bcd60e51b815260206004820152604260248201527f417474656d7074656420746f20617070656e64206d6f726520656c656d656e7460448201527f73207468616e2061726520617661696c61626c6520696e207468652071756575606482015261329760f11b608482015260a40161044a565b6000610d668462ffffff8916611859565b63ffffffff169050600080836020015160001415610d8f57505060408201516060830151610e00565b60006006610d9e60018861187e565b64ffffffffff1681548110610db557610db5611633565b6000918252602091829020604080516060810182526002909302909101805483526001015464ffffffffff808216948401859052650100000000009091041691018190529093509150505b610e24610e0e6001436116e3565b408a62ffffff168564ffffffffff1685856111bb565b7f602f1aeac0ca2e7a13e281a9ef0ad7838542712ce16780fa2ecffd351f05f899610e4f848761187e565b84610e5861075c565b6040805164ffffffffff94851681529390921660208401529082015260600160405180910390a150506005805464ffffffffff191664ffffffffff949094169390931790925550505050505050565b6000610eb1610a55565b6001600160a01b0316631f7b6d326040518163ffffffff1660e01b815260040160206040518083038186803b158015610ee957600080fd5b505afa158015610efd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a78919061179d565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f6d57600080fd5b505afa158015610f81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa591906116b0565b6001600160a01b0316336001600160a01b0316146110055760405162461bcd60e51b815260206004820181905260248201527f4f6e6c792063616c6c61626c6520627920746865204275726e2041646d696e2e604482015260640161044a565b6001819055600282905561101981836117df565b60038190556002546001546040805192835260208301919091528101919091527fc6ed75e96b8b18b71edc1a6e82a9d677f8268c774a262c624eeb2cf0a8b3e07e9060600160405180910390a15050565b600554600654600091610a789164ffffffffff9091169061187e565b6000806000806000611096610a55565b6001600160a01b031663ccf8f9696040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ce57600080fd5b505afa1580156110e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611106919061189c565b64ffffffffff602882901c811697605083901c82169750607883901c8216965060a09290921c169350915050565b61115f6040518060800160405280600081526020016000815260200160008152602001600081525090565b600061116c6010846117df565b61117790600f6117fe565b60408051608081018252823560e890811c82526003840135901c6020820152600683013560d890811c92820192909252600b90920135901c60608201529392505050565b60006111c5610a55565b90506000806111d2611086565b50509150915060006040518060c00160405280856001600160a01b0316631f7b6d326040518163ffffffff1660e01b815260040160206040518083038186803b15801561121e57600080fd5b505afa158015611232573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611256919061179d565b81526020018a81526020018981526020018464ffffffffff16815260200160405180602001604052806000815250815260200160405180602001604052806000815250815250905080600001517fa47512905cf577d4cfae2efc3df461008ddb7234e91ce7f4eefcdb51e1077ccf82602001518360400151846060015185608001518660a001516040516112ee9594939291906118c4565b60405180910390a26000611301826113b4565b9050600061133c83604001518661131891906117b6565b6113228b876117b6565b602890811b9190911760508b901b1760788a901b17901b90565b60405163080549db60e21b81526004810184905264ffffffffff19821660248201529091506001600160a01b03871690632015276c90604401600060405180830381600087803b15801561138f57600080fd5b505af11580156113a3573d6000803e3d6000fd5b505050505050505050505050505050565b6020808201516040808401516060850151608086015160a087015193516000966113e0969591016118c4565b604051602081830303815290604052805190602001209050919050565b60006020828403121561140f57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561144757611447611416565b604051601f8501601f19908116603f0116810190828211818310171561146f5761146f611416565b8160405280935085815286868601111561148857600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156114b457600080fd5b813567ffffffffffffffff8111156114cb57600080fd5b8201601f810184136114dc57600080fd5b6114eb8482356020840161142c565b949350505050565b6001600160a01b038116811461150857600080fd5b50565b60008060006060848603121561152057600080fd5b833561152b816114f3565b925060208401359150604084013567ffffffffffffffff81111561154e57600080fd5b8401601f8101861361155f57600080fd5b61156e8682356020840161142c565b9150509250925092565b803564ffffffffff8116811461158d57600080fd5b919050565b600080600080600080600060e0888a0312156115ad57600080fd5b873596506115bd60208901611578565b95506115cb60408901611578565b94506115d960608901611578565b93506115e760808901611578565b92506115f560a08901611578565b915061160360c08901611578565b905092959891949750929550565b6000806040838503121561162457600080fd5b50508035926020909101359150565b634e487b7160e01b600052603260045260246000fd5b6000815180845260005b8181101561166f57602081850181015186830182015201611653565b81811115611681576000602083870101525b50601f01601f19169290920160200192915050565b6020815260006116a96020830184611649565b9392505050565b6000602082840312156116c257600080fd5b81516116a9816114f3565b634e487b7160e01b600052601160045260246000fd5b6000828210156116f5576116f56116cd565b500390565b60008261171757634e487b7160e01b600052601260045260246000fd5b500490565b6000600019821415611730576117306116cd565b5060010190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061176a90830184611649565b9695505050505050565b83815260606020820152600061178d6060830185611649565b9050826040830152949350505050565b6000602082840312156117af57600080fd5b5051919050565b600064ffffffffff8083168185168083038211156117d6576117d66116cd565b01949350505050565b60008160001904831182151516156117f9576117f96116cd565b500290565b60008219821115611811576118116116cd565b500190565b600063ffffffff8083168185168083038211156117d6576117d66116cd565b600063ffffffff8083168181141561184f5761184f6116cd565b6001019392505050565b600063ffffffff83811690831681811015611876576118766116cd565b039392505050565b600064ffffffffff83811690831681811015611876576118766116cd565b6000602082840312156118ae57600080fd5b815164ffffffffff19811681146116a957600080fd5b85815284602082015283604082015260a0606082015260006118e960a0830185611649565b82810360808401526118fb8185611649565b9897505050505050505056fe436861696e53746f72616765436f6e7461696e65722d4354432d62617463686573a2646970667358221220bf21e62c8db82d401b403c33025017ab1d3f80d9b950a2220a3c716d2618bca164736f6c63430008090033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000006968f3f16c3e64003f02e121cf0d5ccbf5625a420000000000000000000000000000000000000000000000000000000001c9c3800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000ea60
-----Decoded View---------------
Arg [0] : _libAddressManager (address): 0x6968f3F16C3e64003F02E121cf0D5CCBf5625a42
Arg [1] : _maxTransactionGasLimit (uint256): 30000000
Arg [2] : _l2GasDiscountDivisor (uint256): 32
Arg [3] : _enqueueGasCost (uint256): 60000
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000006968f3f16c3e64003f02e121cf0d5ccbf5625a42
Arg [1] : 0000000000000000000000000000000000000000000000000000000001c9c380
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000020
Arg [3] : 000000000000000000000000000000000000000000000000000000000000ea60
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
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.